From e84a1e594d05a595135f9f624ccc5f5615ebba9c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 19 Mar 2021 18:11:31 -0400 Subject: [PATCH] LP1904036 Patron editor: stat cats Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/edit.component.ts | 25 +++++++++++++++++++++- .../src/app/staff/share/patron/patron.service.ts | 22 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) 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 1e2a9f1546..0d264833a3 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 @@ -54,6 +54,11 @@ const FLESH_PATRON_FIELDS = { } }; +interface StatCat { + cat: IdlObject; + entries: ComboboxEntry[]; +} + @Component({ templateUrl: 'edit.component.html', selector: 'eg-patron-edit', @@ -82,8 +87,9 @@ export class EditComponent implements OnInit { userSettings: {[name: string]: any} = {}; userSettingTypes: {[name: string]: IdlObject} = {}; optInSettingTypes: {[name: string]: IdlObject} = {}; - expireDate: Date; secondaryGroups: IdlObject[]; + statCats: StatCat[] = []; + expireDate: Date; // All locations we have the specified permissions permOrgs: {[name: string]: number[]}; @@ -122,10 +128,27 @@ export class EditComponent implements OnInit { .then(_ => this.setInetLevels()) .then(_ => this.setOptInSettings()) .then(_ => this.setOrgSettings()) + .then(_ => this.setStatCats()) .then(_ => this.setSmsCarriers()) .finally(() => this.loading = false); } + setStatCats(): Promise { + this.statCats = []; + return this.patronService.getStatCats().then(cats => { + cats.forEach(cat => { + const entries = cat.entries.map(entry => { + return {id: entry.id(), label: entry.value()}; + }); + + this.statCats.push({ + cat: cat, + entries: entries + }); + }); + }); + } + setOrgSettings(): Promise { return this.serverStore.getItemBatch(ORG_SETTING_TYPES) .then(settings => this.orgSettings = settings); 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 459975aa5f..ea1fb63081 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 @@ -17,6 +17,7 @@ export class PatronService { inetLevels: IdlObject[]; profileGroups: IdlObject[]; smsCarriers: IdlObject[]; + statCats: IdlObject[]; constructor( private net: NetService, @@ -135,5 +136,26 @@ export class PatronService { .pipe(tap(carrier => this.smsCarriers.push(carrier)) ).toPromise().then(_ => this.smsCarriers); } + + // Local stat cats fleshed with entries; sorted. + getStatCats(): Promise { + if (this.statCats) { + return Promise.resolve(this.statCats); + } + + return this.net.request( + 'open-ils.circ', + 'open-ils.circ.stat_cat.actor.retrieve.all', + this.auth.token(), this.auth.user().ws_ou() + ).toPromise().then(cats => { + cats = cats.sort((a, b) => a.name() < b.name() ? -1 : 1); + cats.forEach(cat => { + cat.entries( + cat.entries().sort((a,b) => a.value() < b.value() ? -1 : 1) + ); + }); + return cats; + }); + } } -- 2.11.0