From dd9fbab41dc932d481f2f3ce6944669c6183e6f6 Mon Sep 17 00:00:00 2001 From: Llewellyn Marshall Date: Tue, 20 Dec 2022 16:15:08 -0500 Subject: [PATCH] do not ever allow editing the status when the current status or changed status is "magic". Do not allow alert_message to be set. --- .../app/staff/cat/volcopy/copy-attrs.component.ts | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) 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 e5f08bebdf..43b379f19e 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 @@ -272,6 +272,22 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { return changeSelection[disValue] === true; } + copyChangePermitted(copy: IdlObject, field: string, + value: any) : boolean { + switch(field){ + case 'status': { + return this.statusEditable([copy]) && + !this.volcopy.copyStatIsMagic(value); + } + case 'alert_message': { + return false; + } + default: { + return true; + } + } + } + applyCopyValue(field: string, value?: any, changeSelection?: BatchChangeSelection) { if (value === undefined) { value = this.values[field]; @@ -294,6 +310,11 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { !this.copyWantsChange(copy, field, changeSelection)) { return; } + + // prevent certain changes from going through + if(!this.copyChangePermitted(copy, field, value)){ + return; + } copy[field](value); copy.ischanged(true); @@ -725,14 +746,15 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { return def ? def.label : ''; } - // Returns false if any items are in magic statuses - statusEditable(): boolean { - const copies = this.context.copyList(); - for (let idx = 0; idx < copies.length; idx++) { - if (this.volcopy.copyStatIsMagic(copies[idx].status())) { - return false; - } - } + // Returns false if status is in magic statuses + statusEditable(c?: IdlObject[]): boolean { + if(c === undefined || !c.length) + c = this.context.copyList(); + for (let idx = 0; idx < c.length; idx++) { + if (this.volcopy.copyStatIsMagic(c[idx].status())) { + return false; + } + } return true; } -- 2.11.0