LP1951162 Migrate copy templates setting
authorBill Erickson <berickxx@gmail.com>
Fri, 3 Dec 2021 18:27:01 +0000 (13:27 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 24 Mar 2022 18:36:06 +0000 (14:36 -0400)
Rename the user setting "webstaff.cat.copy.templates" to
"cat.copy.templates" and migrate any existing values.  This operation is
not performed for any databases where a "cat.copy.templates" user or
workstation setting type already exists.

Teach the Angular copy editor to avoid looking up templates in local
storage, since only XUL templates are stored there, which are not
compatible.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-copy-templates.sql [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index 461a7cf..d898c3e 100644 (file)
@@ -132,16 +132,7 @@ export class VolCopyService {
 
     fetchTemplates(): Promise<any> {
 
-        // 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');
-
-        const promise = tmpls ?
-            this.serverStore.setItem('cat.copy.templates', tmpls) :
-            Promise.resolve();
-
-        return promise
-        .then(_ => this.serverStore.getItem('cat.copy.templates'))
+        return this.serverStore.getItem('cat.copy.templates')
         .then(templates => {
 
             if (!templates) { return null; }
index 46f741c..59aab15 100644 (file)
@@ -2990,9 +2990,9 @@ INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatyp
     'object');
 
 INSERT INTO config.usr_setting_type (name, label, description, datatype)
-    VALUES ('webstaff.cat.copy.templates',
-    oils_i18n_gettext('webstaff.cat.copy.templates', 'Web Client Copy Editor Templates', 'cust', 'label'),
-    oils_i18n_gettext('webstaff.cat.copy.templates', 'Web Client Copy Editor Templates', 'cust', 'description'),
+    VALUES ('cat.copy.templates',
+    oils_i18n_gettext('cat.copy.templates', 'Web Client Copy Editor Templates', 'cust', 'label'),
+    oils_i18n_gettext('cat.copy.templates', 'Web Client Copy Editor Templates', 'cust', 'description'),
     'object');
 
 INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-copy-templates.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-copy-templates.sql
new file mode 100644 (file)
index 0000000..9de4034
--- /dev/null
@@ -0,0 +1,33 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
+
+DO $SQL$
+BEGIN
+    
+    PERFORM TRUE FROM config.usr_setting_type WHERE name = 'cat.copy.templates';
+
+    IF NOT FOUND THEN -- no matching user setting
+
+        PERFORM TRUE FROM config.workstation_setting_type WHERE name = 'cat.copy.templates';
+
+        IF NOT FOUND THEN
+            -- no matching workstation setting
+            -- Migrate the existing user setting and its data to the new name.
+
+            UPDATE config.usr_setting_type 
+            SET name = 'cat.copy.templates' 
+            WHERE name = 'webstaff.cat.copy.templates';
+
+            UPDATE actor.usr_setting
+            SET name = 'cat.copy.templates' 
+            WHERE name = 'webstaff.cat.copy.templates';
+
+        END IF;
+    END IF;
+
+END; 
+$SQL$;
+
+COMMIT;
+
index 3a479b7..feb4688 100644 (file)
@@ -299,8 +299,8 @@ function(egCore , $q) {
     service.save_acp_templates = function(t) {
         egCore.hatch.setItem('cat.copy.templates', t);
         egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.update',
-            egCore.auth.token(), egCore.auth.user().id(), { "webstaff.cat.copy.templates": t });
-        // console.warn('Saved ' + JSON.stringify({"webstaff.cat.copy.templates": t}));
+            egCore.auth.token(), egCore.auth.user().id(), { "cat.copy.templates": t });
+        // console.warn('Saved ' + JSON.stringify({"cat.copy.templates": t}));
     };
 
     service.load_remote_acp_templates = function() {
@@ -309,17 +309,17 @@ function(egCore , $q) {
         // can be thrown away.
         return egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.retrieve.authoritative',
             egCore.auth.token(), egCore.auth.user().id(),
-            ['webstaff.cat.copy.templates','staff_client.copy_editor.templates']).then(function(settings) {
-                if (settings['webstaff.cat.copy.templates']) {
-                    egCore.hatch.setItem('cat.copy.templates', settings['webstaff.cat.copy.templates']);
-                    return settings['webstaff.cat.copy.templates'];
+            ['cat.copy.templates','staff_client.copy_editor.templates']).then(function(settings) {
+                if (settings['cat.copy.templates']) {
+                    egCore.hatch.setItem('cat.copy.templates', settings['cat.copy.templates']);
+                    return settings['cat.copy.templates'];
                 } else {
                     if (settings['staff_client.copy_editor.templates']) {
                         var new_templ = service.convert_xul_templates(settings['staff_client.copy_editor.templates']);
                         egCore.hatch.setItem('cat.copy.templates', new_templ);
-                        // console.warn('Saving: ' + JSON.stringify({'webstaff.cat.copy.templates' : new_templ}));
+                        // console.warn('Saving: ' + JSON.stringify({'cat.copy.templates' : new_templ}));
                         egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.update',
-                            egCore.auth.token(), egCore.auth.user().id(), {'webstaff.cat.copy.templates' : new_templ});
+                            egCore.auth.token(), egCore.auth.user().id(), {'cat.copy.templates' : new_templ});
                         return new_templ;
                     }
                 }