mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 20:05:55 +08:00
32 lines
853 B
JavaScript
32 lines
853 B
JavaScript
/* global GLOBAL_CONSTANTS */
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
options: this.field.attributes.data.options?.join('\n')
|
|
};
|
|
},
|
|
computed: {
|
|
validField() {
|
|
return !this.editField.attributes.data.options || this.editField.attributes.data.options.length <= GLOBAL_CONSTANTS.NAME_MAX_LENGTH;
|
|
},
|
|
optionFieldErrors() {
|
|
if (!this.validField) {
|
|
return this.i18n.t('forms.show.options_too_many_error', { limit: GLOBAL_CONSTANTS.NAME_MAX_LENGTH });
|
|
}
|
|
|
|
return '';
|
|
}
|
|
},
|
|
watch: {
|
|
options() {
|
|
const newOptions = this.options.split('\n')
|
|
.filter((option) => option.trim() !== '')
|
|
.map((option) => option.trim());
|
|
// remove duplicates
|
|
const uniqueOptions = [...new Set(newOptions)];
|
|
|
|
this.editField.attributes.data.options = uniqueOptions;
|
|
}
|
|
}
|
|
};
|