fixed AkauntingSelect.vue and AkauntingSelectRemote.vue files.
This commit is contained in:
parent
dc6d53b649
commit
aaafacf601
@ -269,7 +269,7 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'No Matchign Data',
|
default: 'No Matchign Data',
|
||||||
description: "Selectbox search option not found item message"
|
description: "Selectbox search option not found item message"
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -294,6 +294,71 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
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;
|
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options;
|
||||||
|
|
||||||
if (this.group) {
|
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() {
|
change() {
|
||||||
// This controll added add new changed..
|
// This controll added add new changed..
|
||||||
if (typeof(this.selected) === 'object' && typeof(this.selected.type) !== 'undefined') {
|
if (typeof(this.selected) === 'object' && typeof(this.selected.type) !== 'undefined') {
|
||||||
@ -541,6 +548,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onModal(value) {
|
onModal(value) {
|
||||||
|
//this.setSortOptions();
|
||||||
|
|
||||||
let add_new = this.add_new;
|
let add_new = this.add_new;
|
||||||
|
|
||||||
window.axios.get(this.add_new.path)
|
window.axios.get(this.add_new.path)
|
||||||
|
@ -468,6 +468,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSortOptions() {
|
setSortOptions() {
|
||||||
|
// Reset sort_options
|
||||||
|
this.sort_options = [];
|
||||||
|
|
||||||
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options;
|
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options;
|
||||||
|
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
@ -490,11 +493,19 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
created_options.forEach(function (option, index) {
|
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({
|
this.sort_options.push({
|
||||||
index: index,
|
index: index,
|
||||||
key: option.id,
|
key: option.id,
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -508,11 +519,19 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
created_options.forEach(function (option, index) {
|
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({
|
this.sort_options.push({
|
||||||
index: index,
|
index: index,
|
||||||
key: option.id,
|
key: option.id,
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -531,7 +550,7 @@ export default {
|
|||||||
// Option changed sort_option data
|
// Option changed sort_option data
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
this.sort_options.forEach(function (option_group, group_index) {
|
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) {
|
if (this.multiple) {
|
||||||
let indexs = [];
|
let indexs = [];
|
||||||
let values = [];
|
let values = [];
|
||||||
@ -539,7 +558,7 @@ export default {
|
|||||||
let options = [];
|
let options = [];
|
||||||
|
|
||||||
this.selected.forEach(function (selected_option_id, selected_index) {
|
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);
|
indexs.push(selected_index);
|
||||||
values.push(option.id);
|
values.push(option.id);
|
||||||
labels.push(option.value);
|
labels.push(option.value);
|
||||||
@ -552,7 +571,7 @@ export default {
|
|||||||
this.$emit('label', labels);
|
this.$emit('label', labels);
|
||||||
this.$emit('option', options);
|
this.$emit('option', options);
|
||||||
} else {
|
} else {
|
||||||
if (option.value == this.selected) {
|
if (option.key == this.selected) {
|
||||||
this.$emit('index', index);
|
this.$emit('index', index);
|
||||||
this.$emit('value', option.id);
|
this.$emit('value', option.id);
|
||||||
this.$emit('label', option.value);
|
this.$emit('label', option.value);
|
||||||
@ -570,7 +589,7 @@ export default {
|
|||||||
let options = [];
|
let options = [];
|
||||||
|
|
||||||
this.selected.forEach(function (selected_option_id, selected_index) {
|
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);
|
indexs.push(selected_index);
|
||||||
values.push(option.id);
|
values.push(option.id);
|
||||||
labels.push(option.value);
|
labels.push(option.value);
|
||||||
@ -583,7 +602,7 @@ export default {
|
|||||||
this.$emit('label', labels);
|
this.$emit('label', labels);
|
||||||
this.$emit('option', options);
|
this.$emit('option', options);
|
||||||
} else {
|
} else {
|
||||||
if (option.value == this.selected) {
|
if (option.key == this.selected) {
|
||||||
this.$emit('index', index);
|
this.$emit('index', index);
|
||||||
this.$emit('value', option.id);
|
this.$emit('value', option.id);
|
||||||
this.$emit('label', option.value);
|
this.$emit('label', option.value);
|
||||||
@ -982,11 +1001,19 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.forEach(function (option, index) {
|
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({
|
this.sort_options.push({
|
||||||
index: index,
|
index: index,
|
||||||
key: option.id,
|
key: option.id,
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1000,11 +1027,19 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.forEach(function (option, index) {
|
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({
|
this.sort_options.push({
|
||||||
index: index,
|
index: index,
|
||||||
key: option.id,
|
key: option.id,
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user