From 47c088545f6741598efee6ddc4f312c5224c6b9f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 26 May 2022 11:11:59 -0400 Subject: [PATCH] LP#1957179: improve saving of templates in Angular holdings editor This patch makes the following improvements to the handling of holding templates in the Angular holdings editor: - templates are now saved to the cat.copy.templates user setting, matching the AngularJS holdings editor - toast is displayed upon saving or deleting a template - upon saving a completely new template, re-style it in the combobox so that it no longer has the new-and-freetext styling To test ------- [1] Apply the patch and open the Angular holdings editor. [2] Verify that once a template is saved or deleted, that refreshing the Angular holdings editor will show the updated list of templates. [3] Verify that toast is displayed upon saving or deleting a template. Note that because of a quirk in how user settings are cached by the web staff client, if you are testing in more than one browser (but with the same user account), if you save a template in one browser, you'll need to log out and back in with the second browser to see the changes. Signed-off-by: Galen Charlton Signed-off-by: Michele Morgan --- .../app/staff/cat/volcopy/copy-attrs.component.html | 3 +++ .../app/staff/cat/volcopy/copy-attrs.component.ts | 21 +++++++++++++++++++-- .../src/app/staff/cat/volcopy/volcopy.service.ts | 5 ++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html index f312fe8e37..feab30ac6a 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html @@ -11,6 +11,9 @@ + + + { + this.savedHoldingsTemplates.current().then(str => this.toast.success(str)); + if (entry.freetext) { + // once a new template has been added, make it + // display like any other in the comobox + this.copyTemplateCbox.selected = + this.volcopy.templateNames.filter(_ => _.label === name)[0]; + } + }); } exportTemplate($event) { @@ -693,7 +708,9 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { const entry: ComboboxEntry = this.copyTemplateCbox.selected; if (!entry) { return; } delete this.volcopy.templates[entry.id]; - this.volcopy.saveTemplates(); + this.volcopy.saveTemplates().then( + x => this.deletedHoldingsTemplate.current().then(str => this.toast.success(str)) + ); this.copyTemplateCbox.selected = null; } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts index 400825e6e4..ed023eeddd 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts @@ -149,9 +149,8 @@ export class VolCopyService { saveTemplates(): Promise { - this.store.setLocalItem('cat.copy.templates', this.templates); - // Re-sort, etc. - return this.fetchTemplates(); + return this.serverStore.setItem('cat.copy.templates', this.templates) + .then(() => this.fetchTemplates()); } fetchDefaults(): Promise { -- 2.11.0