LP1904036 Patron editor continued
authorBill Erickson <berickxx@gmail.com>
Wed, 17 Mar 2021 16:42:14 +0000 (12:42 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:27 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts

index 7cde10d..b04a12c 100644 (file)
         context: {field: 'ident_type', entries: identTypes}">
     </ng-container>
   </div>
+  <div class="row pt-1 pb-1 mt-1">
+    <ng-container 
+      *ngTemplateOutlet="fieldInput; context: {field: 'ident_value'}">
+    </ng-container>
+  </div>
+  <div class="row pt-1 pb-1 mt-1">
+    <ng-container 
+      *ngTemplateOutlet="fieldCombobox; 
+        context: {field: 'ident_type2', entries: identTypes}">
+    </ng-container>
+  </div>
+  <div class="row pt-1 pb-1 mt-1">
+    <ng-container 
+      *ngTemplateOutlet="fieldInput; context: {field: 'ident_value2'}">
+    </ng-container>
+  </div>
+  <div class="row pt-1 pb-1 mt-1">
+    <ng-container 
+      *ngTemplateOutlet="fieldInput; context: {field: 'email', type: 'email'}">
+    </ng-container>
+  </div>
 </div>
 
index 7bf6098..c6c3a55 100644 (file)
@@ -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<any> {
+
+        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<any> {
         if (this.patronId) {
             return this.patronService.getById(this.patronId, FLESH_PATRON_FIELDS)