Skip to content

Fix Select List content and value #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions src/components/FormSelectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
* @param {*|*[]} list, array of objects
*/
transformOptions(list) {
const suffix = this.attributeParent(this.options.value);
const suffix = this.options.key;
let resultList = [];

list.forEach(item => {
Expand All @@ -183,11 +183,14 @@
parsedOption[this.optionsKey] = itemValue;
parsedOption[this.optionsValue] = itemContent;
if (this.options.valueTypeReturned === 'object') {
resultList.push(eval( suffix.length > 0 ? 'item.' + suffix : 'item'));
}
else {
resultList.push(parsedOption);
parsedOption = suffix.length > 0 ? get(item, suffix) : item;
Object.defineProperty(parsedOption, this.optionsValue, {
get: function() {
return itemContent;
}
});
}
resultList.push(parsedOption);
});
return resultList
},
Expand All @@ -199,13 +202,6 @@

return removed ? removed : str;
},
attributeParent(str) {
let parts = str.replace(/{{/g,'')
.replace(/}}/g,'')
.split('.')
parts.pop();
return parts.join('.');
},
updateWatcherDependentFieldValue(newSelectOptions, oldSelectOptions) {
let dataName = this.options.dataName.split('.');
// Check to see if the watcher output variable has been loaded.
Expand Down Expand Up @@ -308,11 +304,9 @@
optionsValue() {
if (this.options.dataSource && this.options.dataSource === 'provideData') {
return 'content';
} else {
return '__content__';
}

const fieldName = this.options.value || 'content';

return this.stripMustache(fieldName);
},
classList() {
return {
Expand Down