From ad56e47db1643cf75aa2aa9f9ab23711d26dcbcd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Mar 2021 12:19:10 -0400 Subject: [PATCH] LP1904036 Patron editor continued Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../staff/circ/patron/edit-toolbar.component.html | 30 +++- .../staff/circ/patron/edit-toolbar.component.ts | 11 ++ .../src/app/staff/circ/patron/edit.component.html | 162 +++++++++++++++++---- .../src/app/staff/circ/patron/edit.component.ts | 42 +++++- .../src/app/staff/share/patron/patron.service.ts | 13 ++ 5 files changed, 217 insertions(+), 41 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.html index 8b625b9de0..6a6f19fe82 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.html @@ -1,10 +1,26 @@
-
- - - + +
+ Show: + + + +
+ +
+
+ + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts index 15c9d1e164..60f6dbad5c 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts @@ -6,15 +6,21 @@ import {NetService} from '@eg/core/net.service'; import {PatronService} from '@eg/staff/share/patron/patron.service'; import {PatronContextService} from './patron.service'; +type FieldOptions = 'required' | 'suggested' | 'all'; + @Component({ templateUrl: 'edit-toolbar.component.html', selector: 'eg-patron-edit-toolbar' }) export class EditToolbarComponent implements OnInit { + showFields: FieldOptions = 'all'; + @Output() saveClicked: EventEmitter = new EventEmitter(); @Output() saveCloneClicked: EventEmitter = new EventEmitter(); @Output() printClicked: EventEmitter = new EventEmitter(); + @Output() showFieldsChanged: + EventEmitter = new EventEmitter(); constructor( private org: OrgService, @@ -25,5 +31,10 @@ export class EditToolbarComponent implements OnInit { ngOnInit() { } + + changeFields(field: FieldOptions) { + this.showFields = field; + this.showFieldsChanged.emit(field); + } } 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 7d19146092..dfd73ebb9e 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 @@ -1,21 +1,28 @@ -Show: -Required Fields -Suggested Fields -All Fields +
+
+ +
+
-
- + +
+ + + + + + +
+ +
+
+ + + + + + + +
+ + + +
+
+
+ *ngTemplateOutlet="fieldInput; context: {field: 'usrname'}">
+ *ngTemplateOutlet="fieldInput; context: {field: 'passwd'}">
-
+
+ + +
+ + +
+
+
+ + +
+
+ + +
+
+
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 2ccd57c4c6..7bf60989ef 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 @@ -6,6 +6,7 @@ import {IdlService, IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.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 FLESH_PATRON_FIELDS = { flesh: 1, @@ -28,6 +29,9 @@ export class EditComponent implements OnInit { patron: IdlObject; changeHandlerNeeded = false; nameTab = 'primary'; + loading = false; + + identTypes: ComboboxEntry[]; constructor( private org: OrgService, @@ -38,12 +42,29 @@ export class EditComponent implements OnInit { ) {} ngOnInit() { + this.load(); + } + + load(): Promise { + this.loading = true; + return this.loadPatron() + .then(_ => this.setIdentTypes()) + .finally(() => this.loading = false); + } + setIdentTypes(): Promise { + return this.patronService.getIdentTypes() + .then(types => { + this.identTypes = types.map(t => ({id: t.id(), label: t.name()})); + }); + } + + loadPatron(): Promise { if (this.patronId) { - this.patronService.getById(this.patronId, FLESH_PATRON_FIELDS) + return this.patronService.getById(this.patronId, FLESH_PATRON_FIELDS) .then(patron => this.patron = patron); } else { - this.createNewPatron(); + return Promise.resolve(this.createNewPatron()); } } @@ -68,7 +89,19 @@ export class EditComponent implements OnInit { this.idl.classes[idlClass].field_map[field].label; } + // With this, the 'cls' specifier is only needed in the template + // when it's not 'au', which is the base/common class. + getClass(cls: string): string { + return cls || 'au'; + } + + getFieldValue(path: string, field: string): any { + return this.objectFromPath(path)[field](); + } + fieldValueChange(path: string, field: string, value: any) { + if (typeof value === 'boolean') { value = value ? 't' : 'f'; } + this.changeHandlerNeeded = true; this.objectFromPath(path)[field](value); } @@ -80,11 +113,12 @@ export class EditComponent implements OnInit { this.changeHandlerNeeded = false; - console.debug(`Modifying field path=${path} field=${field}`); - // check stuff here.. const obj = path ? this.patron[path]() : this.patron; + const value = obj[field](); + + console.debug(`Modifying field path=${path} field=${field} value=${value}`); } fieldRequired(idlClass: string, field: string): boolean { diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts index d0c98bfccd..ee9cf7df37 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts @@ -11,6 +11,9 @@ import {BarcodeSelectComponent} from '@eg/staff/share/barcodes/barcode-select.co @Injectable() export class PatronService { + + identTypes: IdlObject[]; + constructor( private net: NetService, private org: OrgService, @@ -86,5 +89,15 @@ export class PatronService { return null; }); } + + getIdentTypes(): Promise { + if (this.identTypes) { + return Promise.resolve(this.identTypes); + } + + return this.pcrud.retrieveAll('cit', + {order_by: {cit: ['name']}}, {atomic: true}) + .toPromise().then(types => this.identTypes = types); + } } -- 2.11.0