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; }
'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)
--- /dev/null
+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;
+
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() {
// 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;
}
}