fixed AkauntingSelect.vue and AkauntingSelectRemote.vue files.
This commit is contained in:
parent
dc6d53b649
commit
aaafacf601
@ -269,7 +269,7 @@ export default {
|
||||
type: String,
|
||||
default: 'No Matchign Data',
|
||||
description: "Selectbox search option not found item message"
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
@ -294,6 +294,71 @@ export default {
|
||||
},
|
||||
|
||||
created() {
|
||||
this.setSortOptions();
|
||||
},
|
||||
|
||||
computed: {
|
||||
sortOptions() {
|
||||
if (this.group) {
|
||||
this.sort_options.sort(this.sortBy("key"));
|
||||
|
||||
for (const [index, options] of Object.entries(this.sort_options)) {
|
||||
options.value.sort(this.sortBy(this.option_sortable));
|
||||
}
|
||||
} else {
|
||||
this.sort_options.sort(this.sortBy(this.option_sortable));
|
||||
}
|
||||
|
||||
return this.sort_options;
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// Check Here..
|
||||
this.selected = this.value;
|
||||
|
||||
if (this.model.length) {
|
||||
if (eval(this.model) !== undefined) {
|
||||
this.selected = eval(this.model);
|
||||
} else {
|
||||
this.selected = this.model;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.multiple && !this.selected.length) {
|
||||
this.selected = [];
|
||||
}
|
||||
|
||||
this.$emit('interface', this.selected);
|
||||
|
||||
setTimeout(function() {
|
||||
this.change();
|
||||
}.bind(this), 800);
|
||||
},
|
||||
|
||||
methods: {
|
||||
sortBy(option) {
|
||||
return (firstEl, secondEl) => {
|
||||
let first_element = firstEl[option].toUpperCase(); // ignore upper and lowercase
|
||||
let second_element = secondEl[option].toUpperCase(); // ignore upper and lowercase
|
||||
|
||||
if (first_element < second_element) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (first_element > second_element) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// names must be equal
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
setSortOptions() {
|
||||
// Reset sort_options
|
||||
this.sort_options = [];
|
||||
|
||||
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options;
|
||||
|
||||
if (this.group) {
|
||||
@ -360,64 +425,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
sortOptions() {
|
||||
if (this.group) {
|
||||
this.sort_options.sort(this.sortBy("key"));
|
||||
|
||||
for (const [index, options] of Object.entries(this.sort_options)) {
|
||||
options.value.sort(this.sortBy(this.option_sortable));
|
||||
}
|
||||
} else {
|
||||
this.sort_options.sort(this.sortBy(this.option_sortable));
|
||||
}
|
||||
|
||||
return this.sort_options;
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// Check Here..
|
||||
this.selected = this.value;
|
||||
|
||||
if (this.model.length) {
|
||||
if (eval(this.model) !== undefined) {
|
||||
this.selected = eval(this.model);
|
||||
} else {
|
||||
this.selected = this.model;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.multiple && !this.selected.length) {
|
||||
this.selected = [];
|
||||
}
|
||||
|
||||
this.$emit('interface', this.selected);
|
||||
|
||||
setTimeout(function() {
|
||||
this.change();
|
||||
}.bind(this), 800);
|
||||
},
|
||||
|
||||
methods: {
|
||||
sortBy(option) {
|
||||
return (firstEl, secondEl) => {
|
||||
let first_element = firstEl[option].toUpperCase(); // ignore upper and lowercase
|
||||
let second_element = secondEl[option].toUpperCase(); // ignore upper and lowercase
|
||||
|
||||
if (first_element < second_element) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (first_element > second_element) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// names must be equal
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
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)
|
||||
|
@ -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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user