diff --git a/resources/assets/js/components/AkauntingSelect.vue b/resources/assets/js/components/AkauntingSelect.vue index 2f73bf63c..262960718 100644 --- a/resources/assets/js/components/AkauntingSelect.vue +++ b/resources/assets/js/components/AkauntingSelect.vue @@ -269,7 +269,7 @@ export default { type: String, default: 'No Matchign Data', description: "Selectbox search option not found item message" - } + }, }, data() { @@ -294,70 +294,7 @@ export default { }, created() { - let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options; - - if (this.group) { - // Option set sort_option data - if (!Array.isArray(created_options)) { - for (const [index, options] of Object.entries(created_options)) { - let values = []; - - for (const [key, value] of Object.entries(options)) { - values.push({ - key: key, - value: value - }); - } - - this.sort_options.push({ - key: index, - value: values - }); - } - } else { - created_options.forEach(function (option, index) { - if (typeof(option) == 'string') { - this.sort_options.push({ - index: index, - key: index.toString(), - value: option - }); - } else { - this.sort_options.push({ - index: index, - key: option.id, - value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name - }); - } - }, this); - } - } else { - // Option set sort_option data - if (!Array.isArray(created_options)) { - for (const [key, value] of Object.entries(created_options)) { - this.sort_options.push({ - key: key, - value: value - }); - } - } else { - created_options.forEach(function (option, index) { - if (typeof(option) == 'string') { - this.sort_options.push({ - index: index, - key: index.toString(), - value: option - }); - } else { - this.sort_options.push({ - index: index, - key: option.id, - value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name - }); - } - }, this); - } - } + this.setSortOptions(); }, computed: { @@ -418,6 +355,76 @@ export default { } }, + setSortOptions() { + // Reset sort_options + this.sort_options = []; + + let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options; + + if (this.group) { + // Option set sort_option data + if (!Array.isArray(created_options)) { + for (const [index, options] of Object.entries(created_options)) { + let values = []; + + for (const [key, value] of Object.entries(options)) { + values.push({ + key: key, + value: value + }); + } + + this.sort_options.push({ + key: index, + value: values + }); + } + } else { + created_options.forEach(function (option, index) { + if (typeof(option) == 'string') { + this.sort_options.push({ + index: index, + key: index.toString(), + value: option + }); + } else { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + } + }, this); + } + } else { + // Option set sort_option data + if (!Array.isArray(created_options)) { + for (const [key, value] of Object.entries(created_options)) { + this.sort_options.push({ + key: key, + value: value + }); + } + } else { + created_options.forEach(function (option, index) { + if (typeof(option) == 'string') { + this.sort_options.push({ + index: index, + key: index.toString(), + value: option + }); + } else { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + } + }, this); + } + } + }, + change() { // This controll added add new changed.. if (typeof(this.selected) === 'object' && typeof(this.selected.type) !== 'undefined') { @@ -541,6 +548,8 @@ export default { }, onModal(value) { + //this.setSortOptions(); + let add_new = this.add_new; window.axios.get(this.add_new.path) diff --git a/resources/assets/js/components/AkauntingSelectRemote.vue b/resources/assets/js/components/AkauntingSelectRemote.vue index da1e12cff..6ed5192ef 100644 --- a/resources/assets/js/components/AkauntingSelectRemote.vue +++ b/resources/assets/js/components/AkauntingSelectRemote.vue @@ -88,7 +88,7 @@ - +
@@ -468,6 +468,9 @@ export default { }, setSortOptions() { + // Reset sort_options + this.sort_options = []; + let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options; if (this.group) { @@ -490,11 +493,19 @@ export default { } } else { created_options.forEach(function (option, index) { - this.sort_options.push({ - index: index, - key: option.id, - value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name - }); + if (typeof(option) == 'string') { + this.sort_options.push({ + index: index, + key: index.toString(), + value: option + }); + } else { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + } }, this); } } else { @@ -508,11 +519,19 @@ export default { } } else { created_options.forEach(function (option, index) { - this.sort_options.push({ - index: index, - key: option.id, - value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name - }); + if (typeof(option) == 'string') { + this.sort_options.push({ + index: index, + key: index.toString(), + value: option + }); + } else { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + } }, this); } } @@ -531,7 +550,7 @@ export default { // Option changed sort_option data if (this.group) { this.sort_options.forEach(function (option_group, group_index) { - this.option_group.value.forEach(function (option, index) { + option_group.value.forEach(function (option, index) { if (this.multiple) { let indexs = []; let values = []; @@ -539,7 +558,7 @@ export default { let options = []; this.selected.forEach(function (selected_option_id, selected_index) { - if (option.value == selected_option_id) { + if (option.key == selected_option_id) { indexs.push(selected_index); values.push(option.id); labels.push(option.value); @@ -552,7 +571,7 @@ export default { this.$emit('label', labels); this.$emit('option', options); } else { - if (option.value == this.selected) { + if (option.key == this.selected) { this.$emit('index', index); this.$emit('value', option.id); this.$emit('label', option.value); @@ -570,7 +589,7 @@ export default { let options = []; this.selected.forEach(function (selected_option_id, selected_index) { - if (option.value == selected_option_id) { + if (option.key == selected_option_id) { indexs.push(selected_index); values.push(option.id); labels.push(option.value); @@ -583,7 +602,7 @@ export default { this.$emit('label', labels); this.$emit('option', options); } else { - if (option.value == this.selected) { + if (option.key == this.selected) { this.$emit('index', index); this.$emit('value', option.id); this.$emit('label', option.value); @@ -982,11 +1001,19 @@ export default { } } else { options.forEach(function (option, index) { - this.sort_options.push({ - index: index, - key: option.id, - value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name - }); + if (typeof(option) == 'string') { + this.sort_options.push({ + index: index, + key: index.toString(), + value: option + }); + } else { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + } }, this); } } else { @@ -1000,11 +1027,19 @@ export default { } } else { options.forEach(function (option, index) { - this.sort_options.push({ - index: index, - key: option.id, - value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name - }); + if (typeof(option) == 'string') { + this.sort_options.push({ + index: index, + key: index.toString(), + value: option + }); + } else { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + } }, this); } }