From 07fa5c268c4a08042e8564682f1c3008e8bb8e57 Mon Sep 17 00:00:00 2001 From: Joseph Lewis Date: Wed, 11 Jul 2012 10:39:18 -0600 Subject: [PATCH] perm_list.js transltion fix Updated the translator in perm_list to actually show up. Signed-off-by: Joseph Lewis Signed-off-by: Thomas Berezansky --- .../web/conify/global/permission/perm_list.html | 9 +- Open-ILS/web/conify/global/permission/perm_list.js | 102 +++++++++------------ 2 files changed, 45 insertions(+), 66 deletions(-) diff --git a/Open-ILS/web/conify/global/permission/perm_list.html b/Open-ILS/web/conify/global/permission/perm_list.html index b2a8aed229..ab98dcab17 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 @@ - - - - + + + + @@ -90,4 +90,3 @@ - diff --git a/Open-ILS/web/conify/global/permission/perm_list.js b/Open-ILS/web/conify/global/permission/perm_list.js index c379149898..950d34d632 100644 --- a/Open-ILS/web/conify/global/permission/perm_list.js +++ b/Open-ILS/web/conify/global/permission/perm_list.js @@ -21,11 +21,12 @@ dojo.require('openils.widget.TranslatorPopup'); dojo.require('openils.PermaCrud'); dojo.require('dojo.parser'); dojo.require('dojo.string'); -dojo.require('dojo.cookie'); dojo.require('dojo.data.ItemFileWriteStore'); +dojo.require('dojo.cookie'); dojo.require('dijit.form.TextBox'); dojo.require('dijit.form.ValidationTextBox'); dojo.require('dijit.form.Textarea'); + dojo.require('dijit.layout.ContentPane'); dojo.require('dijit.layout.LayoutContainer'); dojo.require('dijit.layout.BorderContainer'); @@ -35,7 +36,6 @@ dojo.require('dojox.widget.Toaster'); dojo.require('dojox.fx'); dojo.require('openils.XUL'); dojo.require("dojox.grid.cells.dijit"); -dojo.require("dojo.data.ItemFileWriteStore"); dojo.require('dojox.grid.DataGrid'); dojo.requireLocalization("openils.conify", "conify"); @@ -48,19 +48,12 @@ if(!ses && openils.XUL.isXUL()) { } var pCRUD = new openils.PermaCrud({authtoken : ses}); -var ppl_strings = dojo.i18n.getLocalization('openils.conify', 'conify'); - var current_perm; var virgin_out_id = -1; -var highlighter = {}; - +var ppl_strings = dojo.i18n.getLocalization('openils.conify', 'conify'); -dojo.addOnLoad(function() -{ - highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'perm_grid', duration : 500 } ); - highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'perm_grid', duration : 500 } ); -}); +var highlighter = {}; function status_update (markup) { if (parent !== window && parent.status_update) parent.status_update( markup ); @@ -76,7 +69,7 @@ function save_perm () { pCRUD.update(modified_ppl, { onerror : function (r) { highlighter.red.play(); - status_update( dojo.string.substitute(ppl_strings.ERROR_SAVING_DATA, [perm_store.getValue(current_perm, 'code')]) ); + status_update( dojo.string.substitute(ppl_strings.ERROR_SAVING_DATA, [current_perm.code]) ); }, oncomplete : function (r) { perm_store.setValue( current_perm, 'ischanged', 0 ); @@ -97,7 +90,7 @@ function save_them_all (event) { var confirmation = true; - if (event && dirtyStore.length > 0) { + if (event && window.dirtyStore.length > 0) { confirmation = confirm( ppl_strings.CONFIRM_EXIT_PPL ); } @@ -130,66 +123,46 @@ perm_store.onSet = function (item, attr, o, n) { this.setValue( item, 'ischanged', 1); }; +function getTranslationFormat(r, row, grid) +{ + if (!window.perm_rows) window.perm_rows = []; + if (r) { + window.perm_rows[row] = new ccs().fromHash(r); + console.log(window.perm_rows[row]); -var perm_grid_layout = [ - { cells : [ - [ - { name : ppl_strings.LABEL_CODE, field : "code", width : "300px", rowSpan : "2", editable : true }, - { name : ppl_strings.LABEL_DESCRIPTION, field : "description", width : "auto", style : "minHeight:1em;", editable : true } - ], - [ - { name : ppl_strings.LABEL_TRANSLATION, - width : "10em", - height : "2em", - formatter : function (value, row) { - - var r = perm_grid.getItem(row); - if (r) { - perm_rows[row] = new ccs().fromHash(r); - } - var pop = new openils.widget.TranslatorPopup({field:"description", targetObject:"window.perm_rows["+row+"]"}); - pop._destroyOnRemove = true; - return pop; - //return ''; - }/**, - get : function (row) { - console.log("row",row); - var r = perm_grid.getItem(row); - if (r) { - perm_rows[row] = new ccs().fromHash(r); - setTimeout( - 'dojo.query(".perm_grid_trans_desc_' + row + '").'+ - 'instantiate(openils.widget.TranslatorPopup,{field:"description",'+ - 'targetObject:"window.perm_rows['+row+']"});'+ - 'perm_grid.rowHeightChanged('+row+')', - 0 - ); - var oldnode = dojo.byId('description_translation_' + row); - if (oldnode) dijit.byNode(oldnode).destroyRecursive(); - return row; - } - return ''; - }**/ - } - ] - ] + var tp = new openils.widget.TranslatorPopup({field:"code", targetObject:"window.perm_rows["+row+"]"}); + tp._destroyOnRemove=true; + + return tp; } -]; +} + + +var perm_grid_layout = [[ + { name : ppl_strings.LABEL_CODE, field : "code", width : "300px", editable : true }, + { name : ppl_strings.LABEL_DESCRIPTION, field : "description", width : "auto", style : "minHeight:1em;", editable : true }, + { name : ppl_strings.LABEL_TRANSLATION, + width : "10em", + height : "2em", + field:"_item", formatter: getTranslationFormat, + editable: true + } +]]; dojo.addOnUnload( function (event) { perm_store.fetch({ query : { ischanged : 1 }, - onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } }, + onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } }, scope : perm_store }); - if (dirtyStore.length > 0) { + if (window.dirtyStore.length > 0) { var confirmation = confirm(ppl_strings.CONFIRM_EXIT_PPL); if (confirmation) { - for (var i in dirtyStore) { - current_perm = dirtyStore[i]; + for (var i in window.dirtyStore) { + current_perm = window.dirtyStore[i]; save_perm(true); } } @@ -201,7 +174,7 @@ dojo.addOnUnload( function (event) { function saveNewPermCode() { -var new_code = new_perm_code.getValue(); + var new_code = new_perm_code.getValue(); if (!new_code) return; var new_fm_obj = new ppl().fromHash({ @@ -255,3 +228,10 @@ function delete_them() } } } + + +dojo.addOnLoad(function() +{ + highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'perm_grid', duration : 500 } ); + highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'perm_grid', duration : 500 } ); +}); -- 2.11.0