From cc2af7423955417b42943237759c649339986579 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Jun 2020 14:53:52 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../staff/cat/volcopy/copy-attrs.component.html | 147 +++++++++++++++++---- .../app/staff/cat/volcopy/copy-attrs.component.ts | 119 +++++++++++++++-- 2 files changed, 229 insertions(+), 37 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html index 7db5a1c0b6..483a99e455 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html @@ -21,8 +21,7 @@
-
@@ -35,36 +34,31 @@
-
-
-
-
-
@@ -82,36 +76,38 @@ + [labelCounts]="itemAttrCounts('location')" + (changesSaved)="applyCopyValue('location')">
-
-
@@ -124,9 +120,9 @@ + [labelCounts]="itemAttrCounts('copy_number')" + (changesSaved)="applyCopyValue('copy_number')"> @@ -145,8 +141,8 @@ @@ -161,8 +157,8 @@ @@ -171,15 +167,120 @@
+ +
+ +
+ + + + + +
+ +
+ + + + + + + + + +
+ +
+ + + + + + + + + +
+ +
+ + + + + [labelCounts]="itemAttrCounts('age_protect')" + (changesSaved)="applyCopyValue('age_protect')"> + +
+ +
+ + + + + +
+ +
+ + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts index 1f4a00bc51..6053e7b72b 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts @@ -11,12 +11,13 @@ import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; import {VolCopyContext} from './volcopy'; import {VolCopyService} from './volcopy.service'; import {FormatService} from '@eg/core/format.service'; +import {StringComponent} from '@eg/share/string/string.component'; @Component({ selector: 'eg-copy-attrs', templateUrl: 'copy-attrs.component.html' }) -export class CopyAttrsComponent implements OnInit { +export class CopyAttrsComponent implements OnInit, AfterViewInit { @Input() context: VolCopyContext; @@ -25,6 +26,27 @@ export class CopyAttrsComponent implements OnInit { values: {[field: string]: any} = {}; ageProtectRules: IdlObject[] = []; + floatingGroups: IdlObject[] = []; + itemTypeMaps: IdlObject[] = []; + circModifiers: IdlObject[] = []; + + loanDurationLabelMap: {[level: number]: string} = {}; + fineLevelLabelMap: {[level: number]: string} = {}; + + @ViewChild('loanDurationShort', {static: false}) + loanDurationShort: StringComponent; + @ViewChild('loanDurationNormal', {static: false}) + loanDurationNormal: StringComponent; + @ViewChild('loanDurationLong', {static: false}) + loanDurationLong: StringComponent; + + @ViewChild('fineLevelLow', {static: false}) + fineLevelLow: StringComponent; + @ViewChild('fineLevelNormal', {static: false}) + fineLevelNormal: StringComponent; + @ViewChild('fineLevelHigh', {static: false}) + fineLevelHigh: StringComponent; + constructor( private router: Router, @@ -42,13 +64,61 @@ export class CopyAttrsComponent implements OnInit { ) { } ngOnInit() { + this.load(); + } + + ngAfterViewInit() { + + this.loanDurationLabelMap[1] = this.loanDurationShort.text; + this.loanDurationLabelMap[2] = this.loanDurationNormal.text; + this.loanDurationLabelMap[3] = this.loanDurationLong.text; + + this.fineLevelLabelMap[1] = this.fineLevelLow.text; + this.fineLevelLabelMap[2] = this.fineLevelNormal.text; + this.fineLevelLabelMap[3] = this.fineLevelHigh.text; + } + + load() { + + this.pcrud.retrieveAll('crahp') + .pipe(tap(rule => this.ageProtectRules.push(rule))).toPromise() + .then(_ => { + + this.ageProtectRules = this.ageProtectRules.sort( + (a, b) => a.name() < b.name() ? -1 : 1); + + }).then(_ => { + + return this.pcrud.retrieveAll('cfg') + .pipe(tap(rule => this.floatingGroups.push(rule))).toPromise() + + }).then(_ => { + + this.floatingGroups = this.floatingGroups.sort( + (a, b) => a.name() < b.name() ? -1 : 1); + + }).then(_ => { - this.pcrud.retrieveAll('crahp').subscribe( - rule => this.ageProtectRules.push(rule), - err => {}, - () => this.ageProtectRules = this.ageProtectRules.sort( - (a, b) => a.name() < b.name() ? -1 : 1) - ); + return this.pcrud.retrieveAll('ccm') + .pipe(tap(rule => this.circModifiers.push(rule))).toPromise() + + }).then(_ => { + + this.circModifiers = this.circModifiers.sort( + (a, b) => a.name() < b.name() ? -1 : 1); + + console.log('MODS', this.circModifiers); + + }).then(_ => { + + return this.pcrud.retrieveAll('citm') + .pipe(tap(itemType => this.itemTypeMaps.push(itemType))).toPromise() + + }).then(_ => { + + this.itemTypeMaps = this.itemTypeMaps.sort( + (a, b) => a.value() < b.value() ? -1 : 1); + }); } itemAttrCounts(field: string): {[value: string]: number} { @@ -104,13 +174,37 @@ export class CopyAttrsComponent implements OnInit { const rule = this.ageProtectRules.filter( r => r.id() === Number(value))[0]; return rule ? rule.name() : ''; + + case 'floating': + const grp = this.floatingGroups.filter( + g => g.id() === Number(value))[0]; + return grp ? grp.name() : ''; + + case 'loan_duration': + return this.loanDurationLabelMap[value]; + + case 'fine_level': + return this.fineLevelLabelMap[value]; + + case 'circ_as_type': + const map = this.itemTypeMaps.filter( + m => m.code() === value)[0]; + return map ? map.value() : ''; + + case 'circ_modifier': + const mod = this.circModifiers.filter( + m => m.code() === value)[0]; + return mod ? mod.name() : ''; } return value; } - applyCopyValue(field: string, value: any) { - console.log('APPLYING', field, value); + applyCopyValue(field: string, value?: any) { + if (value === undefined) { value = this.values[field]; } + + console.debug('APPLYING', field, value); + this.context.copyList().forEach(copy => { if (copy[field] && copy[field]() !== value) { copy[field](value); @@ -119,12 +213,9 @@ export class CopyAttrsComponent implements OnInit { }); } - locationChanged() { - this.applyCopyValue('location', this.values['location']); - } - circLibChanged() { - this.applyCopyValue('circ_lib', this.values['circ_lib']); + // TODO other stuff happens here? + this.applyCopyValue('circ_lib'); } owningLibChanged() { -- 2.11.0