From 7d79442cf8f7f9d8a6544ce361808b665460fc26 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Tue, 21 Feb 2023 20:48:31 -0800 Subject: [PATCH] LP1999401: Don't override magic statuses from holdings editor templates 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 --- .../app/staff/cat/volcopy/copy-attrs.component.spec.ts | 18 ++++++++++++++++-- .../src/app/staff/cat/volcopy/copy-attrs.component.ts | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.spec.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.spec.ts index 1236b2a69a..561792b4e8 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.spec.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.spec.ts @@ -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(['ischanged'], {'status': () => {1}}); + const contextMock = jasmine.createSpyObj(['copyList']); + contextMock.copyList.and.returnValue([item]); + component.context = contextMock; + spyOn(component, 'emitSaveChange'); + + component.applyCopyValue('status', 0); + expect(item.ischanged).not.toHaveBeenCalled(); + }); + }); }); 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 a1eafa9368..0fce55a34a 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 @@ -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 -- 2.11.0