[terms] sort by exact match first, all containing later
This commit is contained in:
parent
8efc9a88bf
commit
68893ef2ce
|
@ -177,7 +177,15 @@
|
||||||
|
|
||||||
// those must be methods, not computed, because when modified, they don't get updated in the view for some reason
|
// those must be methods, not computed, because when modified, they don't get updated in the view for some reason
|
||||||
visibleEntries() {
|
visibleEntries() {
|
||||||
return Object.values(this.entries).filter(n => n.matches(this.filter));
|
const values = Object.values(this.entries).filter(n => n.matches(this.filter));
|
||||||
|
if (this.filter) {
|
||||||
|
return values.sort((a, b) => {
|
||||||
|
if (a.key && a.key.toLowerCase() === this.filter.toLowerCase()) { return -1; }
|
||||||
|
if (b.key && b.key.toLowerCase() === this.filter.toLowerCase()) { return 1; }
|
||||||
|
return a.term[0].localeCompare(b.term[0]);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return values;
|
||||||
},
|
},
|
||||||
entriesCountApproved() {
|
entriesCountApproved() {
|
||||||
return Object.values(this.entries).filter(n => n.approved).length;
|
return Object.values(this.entries).filter(n => n.approved).length;
|
||||||
|
|
Reference in New Issue