From c3086e18c16f8423bf07b702897bdb720bcc99e8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 8 Apr 2021 16:10:38 -0400 Subject: [PATCH] LP1904036 waivers Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/edit.component.html | 81 ++++++++++++++++------ .../src/app/staff/circ/patron/edit.component.ts | 33 ++++++++- 2 files changed, 91 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html index 49248b43af..f938378800 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html @@ -572,33 +572,72 @@ -
-
Allow others to use my account
+
- + Allow others to use my account
-
- - + +
+
+
+
+ + +
+
+ + +
-
- - +
+
+ + +
+
+ + +
-
-
-
- - +
+
-
- - +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts index 25e986cf07..f76e2fe6ab 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts @@ -721,6 +721,10 @@ export class EditComponent implements OnInit, AfterViewInit { this.userStatCats[map.stat_cat()] = cboxEntry; }); + + if (this.patron.waiver_entries().length === 0) { + this.addWaiver(); + } } createNewPatron() { @@ -748,10 +752,9 @@ export class EditComponent implements OnInit, AfterViewInit { patron.addresses([addr]); this.patron = patron; + this.addWaiver(); } - - objectFromPath(path: string, index: number): IdlObject { const base = path ? this.patron[path]() : this.patron; if (index === null || index === undefined) { @@ -1368,6 +1371,10 @@ export class EditComponent implements OnInit, AfterViewInit { saveUser(): Promise { this.modifiedPatron = null; + // A dummy waiver is added on load. Remove it if no values were added. + this.patron.waiver_entries( + this.patron.waiver_entries().filter(e => !e.isnew() || e.name())); + return this.net.request( 'open-ils.actor', 'open-ils.actor.patron.update', @@ -1614,6 +1621,28 @@ export class EditComponent implements OnInit, AfterViewInit { && !this.editProfiles.includes(this.patron.profile()) ); } + + addWaiver() { + const waiver = this.idl.create('aupw'); + waiver.isnew(true); + waiver.id(this.autoId--); + waiver.usr(this.patronId); + this.patron.waiver_entries().push(waiver); + } + + removeWaiver(waiver: IdlObject) { + if (waiver.isnew()) { + this.patron.waiver_entries( + this.patron.waiver_entries().filter(w => w.id() !== waiver.id())); + + if (this.patron.waiver_entries().length === 0) { + // We need at least one waiver to access action buttons + this.addWaiver(); + } + } else { + waiver.isdeleted(true); + } + } } -- 2.11.0