From: Bill Erickson Date: Wed, 24 Mar 2021 21:34:21 +0000 (-0400) Subject: LP1904036 Barcodes dialog; toolbar integration X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1a0d029718c7928cf85d4be3a6562f0ff9bc81d;p=working%2FEvergreen.git LP1904036 Barcodes dialog; toolbar integration 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-toolbar.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.html index 7b6d74bf4b..1655dd82e0 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 @@ -3,24 +3,24 @@
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 9a686608d4..0569ce39f4 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 @@ -4,7 +4,13 @@ import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {OrgService} from '@eg/core/org.service'; import {NetService} from '@eg/core/net.service'; import {PatronService} from '@eg/staff/share/patron/patron.service'; -import {PatronContextService, FieldVisibilityLevel} from './patron.service'; +import {PatronContextService} from './patron.service'; + +export enum VisibilityLevel { + ALL_FIELDS = 0, + SUGGESTED_FIELDS = 1, + REQUIRED_FIELDS = 2 +} @Component({ templateUrl: 'edit-toolbar.component.html', @@ -12,6 +18,15 @@ import {PatronContextService, FieldVisibilityLevel} from './patron.service'; }) export class EditToolbarComponent implements OnInit { + disableSave = false; + visibilityLevel: VisibilityLevel = VisibilityLevel.ALL_FIELDS; + + disableSaveStateChanged: EventEmitter = new EventEmitter(); + + saveClicked: EventEmitter = new EventEmitter(); + saveCloneClicked: EventEmitter = new EventEmitter(); + printClicked: EventEmitter = new EventEmitter(); + constructor( private org: OrgService, private net: NetService, @@ -20,10 +35,12 @@ export class EditToolbarComponent implements OnInit { ) {} ngOnInit() { + // Emitted by our editor component. + this.disableSaveStateChanged.subscribe(d => this.disableSave = d); } - changeFields(v: FieldVisibilityLevel) { - this.context.editorFieldVisibilityLevel = v; + changeFields(v: VisibilityLevel) { + this.visibilityLevel = v; } } 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 fa6d555754..fe3d34f8c8 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 @@ -13,6 +13,7 @@ +
@@ -161,7 +162,7 @@ -
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 4b08ab908e..4bdffa9e7b 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 @@ -8,7 +8,7 @@ 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, FieldVisibilityLevel} from './patron.service'; +import {PatronContextService} from './patron.service'; import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component'; import {DateUtil} from '@eg/share/util/date'; import {ProfileSelectComponent} from '@eg/staff/share/patron/profile-select.component'; @@ -18,6 +18,7 @@ import {EventService} from '@eg/core/event.service'; import {PermService} from '@eg/core/perm.service'; import {SecondaryGroupsDialogComponent} from './secondary-groups.component'; import {ServerStoreService} from '@eg/core/server-store.service'; +import {EditToolbarComponent, VisibilityLevel} from './edit-toolbar.component'; const COMMON_USER_SETTING_TYPES = [ 'circ.holds_behind_desk', @@ -94,6 +95,7 @@ export class EditComponent implements OnInit { @Input() patronId: number; @Input() cloneId: number; @Input() stageUsername: string; + @Input() toolbar: EditToolbarComponent; @ViewChild('profileSelect') private profileSelect: ProfileSelectComponent; @@ -118,6 +120,7 @@ export class EditComponent implements OnInit { optInSettingTypes: {[name: string]: IdlObject} = {}; secondaryGroups: IdlObject[]; expireDate: Date; + changesPending = false; fieldVisibility: {[key: string]: FieldVisibility} = {}; @@ -148,9 +151,9 @@ export class EditComponent implements OnInit { ngOnInit() { // Listen for edit-toolbar events - this.context.saveClicked.subscribe(_ => this.save()); - this.context.saveCloneClicked.subscribe(_ => this.saveClone()); - this.context.printClicked.subscribe(_ => this.printPatron()); + this.toolbar.saveClicked.subscribe(_ => this.save()); + this.toolbar.saveCloneClicked.subscribe(_ => this.saveClone()); + this.toolbar.printClicked.subscribe(_ => this.printPatron()); this.load(); } @@ -169,6 +172,9 @@ export class EditComponent implements OnInit { .then(_ => this.loading = false); } + setupToolbar() { + } + setSurveys(): Promise { return this.patronService.getSurveys() .then(surveys => this.surveys = surveys); @@ -388,10 +394,18 @@ export class EditComponent implements OnInit { return this.objectFromPath(path, index)[field](); } + adjustSaveSate() { + // Avoid responding to any value changes while we are loading + if (this.loading) { return; } - userStatCatChange(cat: IdlObject, entry: ComboboxEntry) { - // TODO: set dirty + // TODO other checks + this.changesPending = true; + const canSave = document.querySelector('.ng-invalid') === null; + this.toolbar.disableSaveStateChanged.emit(!canSave); + } + + userStatCatChange(cat: IdlObject, entry: ComboboxEntry) { let map = this.patron.stat_cat_entries() .filter(m => m.stat_cat() === cat.id())[0]; @@ -411,11 +425,13 @@ export class EditComponent implements OnInit { map.target_usr(this.patronId); this.patron.stat_cat_entries().push(map); } + + this.adjustSaveSate(); } userSettingChange(name: string, value: any) { - // TODO: set dirty this.userSettings[name] = value; + this.adjustSaveSate(); } applySurveyResponse(question: IdlObject, answer: ComboboxEntry) { @@ -458,8 +474,6 @@ export class EditComponent implements OnInit { if (!this.changeHandlerNeeded) { return; } // no changes applied this.changeHandlerNeeded = false; - // TODO: set dirty - const obj = this.objectFromPath(path, index); const value = this.getFieldValue(path, index, field); obj.ischanged(true); // isnew() supersedes @@ -474,6 +488,7 @@ export class EditComponent implements OnInit { this.setExpireDate(); break; } + this.adjustSaveSate(); } showField(field: string): boolean { @@ -517,13 +532,17 @@ export class EditComponent implements OnInit { this.fieldVisibility[field] = DEFAULT_FIELD_VISIBILITY[field] || 0; } - return this.fieldVisibility[field] >= - this.context.editorFieldVisibilityLevel; + return this.fieldVisibility[field] >= this.toolbar.visibilityLevel; } fieldRequired(field: string): boolean { - // TODO - return false; + + // Password field is not required for existing patrons. + if (field === 'au.passwd' && !this.patronId) { + return false; + } + + return this.fieldVisibility[field] == 3; } @@ -834,6 +853,10 @@ export class EditComponent implements OnInit { showBarcodes() { } + + canSave(): boolean { + return document.querySelector('.ng-invalid') === null; + } } diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html index e830e7a4ad..c67b31e524 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html @@ -104,7 +104,8 @@
  • Edit - + +
  • @@ -190,7 +191,7 @@ - +
    diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts index d155585a69..d37e6187bf 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, AfterViewInit} from '@angular/core'; +import {Component, ViewChild, OnInit, AfterViewInit} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {NetService} from '@eg/core/net.service'; @@ -8,6 +8,7 @@ import {PatronService} from '@eg/staff/share/patron/patron.service'; import {PatronContextService, BillGridEntry} from './patron.service'; import {PatronSearch, PatronSearchComponent } from '@eg/staff/share/patron/search.component'; +import {EditToolbarComponent} from './edit-toolbar.component'; const MAIN_TABS = ['checkout', 'items_out', 'holds', 'bills', 'messages', 'edit', 'search']; @@ -25,6 +26,11 @@ export class PatronComponent implements OnInit, AfterViewInit { showSummary = true; loading = true; + /* eg-patron-edit is unable to find #editorToolbar directly + * within the template. Adding a ref here allows it to + * successfully transfer to the editor */ + @ViewChild('editorToolbar') editorToolbar: EditToolbarComponent; + constructor( private router: Router, private route: ActivatedRoute, diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts index e4bed3ba32..439059fc53 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts @@ -28,6 +28,7 @@ import {PatronStatCatsComponent} from './statcats.component'; import {PatronGroupComponent} from './group.component'; import {RegisterPatronComponent} from './register.component'; import {SecondaryGroupsDialogComponent} from './secondary-groups.component'; +import {PatronBarcodesDialogComponent} from './barcodes.component'; @NgModule({ declarations: [ @@ -47,6 +48,7 @@ import {SecondaryGroupsDialogComponent} from './secondary-groups.component'; PatronGroupComponent, RegisterPatronComponent, PatronStatCatsComponent, + PatronBarcodesDialogComponent, SecondaryGroupsDialogComponent ], imports: [ diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts index 49be822e76..bb703bc6ed 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts @@ -8,12 +8,6 @@ import {PatronSearch} from '@eg/staff/share/patron/search.component'; import {StoreService} from '@eg/core/store.service'; import {CircService, CircDisplayInfo} from '@eg/staff/share/circ/circ.service'; -export enum FieldVisibilityLevel { - ALL_FIELDS = 0, - SUGGESTED_FIELDS = 1, - REQUIRED_FIELDS = 2 -} - export interface BillGridEntry extends CircDisplayInfo { xact: IdlObject; // mbt billingLocation?: string; @@ -115,16 +109,6 @@ export class PatronContextService { settingsCache: {[key: string]: any} = {}; - // Emitted by the patron edit toolbar, which is kept as a - // separate component so it can be positioned differently. - // We just act as a go-between. - saveClicked: EventEmitter = new EventEmitter(); - saveCloneClicked: EventEmitter = new EventEmitter(); - printClicked: EventEmitter = new EventEmitter(); - - editorFieldVisibilityLevel: FieldVisibilityLevel = - FieldVisibilityLevel.ALL_FIELDS; - constructor( private store: StoreService, private net: NetService, diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html index fd7f2834b5..94284b62f7 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html @@ -3,7 +3,8 @@
    - - + +