LP1888723 Prevent magic status change via template
authorBill Erickson <berickxx@gmail.com>
Thu, 29 Apr 2021 14:45:53 +0000 (10:45 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 29 Apr 2021 17:05:40 +0000 (13:05 -0400)
Put hard stop on changing a copy status to/from a "magic" system status
via template.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts

index 632640a..5190514 100644 (file)
 
       <ng-template #noEditStat>
         <eg-batch-item-attr label="Status" i18n-label [readOnly]="true"
-          [labelCounts]="itemAttrCounts('status')">
+          name="status" [labelCounts]="itemAttrCounts('status')">
         </eg-batch-item-attr>
       </ng-template>
     </div>
index 1967a77..ebff702 100644 (file)
@@ -286,6 +286,14 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
                     return;
                 }
 
+                // Put a hard-stop on modifying magic copy statuses.
+                // We can get here by applying a copy template.
+                if (field === 'status' && (
+                    this.volcopy.copyStatIsMagic(copy.status()) ||
+                    this.volcopy.copyStatIsMagic(value))) {
+                    return;
+                }
+
                 copy[field](value);
                 copy.ischanged(true);
             });