LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Thu, 25 Jun 2020 14:49:15 +0000 (10:49 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 25 Jun 2020 14:49:15 +0000 (10:49 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts
Open-ILS/src/sql/Pg/upgrade/XXXX.data.volcopy-settings.sql

index 63081e3..31e4661 100644 (file)
@@ -187,21 +187,31 @@ export class VolCopyService {
 
     fetchTemplates(): Promise<any> {
 
-        // 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<any> {
-        // TODO: templates should be stored on the server.
         this.store.setLocalItem('cat.copy.templates', this.templates);
         // Re-sort, etc.
         return this.fetchTemplates();
index 74396a1..cbac2a5 100644 (file)
@@ -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'
+    )
 );