do not ever allow editing the status when the current status or changed status is... user/lew/3_9_1_volcopy-status-glitch
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Tue, 20 Dec 2022 21:15:08 +0000 (16:15 -0500)
committerLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 21 Dec 2022 20:56:39 +0000 (15:56 -0500)
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts

index e5f08be..43b379f 100644 (file)
@@ -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;
     }