From f5cb4995bc9e3c073ce54aa9218cf13cc5a071b2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 3 Dec 2021 13:27:01 -0500 Subject: [PATCH] LP1951162 Migrate copy templates setting 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 Signed-off-by: Terran McCanna Signed-off-by: Mike Rylander --- .../app/staff/cat/volcopy/volcopy.service.ts | 11 +------ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 6 ++-- .../XXXX.data.angular-copy-templates.sql | 33 +++++++++++++++++++ .../js/ui/default/staff/cat/volcopy/app.js | 16 ++++----- 4 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-copy-templates.sql 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 461a7cf327..d898c3e27f 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 @@ -132,16 +132,7 @@ export class VolCopyService { fetchTemplates(): Promise { - // 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; } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 7f378cd9d3..021ce8fe10 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -2993,9 +2993,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 index 0000000000..9de4034b56 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-copy-templates.sql @@ -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; + diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 3a479b7069..feb46886f3 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -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; } } -- 2.43.2