From 0eac3a972cf0876a474d7c0d9fc024d12b2110e9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 29 Mar 2021 15:42:31 -0400 Subject: [PATCH] LP1904036 Dupe searches, help/example text Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../staff/circ/patron/edit-toolbar.component.html | 25 +++++++++------- .../staff/circ/patron/edit-toolbar.component.ts | 34 +++++++++------------- .../src/app/staff/circ/patron/edit.component.html | 15 +++++++++- .../src/app/staff/circ/patron/edit.component.ts | 26 ++++++++++++++++- .../src/app/staff/share/patron/search.component.ts | 22 +++++++++++--- 5 files changed, 85 insertions(+), 37 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 5af7748763..580a745b92 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 @@ -25,19 +25,22 @@ -
+
-
- {{dupe.count}} patron(s) with same - - phone - email - name - identifier - address - +
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 32a3329f44..d715cbc639 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 @@ -20,6 +20,7 @@ interface DupeSearch { category: SearchCategory; count: number; search: PatronSearchFieldSet; + json: string; } @Component({ @@ -39,7 +40,7 @@ export class EditToolbarComponent implements OnInit { saveCloneClicked: EventEmitter = new EventEmitter(); printClicked: EventEmitter = new EventEmitter(); - dupeSearches: DupeSearch[] = []; + searches: {[category: string]: DupeSearch} = {}; constructor( private org: OrgService, @@ -58,6 +59,12 @@ export class EditToolbarComponent implements OnInit { this.visibilityLevel = v; } + dupesFound(): DupeSearch[] { + return Object.values(this.searches).filter(dupe => dupe.count > 0); + } + + + checkDupes(category: string, search: PatronSearchFieldSet) { this.net.request( @@ -70,25 +77,12 @@ export class EditToolbarComponent implements OnInit { true // as id ).subscribe(ids => { ids = ids.filter(id => Number(id) !== this.patronId); - const count = ids.length; - - if (count > 0) { - const existing = - this.dupeSearches.filter(s => s.category === category)[0]; - if (existing) { - existing.search = search; - existing.count = count; - } else { - this.dupeSearches.push({ - category: category as SearchCategory, - search: search, - count: count - }); - } - } else { - this.dupeSearches = - this.dupeSearches.filter(s => s.category !== category); - } + this.searches[category] = { + category: category as SearchCategory, + count: ids.length, + search: search, + json: JSON.stringify(search) + }; }); } } 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 75d06e0105..5b05342888 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 @@ -21,13 +21,22 @@
+ + + Example: {{exampleText(args.cls, args.field)}} + + +
- + +
@@ -143,6 +152,8 @@ + +
@@ -336,6 +347,8 @@ + + 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 50553da4d3..d379718fb4 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 @@ -159,6 +159,8 @@ export class EditComponent implements OnInit, AfterViewInit { holdNotifyTypes: {email?: boolean, phone?: boolean, sms?: boolean} = {}; + fieldDoc: {[cls: string]: {[field: string]: string}} = {}; + constructor( private org: OrgService, private net: NetService, @@ -184,6 +186,7 @@ export class EditComponent implements OnInit, AfterViewInit { load(): Promise { this.loading = true; return this.setStatCats() + .then(_ => this.getFieldDocs()) .then(_ => this.setSurveys()) .then(_ => this.loadPatron()) .then(_ => this.getSecondaryGroups()) @@ -196,7 +199,28 @@ export class EditComponent implements OnInit, AfterViewInit { .then(_ => this.loading = false); } - setupToolbar() { + getFieldDocs(): Promise { + return this.pcrud.search('fdoc', { + fm_class: ['au', 'ac', 'aua', 'actsc', 'asv', 'asvq', 'asva']}) + .pipe(tap(doc => { + if (!this.fieldDoc[doc.fm_class()]) { + this.fieldDoc[doc.fm_class()] = {}; + } + this.fieldDoc[doc.fm_class()][doc.field()] = doc.string(); + console.log(this.fieldDoc); + })).toPromise(); + } + + getFieldDoc(cls: string, field: string): string { + cls = this.getClass(cls); + if (this.fieldDoc[cls]) { + return this.fieldDoc[cls][field]; + } + } + + exampleText(cls: string, field: string): string { + cls = this.getClass(cls); + return this.context.settingsCache[`ui.patron.edit.${cls}.${field}.example`]; } setSurveys(): Promise { diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts index d8a172c312..88025d7083 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts @@ -1,5 +1,6 @@ import {Component, Input, Output, OnInit, AfterViewInit, - EventEmitter, ViewChild, Renderer2} from '@angular/core'; + EventEmitter, ViewChild} from '@angular/core'; +import {ActivatedRoute, ParamMap} from '@angular/router'; import {Observable, of} from 'rxjs'; import {map} from 'rxjs/operators'; import {IdlObject} from '@eg/core/idl.service'; @@ -38,7 +39,7 @@ export interface PatronSearchFieldSet { export interface PatronSearch { search: PatronSearchFieldSet; - orgId: number; + orgId?: number; } @Component({ @@ -72,7 +73,7 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { profileGroups: IdlObject[] = []; constructor( - private renderer: Renderer2, + private route: ActivatedRoute, private net: NetService, public org: OrgService, private auth: AuthService, @@ -90,6 +91,18 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { } ngOnInit() { + + this.route.queryParamMap.subscribe((params: ParamMap) => { + const search = params.get('search'); + if (search) { + try { + this.startWithSearch = {search: JSON.parse(search)}; + } catch (E) { + console.error("Invalid JSON search value", search, E); + } + } + }); + this.searchOrg = this.org.root(); this.store.getItemBatch([EXPAND_FORM, INCLUDE_INACTIVE]) .then(settings => { @@ -99,7 +112,8 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { } ngAfterViewInit() { - this.renderer.selectRootElement('#focus-this-input').focus(); + const node = document.getElementById('focus-this-input'); + if (node) { node.focus(); } } toggleExpandForm() { -- 2.11.0