From 2ce6d790f0c910c01127b4fd48b8b12ed3ddf686 Mon Sep 17 00:00:00 2001 From: phasefx Date: Sat, 1 May 2010 09:57:46 +0000 Subject: [PATCH] Org unit settings gui.disable_local_save_columns and url.remote_column_settings. Respectively, these allow us to prevent the local saving and use of column settings, and allows us to specify column settings remotely. If local settings are allowed and remote settings are also configured, then local settings will trump remote settings. Currently these only work with xul lists, not dojo. There is no UI for saving settings remotely; for now the notion is that an admin sets columns up locally, and then transfers the setting files to the remote server. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16369 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 30 ++++++++++++++ ...data.org-setting-url.remote_column_settings.sql | 36 +++++++++++++++++ .../xul/staff_client/chrome/content/util/list.js | 47 +++++++++++++++++----- .../chrome/locale/en-US/offline.properties | 1 + 5 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0250.data.org-setting-url.remote_column_settings.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 6e6976252..d4afa6101 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0249'); -- berick +INSERT INTO config.upgrade_log (version) VALUES ('0250'); -- phasefx CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, 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 6bbf9e190..464b81528 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -2017,6 +2017,36 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) 'bool' ); +-- 0250.data.org-setting-url.remote_column_settings.sql +INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES ( + 'url.remote_column_settings', + oils_i18n_gettext( + 'url.remote_column_settings', + 'GUI: URL for remote directory containing list column settings.', + 'coust', + 'label'), + oils_i18n_gettext( + 'url.remote_column_settings', + 'GUI: URL for remote directory containing list column settings. The format and naming convention for the files found in this directory match those in the local settings directory for a given workstation. An administrator could create the desired settings locally and then copy all the tree_columns_for_* files to the remote directory.', + 'coust', + 'description'), + 'string' +); +INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES ( + 'gui.disable_local_save_columns', + oils_i18n_gettext( + 'gui.disable_local_save_columns', + 'GUI: Disable the ability to save list column configurations locally.', + 'coust', + 'label'), + oils_i18n_gettext( + 'gui.disable_local_save_columns', + 'GUI: Disable the ability to save list column configurations locally. If set, columns may still be manipulated, however, the changes do not persist. Also, existing local configurations are ignored if this setting is true.', + 'coust', + 'description'), + 'bool' +); + -- Org_unit_setting_type(s) that need an fm_class: INSERT into config.org_unit_setting_type ( name, label, description, datatype, fm_class ) VALUES diff --git a/Open-ILS/src/sql/Pg/upgrade/0250.data.org-setting-url.remote_column_settings.sql b/Open-ILS/src/sql/Pg/upgrade/0250.data.org-setting-url.remote_column_settings.sql new file mode 100644 index 000000000..cb550e332 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0250.data.org-setting-url.remote_column_settings.sql @@ -0,0 +1,36 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0250'); -- phasefx + +INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES ( + 'url.remote_column_settings', + oils_i18n_gettext( + 'url.remote_column_settings', + 'GUI: URL for remote directory containing list column settings.', + 'coust', + 'label'), + oils_i18n_gettext( + 'url.remote_column_settings', + 'GUI: URL for remote directory containing list column settings. The format and naming convention for the files found in this directory match those in the local settings directory for a given workstation. An administrator could create the desired settings locally and then copy all the tree_columns_for_* files to the remote directory.', + 'coust', + 'description'), + 'string' +); + +INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES ( + 'gui.disable_local_save_columns', + oils_i18n_gettext( + 'gui.disable_local_save_columns', + 'GUI: Disable the ability to save list column configurations locally.', + 'coust', + 'label'), + oils_i18n_gettext( + 'gui.disable_local_save_columns', + 'GUI: Disable the ability to save list column configurations locally. If set, columns may still be manipulated, however, the changes do not persist. Also, existing local configurations are ignored if this setting is true.', + 'coust', + 'description'), + 'bool' +); + + +COMMIT; diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index 808682797..5bf63e53c 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -20,6 +20,8 @@ util.list = function (id) { JSAN.use('util.error'); this.error = new util.error(); + JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.stash_retrieve(); + return this; }; @@ -218,9 +220,13 @@ util.list.prototype = { 'save_columns' : function (params) { var obj = this; - switch (this.node.nodeName) { - case 'tree' : this._save_columns_tree(params); break; - default: throw('NYI: Need .save_columns() for ' + this.node.nodeName); break; + if (obj.data.hash.aous['gui.disable_local_save_columns']) { + alert(document.getElementById('offlineStrings').getString('list.column_save_disabled')); + } else { + switch (this.node.nodeName) { + case 'tree' : this._save_columns_tree(params); break; + default: throw('NYI: Need .save_columns() for ' + this.node.nodeName); break; + } } }, @@ -271,10 +277,26 @@ util.list.prototype = { return; } - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id)); - if (file._file.exists()) { - var my_cols = file.get_object(); file.close(); + var my_cols; + if (! obj.data.hash.aous['gui.disable_local_save_columns']) { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id)); + if (file._file.exists()) { + my_cols = file.get_object(); file.close(); + } + } + /* local file will trump remote file if allowed, so save ourselves an http request if this is the case */ + if (obj.data.hash.aous['url.remote_column_settings'] && ! my_cols ) { + var x = new XMLHttpRequest(); + var url = obj.data.hash.aous['url.remote_column_settings'] + '/tree_columns_for_' + window.escape(id); + x.open("GET", url, false); + x.send(null); + if (x.status == 200) { + my_cols = JSON2js( x.responseText ); + } + } + + if (my_cols) { var nl = obj.node.getElementsByTagName('treecol'); for (var i = 0; i < nl.length; i++) { var col = nl[i]; @@ -1285,7 +1307,7 @@ util.list.prototype = { '_print_tree' : function(params) { var obj = this; try { - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); + var data = obj.data; data.stash_retrieve(); if (!params.staff && data.list.au && data.list.au[0]) { params.staff = data.list.au[0]; } @@ -1347,8 +1369,8 @@ util.list.prototype = { try { var obj = this; var dump = obj.dump_selected_with_keys({'skip_hidden_columns':true,'labels_instead_of_ids':true}); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); - data.list_clipboard = dump; data.stash('list_clipboard'); + obj.data.stash_retrieve(); + obj.data.list_clipboard = dump; obj.data.stash('list_clipboard'); JSAN.use('util.window'); var win = new util.window(); win.open(urls.XUL_LIST_CLIPBOARD,'list_clipboard','chrome,resizable,modal'); window.focus(); // sometimes the main window will lower after a clipboard action @@ -1527,6 +1549,9 @@ util.list.prototype = { mi.setAttribute('id',obj.node.id + '_save_columns'); mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.save_column_configuration.label')); mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.save_column_configuration.accesskey')); + if (obj.data.hash.aous['gui.disable_local_save_columns']) { + mi.setAttribute('disabled','true'); + } mp.appendChild(mi); return btn; } catch(E) { @@ -1642,7 +1667,7 @@ util.list.prototype = { if (typeof fieldmapper.IDL.fmclasses == 'undefined') { throw 'fieldmapper.IDL.fmclasses undefined'; } if (typeof fieldmapper.IDL.fmclasses[hint] == 'undefined') { throw 'fieldmapper.IDL.fmclasses.' + hint + ' undefined'; } var my_class = fieldmapper.IDL.fmclasses[hint]; - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); + var data = obj.data; data.stash_retrieve(); function col_def(my_field) { var col_id = hint + '_' + my_field.name; diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index e6d7bec1e..c2d7127f3 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -194,6 +194,7 @@ openils.global_util.content_window.error=Error with get_contentWindow(%1$s): %2$ openils.global_util.font_size.error=Error adjusting the font size: %1$s list.row_fetch_warning=WARNING: Only %1$s out of %2$s rows in this list have been retrieved for immediate viewing. Sorting this list requires that all these rows be retrieved, and this may take some time and lag the staff client. Would you like to proceed? list.columns_saved=Column configuration saved. +list.column_save_disabled=Column configuration save disabled by server policy. list.row_retrieving=Retrieving... list.save_csv_as=Save List CSV As... list.actions.menu.label=List Actions -- 2.11.0