From 52abc07ea7947290aa577aab41a74d9b75670458 Mon Sep 17 00:00:00 2001 From: Llewellyn Marshall Date: Fri, 11 Mar 2022 14:42:25 -0500 Subject: [PATCH] added simple sort to angular catalog to mirror the traditional catalog's method where simple sort CCVMs are sorted and separated from regular CCVMs by an empty option in the drop down. --- .../app/staff/catalog/search-form.component.html | 31 +++++++++++----------- .../src/app/staff/catalog/search-form.component.ts | 26 ++++++++++++++++++ 2 files changed, 41 insertions(+), 16 deletions(-) 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..576538307f 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,15 +1,14 @@ - - - + - + @@ -42,7 +41,7 @@ @@ -172,7 +171,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.item_type"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.item_type, simple:ccvmSimpleMap.item_type}"> @@ -181,7 +180,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.item_form"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.item_form, simple:ccvmSimpleMap.item_form}"> @@ -190,7 +189,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.item_lang" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.item_lang, simple:ccvmSimpleMap.item_lang}"> @@ -199,7 +198,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.audience" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.audience, simple:ccvmSimpleMap.audience}"> @@ -208,7 +207,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.vr_format" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.vr_format, simple:ccvmSimpleMap.vr_format}"> @@ -217,7 +216,7 @@ [(ngModel)]="context.termSearch.ccvmFilters.bib_level" multiple="true"> + *ngTemplateOutlet="ccvmOption;context:{list:ccvmMap.bib_level, simple:ccvmSimpleMap.bib_level}"> @@ -226,7 +225,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..9615b49292 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[]; @@ -61,6 +62,9 @@ export class SearchFormComponent implements OnInit, AfterViewInit { // Start with advanced search options open // if any filters are active. this.showSearchFilters = this.filtersActive(); + + //create our simple sort list + this.CompileSimpleSelector(); // Some search scenarios, like rendering a search template, // will not be searchable and thus not resovle to a specific @@ -312,6 +316,28 @@ 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; + }); + }); + } } -- 2.11.0