From: Llewellyn Marshall Date: Tue, 26 Jul 2022 17:41:02 +0000 (-0400) Subject: simple sort 3.9 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c759122ffa5bbeef3da4dcf045341860158fe028;p=working%2FEvergreen.git simple sort 3.9 --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html index 18bae19865..97aba1aac0 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html @@ -1,10 +1,11 @@ - - + + + + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.item_type, simple:ccvmSimpleMap.item_type}"> @@ -181,7 +182,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.item_form"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.item_form, simple:ccvmSimpleMap.item_form}"> @@ -190,7 +191,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.item_lang" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.item_lang, simple:ccvmSimpleMap.item_lang}"> @@ -199,7 +200,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.audience" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.audience, simple:ccvmSimpleMap.audience}"> @@ -208,7 +209,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.vr_format" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.vr_format, simple:ccvmSimpleMap.vr_format}"> @@ -217,7 +218,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.bib_level" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.bib_level, simple:ccvmSimpleMap.bib_level}"> @@ -226,7 +227,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.lit_form" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.lit_form, simple:ccvmSimpleMap.lit_form}"> diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts index c7d9898be9..b9fd2d1a79 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts @@ -30,6 +30,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { context: CatalogSearchContext; ccvmMap: {[ccvm: string]: IdlObject[]} = {}; + ccvmSimpleMap: {[ccvm: string]: IdlObject[]} = {}; cmfMap: {[cmf: string]: IdlObject} = {}; showSearchFilters = false; copyLocations: IdlObject[]; @@ -57,6 +58,9 @@ export class SearchFormComponent implements OnInit, AfterViewInit { this.ccvmMap = this.cat.ccvmMap; this.cmfMap = this.cat.cmfMap; this.context = this.staffCat.searchContext; + + //create our simple sort list + this.CompileSimpleSelector(); // Start with advanced search options open // if any filters are active. @@ -312,6 +316,30 @@ export class SearchFormComponent implements OnInit, AfterViewInit { searchFilters(): string[] { return this.staffCat.searchFilters; } + + //filters out CCVMs based on their is_simple attribute + CompileSimpleSelector(): void { + Object.keys(this.ccvmMap).forEach(cType => { + if (!this.ccvmSimpleMap[cType]) { + //creates simple sort list even if there might be no entries + this.ccvmSimpleMap[cType] = []; + } + + this.ccvmMap[cType].forEach(ccvm => { + if(ccvm.is_simple() === 't'){ + //push the is_simple ccvms to the simple map + this.ccvmSimpleMap[cType].push(ccvm) + }}); + }); + + //order the simple sort list + Object.keys(this.ccvmSimpleMap).forEach(cType => { + this.ccvmSimpleMap[cType] = + this.ccvmSimpleMap[cType].sort((a, b) => { + return a.value() < b.value() ? -1 : 1; + }); + }); + } }