}
};
+interface StatCat {
+ cat: IdlObject;
+ entries: ComboboxEntry[];
+}
+
@Component({
templateUrl: 'edit.component.html',
selector: 'eg-patron-edit',
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[]};
.then(_ => this.setInetLevels())
.then(_ => this.setOptInSettings())
.then(_ => this.setOrgSettings())
+ .then(_ => this.setStatCats())
.then(_ => this.setSmsCarriers())
.finally(() => this.loading = false);
}
+ setStatCats(): Promise<any> {
+ 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<any> {
return this.serverStore.getItemBatch(ORG_SETTING_TYPES)
.then(settings => this.orgSettings = settings);
inetLevels: IdlObject[];
profileGroups: IdlObject[];
smsCarriers: IdlObject[];
+ statCats: IdlObject[];
constructor(
private net: NetService,
.pipe(tap(carrier => this.smsCarriers.push(carrier))
).toPromise().then(_ => this.smsCarriers);
}
+
+ // Local stat cats fleshed with entries; sorted.
+ getStatCats(): Promise<IdlObject[]> {
+ 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;
+ });
+ }
}