From 9d88c04731403ccc473a8d746e21548d89a1f8b8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 22 Jun 2020 16:42:36 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/config.component.html | 62 ++++++++------- .../src/app/staff/cat/volcopy/config.component.ts | 5 +- .../staff/cat/volcopy/copy-attrs.component.html | 93 +++++++++++----------- .../app/staff/cat/volcopy/copy-attrs.component.ts | 4 + .../app/staff/cat/volcopy/vol-edit.component.ts | 3 +- .../src/app/staff/cat/volcopy/volcopy.component.ts | 1 - .../src/app/staff/cat/volcopy/volcopy.service.ts | 47 ++++++++--- .../sql/Pg/upgrade/XXXX.data.volcopy-settings.sql | 12 +++ 8 files changed, 135 insertions(+), 92 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 419d4773ca..e32ac7ce99 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 @@ -1,4 +1,4 @@ -

Holdings Defaults

+

Holdings Defaults

@@ -11,7 +11,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.classification"> @@ -21,7 +21,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.prefix"> @@ -31,7 +31,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.suffix"> @@ -56,9 +56,9 @@
+ (onChange)="volcopy.volCopyDefaults.values.classification = $entry ? $entry.id : null"> @@ -74,9 +74,9 @@
+ (onChange)="volcopy.volCopyDefaults.values.prefix = $entry ? $entry.id : null"> @@ -95,9 +95,9 @@
+ (onChange)="volcopy.volCopyDefaults.values.suffix = $entry ? $entry.id : null"> @@ -117,8 +117,10 @@
-

Item Attributes Defaults

-Selected Attributes Will Be Visible +

Hide Item Attributes

+ + Selected Attributes Will be Hidden from the Item Attributes Form. +
@@ -131,7 +133,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.status"> @@ -141,7 +143,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.barcode"> @@ -151,7 +153,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.create_date"> @@ -161,7 +163,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.active_date"> @@ -171,7 +173,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.creator"> @@ -181,7 +183,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.edit_date"> @@ -191,7 +193,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.editor"> @@ -210,7 +212,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.location"> @@ -220,7 +222,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.circ_lib"> @@ -230,7 +232,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.owning_lib"> @@ -240,7 +242,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.copy_number"> @@ -260,7 +262,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.circulate"> @@ -270,7 +272,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.holdable"> @@ -280,7 +282,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.age_protect"> @@ -290,7 +292,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.floating"> @@ -300,7 +302,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.loan_duration"> @@ -310,7 +312,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.fine_level"> @@ -320,7 +322,7 @@
+ [(ngModel)]="volcopy.volCopyDefaults.hidden.circ_as_type"> 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 b21f546384..f7fe3125bb 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 @@ -40,11 +40,14 @@ export class VolCopyConfigComponent implements OnInit, AfterViewInit { ) { } ngOnInit() { - console.log('DEFAULTS', this.volcopy.defaultValues); + console.log('DEFAULTS', this.volcopy.volCopyDefaults); } 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 b99e85298b..d5016f9753 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 @@ -38,44 +38,44 @@

Identification

-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -87,7 +87,7 @@

Location

-
+
@@ -101,7 +101,7 @@
-
+
-
+
-
+
@@ -154,7 +154,7 @@

Circulation

-
+
@@ -168,7 +168,7 @@
-
+
@@ -182,7 +182,7 @@
-
+
@@ -218,7 +218,7 @@
-
+
@@ -240,7 +240,7 @@
-
+
@@ -262,7 +262,7 @@
-
+
@@ -318,7 +318,7 @@
--> -
+
Add Item Alerts
@@ -328,7 +328,7 @@
-
+
@@ -342,7 +342,7 @@
-
+
@@ -356,7 +356,7 @@
-
+
@@ -370,7 +370,7 @@
-
+
@@ -384,7 +384,7 @@
-
+
@@ -398,7 +398,7 @@
-
+
@@ -413,7 +413,7 @@
-
+
@@ -439,25 +439,26 @@

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 723638cbbf..427f93c871 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 @@ -311,6 +311,10 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { this.applyCopyValue(field, value); }); } + + displayAttr(field: string): boolean { + return this.volcopy.volCopyDefaults.hidden[field] !== true; + } } 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 c5007f2388..747b4bf761 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 @@ -491,8 +491,7 @@ export class VolEditComponent implements OnInit { } displayColumn(field: string): boolean { - const key = `hide_${field}_column`; - return this.volcopy.defaultValues[key] !== true; + return this.volcopy.volCopyDefaults.hidden[field] !== true; } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts index 4d884f09a4..8f156351fd 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts @@ -114,7 +114,6 @@ export class VolCopyComponent implements OnInit { this.context.reset(); this.volcopy.load() - .then(_ => console.log('VOLCOPYLOADED')) .then(_ => this.fetchHoldings(copyIds)) .then(_ => this.volcopy.applyVolLabels( this.context.volNodes().map(n => n.target))) 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 fad55a8ca9..118c3935dd 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,17 @@ 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; + volCopyDefaults: VolCopyDefaults = null; copyStatuses: {[id: number]: IdlObject} = null; // Track this here so it can survive route changes. @@ -166,17 +171,17 @@ export class VolCopyService { } fetchDefaults(): Promise { - if (this.defaultValues) { return Promise.resolve(); } + if (this.volCopyDefaults) { return Promise.resolve(); } - return this.serverStore.getItem('cat.copy.defaults').then( - defaults => { - this.defaultValues = defaults || {}; + return this.serverStore.getItem('cat.volcopy.defaults').then( + (defaults: VolCopyDefaults) => { + this.volCopyDefaults = defaults || {values: {}, hidden: {}}; } ).then(_ => { // Default to location ID 1 (Stacks) return this.pcrud.retrieve('acpl', 1).toPromise() - .then(loc => this.defaultValues.location = loc); + .then(loc => this.volCopyDefaults.values.location = loc); }); } @@ -202,7 +207,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.volCopyDefaults.values.classification || null ).toPromise().then(res => { return Object.values(res) .map(blob => Object.values(blob)[0]).sort(); @@ -218,8 +223,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.volCopyDefaults.values.prefix || -1); + vol.suffix(this.volCopyDefaults.values.suffix || -1); return vol; } @@ -237,7 +242,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.volCopyDefaults.values.location); // Stacks / fleshed copy.circulate('t'); copy.holdable('t'); copy.opac_visible('t'); @@ -270,12 +275,12 @@ export class VolCopyService { let promise = Promise.resolve(); // Serialization - if (this.defaultValues.classification) { + if (this.volCopyDefaults.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.volCopyDefaults.values.classification)); return promise; @@ -390,6 +395,24 @@ export class VolCopyService { } + saveDefaults(): Promise { + + // Scrub unnecessary content before storing. + + Object.keys(this.volCopyDefaults.values).forEach(field => { + if (this.volCopyDefaults.values[field] === null) { + delete this.volCopyDefaults.values[field]; + } + }); + + Object.keys(this.volCopyDefaults.hidden).forEach(field => { + if (this.volCopyDefaults.hidden[field] !== true) { + delete this.volCopyDefaults.hidden[field]; + } + }); + return this.serverStore.setItem( + 'cat.volcopy.defaults', this.volCopyDefaults); + } } 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