mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-25 03:58:17 +02:00
Sort lexically + active filter first
This commit is contained in:
parent
c7640de07e
commit
744d7368d4
1 changed files with 18 additions and 0 deletions
|
@ -27,6 +27,7 @@ const MciViewIds = {
|
|||
filterName : 6,
|
||||
navMenu : 7,
|
||||
|
||||
// :TODO: use the customs new standard thing - filter obj can have active/selected, etc.
|
||||
selectedFilterInfo : 10, // { ...filter object ... }
|
||||
activeFilterInfo : 11, // { ...filter object ... }
|
||||
error : 12, // validation errors
|
||||
|
@ -40,6 +41,23 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
|
|||
this.filtersArray = new FileBaseFilters(this.client).toArray(); // ordered, such that we can index into them
|
||||
this.currentFilterIndex = 0; // into |filtersArray|
|
||||
|
||||
//
|
||||
// Lexical sort + keep currently active filter (if any) as the first item in |filtersArray|
|
||||
//
|
||||
const activeFilter = FileBaseFilters.getActiveFilter(this.client);
|
||||
this.filtersArray.sort( (filterA, filterB) => {
|
||||
if(activeFilter) {
|
||||
if(filterA.uuid === activeFilter.uuid) {
|
||||
return -1;
|
||||
}
|
||||
if(filterB.uuid === activeFilter.uuid) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return filterA.name.localeCompare(filterB.name);
|
||||
});
|
||||
|
||||
this.menuMethods = {
|
||||
saveFilter : (formData, extraArgs, cb) => {
|
||||
return this.saveCurrentFilter(formData, cb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue