From 9af988adeb2e709252106dcdffd282eafef74016 Mon Sep 17 00:00:00 2001 From: Joseph Lewis Date: Wed, 11 Jul 2012 09:09:45 -0600 Subject: [PATCH] Auto update of several scripts. Signed-off-by: Joseph Lewis --- Open-ILS/src/templates/acq/common/jubgrid.tt2 | 6 +- Open-ILS/web/conify/global/actor/org_unit.html | 8 +- .../web/conify/global/actor/org_unit_type.html | 8 +- Open-ILS/web/conify/global/config/copy_status.html | 251 ++------------------- Open-ILS/web/conify/global/config/copy_status.js | 225 +++++++++++++++++- .../web/conify/global/permission/perm_list.html | 8 +- Open-ILS/web/js/ui/default/acq/common/jubgrid.js | 46 ++-- .../staff_client/server/admin/org_unit_settings.js | 12 +- .../server/admin/org_unit_settings.xhtml | 2 +- 9 files changed, 288 insertions(+), 278 deletions(-) diff --git a/Open-ILS/src/templates/acq/common/jubgrid.tt2 b/Open-ILS/src/templates/acq/common/jubgrid.tt2 index ce13d56449..cf4e145e1f 100644 --- a/Open-ILS/src/templates/acq/common/jubgrid.tt2 +++ b/Open-ILS/src/templates/acq/common/jubgrid.tt2 @@ -47,7 +47,7 @@ pointing to the JUB model (and store) that you have created. - - - + + + + diff --git a/Open-ILS/web/conify/global/actor/org_unit_type.html b/Open-ILS/web/conify/global/actor/org_unit_type.html index 4b1e843807..442db91ac7 100644 --- a/Open-ILS/web/conify/global/actor/org_unit_type.html +++ b/Open-ILS/web/conify/global/actor/org_unit_type.html @@ -49,10 +49,10 @@ - - - - + + + + diff --git a/Open-ILS/web/conify/global/config/copy_status.html b/Open-ILS/web/conify/global/config/copy_status.html index 262eaf21c9..644ad0e0b8 100644 --- a/Open-ILS/web/conify/global/config/copy_status.html +++ b/Open-ILS/web/conify/global/config/copy_status.html @@ -22,7 +22,8 @@ &conify.copy_status.title; - - - - + + + + @@ -62,246 +67,24 @@ - - - -
- -
+
&conify.copy_status.new_status.label;
- -
+ -
-
-
- -
-
- -
- - - - +
+
- - - diff --git a/Open-ILS/web/conify/global/config/copy_status.js b/Open-ILS/web/conify/global/config/copy_status.js index 1613ae8eb7..9c29bcb810 100644 --- a/Open-ILS/web/conify/global/config/copy_status.js +++ b/Open-ILS/web/conify/global/config/copy_status.js @@ -31,7 +31,9 @@ dojo.require('dijit.layout.LayoutContainer'); dojo.require('dijit.layout.BorderContainer'); dojo.require('dojox.widget.Toaster'); dojo.require('dojox.fx'); -dojo.require('dojox.grid.Grid'); +dojo.require('dojox.grid.cells.dijit'); +dojo.require('dojo.data.ItemFileWriteStore'); +dojo.require('dojox.grid.DataGrid'); dojo.requireLocalization("openils.conify", "conify"); // some handy globals @@ -97,3 +99,224 @@ function save_them_all (event) { dojo.addOnUnload( save_them_all ); + + +var dirtyStore = []; + +var _status_list = pCRUD.retrieveAll('ccs', { + order_by: { + ccs: 'name' + } +}); +var _status_data = ccs.toStoreData(_status_list, 'name'); +var status_store = new dojo.data.ItemFileWriteStore({ + data: _status_data +}); + +status_store.onSet = function (item, attr, o, n) { + if (attr == 'ischanged') return; + if (n == o) return; + this.setValue(item, 'ischanged', 1); + + if (attr == 'holdable' && typeof n != 'string') this.setValue(item, 'holdable', n ? 't' : 'f'); + + if (attr == 'opac_visible' && typeof n != 'string') this.setValue(item, 'opac_visible', n ? 't' : 'f'); + + if (attr == 'copy_active' && typeof n != 'string') this.setValue(item, 'copy_active', n ? 't' : 'f'); +}; + +dojo.addOnUnload(function (event) { + + status_store.fetch({ + query: { + ischanged: 1 + }, + onItem: function (item, req) { + try { + if (this.isItem(item)) dirtyStore.push(item); + } catch (e) { /* meh */ + } + }, + scope: status_store + }); + + if (dirtyStore.length > 0) { + var confirmation = confirm( + ccs_strings.CONFIRM_EXIT_CCS); + + if (confirmation) { + for (var i in window.dirtyStore) { + current_status = dirtyStore[i]; + save_status(true); + } + } + } + +}); + +/** + * Creates a new copy status, saves it, and re-populates the grid. + */ +function newCopyStatus() +{ + var new_name = new_status_name.getValue(); + if (!new_name) return; + + var new_fm_obj = new ccs().fromHash({ + isnew : 1, + name : new_name + }); + + var err = false; + pCRUD.create(new_fm_obj, { + onerror : function (r) { + highlighter.red.play(); + status_update( ccs_strings.ERROR_CALLING_METHOD_CCS ); + err = true; + }, + oncomplete : function (r, list) { + var new_item_hash = list[0].toHash(); + status_store.newItem( new_item_hash ); + status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) ); + status_grid.model.sort(-2); + highlighter.green.play(); + } + }); +} + + +function delete_them() +{ + var selected_rows = status_grid.selection.getSelected(); + + var selected_items = []; + for (var i in selected_rows) { + selected_items.push( + status_grid.getItem( selected_rows[i] ).__dojo_data_item + ); + } + + status_grid.selection.clear(); + + for (var i in selected_items) { + current_status = selected_items[i]; + + if ( confirm(dojo.string.substitute(ccs_strings.CONFIRM_DELETE, [status_store.getValue( current_status, 'name' )]))) { + + status_store.setValue( current_status, 'isdeleted', 1 ); + + var modified_ccs = new ccs().fromStoreItem( current_status ); + modified_ccs.isdeleted( 1 ); + + pCRUD.eliminate(modified_ccs, { + onerror : function (r) { + highlighter.red.play(); + status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) ); + }, + oncomplete : function (r) { + var old_name = status_store.getValue( current_status, 'name' ); + + status_store.fetch({ + query : { id : status_store.getValue( current_status, 'id' ) }, + onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } }, + scope : status_store + }); + + current_status = null; + + highlighter.green.play(); + status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) ); + } + }); + + } + } +} + + +var status_grid_layout = [ +{ cells : [ + [ + { name : ccs_strings.ID, + field : "id", + }, + { name : ccs_strings.NAME, + field : "name", + width : "auto", + //editor : dojox.grid.editors.Dijit + editable: true + }, + { name : ccs_strings.TRANSLATION, + width : "10em", + height : "2em", + formatter: function (row) { + return ''; + }, + get : function (row) { + if (!window.status_rows) window.status_rows = []; + var r = grid_container.getItem(row); + if (r) { + window.status_rows[row] = new ccs().fromHash(grid_container.getItem(row)); + setTimeout( + 'dojo.query(".status_grid_trans_cell_' + row + '").'+ + 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+ + 'targetObject:"window.status_rows['+row+']"});'+ + 'status_grid.rowHeightChanged('+row+')', + 0 + ); + return row; + } + return ''; + } + }, + { name : ccs_strings.HOLDABLE, + field : "holdable", + editable: true, + //editor : dojox.grid.editors.bool, + get : function (row) { + var r = grid_container.getItem(row); + if (r) { + var h = r.holdable; + if (h == 't' || h === true) return true; + return false; + } + } + }, + { name : ccs_strings.OPAC_VISIBLE, + field : "opac_visible", + editable: true, + //editor : dojox.grid.editors.bool, + get : function (row) { + var r = grid_container.getItem(row); + if (r) { + var h = r.opac_visible; + if (h == 't' || h === true) return true; + return false; + } + } + }, + { name : ccs_strings.COPY_ACTIVE, + field : "copy_active", + //editor : dojox.grid.editors.bool, + editable: true, + get : function (row) { + var r = grid_container.getItem(row); + if (r) { + var h = r.copy_active; + if (h == 't' || h === true) return true; + return false; + } + } + } + ] + ] +} +]; + + + +dojo.addOnLoad(function() +{ + highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } ); + highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } ); +}); diff --git a/Open-ILS/web/conify/global/permission/perm_list.html b/Open-ILS/web/conify/global/permission/perm_list.html index fe6f5d8238..b2a8aed229 100644 --- a/Open-ILS/web/conify/global/permission/perm_list.html +++ b/Open-ILS/web/conify/global/permission/perm_list.html @@ -56,10 +56,10 @@ - - - - + + + + diff --git a/Open-ILS/web/js/ui/default/acq/common/jubgrid.js b/Open-ILS/web/js/ui/default/acq/common/jubgrid.js index 6a0c451aef..2edc3870f3 100644 --- a/Open-ILS/web/js/ui/default/acq/common/jubgrid.js +++ b/Open-ILS/web/js/ui/default/acq/common/jubgrid.js @@ -3,20 +3,22 @@ dojo.require('dijit.layout.SplitContainer'); dojo.require('dijit.Dialog'); dojo.require('dijit.form.FilteringSelect'); dojo.require('dijit.form.Button'); -dojo.require('dojox.grid.Grid'); +dojo.require('dojox.grid.cells.dijit'); +dojo.require('dojo.data.ItemFileWriteStore'); +dojo.require('dojox.grid.DataGrid'); dojo.require('dojo.date.locale'); dojo.require('dojo.date.stamp'); -dojo.require("openils.User"); -dojo.require("openils.acq.Fund"); -dojo.require("openils.acq.Lineitem"); +dojo.require('openils.User'); +dojo.require('openils.acq.Fund'); +dojo.require('openils.acq.Lineitem'); dojo.require('openils.acq.Provider'); -dojo.require("openils.widget.FundSelector"); +dojo.require('openils.widget.FundSelector'); dojo.require('openils.editors'); dojo.require('openils.Event'); -dojo.require("openils.widget.OrgUnitFilteringSelect"); -dojo.require("fieldmapper.OrgUtils"); +dojo.require('openils.widget.OrgUnitFilteringSelect'); +dojo.require('fieldmapper.OrgUtils'); /* put all the accessors, etc. into a local object for namespacing */ var JUBGrid = { @@ -32,7 +34,7 @@ var JUBGrid = { }, _getMARCAttr : function(rowIndex, attr) { - var data = JUBGrid.jubGrid.model.getRow(rowIndex); + var data = JUBGrid.jubGrid.getItem(rowIndex); if (!data) return ''; return new openils.acq.Lineitem( {lineitem:JUBGrid.getLi(data.id)}).findAttr(attr, 'lineitem_marc_attr_definition') @@ -47,7 +49,7 @@ var JUBGrid = { return JUBGrid._getMARCAttr(rowIndex, 'isbn'); }, getJUBActualPrice : function(rowIndex) { - var data = JUBGrid.jubGrid.model.getRow(rowIndex); + var data = JUBGrid.jubGrid.getItem(rowIndex); if (!data) return ''; var price = new openils.acq.Lineitem( {lineitem:JUBGrid.getLi(data.id)}).getActualPrice(); @@ -55,7 +57,7 @@ var JUBGrid = { return '' }, getJUBEstimatedPrice : function(rowIndex) { - var data = JUBGrid.jubGrid.model.getRow(rowIndex); + var data = JUBGrid.jubGrid.getItem(rowIndex); if (!data) return ''; var price = new openils.acq.Lineitem( {lineitem:JUBGrid.getLi(data.id)}).getEstimatedPrice(); @@ -66,23 +68,23 @@ var JUBGrid = { return JUBGrid._getMARCAttr(rowIndex, 'pubdate'); }, getProvider : function(rowIndex) { - data = JUBGrid.jubGrid.model.getRow(rowIndex); + data = JUBGrid.jubGrid.getItem(rowIndex); if(!data || !data.provider) return; return openils.acq.Provider.retrieve(data.provider).code(); }, getRecvTime : function(rowIndex) { - var data = JUBGrid.jubDetailGrid.model.getRow(rowIndex); + var data = JUBGrid.jubDetailGrid.getItem(rowIndex); if (!(data && data.recv_time)) return ''; var date = dojo.date.stamp.fromISOString(data.recv_time); return dojo.date.locale.format(date, {formatLength:'medium'}); }, getCopyLocation : function(rowIndex) { - var data = JUBGrid.jubDetailGrid.model.getRow(rowIndex); + var data = JUBGrid.jubDetailGrid.getItem(rowIndex); if(!data || !data.location) return ''; return openils.CopyLocation.retrieve(data.location).name(); }, getLIDFundName : function(rowIndex) { - var data = JUBGrid.jubDetailGrid.model.getRow(rowIndex); + var data = JUBGrid.jubDetailGrid.getItem(rowIndex); if (!data || !data.fund) return; try { return openils.acq.Fund.retrieve(data.fund).name(); @@ -91,7 +93,7 @@ var JUBGrid = { } }, getLIDFundCode : function(rowIndex) { - var data = JUBGrid.jubDetailGrid.model.getRow(rowIndex); + var data = JUBGrid.jubDetailGrid.getItem(rowIndex); if (!data || !data.fund) return; try { return openils.acq.Fund.retrieve(data.fund).code(); @@ -100,7 +102,7 @@ var JUBGrid = { } }, getLIDLibName : function(rowIndex) { - var data = JUBGrid.jubDetailGrid.model.getRow(rowIndex); + var data = JUBGrid.jubDetailGrid.getItem(rowIndex); if (!data || !data.owning_lib) return; return fieldmapper.aou.findOrgUnit(data.owning_lib).shortname(); }, @@ -114,7 +116,7 @@ var JUBGrid = { for (var i in lineitems) { JUBGrid.lineitems[lineitems[i].id()] = lineitems[i]; } - JUBGrid.jubGrid = gridWidget; +//FIXME JUBGrid.jubGrid = gridWidget; JUBGrid.jubGrid.setModel(model); if(JUBGrid.showDetails) { dojo.connect(gridWidget, "onRowClick", @@ -132,7 +134,7 @@ var JUBGrid = { } openils.acq.Lineitem.loadLIDGrid( JUBGrid.jubDetailGrid, - JUBGrid.jubGrid.model.getRow(evt.rowIndex).id, grid); + JUBGrid.jubGrid.getItem(evt.rowIndex).id, grid); } ); } @@ -146,7 +148,7 @@ var JUBGrid = { var selected = JUBGrid.jubGrid.selection.getSelected(); for (var idx = 0; idx < selected.length; idx++) { var rowIdx = selected[idx]; - JUBGrid.approveSingleJUB(JUBGrid.jubGrid.model.getRow(rowIdx)); + JUBGrid.approveSingleJUB(JUBGrid.jubGrid.getItem(rowIdx)); } }, @@ -204,7 +206,7 @@ var JUBGrid = { var deleted = false; for(var i = 0; i < selected.length; i++) { var rowIdx = selected[i]; - var jubid = JUBGrid.jubGrid.model.getRow(rowIdx).id; + var jubid = JUBGrid.jubGrid.getItem(rowIdx).id; if(jubid == id) { if (lineitems[id].state() == 'new') { deleteMe.push(lineitems[id]); @@ -233,7 +235,7 @@ var JUBGrid = { var selected = JUBGrid.jubDetailGrid.selection.getSelected(); for (var idx = 0; idx < selected.length; idx++) { var rowIdx = selected[idx]; - var lid = JUBGrid.jubDetailGrid.model.getRow(rowIdx); + var lid = JUBGrid.jubDetailGrid.getItem(rowIdx); var deleteFromStore = function (evt) { if (evt) { @@ -277,7 +279,7 @@ var JUBGrid = { var selected = JUBGrid.jubDetailGrid.selection.getSelected(); for (var idx = 0; idx < selected.length; idx++) { var rowIdx = selected[idx]; - var lid = JUBGrid.jubDetailGrid.model.getRow(rowIdx); + var lid = JUBGrid.jubDetailGrid.getItem(rowIdx); list.push(lid.id); } if(lid != null) { // is at least one selected? diff --git a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js index 9ca048c165..c8cad56764 100644 --- a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js +++ b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js @@ -5,7 +5,9 @@ dojo.require('dijit.form.FilteringSelect'); dojo.require('dijit.Dialog'); dojo.require('dijit.form.Textarea'); dojo.require('dijit.form.ComboBox'); -dojo.require('dojox.grid.Grid'); +dojo.require('dojox.grid.cells.dijit'); +dojo.require('dojo.data.ItemFileWriteStore'); +dojo.require('dojox.grid.DataGrid'); dojo.require('fieldmapper.Fieldmapper'); dojo.require('fieldmapper.dojoData'); dojo.require('fieldmapper.OrgUtils'); @@ -316,13 +318,13 @@ function osLoadGrid(data) { var model = new dojox.grid.data.DojoData( null, store, {rowsPerPage: 100, clientSort: true, query:{name:'*'}}); - osGrid.setModel(model); +//FIXME osGrid.setModel(model); osGrid.setStructure(osGridLayout); osGrid.update(); } function osGetGridData(rowIdx) { - var data = this.grid.model.getRow(rowIdx); + var data = this.grid.getItem(rowIdx); if(!data) return ''; var setting = osSettings[data.name]; var value = setting[this.field]; @@ -362,7 +364,7 @@ function osGetGridData(rowIdx) { } function osGetEditLink(rowIdx) { - var data = this.grid.model.getRow(rowIdx); + var data = this.grid.getItem(rowIdx); if(!data) return ''; return data.name; } @@ -510,7 +512,7 @@ function osRevertSetting(context, name, value) { } function osGetHistoryLink(rowIdx) { - var data = this.grid.model.getRow(rowIdx); + var data = this.grid.getItem(rowIdx); if(!data) return ''; return data.name; } diff --git a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml index e54a639c26..7d89c4364c 100644 --- a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml @@ -125,7 +125,7 @@ ]] }]; -
+
-- 2.11.0