From: Galen Charlton Date: Sat, 5 Feb 2022 22:34:16 +0000 (-0500) Subject: LP#1929749: teach LI alert checking to handle more than one LI X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3c506734636d29bb5cd6c9f14046ad92b50da848;p=working%2FEvergreen.git LP#1929749: teach LI alert checking to handle more than one LI Signed-off-by: Galen Charlton --- 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 568c0bcc17..370ed34da0 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.liService.checkLiAlerts(this.lineitem, this.confirmAlertsDialog).then(ok => { + this.liService.checkLiAlerts([this.lineitem], this.confirmAlertsDialog).then(ok => { this.net.request( 'open-ils.acq', 'open-ils.acq.lineitem_detail.receive', diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.html index 8c5942e668..05a02d8204 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.html @@ -3,9 +3,15 @@ dialogTitle="Confirm Alert" [dialogBodyTemplate]="confirmAlertsMsg"> +
+ Alert {{alertIndex}} out of {{numAlerts}} +
An alert has been placed on line item {{liId}} ({{title}})
{{alertText.code()}}
{{alertText.description()}}
{{alertComment}}
-
Choose "Confirm" to acknowledge this alert and continue with receiving. Otherwise, choose "Cancel".
+
Choose "Confirm" to acknowledge this alert and continue with receiving. + Otherwise, choose "Cancel" to not receive the line item(s). If there is more than one alert, + all of them must be confirmed in order to complete the receiving. +
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.ts index 3faecae011..37b480d291 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-alert-dialog.component.ts @@ -13,6 +13,8 @@ export class LineitemAlertDialogComponent { @Input() title: string; @Input() alertText: IdlObject; @Input() alertComment: string; + @Input() numAlerts = 0; + @Input() alertIndex = 0; @ViewChild('confirmAlertsDialog') confirmAlertsDialog: ConfirmDialogComponent; 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 5bbe82c56c..5fc3d38a85 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 @@ -56,6 +56,13 @@ export interface FleshCacheParams { toCache?: boolean; } +interface LineitemAlertData { + liId: number; + title: string; + alertText: IdlObject; + alertComment: string; +} + @Injectable() export class LineitemService { @@ -473,25 +480,38 @@ export class LineitemService { ); } - checkLiAlerts(li: IdlObject, dialog: LineitemAlertDialogComponent): Promise { + checkLiAlerts(lis: IdlObject[], dialog: LineitemAlertDialogComponent): Promise { let promise = Promise.resolve(true); - const notes = li.lineitem_notes().filter(note => - note.alert_text() && !this.alertAcks[note.id()]); + const alerts: LineitemAlertData[] = []; + lis.forEach(li => { + li.lineitem_notes().filter( + note => note.alert_text() && !this.alertAcks[note.id()] + ).forEach(alert => + alerts.push({ + liId: li.id(), + title: this.getFirstAttributeValue(li, 'title'), + alertText: alert.alert_text(), + alertComment: alert.value() + }) + ); + }); - if (notes.length === 0) { return promise; } + if (alerts.length === 0) { return promise; } - dialog.liId = li.id(); - dialog.title = this.getFirstAttributeValue(li, 'title'); + dialog.numAlerts = alerts.length; - notes.forEach(n => { + alerts.forEach((alert, i) => { promise = promise.then(_ => { - dialog.alertText = n.alert_text(); - dialog.alertComment = n.value(); + dialog.liId = alert.liId; + dialog.title = alert.title; + dialog.alertText = alert.alertText; + dialog.alertComment = alert.alertComment; + dialog.alertIndex = i + 1; return dialog.open().toPromise().then(ok => { if (!ok) { return Promise.reject(); } - this.alertAcks[n.id()] = true; + this.alertAcks[alert.alertText.id()] = true; return true; }); });