From fa453b2385e567ca890b91b172aae79d9b26fef0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 8 Jul 2022 11:17:51 -0400 Subject: [PATCH] LP1956790 Support applying copy alerts via templates Fixes an issue where copy alerts contained within copy templates failed to apply when using the new Angular holdings editor. Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/copy-attrs.component.ts | 33 ++++++++++++++++++++-- .../src/app/staff/cat/volcopy/volcopy.service.ts | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts index 8b4c29bc9c..402de23917 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts @@ -497,9 +497,38 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { if (field === 'statcats') { Object.keys(value).forEach(catId => { - this.statCatValues[+catId] = value[+catId]; - this.statCatChanged(+catId); + if (value[+catId] !== null) { + this.statCatValues[+catId] = value[+catId]; + this.statCatChanged(+catId); + } + }); + return; + } + + // Copy alerts are stored as hashes of the bits we need. + // Templates can be used to create alerts, but not edit them. + if (field === 'copy_alerts' && Array.isArray(value)) { + value.forEach(a => { + this.context.copyList().forEach(copy => { + const newAlert = this.idl.create('aca'); + newAlert.isnew(true); + newAlert.copy(copy.id()); + newAlert.alert_type(a.alert_type); + newAlert.temp(a.temp); + newAlert.note(a.note); + newAlert.create_staff(this.auth.user().id()); + newAlert.create_time('now'); + + if (Array.isArray(copy.copy_alerts())) { + copy.copy_alerts().push(newAlert); + } else { + copy.copy_alerts([newAlert]); + } + + copy.ischanged(true); + }); }); + return; } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts index d898c3e27f..2306220c55 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts @@ -226,6 +226,7 @@ export class VolCopyService { copy.parts([]); copy.tags([]); copy.notes([]); + copy.copy_alerts([]); copy.stat_cat_entries([]); return copy; -- 2.11.0