Merge pull request #2825 from brkcvn/master

Value improvement for select component
This commit is contained in:
Burak Civan
2022-12-15 17:05:39 +03:00
committed by GitHub
2 changed files with 43 additions and 41 deletions

View File

@ -362,7 +362,7 @@ export default {
mounted() { mounted() {
// Check Here.. // Check Here..
this.selected = this.value; this.selected = this.value;
if (this.model.length) { if (this.model.length) {
try { try {
if (eval(this.model) !== undefined) { if (eval(this.model) !== undefined) {
@ -939,29 +939,30 @@ export default {
}, },
value: function (selected) { value: function (selected) {
if (!this.multiple) { // we tested this function works with post a form and after the selected function so put in the comment line
this.selected = selected.toString(); // if (!this.multiple) {
} else { // this.selected = selected.toString();
if (Array.isArray(this.selected) && !this.selected.length) { // } else {
this.selected = selected; // if (Array.isArray(this.selected) && !this.selected.length) {
} else { // this.selected = selected;
let is_string = false; // } else {
let pre_value = []; // let is_string = false;
// let pre_value = [];
selected.forEach(item => { // selected.forEach(item => {
if (typeof item != 'string') { // if (typeof item != 'string') {
is_string = true; // is_string = true;
pre_value.push(item.toString()); // pre_value.push(item.toString());
} // }
}); // });
if (is_string) { // if (is_string) {
this.selected = pre_value; // this.selected = pre_value;
} // }
} // }
} // }
this.change(); // this.change();
}, },
model: function (selected) { model: function (selected) {

View File

@ -1147,29 +1147,30 @@ export default {
}, },
value: function (selected) { value: function (selected) {
if (!this.multiple) { // we tested this function works with post a form and after the selected function so put in the comment line
this.selected = selected.toString(); // if (!this.multiple) {
} else { // this.selected = selected.toString();
if (Array.isArray(this.selected) && !this.selected.length) { // } else {
this.selected = selected; // if (Array.isArray(this.selected) && !this.selected.length) {
} else { // this.selected = selected;
let is_string = false; // } else {
let pre_value = []; // let is_string = false;
// let pre_value = [];
selected.forEach(item => { // selected.forEach(item => {
if (typeof item != 'string') { // if (typeof item != 'string') {
is_string = true; // is_string = true;
pre_value.push(item.toString()); // pre_value.push(item.toString());
} // }
}); // });
if (is_string) { // if (is_string) {
this.selected = pre_value; // this.selected = pre_value;
} // }
} // }
} // }
this.change(); // this.change();
}, },
model: function (selected) { model: function (selected) {