From deab630a5837dbe723fe2f2b7fbe38926ca86121 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 8 Jul 2022 12:03:35 -0400 Subject: [PATCH] LP#1955065: fix deletion of item notes in Angular item attributes editor This patch fixes several bugs that prevent item notes from being correctly deleted by the Angular item attributes editor. To test ------- [1] Apply patch. [2] Edit a single item in the Angular item attributes editor. [3] Verify that notes can be added and deleted. [4] In Holdings View, choose Add/Manage Item Notes for a single selected item. [5] Verify that notes can be added and deleted; [6] Repeat steps 4 and 5 for a different item after successfully deleting an item note. Verify that notes can be added and deleted. [7] In Holdings View, choose Add/Manage Item Notes for multiple selected items. [8] Verify that ntoes can be added to the selected items. Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../app/staff/cat/volcopy/copy-attrs.component.ts | 21 +++++++++++++++++---- .../app/staff/catalog/record/holdings.component.ts | 4 ++-- .../share/holdings/copy-notes-dialog.component.ts | 10 ++++++++-- 3 files changed, 27 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 e04a2bc3ba..4abf63b2a3 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 @@ -469,11 +469,14 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { this.copyNotesDialog.inPlaceCreateMode = true; this.copyNotesDialog.copyIds = this.context.copyList().map(c => c.id()); - this.copyNotesDialog.open({size: 'lg'}).subscribe(newNotes => { - if (!newNotes || newNotes.length === 0) { return; } + this.copyNotesDialog.open({size: 'lg'}).subscribe(changes => { + if ((!changes.newNotes || changes.newNotes.length === 0) && + (!changes.delNotes || changes.delNotes.length === 0) + ) { + return; + } - console.log(newNotes); - newNotes.forEach(note => { + changes.newNotes.forEach(note => { this.context.copyList().forEach(copy => { const n = this.idl.clone(note); n.owning_copy(copy.id()); @@ -481,6 +484,16 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { copy.ischanged(true); }); }); + if (this.context.copyList().length === 1) { + const copy = this.context.copyList()[0]; + changes.delNotes.forEach(note => { + const existing = copy.notes().filter(n => n.id() === note.id())[0]; + if (existing) { + existing.isdeleted(true); + copy.ischanged(true); + } + }); + } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts index fa7343d4a4..57b9981a48 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts @@ -970,8 +970,8 @@ export class HoldingsMaintenanceComponent implements OnInit { this.copyNotesDialog.copyIds = copyIds; this.copyNotesDialog.open({size: 'lg'}).subscribe( - modified => { - if (modified) { + changes => { + if (changes.newNotes.length > 0 || changes.delNotes.length > 0) { this.hardRefresh(); } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-notes-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-notes-dialog.component.ts index ad9d94d845..a62dd4f4be 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-notes-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-notes-dialog.component.ts @@ -16,6 +16,11 @@ import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; * Dialog for managing copy notes. */ +export interface CopyNotesChanges { + newNotes: IdlObject[]; + delNotes: IdlObject[]; +} + @Component({ selector: 'eg-copy-notes-dialog', templateUrl: 'copy-notes-dialog.component.html' @@ -67,10 +72,11 @@ export class CopyNotesDialogComponent /** */ - open(args: NgbModalOptions): Observable { + open(args: NgbModalOptions): Observable { this.copy = null; this.copies = []; this.newNotes = []; + this.delNotes = []; if (this.copyIds.length === 0 && !this.inPlaceCreateMode) { return throwError('copy ID required'); @@ -141,7 +147,7 @@ export class CopyNotesDialogComponent applyChanges() { if (this.inPlaceCreateMode) { - this.close(this.newNotes); + this.close({ newNotes: this.newNotes, delNotes: this.delNotes }); return; } -- 2.11.0