refactoring

This commit is contained in:
Burak Civan 2022-10-06 12:35:06 +03:00
parent a7da2ab3c9
commit 3cab2fee8b

View File

@ -107,7 +107,7 @@
<span slot="infoBlock" class="absolute right-8 top-3 bg-green text-white px-2 py-1 rounded-md text-xs" v-if="new_options[selected]">{{ addNew.new_text }}</span> <span slot="infoBlock" class="absolute right-8 top-3 bg-green text-white px-2 py-1 rounded-md text-xs" v-if="new_options[selected]">{{ addNew.new_text }}</span>
<select :name="name" :id="name" v-model="selected" class="d-none"> <select :name="name" :id="name" class="hidden">
<option v-for="option in sortedOptions" :key="option.key" :value="option.key">{{ option.value }}</option> <option v-for="option in sortedOptions" :key="option.key" :value="option.key">{{ option.value }}</option>
</select> </select>
</base-input> </base-input>
@ -355,7 +355,6 @@ export default {
} else { } else {
this.sorted_options.sort(this.sortBy(this.option_sortable)); this.sorted_options.sort(this.sortBy(this.option_sortable));
} }
return this.sorted_options; return this.sorted_options;
}, },
}, },
@ -1025,31 +1024,26 @@ export default {
}, this); }, this);
} }
if (this.selectedControl) { if (this.selectedControl) {
if (this.multiple) { if (this.multiple) {
let selected = this.selected; let selected = this.selected;
this.selected = []; this.selected = [];
if (selected !== undefined) {
selected.forEach(function (select, index) { selected.forEach(function (select, index) {
if (this.sorted_options.find(option => option.key == select)) { if (this.sorted_options.find(option => option.key == select)) {
this.selected.push(select); this.selected.push(select);
} else {
this.selected = [];
} }
}, this); }, this);
}
} else { } else {
if (! options.find(option => option == this.selected)) { if (! options.find(option => option == this.selected)) {
this.selected = []; this.selected = null;
} }
} }
} else { } else {
if (this.multiple) { if (this.multiple) {
this.selected = []; this.selected = [];
} else { } else {
this.selected = ''; this.selected = null;
} }
} }
} }