Akaunting Select Group issue fixed
This commit is contained in:
parent
3d1522f545
commit
8665d89ef3
@ -67,17 +67,17 @@
|
|||||||
|
|
||||||
<el-option-group
|
<el-option-group
|
||||||
v-if="group"
|
v-if="group"
|
||||||
v-for="(group_options, name) in sortOptions"
|
v-for="(group_options, group_index) in sortOptions"
|
||||||
:key="name"
|
:key="group_options.key"
|
||||||
:label="name">
|
:label="group_options.key">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(label, value) in group_options"
|
v-for="(option, option_index) in group_options.value"
|
||||||
:key="value"
|
:key="option.option_index"
|
||||||
:disabled="disabledOptions.includes(value)"
|
:disabled="disabledOptions.includes(option.key)"
|
||||||
:label="label"
|
:label="option.value"
|
||||||
:value="value">
|
:value="option.key">
|
||||||
<span class="float-left">{{ label }}</span>
|
<span class="float-left">{{ option.value }}</span>
|
||||||
<span class="badge badge-pill badge-success float-right mt-2" v-if="new_options[value]">{{ addNew.new_text }}</span>
|
<span class="badge badge-pill badge-success float-right mt-2" v-if="new_options[option.key]">{{ addNew.new_text }}</span>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-option-group>
|
</el-option-group>
|
||||||
|
|
||||||
@ -279,42 +279,107 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
// Option set sort_option data
|
if (this.group) {
|
||||||
if (!Array.isArray(this.options)) {
|
// Option set sort_option data
|
||||||
for (const [key, value] of Object.entries(this.options)) {
|
if (!Array.isArray(this.options)) {
|
||||||
this.sort_options.push({
|
for (const [index, options] of Object.entries(this.options)) {
|
||||||
key: key,
|
let values = [];
|
||||||
value: value
|
|
||||||
});
|
for (const [key, value] of Object.entries(options)) {
|
||||||
|
values.push({
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sort_options.push({
|
||||||
|
key: index,
|
||||||
|
value: values
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.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
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.options.forEach(function (option, index) {
|
// Option set sort_option data
|
||||||
this.sort_options.push({
|
if (!Array.isArray(this.options)) {
|
||||||
index: index,
|
for (const [key, value] of Object.entries(this.options)) {
|
||||||
key: option.id,
|
this.sort_options.push({
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
key: key,
|
||||||
});
|
value: value
|
||||||
}, this);
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.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
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
sortOptions() {
|
sortOptions() {
|
||||||
this.sort_options.sort(function (a, b) {
|
if (this.group) {
|
||||||
var nameA = a.value.toUpperCase(); // ignore upper and lowercase
|
this.sort_options.sort(function (a, b) {
|
||||||
var nameB = b.value.toUpperCase(); // ignore upper and lowercase
|
var nameA = a.key.toUpperCase(); // ignore upper and lowercase
|
||||||
|
var nameB = b.key.toUpperCase(); // ignore upper and lowercase
|
||||||
|
|
||||||
if (nameA < nameB) {
|
if (nameA < nameB) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameA > nameB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const [index, options] of Object.entries(this.sort_options)) {
|
||||||
|
options.value.sort(function (aa, bb) {
|
||||||
|
var nameAA = aa.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
var nameBB = bb.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
|
||||||
|
if (nameAA < nameBB) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameAA > nameBB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.sort_options.sort(function (a, b) {
|
||||||
|
var nameA = a.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
var nameB = b.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
|
||||||
if (nameA > nameB) {
|
if (nameA < nameB) {
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// names must be equal
|
if (nameA > nameB) {
|
||||||
return 0;
|
return 1;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return this.sort_options;
|
return this.sort_options;
|
||||||
},
|
},
|
||||||
|
@ -69,17 +69,17 @@
|
|||||||
|
|
||||||
<el-option-group
|
<el-option-group
|
||||||
v-if="group"
|
v-if="group"
|
||||||
v-for="(group_options, name) in sortOptions"
|
v-for="(group_options, group_index) in sortOptions"
|
||||||
:key="name"
|
:key="group_options.key"
|
||||||
:label="name">
|
:label="group_options.key">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(label, value) in group_options"
|
v-for="(option, option_index) in group_options.value"
|
||||||
:key="value"
|
:key="option.option_index"
|
||||||
:disabled="disabledOptions.includes(value)"
|
:disabled="disabledOptions.includes(option.key)"
|
||||||
:label="label"
|
:label="option.value"
|
||||||
:value="value">
|
:value="option.key">
|
||||||
<span class="float-left">{{ label }}</span>
|
<span class="float-left">{{ option.value }}</span>
|
||||||
<span class="badge badge-pill badge-success float-right mt-2" v-if="new_options[value]">{{ addNew.new_text }}</span>
|
<span class="badge badge-pill badge-success float-right mt-2" v-if="new_options[option.key]">{{ addNew.new_text }}</span>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-option-group>
|
</el-option-group>
|
||||||
|
|
||||||
@ -165,18 +165,17 @@
|
|||||||
|
|
||||||
<el-option-group
|
<el-option-group
|
||||||
v-if="group"
|
v-if="group"
|
||||||
v-for="(group_options, name) in sortOptions"
|
v-for="(group_options, group_index) in sortOptions"
|
||||||
:key="name"
|
:key="group_options.key"
|
||||||
:label="name">
|
:label="group_options.key">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(label, value) in group_options"
|
v-for="(option, option_index) in group_options.value"
|
||||||
:key="value"
|
:key="option.option_index"
|
||||||
:disabled="disabledOptions.includes(value)"
|
:disabled="disabledOptions.includes(option.key)"
|
||||||
:label="label"
|
:label="option.value"
|
||||||
:value="value">
|
:value="option.key">
|
||||||
<span class="float-left">{{ label }}</span>
|
<span class="float-left">{{ option.value }}</span>
|
||||||
<span class="badge badge-pill badge-success float-right mt-2" v-if="new_options[value]">{{ addNew.new_text }}</span>
|
<span class="badge badge-pill badge-success float-right mt-2" v-if="new_options[option.key]">{{ addNew.new_text }}</span>
|
||||||
</el-option>
|
|
||||||
</el-option-group>
|
</el-option-group>
|
||||||
|
|
||||||
<el-option class="el-select__footer" :disabled="true" :value="add_new">
|
<el-option class="el-select__footer" :disabled="true" :value="add_new">
|
||||||
@ -399,21 +398,57 @@ export default {
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
sortOptions() {
|
sortOptions() {
|
||||||
this.sort_options.sort(function (a, b) {
|
if (this.group) {
|
||||||
var nameA = a.value.toUpperCase(); // ignore upper and lowercase
|
this.sort_options.sort(function (a, b) {
|
||||||
var nameB = b.value.toUpperCase(); // ignore upper and lowercase
|
var nameA = a.key.toUpperCase(); // ignore upper and lowercase
|
||||||
|
var nameB = b.key.toUpperCase(); // ignore upper and lowercase
|
||||||
|
|
||||||
if (nameA < nameB) {
|
if (nameA < nameB) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameA > nameB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const [index, options] of Object.entries(this.sort_options)) {
|
||||||
|
options.value.sort(function (aa, bb) {
|
||||||
|
var nameAA = aa.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
var nameBB = bb.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
|
||||||
|
if (nameAA < nameBB) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameAA > nameBB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.sort_options.sort(function (a, b) {
|
||||||
|
var nameA = a.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
var nameB = b.value.toUpperCase(); // ignore upper and lowercase
|
||||||
|
|
||||||
if (nameA > nameB) {
|
if (nameA < nameB) {
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// names must be equal
|
if (nameA > nameB) {
|
||||||
return 0;
|
return 1;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return this.sort_options;
|
return this.sort_options;
|
||||||
},
|
},
|
||||||
@ -444,6 +479,34 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
setSortOptions() {
|
setSortOptions() {
|
||||||
|
if (this.group) {
|
||||||
|
// Option set sort_option data
|
||||||
|
if (!Array.isArray(this.options)) {
|
||||||
|
for (const [index, options] of Object.entries(this.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 {
|
||||||
|
this.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
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Option set sort_option data
|
// Option set sort_option data
|
||||||
if (!Array.isArray(this.options)) {
|
if (!Array.isArray(this.options)) {
|
||||||
for (const [key, value] of Object.entries(this.options)) {
|
for (const [key, value] of Object.entries(this.options)) {
|
||||||
@ -461,6 +524,7 @@ export default {
|
|||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
change() {
|
change() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user