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"
|
description: "Selectbox input search placeholder text"
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedControl: {
|
dynamicOptionsValueCheck: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
@ -869,6 +869,31 @@ export default {
|
|||||||
this.setSortedOptions();
|
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: {
|
watch: {
|
||||||
@ -1024,28 +1049,7 @@ export default {
|
|||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selectedControl) {
|
this.dynamicOptionsValue(options);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -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: {
|
watch: {
|
||||||
selected: function (selected) {
|
selected: function (selected) {
|
||||||
if (!this.multiple) {
|
if (!this.multiple) {
|
||||||
@ -1237,6 +1262,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.dynamicOptionsValue(options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -65,10 +65,10 @@
|
|||||||
search-text="{{ $searchText }}"
|
search-text="{{ $searchText }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (! empty($attributes['selected-control']))
|
@if (! empty($attributes['dynamic-options-value-check']))
|
||||||
selected-control
|
dynamic-options-value-check
|
||||||
@elseif (! empty($selectedControl))
|
@elseif (! empty($dynamicOptionsValueCheck))
|
||||||
selected-control
|
dynamic-options-value-check
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (empty($multiple))
|
@if (empty($multiple))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user