dynamic options function refactoring
This commit is contained in:
parent
3cab2fee8b
commit
fdd00f666c
@ -300,7 +300,7 @@ export default {
|
||||
description: "Selectbox input search placeholder text"
|
||||
},
|
||||
|
||||
selectedControl: {
|
||||
dynamicOptionsValueCheck: {
|
||||
type: [Boolean, String],
|
||||
default: false,
|
||||
},
|
||||
@ -869,6 +869,31 @@ export default {
|
||||
this.setSortedOptions();
|
||||
}
|
||||
},
|
||||
|
||||
dynamicOptionsValue(options) {
|
||||
if (this.dynamicOptionsValueCheck) {
|
||||
if (this.multiple) {
|
||||
let selected = this.selected;
|
||||
this.selected = [];
|
||||
|
||||
selected.forEach(function (select, index) {
|
||||
if (this.sorted_options.find((option) => option.key == select)) {
|
||||
this.selected.push(select);
|
||||
}
|
||||
}, this);
|
||||
} else {
|
||||
if (!options.find((option) => option == this.selected)) {
|
||||
this.selected = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.multiple) {
|
||||
this.selected = [];
|
||||
} else {
|
||||
this.selected = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
@ -1024,28 +1049,7 @@ export default {
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (this.selectedControl) {
|
||||
if (this.multiple) {
|
||||
let selected = this.selected;
|
||||
this.selected = [];
|
||||
|
||||
selected.forEach(function (select, index) {
|
||||
if (this.sorted_options.find(option => option.key == select)) {
|
||||
this.selected.push(select);
|
||||
}
|
||||
}, this);
|
||||
} else {
|
||||
if (! options.find(option => option == this.selected)) {
|
||||
this.selected = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.multiple) {
|
||||
this.selected = [];
|
||||
} else {
|
||||
this.selected = null;
|
||||
}
|
||||
}
|
||||
this.dynamicOptionsValue(options);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -1089,6 +1089,31 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
dynamicOptionsValue(options) {
|
||||
if (this.dynamicOptionsValueCheck) {
|
||||
if (this.multiple) {
|
||||
let selected = this.selected;
|
||||
this.selected = [];
|
||||
|
||||
selected.forEach(function (select, index) {
|
||||
if (this.sorted_options.find((option) => option.key == select)) {
|
||||
this.selected.push(select);
|
||||
}
|
||||
}, this);
|
||||
} else {
|
||||
if (!options.find((option) => option == this.selected)) {
|
||||
this.selected = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.multiple) {
|
||||
this.selected = [];
|
||||
} else {
|
||||
this.selected = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
selected: function (selected) {
|
||||
if (!this.multiple) {
|
||||
@ -1237,6 +1262,8 @@ export default {
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
this.dynamicOptionsValue(options);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -65,10 +65,10 @@
|
||||
search-text="{{ $searchText }}"
|
||||
@endif
|
||||
|
||||
@if (! empty($attributes['selected-control']))
|
||||
selected-control
|
||||
@elseif (! empty($selectedControl))
|
||||
selected-control
|
||||
@if (! empty($attributes['dynamic-options-value-check']))
|
||||
dynamic-options-value-check
|
||||
@elseif (! empty($dynamicOptionsValueCheck))
|
||||
dynamic-options-value-check
|
||||
@endif
|
||||
|
||||
@if (empty($multiple))
|
||||
|
Loading…
x
Reference in New Issue
Block a user