From d07b6d960a3c436db51cd6eba785ce13da52b8b7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 14 Jul 2020 17:15:04 -0400 Subject: [PATCH] LPXXX volcopy batch edit select specific Signed-off-by: Bill Erickson --- .../staff/cat/volcopy/copy-attrs.component.html | 2 +- .../app/staff/cat/volcopy/copy-attrs.component.ts | 34 +++++++++++++++----- .../share/holdings/batch-item-attr.component.html | 22 ++++++++----- .../share/holdings/batch-item-attr.component.ts | 36 +++++++++++++++++----- 4 files changed, 72 insertions(+), 22 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 736de9d53a..5e13cffd86 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 @@ -24,7 +24,7 @@ [editTemplate]="template" [labelCounts]="itemAttrCounts(field)" (valueCleared)="applyCopyValue(field, null)" - (changesSaved)="applyCopyValue(field)"> + (changesSaved)="applyCopyValue(field, undefined, $event)"> 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 6bdda44263..91cae6f1b1 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 @@ -20,7 +20,8 @@ import {CopyAlertsDialogComponent import {CopyTagsDialogComponent } from '@eg/staff/share/holdings/copy-tags-dialog.component'; import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component'; -import {BatchItemAttrComponent} from '@eg/staff/share/holdings/batch-item-attr.component'; +import {BatchItemAttrComponent, BatchChangeSelection + } from '@eg/staff/share/holdings/batch-item-attr.component'; import {FileExportService} from '@eg/share/util/file-export.service'; @Component({ @@ -247,7 +248,13 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { return value; } - applyCopyValue(field: string, value?: any) { + copyWantsChange(copy: IdlObject, field: string, + changeSelection: BatchChangeSelection): boolean { + const disValue = this.getFieldDisplayValue(field, copy); + return changeSelection[disValue] === true; + } + + applyCopyValue(field: string, value?: any, changeSelection?: BatchChangeSelection) { if (value === undefined) { value = this.values[field]; } else { @@ -255,18 +262,26 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { } if (field === 'owning_lib') { - return this.owningLibChanged(value); + return this.owningLibChanged(value, changeSelection); } this.context.copyList().forEach(copy => { - if (copy[field] && copy[field]() !== value) { - copy[field](value); - copy.ischanged(true); + if (!copy[field] || copy[field]() === value) { return; } + + // Change selection indicates which items should be modified + // based on the display value for the selected field at + // time of editing. + if (changeSelection && + !this.copyWantsChange(copy, field, changeSelection)) { + return; } + + copy[field](value); + copy.ischanged(true); }); } - owningLibChanged(orgId: number) { + owningLibChanged(orgId: number, changeSelection?: BatchChangeSelection) { if (!orgId) { return; } // Map existing vol IDs to their replacments. @@ -274,6 +289,11 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { this.context.copyList().forEach(copy => { + if (changeSelection && + !this.copyWantsChange(copy, 'owning_lib', changeSelection)) { + return; + } + // Change the copy circ lib to match the new owning lib // if configured to do so. if (this.volcopy.defaults.values.circ_lib_mod_with_owning_lib) { 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 e126ca9885..cc660d6208 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 @@ -12,16 +12,22 @@ -
+
- + ... - -
+ + +
+ +
+
+
Yes No @@ -41,7 +47,9 @@ {{count.key}}
-
{{count.value}} copies
+
+ {{count.value}} copies +
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 55519df57e..e970e2da71 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 @@ -7,6 +7,13 @@ import {StringComponent} from '@eg/share/string/string.component'; * updates to batches of items. */ + +// Map of display value to boolean indicating whether a given item +// should be modified. +export interface BatchChangeSelection { + [value: string]: boolean; +} + @Component({ selector: 'eg-batch-item-attr', templateUrl: 'batch-item-attr.component.html', @@ -50,7 +57,9 @@ export class BatchItemAttrComponent { // and expandy. @Input() defaultDisplayCount = 7; - @Output() changesSaved: EventEmitter = new EventEmitter(); + @Output() changesSaved: EventEmitter = + new EventEmitter(); + @Output() changesCanceled: EventEmitter = new EventEmitter(); @Output() valueCleared: EventEmitter = new EventEmitter(); @@ -62,12 +71,15 @@ export class BatchItemAttrComponent { // Showing all entries? expanded = false; + // Indicate which display values the user wants to modify. + editValues: BatchChangeSelection = {}; + constructor() {} save() { this.hasChanged = true; this.editing = false; - this.changesSaved.emit(); + this.changesSaved.emit(this.editValues); } cancel() { @@ -85,6 +97,10 @@ export class BatchItemAttrComponent { return Object.keys(this.labelCounts).length > this.defaultDisplayCount; } + multiValue(): boolean { + return Object.keys(this.labelCounts).length > 1; + } + toggleEditMode() { if (this.readOnly) { return; } @@ -92,11 +108,17 @@ export class BatchItemAttrComponent { // Avoid using selectRootElement to focus. // https://stackoverflow.com/a/36059595 - if (this.editing && this.editInputDomId) { - setTimeout(() => { - const node = document.getElementById(this.editInputDomId); - if (node) { node.focus(); } - }); + if (this.editing) { + + Object.keys(this.labelCounts).forEach( + key => this.editValues[key] = true); + + if (this.editInputDomId) { + setTimeout(() => { + const node = document.getElementById(this.editInputDomId); + if (node) { node.focus(); } + }); + } } } } -- 2.11.0