From cb4cb456b40eda6b460837c4d853dc19b589c363 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Jun 2020 11:48:45 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../staff/cat/volcopy/copy-attrs.component.html | 376 +++++++++++++++++++-- .../app/staff/cat/volcopy/copy-attrs.component.ts | 197 +++++++++-- .../app/staff/cat/volcopy/volcopy.component.html | 4 + .../share/holdings/batch-item-attr.component.html | 13 +- 4 files changed, 526 insertions(+), 64 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 c834bf82a1..9b0bc012f8 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 @@ -4,67 +4,52 @@
- - -
-

Identification

-

Location

-

Circulation

-

Miscellaneous

-

Statistics

-
-
+

Identification

-
-
-
-
-
-
-
@@ -73,34 +58,359 @@
+

Location

- - + - + (changesSaved)="applyCopyValue('location')"> + +
+ +
+ + + + + + + +
+ +
+ + + + + +
-
+
+ + + + + + +
+ +
+
-
+

Circulation

+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + + + +
+ +
+ + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+
-
+ +

Miscellaneous

+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + + +
+ +
-
+

Statistics

+ 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 5b8e12281e..ccfe284ff1 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,16 +11,46 @@ 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; - batchLocation: any; + // Batch values applied from the form. + // Some values are scalar, some IdlObjects depending on copy fleshyness. + 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; + + @ViewChild('mintConditionYes', {static: false}) + mintConditionYes: StringComponent; + @ViewChild('mintConditionNo', {static: false}) + mintConditionNo: StringComponent; constructor( private router: Router, @@ -37,36 +67,67 @@ export class CopyAttrsComponent implements OnInit { private format: FormatService ) { } - 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(_ => { + + 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); + + }).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} { const counts = {}; this.context.copyList().forEach(copy => { - let value = copy[field](); - if (value === undefined || value === null) { value = ''; } - - if (value !== '') { - - if (field === 'status') { - if (value in this.volcopy.copyStatuses) { - value = this.volcopy.copyStatuses[value].name(); - } - - } else if (field === 'location') { - value = value.name(); - - } else if (field.match(/date/)) { - value = this.format.transform({ - datatype: 'timestamp', - value: value - }); - } else if (field === 'creator' || field === 'editor') { - value = value.usrname(); - } - } + const value = this.getFieldDisplayValue(field, copy); if (counts[value] === undefined) { counts[value] = 0; @@ -77,7 +138,81 @@ export class CopyAttrsComponent implements OnInit { return counts; } - applyCopyValue(field: string, value: any) { + getFieldDisplayValue(field: string, copy: IdlObject): string { + + // Some fields don't live directly on the copy. + if (field === 'owning_lib') { + return this.org.get( + copy.call_number().owning_lib()).shortname() + + ' : ' + copy.call_number().label(); + } + + let value = copy[field](); + + if (!value && value !== 0) { return ''; } + + switch(field) { + + case 'status': + return this.volcopy.copyStatuses[value].name(); + + case 'location': + return value.name() + + ' (' + this.org.get(value.owning_lib()).shortname() + ')'; + + case 'edit_date': + case 'create_date': + case 'active_date': + return this.format.transform( + {datatype: 'timestamp', value: value}); + + case 'editor': + case 'creator': + return value.usrname(); + + case 'circ_lib': + return this.org.get(value).shortname(); + + case 'age_protect': + 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() : ''; + + case 'mint_condition': + if (!this.mintConditionYes) { return ''; } + return value === 't' ? + this.mintConditionYes.text : this.mintConditionNo.text; + } + + return 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); @@ -86,8 +221,14 @@ export class CopyAttrsComponent implements OnInit { }); } - locationChanged() { - this.applyCopyValue('location', this.batchLocation); + circLibChanged() { + // TODO other stuff happens here? + this.applyCopyValue('circ_lib'); + } + + owningLibChanged() { + // TODO + console.log('OWNING LIB ', this.values['owning_lib']); } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html index 086edc9ccb..156540f789 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html @@ -20,6 +20,10 @@ + +
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html index 3927094296..8597d91332 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html @@ -1,6 +1,8 @@
-
{{label}}
+
+ {{label}} * +
No - {{count.key | currency}} + + <Unset> + + {{count.key | currency}} - + <Unset> {{count.key}} -- 2.11.0