From: Bill Erickson Date: Wed, 10 Feb 2021 20:15:13 +0000 (-0500) Subject: LP1899406 Basket view allows for (de)select all operation X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flp1899406-staff-cat-view-basket-selection-v2;p=working%2FEvergreen.git 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 --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index af996c2383..36c3ead829 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -99,11 +99,14 @@ export class CatalogService { return this.basket.getRecordIds().then(ids => { + const pageIds = + ids.slice(ctx.pager.offset, ctx.pager.limit + ctx.pager.offset); + // Map our list of IDs into a search results object // the search context can understand. const result = { count: ids.length, - ids: ids.map(id => [id]) + ids: pageIds.map(id => [id]) }; this.applyResultData(ctx, result); 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 ac78bbad21..094d9efa9d 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

+