From dfea746219b49692db8698559ce83efa2c30027c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 10 Feb 2021 15:15:13 -0500 Subject: [PATCH] LP1899406 Basket view allows for (de)select all operation Within the staff client catalog basket view page, users can now select and deselect all items in the basket for basket actions, without otherwise affecting the contents of the basket. Signed-off-by: Bill Erickson Signed-off-by: Michele Morgan --- .../app/staff/catalog/basket-actions.component.ts | 2 +- .../app/staff/catalog/basket-selection.service.ts | 3 ++ .../app/staff/catalog/result/record.component.ts | 18 ++++--- .../staff/catalog/result/results.component.html | 5 ++ .../app/staff/catalog/result/results.component.ts | 60 ++++++++++++++++------ 5 files changed, 63 insertions(+), 25 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts index bcd5dfe84a..13bf25dc3d 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts @@ -35,7 +35,7 @@ export class BasketActionsComponent implements OnInit { private printer: PrintService, private basket: BasketService, private cat: CatalogService, - private staffCat: StaffCatalogService + private staffCat: StaffCatalogService, private basketSelect: BasketSelectionService ) { this.basketAction = ''; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket-selection.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/basket-selection.service.ts index 892de60e23..ce9001e552 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/basket-selection.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/basket-selection.service.ts @@ -13,6 +13,8 @@ export class BasketSelectionService { idList: number[]; + onChange: EventEmitter = new EventEmitter(); + constructor(private basket: BasketService) { this.idList = []; } @@ -35,6 +37,7 @@ export class BasketSelectionService { setRecordIds(ids: number[]): Promise { this.idList = ids; + this.onChange.emit(this.idList); return Promise.resolve(this.idList); } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts index eb22bd8e02..0501c5f713 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts @@ -29,7 +29,7 @@ export class ResultRecordComponent implements OnInit, OnDestroy { searchContext: CatalogSearchContext; isRecordSelected: boolean; - basketSub: Subscription; + selectorSub: Subscription; hasCourse = false; courses: any[] = []; @@ -49,22 +49,24 @@ export class ResultRecordComponent implements OnInit, OnDestroy { ngOnInit() { this.searchContext = this.staffCat.searchContext; this.loadCourseInformation(this.summary.id); - this.isRecordSelected = this.basket.hasRecordId(this.summary.id); - - // Watch for basket changes caused by other components - this.basketSub = this.basket.onChange.subscribe(() => { - this.isRecordSelected = this.basket.hasRecordId(this.summary.id); - }); if (this.searchContext.showBasket) { this.recordSelector = this.basketSelect; } else { this.recordSelector = this.basket; } + + this.isRecordSelected = this.recordSelector.hasRecordId(this.summary.id); + + // Watch for basket changes caused by other components + this.selectorSub = this.recordSelector.onChange.subscribe(() => { + this.isRecordSelected = + this.recordSelector.hasRecordId(this.summary.id); + }); } ngOnDestroy() { - this.basketSub.unsubscribe(); + this.selectorSub.unsubscribe(); } loadCourseInformation(recordId) { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html index 8ca7b0f464..515121d186 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html @@ -44,6 +44,11 @@

Basket View

+