From 5f2dd33849dc68dfb2b692b0f17b9da028a8aa81 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 6 Jul 2011 03:19:09 -0400 Subject: [PATCH] dynamic Record Summary layout based on preference For now, you could add something like this to server/skin/custom.js to re-configure the display: try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']); prefs.setCharPref( 'oils.bib_brief.horizontal.dynamic_grid_replacement.data', js2JSON([ ['title', 'edition', 'editor'], ['author', 'pubdate', 'edit_date'], ['bib_call_number', 'tcn', 'create_date'] ]) ); } catch(E) { dump('Error in custom.js trying to set oils.bib_brief.horizontal.dynamic_grid_replacement.data: ' + E + '\n'); } Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson --- Open-ILS/xul/staff_client/server/cat/bib_brief.js | 101 +++++++++++++++++++++ .../server/locale/en-US/cat.properties | 24 +++++ 2 files changed, 125 insertions(+) diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief.js b/Open-ILS/xul/staff_client/server/cat/bib_brief.js index 930e68c7c0..b7c5c02318 100644 --- a/Open-ILS/xul/staff_client/server/cat/bib_brief.js +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief.js @@ -5,6 +5,8 @@ function my_init(orientation) { ui_init(); // JSAN, etc. + if (! orientation) { orientation = 'horizontal'; } + JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve(); @@ -52,6 +54,7 @@ function my_init(orientation) { try { g.meta = req2.getResultObject()[0]; set_caption(); + dynamic_grid_replacement(orientation); bib_brief_overlay({ 'mvr' : g.mods, 'bre' : g.meta @@ -202,3 +205,101 @@ function ui_init() { g.error.sdump('D_TRACE','my_init() for cat_bib_brief.xul'); } +function dynamic_grid_replacement(orientation) { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var prefs = Components.classes[ + '@mozilla.org/preferences-service;1' + ].getService( + Components.interfaces['nsIPrefBranch'] + ); + if (! prefs.prefHasUserValue( + 'oils.bib_brief.'+orientation+'.dynamic_grid_replacement.data' + ) + ) { + return; + } + + var gridData = JSON2js( + prefs.getCharPref( + 'oils.bib_brief.'+orientation+'.dynamic_grid_replacement.data' + ) + ); + + var grid = document.getElementById('bib_brief_grid'); + if (!grid) { return; } + + JSAN.use('util.widgets'); + + util.widgets.remove_children(grid); + + var columns = document.createElement('columns'); + grid.appendChild(columns); + + var maxColumns = 0; + for (var i = 0; i < gridData.length; i++) { + if (gridData[i].length > maxColumns) { + maxColumns = gridData[i].length; + } + } + + for (var i = 0; i < maxColumns; i++) { + var columnA = document.createElement('column'); + columns.appendChild(columnA); + var columnB = document.createElement('column'); + columns.appendChild(columnB); + } + + // Flex the column where the title usually goes + columns.firstChild.nextSibling.setAttribute('flex','1'); + + var rows = document.createElement('rows'); + grid.appendChild(rows); + +/* + + +*/ + + var catStrings = document.getElementById('catStrings'); + + for (var i = 0; i < gridData.length; i++) { + var row = document.createElement('row'); + row.setAttribute('id','bib_brief_grid_row'+i); + rows.appendChild(row); + + for (var j = 0; j < gridData[i].length; j++) { + var name = gridData[i][j]; + + var label = document.createElement('label'); + label.setAttribute('control',name); + label.setAttribute('class','emphasis'); + label.setAttribute('value', + catStrings.testString('staff.cat.bib_brief.'+name+'.label') + ? catStrings.getString('staff.cat.bib_brief.'+name+'.label') + : name + ); + label.setAttribute('accesskey', + catStrings.testString('staff.cat.bib_brief.'+name+'.accesskey') + ? catStrings.getString('staff.cat.bib_brief.'+name+'.accesskey') + : name + ); + row.appendChild(label); + + var textbox = document.createElement('textbox'); + textbox.setAttribute('id',name); + textbox.setAttribute('name',name); + textbox.setAttribute('readonly','true'); + textbox.setAttribute('context','clipboard'); + textbox.setAttribute('class','plain'); + textbox.setAttribute('onfocus','this.select()'); + row.appendChild(textbox); + } + } +} + diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index f035034882..fb389cade2 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -516,3 +516,27 @@ staff.cat.z3950.spawn_marc_editor_for_overlay.success_overlay=Record successfull staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_error=Record not likely overlaid. staff.cat.z3950.load_creds.z3950_cred_error=Error retrieving stored z39.50 credentials staff.cat.z3950.save_creds.z3950_cred_error=Problem storing z39.50 credentials. +staff.cat.bib_brief.title.label=Title: +staff.cat.bib_brief.title.accesskey= +staff.cat.bib_brief.author.label=Author: +staff.cat.bib_brief.author.accesskey= +staff.cat.bib_brief.edition.label=Edition: +staff.cat.bib_brief.edition.accesskey= +staff.cat.bib_brief.pubdate.label=Pub Date: +staff.cat.bib_brief.pubdate.accesskey= +staff.cat.bib_brief.bib_call_number.label=Bib Call #: +staff.cat.bib_brief.bib_call_number.accesskey= +staff.cat.bib_brief.tcn.label=TCN: +staff.cat.bib_brief.tcn.accesskey= +staff.cat.bib_brief.mvr_doc_id.label=Record ID: +staff.cat.bib_brief.mvr_doc_id.accesskey= +staff.cat.bib_brief.owner.label=Record Owner: +staff.cat.bib_brief.owner.accesskey= +staff.cat.bib_brief.creator.label=Created By: +staff.cat.bib_brief.creator.accesskey= +staff.cat.bib_brief.create_date.label=Created On: +staff.cat.bib_brief.create_date.accesskey= +staff.cat.bib_brief.editor.label=Last Edited By: +staff.cat.bib_brief.editor.accesskey= +staff.cat.bib_brief.edit_date.label=Last Edited On: +staff.cat.bib_brief.edit_date.accesskey= -- 2.11.0