From 16f23dd80cdea7b29507bfd2f68950812f1f19d3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 25 Jun 2020 10:49:15 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../src/app/staff/cat/volcopy/volcopy.service.ts | 26 +++++++++++++++------- .../sql/Pg/upgrade/XXXX.data.volcopy-settings.sql | 7 ++++++ 2 files changed, 25 insertions(+), 8 deletions(-) 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 63081e381e..31e4661ba8 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 @@ -187,21 +187,31 @@ export class VolCopyService { fetchTemplates(): Promise { - // TODO: copy templates should be server settings + // First check for local copy templates, since server-side + // templates are new w/ this code. Move them to the server. const tmpls = this.store.getLocalItem('cat.copy.templates'); - if (!tmpls) { return Promise.resolve(); } - this.templates = tmpls; - this.templateNames = Object.keys(tmpls) - .sort((n1, n2) => n1 < n2 ? -1 : 1) - .map(name => ({id: name, label: name})); + const promise = tmpls ? + this.serverStore.setItem('cat.copy.templates', tmpls) : + Promise.resolve(); - return Promise.resolve(); + return promise + .then(_ => + this.serverStore.getItem('cat.copy.templates')) + .then(templates => { + + this.templates = templates; + + this.templateNames = Object.keys(tmpls) + .sort((n1, n2) => n1 < n2 ? -1 : 1) + .map(name => ({id: name, label: name})); + + this.store.removeLocalItem('cat.copy.templates'); + }); } saveTemplates(): Promise { - // TODO: templates should be stored on the server. this.store.setLocalItem('cat.copy.templates', this.templates); // Re-sort, etc. return this.fetchTemplates(); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql index 74396a1b48..cbac2a5503 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql @@ -7,6 +7,13 @@ VALUES ( 'Holdings Editor Default Values and Visibility', 'cwst', 'label' ) +), ( + 'cat.copy.templates', 'cat', 'object', + oils_i18n_gettext( + 'cat.copy.templates', + 'Holdings Editor Copy Templates', + 'cwst', 'label' + ) ); -- 2.11.0