From c80beb8e3d55f988ad59cad13af2c5248370222e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Mar 2021 12:42:14 -0400 Subject: [PATCH] LP1904036 Patron editor continued Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/edit.component.html | 21 ++++++++++ .../src/app/staff/circ/patron/edit.component.ts | 49 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) 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 7cde10d9c9..b04a12c462 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 @@ -250,5 +250,26 @@ context: {field: 'ident_type', entries: identTypes}"> +
+ + +
+
+ + +
+
+ + +
+
+ + +
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 7bf60989ef..c6c3a55b1d 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 @@ -4,10 +4,22 @@ import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {OrgService} from '@eg/core/org.service'; import {IdlService, IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {PcrudService} from '@eg/core/pcrud.service'; import {PatronService} from '@eg/staff/share/patron/patron.service'; import {PatronContextService} from './patron.service'; import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component'; +const COMMON_USER_SETTING_TYPES = [ + 'circ.holds_behind_desk', + 'circ.collections.exempt', + 'opac.hold_notify', + 'opac.default_phone', + 'opac.default_pickup_location', + 'opac.default_sms_carrier', + 'opac.default_sms_notify' +]; + const FLESH_PATRON_FIELDS = { flesh: 1, flesh_fields: { @@ -32,10 +44,14 @@ export class EditComponent implements OnInit { loading = false; identTypes: ComboboxEntry[]; + userSettingTypes: {[name: string]: IdlObject} = {}; + optInSettingTypes: {[name: string]: IdlObject} = {}; constructor( private org: OrgService, private net: NetService, + private auth: AuthService, + private pcrud: PcrudService, private idl: IdlService, public patronService: PatronService, public context: PatronContextService @@ -49,6 +65,7 @@ export class EditComponent implements OnInit { this.loading = true; return this.loadPatron() .then(_ => this.setIdentTypes()) + .then(_ => this.setOptInSettings()) .finally(() => this.loading = false); } @@ -59,6 +76,38 @@ export class EditComponent implements OnInit { }); } + setOptInSettings(): Promise { + + const orgIds = this.org.ancestors(this.auth.user().ws_ou(), true); + + const query = { + '-or' : [ + {name : COMMON_USER_SETTING_TYPES}, + {name : { // opt-in notification user settings + 'in': { + select : {atevdef : ['opt_in_setting']}, + from : 'atevdef', + // we only care about opt-in settings for + // event_defs our users encounter + where : {'+atevdef' : {owner : orgIds}} + } + }} + ] + }; + + return this.pcrud.search('cust', query, {}, {atomic : true}) + .toPromise().then(types => { + + types.forEach(stype => { + this.userSettingTypes[stype.name()] = stype; + if (!COMMON_USER_SETTING_TYPES.includes(stype.name())) { + this.optInSettingTypes[stype.name()] = stype; + } + }); + }); + }; + + loadPatron(): Promise { if (this.patronId) { return this.patronService.getById(this.patronId, FLESH_PATRON_FIELDS) -- 2.11.0