From 8f0c10ab3f1e18af13c5ac630e18255c6dd1b9f8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 22 Jun 2020 15:34:14 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/config.component.html | 476 +++++++++++++++++++++ .../src/app/staff/cat/volcopy/config.component.ts | 8 +- .../staff/cat/volcopy/copy-attrs.component.html | 359 +++++++--------- .../app/staff/cat/volcopy/copy-attrs.component.ts | 47 +- .../app/staff/cat/volcopy/vol-edit.component.html | 30 +- .../app/staff/cat/volcopy/vol-edit.component.ts | 27 +- .../app/staff/cat/volcopy/volcopy.component.html | 2 +- .../src/app/staff/cat/volcopy/volcopy.service.ts | 87 +++- .../share/holdings/batch-item-attr.component.html | 1 + .../share/holdings/batch-item-attr.component.ts | 12 + .../sql/Pg/upgrade/XXXX.data.volcopy-settings.sql | 12 + 11 files changed, 777 insertions(+), 284 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.html index e69de29bb2..93b264c47e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.html @@ -0,0 +1,476 @@ +
+
+ +
+ +

Holdings Defaults

+ +
+
+
+
+
+
Holdings Display Defaults
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+
+
+
+
+
+
+
Holdings Creation Defaults
+
    +
  • +
    +
    + +
    +
    + + + + +
    +
    +
  • +
  • +
    +
    + +
    +
    + + + + + + +
    +
    +
  • +
  • +
    +
    + +
    +
    + + + + + + +
    +
    +
  • +
+
+
+
+
+
+ +
+ +

Hide Item Attributes

+ + Selected Attributes Will be Hidden from the Item Attributes Form. + + +
+ + +
+
+
Identification
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+ + +
+
+
Location
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+ + + +
+
+
Circulation
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+ + + +
+
+
Miscellaneous
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+ + + +
+
+
Statistics
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+
+ +
+
+ +
+ + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.ts index 35c926b810..5716f9e0a0 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.ts @@ -34,16 +34,20 @@ export class VolCopyConfigComponent implements OnInit, AfterViewInit { private auth: AuthService, private pcrud: PcrudService, private holdings: HoldingsService, - private volcopy: VolCopyService, private format: FormatService, - private store: StoreService + private store: StoreService, + public volcopy: VolCopyService ) { } ngOnInit() { + console.log('DEFAULTS', this.volcopy.defaults); } ngAfterViewInit() { + } + save() { + this.volcopy.saveDefaults(); } } 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 3086135ac2..4ea94abcb6 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 @@ -12,6 +12,21 @@ + + + + +
@@ -38,44 +53,44 @@

Identification

-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -87,37 +102,31 @@

Location

-
+
- - + +
-
+
- - + +
-
+
- - + +
-
+
- - + +
-
@@ -154,71 +155,57 @@

Circulation

-
+
- - + +
-
+
- - + +
-
+
- + + + + - - + +
-
+
- + + + + - - + +
-
+
@@ -231,16 +218,12 @@ - - + +
-
+
@@ -253,48 +236,27 @@ - - -
- -
- - - - - + +
-
+
- + + + + - - + +
-
+
- - + +
@@ -334,7 +293,7 @@
--> -
+
Add Item Alerts
@@ -344,92 +303,67 @@
-
+
- - + +
-
+
- - + +
-
+
- - + +
-
+
- - + +
-
+
- - + +
-
+
- - + +
-
+
@@ -440,13 +374,9 @@ - - + +
@@ -455,25 +385,38 @@

Statistics

-
- - - - - - - - +
+ +
Add Item Tags
+
+ +
+ +
+ + + + + + + + +
+
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 723638cbbf..44d2858bbb 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 @@ -1,4 +1,5 @@ -import {Component, Input, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core'; +import {Component, Input, OnInit, AfterViewInit, ViewChild, + QueryList, ViewChildren} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {tap} from 'rxjs/operators'; import {IdlObject, IdlService} from '@eg/core/idl.service'; @@ -16,6 +17,7 @@ import {StringComponent} from '@eg/share/string/string.component'; import {CopyAlertsDialogComponent } from '@eg/staff/share/holdings/copy-alerts-dialog.component'; import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component'; +import {BatchItemAttrComponent} from '@eg/staff/share/holdings/batch-item-attr.component'; @Component({ selector: 'eg-copy-attrs', @@ -66,10 +68,12 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { @ViewChild('copyTemplateCbox', {static: false}) copyTemplateCbox: ComboboxComponent; + @ViewChildren(BatchItemAttrComponent) + batchAttrs: QueryList; + constructor( private router: Router, private route: ActivatedRoute, - private renderer: Renderer2, private evt: EventService, private idl: IdlService, private org: OrgService, @@ -77,9 +81,9 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { private auth: AuthService, private pcrud: PcrudService, private holdings: HoldingsService, - private volcopy: VolCopyService, private format: FormatService, - private store: StoreService + private store: StoreService, + public volcopy: VolCopyService ) { } ngOnInit() { @@ -221,7 +225,13 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { } applyCopyValue(field: string, value?: any) { - if (value === undefined) { value = this.values[field]; } + if (value === undefined) { + value = this.values[field]; + } else { + this.values[field] = value; + } + + // TODO: handle circ_lib, owning_lib changes specially console.debug('APPLYING', field, value); @@ -233,18 +243,6 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { }); } - circLibChanged() { - // TODO other stuff happens here? - this.applyCopyValue('circ_lib'); - } - - owningLibChanged() { - // TODO - // copies.ischanged(true); - console.log('OWNING LIB ', this.values['owning_lib']); - } - - // Create or modify a stat cat entry for each copy that does not // already match the new value. statCatChanged(catId: number) { @@ -311,6 +309,21 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { this.applyCopyValue(field, value); }); } + + saveTemplate() { + this.batchAttrs.forEach(comp => { + console.log(comp.editInputDomId); + }); + } + + displayAttr(field: string): boolean { + return this.volcopy.defaults.hidden[field] !== true; + } + + copyFieldLabel(field: string): string { + const def = this.idl.classes.acp.field_map[field]; + return def ? def.label : ''; + } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html index 9edeb21944..8d06132c4e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html @@ -15,21 +15,21 @@
-
+
-
-
+
- @@ -44,11 +44,11 @@
-
+
- @@ -92,16 +92,16 @@
-
+
-
+
-
+
@@ -144,20 +144,20 @@ (ngModelChange)="volCountChanged(orgNode, $event)"/>
-
+
-
-
+
- @@ -182,7 +182,7 @@ (change)="applyVolValue(volNode.target, 'label', $event.target.value)">
-
+
- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts index 4dc657440b..b6948a41d7 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -30,9 +30,6 @@ export class VolEditComponent implements OnInit { flexSettings: {[column: number]: number} = { 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 1, 7: 1, 8: 2, 9: 1, 10: 1}; - volClasses: IdlObject[] = null; - volPrefixes: IdlObject[] = null; - volSuffixes: IdlObject[] = null; bibParts: {[bibId: number]: IdlObject[]} = {}; batchVolClass: ComboboxEntry; @@ -64,7 +61,7 @@ export class VolEditComponent implements OnInit { private net: NetService, private auth: AuthService, private holdings: HoldingsService, - private volcopy: VolCopyService + public volcopy: VolCopyService ) {} ngOnInit() { @@ -76,24 +73,6 @@ export class VolEditComponent implements OnInit { .then(labels => this.recordVolLabels = labels) .then(_ => this.fetchBibParts()) .then(_ => this.addStubCopies()); - - this.holdings.fetchCallNumberClasses().then( - classes => this.volClasses = classes); - - const myOrgs = this.org.fullPath(this.auth.user().ws_ou(), true); - - // The batch edit controls only include values for "here" - this.holdings.fetchCallNumberPrefixes().then(prefixes => - this.volPrefixes = prefixes - .filter(sfx => sfx.id() !== -1) - .filter(pfx => myOrgs.includes(pfx.owning_lib())) - ); - - this.holdings.fetchCallNumberSuffixes().then(suffixes => - this.volSuffixes = suffixes - .filter(sfx => sfx.id() !== -1) - .filter(sfx => myOrgs.includes(sfx.owning_lib())) - ); } @@ -510,5 +489,9 @@ export class VolEditComponent implements OnInit { } } } + + displayColumn(field: string): boolean { + return this.volcopy.defaults.hidden[field] !== true; + } } 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 2c697788e4..996ebb7ae3 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 @@ -6,7 +6,7 @@
- + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts index 07e009e531..d9ce8a0594 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts @@ -15,12 +15,18 @@ import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.comp /* Managing volcopy data */ +interface VolCopyDefaults { + values: {[field: string]: any}, + hidden: {[field: string]: boolean} +} + @Injectable() export class VolCopyService { autoId = -1; - defaultValues: any = null; + defaults: VolCopyDefaults = null; + defaultLocation: IdlObject; copyStatuses: {[id: number]: IdlObject} = null; // Track this here so it can survive route changes. @@ -32,6 +38,9 @@ export class VolCopyService { circModifiers: IdlObject[] = []; statCats: IdlObject[] = []; statCatEntryMap: {[id: number]: IdlObject} = {}; // entry id => entry + volClasses: IdlObject[] = null; + volPrefixes: IdlObject[] = null; + volSuffixes: IdlObject[] = null; templateNames: ComboboxEntry[] = []; templates: any = {}; @@ -52,14 +61,30 @@ export class VolCopyService { // Fetch the data that is always needed. load(): Promise { - if (this.itemTypeMaps.length > 0) { - return Promise.resolve(); - } + if (this.itemTypeMaps.length > 0) { return Promise.resolve(); } + + const myOrgs = this.org.fullPath(this.auth.user().ws_ou(), true); return this.fetchDefaults() .then(_ => this.holdings.fetchCallNumberClasses()) - .then(_ => this.holdings.fetchCallNumberPrefixes()) - .then(_ => this.holdings.fetchCallNumberSuffixes()) + .then(cls => this.volClasses = cls) + + .then(_ => { + return this.holdings.fetchCallNumberPrefixes().then(prefixes => + this.volPrefixes = prefixes + .filter(sfx => sfx.id() !== -1) + .filter(pfx => myOrgs.includes(pfx.owning_lib())) + ); + }) + + .then(_ => { + return this.holdings.fetchCallNumberSuffixes().then(suffixes => + this.volSuffixes = suffixes + .filter(sfx => sfx.id() !== -1) + .filter(sfx => myOrgs.includes(sfx.owning_lib())) + ); + }) + .then(_ => this.fetchCopyStats()) .then(_ => this.fetchTemplates()) .then(_ => { @@ -147,17 +172,23 @@ export class VolCopyService { } fetchDefaults(): Promise { - if (this.defaultValues) { return Promise.resolve(); } + if (this.defaults) { return Promise.resolve(); } - return this.serverStore.getItem('cat.copy.defaults').then( - defaults => { - this.defaultValues = defaults || {}; + return this.serverStore.getItem('eg.cat.volcopy.defaults').then( + (defaults: VolCopyDefaults) => { + this.defaults = defaults || {values: {}, hidden: {}}; } + ).then(_ => { - // Default to location ID 1 (Stacks) - return this.pcrud.retrieve('acpl', 1).toPromise() - .then(loc => this.defaultValues.location = loc); + // Use the first non-deleted copy location within org unit + // range as the default. Typically "Stacks". + + const myOrgs = this.org.fullPath(this.auth.user().ws_ou(), true); + return this.pcrud.search('acpl', + {deleted: 'f', owning_lib: myOrgs}, + {order_by: {acpl: 'id'}, limit: 1} + ).toPromise().then(loc => this.defaultLocation = loc); }); } @@ -183,7 +214,7 @@ export class VolCopyService { return this.net.request( 'open-ils.cat', 'open-ils.cat.biblio.record.marc_cn.retrieve', - id, this.defaultValues.classification || null + id, this.defaults.values.classification || null ).toPromise().then(res => { return Object.values(res) .map(blob => Object.values(blob)[0]).sort(); @@ -199,8 +230,8 @@ export class VolCopyService { vol.record(recordId); vol.label(null); vol.owning_lib(Number(orgId)); - vol.prefix(this.defaultValues.prefix || -1); - vol.suffix(this.defaultValues.suffix || -1); + vol.prefix(this.defaults.values.prefix || -1); + vol.suffix(this.defaults.values.suffix || -1); return vol; } @@ -218,7 +249,7 @@ export class VolCopyService { copy.deposit_amount(0); copy.fine_level(2); // Normal copy.loan_duration(2); // Normal - copy.location(this.defaultValues.location); // Stacks / fleshed + copy.location(this.defaultLocation); // Stacks / fleshed copy.circulate('t'); copy.holdable('t'); copy.opac_visible('t'); @@ -251,12 +282,12 @@ export class VolCopyService { let promise = Promise.resolve(); // Serialization - if (this.defaultValues.classification) { + if (this.defaults.values.classification) { // Workstation default classification overrides the // classification that might be used at the owning lib. vols.forEach(vol => - vol.label_class(this.defaultValues.classification)); + vol.label_class(this.defaults.values.classification)); return promise; @@ -371,6 +402,24 @@ export class VolCopyService { } + saveDefaults(): Promise { + + // Scrub unnecessary content before storing. + + Object.keys(this.defaults.values).forEach(field => { + if (this.defaults.values[field] === null) { + delete this.defaults.values[field]; + } + }); + Object.keys(this.defaults.hidden).forEach(field => { + if (this.defaults.hidden[field] !== true) { + delete this.defaults.hidden[field]; + } + }); + + return this.serverStore.setItem( + 'eg.cat.volcopy.defaults', this.defaults); + } } 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 e8f00a2dc0..f364cd5b50 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 @@ -36,6 +36,7 @@
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts index 408ebf9284..a72545454f 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts @@ -21,6 +21,10 @@ export class BatchItemAttrComponent { // Main display label, e.g. "Circulation Modifier" @Input() label: string; + // Optional. Useful for exracting information (i.e. hasChanges) + // on a specific field from a set of batch attr components. + @Input() name: string; + // Maps display labels to the number of items that have the label. // e.g. {"Stacks": 4, "Display": 12} @Input() labelCounts: {[label: string]: number} = {}; @@ -44,6 +48,7 @@ export class BatchItemAttrComponent { @Output() changesSaved: EventEmitter = new EventEmitter(); @Output() changesCanceled: EventEmitter = new EventEmitter(); + @Output() valueCleared: EventEmitter = new EventEmitter(); // Is the editTtemplate visible? editing = false; @@ -63,6 +68,13 @@ export class BatchItemAttrComponent { this.changesCanceled.emit(); } + clear() { + this.hasChanged = true; + this.editing = false; + this.valueCleared.emit(); + } + + toggleEditMode() { if (this.readOnly) { return; } diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql new file mode 100644 index 0000000000..74396a1b48 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql @@ -0,0 +1,12 @@ + +INSERT INTO config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.cat.volcopy.defaults', 'cat', 'object', + oils_i18n_gettext( + 'eg.cat.volcopy.defaults', + 'Holdings Editor Default Values and Visibility', + 'cwst', 'label' + ) +); + + -- 2.11.0