diff --git a/resources/assets/js/components/AkauntingSelect.vue b/resources/assets/js/components/AkauntingSelect.vue index 0ac043bd8..7ea02ce16 100644 --- a/resources/assets/js/components/AkauntingSelect.vue +++ b/resources/assets/js/components/AkauntingSelect.vue @@ -533,7 +533,6 @@ export default { add_new_html: '', form: {}, new_options: false, - hide_selected: false, } }, @@ -544,6 +543,10 @@ export default { mounted() { this.real_model = this.value; + if (this.multiple && !this.real_model.length) { + this.real_model = []; + } + this.$emit('interface', this.real_model); }, @@ -558,10 +561,6 @@ export default { }, async onAddItem() { - if (this.multiple) { - this.hide_selected = this.real_model; - } - // Get Select Input value if (this.title) { var value = this.$children[0].$children[0].$children[0].$refs.input.value; @@ -581,9 +580,6 @@ export default { }, addInline(value) { - if (this.multiple) { - this.hide_selected = false; - } }, onModal(value) { @@ -679,7 +675,7 @@ export default { this.form.loading = false; if (response.data.success) { - if (!this.selectOptions.length) { + if (!Object.keys(this.options).length) { this.selectOptions = {}; } @@ -697,10 +693,6 @@ export default { this.add_new.html = ''; this.add_new_html = null; - if (this.multiple) { - this.hide_selected = false; - } - this.$emit('new', response.data.data); this.change(); @@ -732,7 +724,7 @@ export default { this.selectOptions = options; if (Object.keys(this.new_options).length) { - if (!this.selectOptions.length) { + if (!Object.keys(this.options).length) { this.selectOptions = {}; } @@ -744,12 +736,6 @@ export default { } }, - real_model: function (value) { - if (this.multiple && this.hide_selected) { - this.real_model = this.hide_selected; - } - }, - value: function (value) { if (this.multiple) { this.real_model = value; diff --git a/resources/assets/js/components/AkauntingSelectRemote.vue b/resources/assets/js/components/AkauntingSelectRemote.vue index b9a78ed04..950f10a18 100644 --- a/resources/assets/js/components/AkauntingSelectRemote.vue +++ b/resources/assets/js/components/AkauntingSelectRemote.vue @@ -584,6 +584,10 @@ export default { mounted() { this.real_model = this.value; + if (this.multiple && !this.real_model.length) { + this.real_model = []; + } + this.$emit('interface', this.real_model); }, @@ -683,6 +687,10 @@ export default { }) .then(response => { if (response.data.success) { + if (!Object.keys(this.options).length) { + this.selectOptions = {}; + } + this.selectOptions.push(response.data.data); this.new_options[response.data.data[this.add_new.field.key]] = response.data.data; this.real_model = response.data.data[this.add_new.field.key]; @@ -800,7 +808,10 @@ export default { this.form.loading = false; if (response.data.success) { - + if (!Object.keys(this.options).length) { + this.selectOptions = {}; + } + this.selectOptions.push(response.data.data); //this.selectOptions[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; @@ -842,6 +853,10 @@ export default { this.selectOptions = options; if (Object.keys(this.new_options).length) { + if (!Object.keys(this.options).length) { + this.selectOptions = {}; + } + Object.values(this.new_options).forEach(item => { this.selectOptions.push(item); });