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>
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: {
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
this.loading = true;
return this.loadPatron()
.then(_ => this.setIdentTypes())
+ .then(_ => this.setOptInSettings())
.finally(() => this.loading = false);
}
});
}
+ 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)