dynamic options controlled
This commit is contained in:
parent
4e6988373c
commit
e80e9b5f34
@ -299,6 +299,11 @@ export default {
|
|||||||
default: '',
|
default: '',
|
||||||
description: "Selectbox input search placeholder text"
|
description: "Selectbox input search placeholder text"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectedControl: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -882,18 +887,20 @@ export default {
|
|||||||
let is_string = false;
|
let is_string = false;
|
||||||
let pre_value = [];
|
let pre_value = [];
|
||||||
|
|
||||||
selected.forEach(item => {
|
if (selected !== undefined) {
|
||||||
if (typeof item != 'string') {
|
selected.forEach(item => {
|
||||||
is_string = true;
|
if (typeof item != 'string') {
|
||||||
|
is_string = true;
|
||||||
|
|
||||||
if (item != '') {
|
if (item != '') {
|
||||||
pre_value.push(item.toString());
|
pre_value.push(item.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (is_string) {
|
if (is_string) {
|
||||||
this.selected = pre_value;
|
this.selected = pre_value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -949,7 +956,6 @@ export default {
|
|||||||
|
|
||||||
dynamicOptions: function(options) {
|
dynamicOptions: function(options) {
|
||||||
this.sorted_options = [];
|
this.sorted_options = [];
|
||||||
this.selected = '';
|
|
||||||
|
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
// Option set sort_option data
|
// Option set sort_option data
|
||||||
@ -1018,6 +1024,32 @@ export default {
|
|||||||
}
|
}
|
||||||
}, this);
|
}, 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);
|
||||||
|
} else {
|
||||||
|
this.selected = [];
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
} else {
|
||||||
|
if (! options.find(option => option == this.selected)) {
|
||||||
|
this.selected = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.multiple) {
|
||||||
|
this.selected = [];
|
||||||
|
} else {
|
||||||
|
this.selected = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -65,6 +65,12 @@
|
|||||||
search-text="{{ $searchText }}"
|
search-text="{{ $searchText }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (! empty($attributes['selected-control']))
|
||||||
|
selected-control
|
||||||
|
@elseif (! empty($selectedControl))
|
||||||
|
selected-control
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (empty($multiple))
|
@if (empty($multiple))
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user