From 9229a06500787a64705cb34c3b2d6d659229114c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 5 Feb 2022 16:50:01 -0500 Subject: [PATCH] LP#1929749: move the LI alert check to the service Signed-off-by: Galen Charlton --- .../staff/acq/lineitem/batch-copies.component.ts | 29 +--------------------- .../src/app/staff/acq/lineitem/lineitem.service.ts | 28 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.ts index 738b44cb20..568c0bcc17 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.ts @@ -105,7 +105,7 @@ export class LineitemBatchCopiesComponent implements OnInit { } receiveCopy(copy: IdlObject) { - this.checkLiAlerts().then(ok => { + this.liService.checkLiAlerts(this.lineitem, this.confirmAlertsDialog).then(ok => { this.net.request( 'open-ils.acq', 'open-ils.acq.lineitem_detail.receive', @@ -122,33 +122,6 @@ export class LineitemBatchCopiesComponent implements OnInit { ).subscribe(ok => this.handleActionResponse(ok)); } - checkLiAlerts(): Promise { - - let promise = Promise.resolve(true); - - const notes = this.lineitem.lineitem_notes().filter(note => - note.alert_text() && !this.liService.alertAcks[note.id()]); - - if (notes.length === 0) { return promise; } - - this.confirmAlertsDialog.liId = this.lineitem.id(); - this.confirmAlertsDialog.title = this.liService.getFirstAttributeValue(this.lineitem, 'title'); - - notes.forEach(n => { - promise = promise.then(_ => { - this.confirmAlertsDialog.alertText = n.alert_text(); - this.confirmAlertsDialog.alertComment = n.value(); - return this.confirmAlertsDialog.open().toPromise().then(ok => { - if (!ok) { return Promise.reject(); } - this.liService.alertAcks[n.id()] = true; - return true; - }); - }); - }); - - return promise; - } - hasEditableCopies(): boolean { if (this.lineitem) { const copies = this.lineitem.lineitem_details(); diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts index 7bc5b94a82..5bbe82c56c 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.service.ts @@ -8,6 +8,7 @@ import {PcrudService} from '@eg/core/pcrud.service'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; import {ItemLocationService} from '@eg/share/item-location-select/item-location-select.service'; import {saveAs} from 'file-saver'; +import {LineitemAlertDialogComponent} from './lineitem-alert-dialog.component'; const LINEITEM_DISPOSITIONS: 'new' | 'selector-ready' | 'order-ready' | 'pending-order' | 'on-order' | 'received' | 'delayed' = null; @@ -471,5 +472,32 @@ export class LineitemService { } ); } + + checkLiAlerts(li: IdlObject, dialog: LineitemAlertDialogComponent): Promise { + + let promise = Promise.resolve(true); + + const notes = li.lineitem_notes().filter(note => + note.alert_text() && !this.alertAcks[note.id()]); + + if (notes.length === 0) { return promise; } + + dialog.liId = li.id(); + dialog.title = this.getFirstAttributeValue(li, 'title'); + + notes.forEach(n => { + promise = promise.then(_ => { + dialog.alertText = n.alert_text(); + dialog.alertComment = n.value(); + return dialog.open().toPromise().then(ok => { + if (!ok) { return Promise.reject(); } + this.alertAcks[n.id()] = true; + return true; + }); + }); + }); + + return promise; + } } -- 2.11.0