From: Bill Erickson Date: Mon, 22 Mar 2021 20:34:47 +0000 (-0400) Subject: LP1904036 surveys and more addresses X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=db39dc68ed548f596aaf3fae2d37fde896b41769;p=working%2FEvergreen.git LP1904036 surveys and more addresses Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- 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 2412f672cb..57558f8d1a 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 @@ -424,7 +424,9 @@ -
User Settings
+
+
User Settings
+
@@ -505,27 +507,34 @@ - -
-
Address
-
-
- - -
-
- - +
+
Addresses
+
+ +
+ +
+
+
Address #{{index + 1}}
+
+
+ + +
+
+ + +
+
-
- +
-
Statistical Categories
+
+
Statistical Categories
+
@@ -580,13 +591,27 @@
-
Surveys
+
+
Surveys
+
-
-
- -
-
+
+
{{survey.name()}}
+
+
+
+ +
+
+ + +
+
+
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 4d5a52cb40..e96149ddb8 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 @@ -361,6 +361,25 @@ export class EditComponent implements OnInit { this.userSettings[name] = value; } + applySurveyResponse(question: IdlObject, answer: ComboboxEntry) { + if (!this.patron.survey_responses()) { + this.patron.survey_responses([]); + } + + const responses = this.patron.survey_responses() + .filter(resp => resp.question() !== question.id()); + + const resp = this.idl.create('asvr'); + resp.isnew(true); + resp.survey(question.survey()); + resp.question(question.id()); + resp.answer(answer.id); + resp.usr(this.patron.id()); + resp.answer_date('now'); + responses.push(resp); + this.patron.survey_responses(responses); + } + // Called as the model changes. // This may be called many times before the final value is applied, // so avoid any heavy lifting here. See afterFieldChange(); @@ -568,14 +587,57 @@ export class EditComponent implements OnInit { } deleteAddr(addr: IdlObject) { + const addresses = this.patron.addresses(); + let promise = Promise.resolve(false); + + if (this.patron.isnew() && addresses.length === 1) { + promise = this.serverStore.getItem( + 'ui.patron.registration.require_address'); + } + + promise.then(required => { + if (required) { + // TODO alert and exit + return; + } + + // Roll the mailing/billing designation to another + // address when needed. + if (this.patron.mailing_address().id() === addr.id()) { + this.setAddrType('mailing', addr, false); + } + + if (this.patron.billing_address().id() === addr.id()) { + this.setAddrType('billing', addr, false); + } + + if (addr.isnew()) { + let idx = 0; + + addresses.some((a, i) => { + if (a.id() === addr.id()) { idx = i; return true; } + }); + + // New addresses can be discarded + addresses.splice(idx, 1); + + } else { + addr.isdeleted(true); + } + }); } newAddr() { const addr = this.idl.create('aua'); + addr.id(this.autoId--); addr.isnew(true); addr.valid('t'); this.patron.addresses().push(addr); } + + nonDeletedAddresses(): IdlObject[] { + return this.patron.addresses().filter(a => !a.isdeleted()); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts index 7f96c44c6f..90cf9df1c7 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts @@ -44,6 +44,7 @@ export class PatronResolver implements Resolve> { 'circ.staff_client.do_not_auto_attempt_print', 'circ.disable_patron_credit', 'sms.enable', + 'ui.patron.registration.require_address', 'credit.processor.default' ]).then(settings => { this.context.noTallyClaimsReturned =