LP1999401: Don't override magic statuses from holdings editor templates
authorJane Sandberg <sandbergja@gmail.com>
Wed, 22 Feb 2023 04:48:31 +0000 (20:48 -0800)
committerMichele Morgan <mmorgan@noblenet.org>
Fri, 3 Mar 2023 16:27:18 +0000 (11:27 -0500)
1. Create a new template including a status
2. Check out an item
3. Apply your template to the item
4. Note that the item's status is no longer Checked Out
5. Apply this patch
6. Retry steps 1-3.  Note that the item's status is still Checked Out

Signed-off-by: Jane Sandberg <sandbergja@gmail.com>
Signed-off-by: Elizabeth Davis <elizabeth.davis@sparkpa.org>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>

Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.spec.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts

index 1236b2a..561792b 100644 (file)
@@ -1,14 +1,15 @@
+import { IdlService, IdlObject } from './../../../core/idl.service';
 import { QueryList } from "@angular/core";
 import { waitForAsync } from "@angular/core/testing";
 import { AuthService } from "@eg/core/auth.service";
 import { FormatService } from "@eg/core/format.service";
-import { IdlService } from "@eg/core/idl.service";
 import { OrgService } from "@eg/core/org.service";
 import { StoreService } from "@eg/core/store.service";
 import { ComboboxComponent } from "@eg/share/combobox/combobox.component";
 import { ToastService } from "@eg/share/toast/toast.service";
 import { FileExportService } from "@eg/share/util/file-export.service";
 import { CopyAttrsComponent } from "./copy-attrs.component";
+import { VolCopyContext } from "./volcopy";
 import { VolCopyService } from "./volcopy.service";
 
 describe('CopyAttrsComponent', () => {
@@ -44,5 +45,18 @@ describe('CopyAttrsComponent', () => {
                 expect(component.applyCopyValue).not.toHaveBeenCalled();
             }));
         });
-    })
+    });
+    describe('#applyCopyValue', () => {
+        it('does not override a magic status', () => {
+            volCopyServiceMock.copyStatIsMagic.and.returnValue(true);
+            const item = jasmine.createSpyObj<IdlObject>(['ischanged'], {'status': () => {1}});
+            const contextMock = jasmine.createSpyObj<VolCopyContext>(['copyList']);
+            contextMock.copyList.and.returnValue([item]);
+            component.context = contextMock;
+            spyOn(component, 'emitSaveChange');
+
+            component.applyCopyValue('status', 0);
+            expect(item.ischanged).not.toHaveBeenCalled();
+        });
+    });
 });
index a1eafa9..0fce55a 100644 (file)
@@ -274,6 +274,8 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
 
             this.context.copyList().forEach(copy => {
                 if (!copy[field] || copy[field]() === value) { return; }
+                // Don't overwrite magic statuses
+                if (field === 'status' && this.volcopy.copyStatIsMagic(copy[field]()) ) { return; }
 
                 // Change selection indicates which items should be modified
                 // based on the display value for the selected field at