refs #1511 multi_select_remote_group fixes

This commit is contained in:
Cüneyt Şentürk 2020-07-03 12:24:37 +03:00
parent a96d6f22bc
commit fc97798d0b
2 changed files with 62 additions and 16 deletions

View File

@ -480,14 +480,14 @@ export default {
},
value: {
type: [String, Number, Array],
default: null,
default: '',
description: "Selectbox selected value"
},
options: null,
model: {
type: [String, Number],
default: '',
default: null,
description: "Selectbox selected model"
},
@ -598,10 +598,22 @@ export default {
},
mounted() {
this.real_model = this.value;
if (this.multiple && !this.real_model.length) {
if (this.multiple) {
if (!this.value.length) {
this.real_model = [];
} else {
let pre_value = [];
this.value.forEach(item => {
pre_value.push(item.toString());
});
this.real_model = pre_value;
}
} else {
this.real_model = this.value;
}
this.$emit('interface', this.real_model);
@ -650,13 +662,18 @@ export default {
},
change() {
if (typeof(this.real_model) === 'object') {
if (typeof(this.real_model) === 'object' && !Array.isArray(this.real_model)) {
return false;
}
if (Array.isArray(this.real_model) && !this.real_model.length) {
return false;
}
this.$emit('interface', this.real_model);
this.$emit('change', this.real_model);
if (Array.isArray(this.selectOptions)) {
this.selectOptions.forEach(item => {
if (item.id == this.real_model) {
this.$emit('label', item.name);
@ -665,6 +682,7 @@ export default {
return true;
}
});
}
},
onPressEnter() {
@ -887,9 +905,37 @@ export default {
}
},
real_model: function (value) {
if (this.multiple) {
return;
}
if (this.real_model != value) {
this.change();
}
let e = $.Event('keyup');
e.keyCode= 9; // tab
$('#' + this.name).trigger(e);
let event = new window.KeyboardEvent('keydown', { keyCode: 9 }); // Tab key
window.dispatchEvent(event);
},
value: function (value) {
if (this.multiple) {
if (Array.isArray(this.real_model) && !this.real_model.length) {
this.real_model = value;
} else {
let pre_value = [];
value.forEach(item => {
pre_value.push(item.toString());
});
this.real_model = pre_value;
}
} else {
//this.real_model = value.toString();
this.real_model = value;

View File

@ -17,7 +17,7 @@
name="{{ $name }}"
:options="{{ json_encode($values) }}"
@if (isset($selected) || old($name))
@if (!empty($selected) || old($name))
:value="{{ json_encode(old($name, $selected)) }}"
@endif
@ -62,7 +62,7 @@
@endif
remote-action="{{ $attributes['remote_action'] }}"
remote-type="'{{ $attributes['remote_type'] }}"
remote-type="{{ $attributes['remote_type'] }}"
@if (!empty($attributes['currecny_code']))
currency-code="{{ $attributes['currecny_code'] }}"