From: miker Date: Sat, 12 May 2007 03:27:31 +0000 (+0000) Subject: trying a fix for the textbox bug X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=864d316a8f794cf87d92805abe516a9749e54b10;p=Evergreen.git trying a fix for the textbox bug git-svn-id: svn://svn.open-ils.org/ILS/trunk@7252 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/reports/xul/template-config.js b/Open-ILS/web/reports/xul/template-config.js index 5b10a81401..6371c802e9 100644 --- a/Open-ILS/web/reports/xul/template-config.js +++ b/Open-ILS/web/reports/xul/template-config.js @@ -10,6 +10,7 @@ function removeReportAtom (args) { var tabpanel = $( tabname + 'panel' ); var tree = tabpanel.getElementsByTagName('tree')[0]; + var item_pos = tree.view.selection.currentIndex; var fields = getSelectedItems(tree); @@ -35,6 +36,7 @@ function removeReportAtom (args) { } renderSources(); + tree.view.selection.select( item_pos ); } function addReportAtoms () { @@ -179,24 +181,23 @@ function alterColumnLabel () { var tabpanel = $( tabname + 'panel' ); var tree = tabpanel.getElementsByTagName('tree')[0]; - var items = getSelectedItems(tree); + var item_pos = tree.view.selection.currentIndex; - for (var i in items) { - var item = items[i]; - var relation_alias = item.getAttribute('relation'); + var item = getSelectedItems(tree)[0]; + var relation_alias = item.getAttribute('relation'); - var field = item.firstChild.firstChild; - var colname = field.nextSibling.getAttribute('label'); + var field = item.firstChild.firstChild; + var colname = field.nextSibling.getAttribute('label'); - var new_label = prompt( - "Change the column header to:", - field.getAttribute("label") - ); + var new_label = prompt( + "Change the column header to:", + field.getAttribute("label") + ); - if (new_label) { - rpt_rel_cache[relation_alias].fields[tabname][colname].alias = new_label; - renderSources(true); - } + if (new_label) { + rpt_rel_cache[relation_alias].fields[tabname][colname].alias = new_label; + renderSources(true); + tree.view.selection.select( item_pos ); } } @@ -214,6 +215,7 @@ function alterColumnTransform (trans) { var tabpanel = $( tabname + 'panel' ); var tree = tabpanel.getElementsByTagName('tree')[0]; + var item_pos = tree.view.selection.currentIndex; var item = getSelectedItems(tree)[0]; var relation_alias = item.getAttribute('relation'); @@ -226,7 +228,8 @@ function alterColumnTransform (trans) { rpt_rel_cache[relation_alias].fields[tabname][colname].transform_label = transform.label; renderSources(true); - return false; + tree.view.selection.select( item_pos ); + return true; } function changeOperator (args) { @@ -241,21 +244,19 @@ function changeOperator (args) { var tabpanel = $( tabname + 'panel' ); var tree = tabpanel.getElementsByTagName('tree')[0]; - var items = getSelectedItems(tree); - - for (var i in items) { - var item = items[i]; - var relation_alias = item.getAttribute('relation'); + var item_pos = tree.view.selection.currentIndex; + var item = getSelectedItems(tree)[0]; - var field = item.firstChild.firstChild; - var colname = field.nextSibling.getAttribute('label'); + var relation_alias = item.getAttribute('relation'); - rpt_rel_cache[relation_alias].fields[tabname][colname].op = args.op; - rpt_rel_cache[relation_alias].fields[tabname][colname].op_label = args.label; + var field = item.firstChild.firstChild; + var colname = field.nextSibling.getAttribute('label'); - } + rpt_rel_cache[relation_alias].fields[tabname][colname].op = args.op; + rpt_rel_cache[relation_alias].fields[tabname][colname].op_label = args.label; renderSources(true); + tree.view.selection.select( item_pos ); return true; } @@ -271,19 +272,17 @@ function removeTemplateFilterValue () { var tabpanel = $( tabname + 'panel' ); var tree = tabpanel.getElementsByTagName('tree')[0]; - var items = getSelectedItems(tree); - - for (var i in items) { - var item = items[i]; - var relation_alias = item.getAttribute('relation'); + var item_pos = tree.view.selection.currentIndex; + var item = getSelectedItems(tree)[0]; + var relation_alias = item.getAttribute('relation'); - var field = item.firstChild.firstChild; - var colname = field.nextSibling.getAttribute('label'); + var field = item.firstChild.firstChild; + var colname = field.nextSibling.getAttribute('label'); - rpt_rel_cache[relation_alias].fields[tabname][colname].op_value = {}; - } + rpt_rel_cache[relation_alias].fields[tabname][colname].op_value = {}; renderSources(true); + tree.view.selection.select( item_pos ); } function timestampSetDate (obj, cal, date) { @@ -308,7 +307,8 @@ function changeTemplateFilterValue () { var tabpanel = $( tabname + 'panel' ); var tree = tabpanel.getElementsByTagName('tree')[0]; - var items = getSelectedItems(tree); + var item_pos = tree.view.selection.currentIndex; + var item = getSelectedItems(tree)[0]; var targetCmd = $( tabname + '_value_action' ); @@ -317,147 +317,144 @@ function changeTemplateFilterValue () { targetCmd.oncommand = null; targetCmd.removeEventListener( 'command', __handler_cache, true ); - for (var i in items) { - var item = items[i]; - var relation_alias = item.getAttribute('relation'); + var relation_alias = item.getAttribute('relation'); - var field = item.firstChild.firstChild; - var colname = field.nextSibling.getAttribute('label'); + var field = item.firstChild.firstChild; + var colname = field.nextSibling.getAttribute('label'); - var obj = rpt_rel_cache[relation_alias].fields[tabname][colname] - var operation = OILS_RPT_FILTERS[obj.op]; + var obj = rpt_rel_cache[relation_alias].fields[tabname][colname] + var operation = OILS_RPT_FILTERS[obj.op]; - switch (obj.datatype) { - case 'timestamp': - var cal_popup = $('calendar-widget'); + switch (obj.datatype) { + case 'timestamp': + var cal_popup = $('calendar-widget'); - while (cal_popup.firstChild) cal_popup.removeChild(cal_popup.lastChild); - var calendar = new Calendar( - 0, - obj.op_value.object, - function (cal,date) { timestampSetDate(obj,cal,date) }, - function (cal) { cal_popup.hidePopup(); cal.destroy(); } - ); + while (cal_popup.firstChild) cal_popup.removeChild(cal_popup.lastChild); + var calendar = new Calendar( + 0, + obj.op_value.object, + function (cal,date) { timestampSetDate(obj,cal,date) }, + function (cal) { cal_popup.hidePopup(); cal.destroy(); } + ); - var format = OILS_RPT_TRANSFORMS[obj.transform].cal_format || '%Y-%m-%d'; + var format = OILS_RPT_TRANSFORMS[obj.transform].cal_format || '%Y-%m-%d'; - calendar.setDateFormat(format); - calendar.create(cal_popup); + calendar.setDateFormat(format); + calendar.create(cal_popup); - targetCmd.menu = 'calendar-widget'; + targetCmd.menu = 'calendar-widget'; - break; + break; - case 'bool': + case 'bool': - function __bool_value_event_handler () { - var state, answer; + function __bool_value_event_handler () { + var state, answer; - try { - // get a reference to the prompt service component. - var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); + try { + // get a reference to the prompt service component. + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); - // set the buttons that will appear on the dialog. It should be - // a set of constants multiplied by button position constants. In this case, - // three buttons appear, Save, Cancel and a custom button. - var flags=promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 + - promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 + - promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_2; + // set the buttons that will appear on the dialog. It should be + // a set of constants multiplied by button position constants. In this case, + // three buttons appear, Save, Cancel and a custom button. + var flags=promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 + + promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 + + promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_2; - // display the dialog box. The flags set above are passed - // as the fourth argument. The next three arguments are custom labels used for - // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a - // particular button. The last two arguments are for an optional check box. - answer = promptService.select( - window, - "Boolean Value", - "Select the value, or cancel:", - 2, ["True", "False"], state - ); - } catch (e) { - answer = true; - state = confirm("Click OK for TRUE and Cancel for FALSE."); - state ? state = 0 : state = 1; - } + // display the dialog box. The flags set above are passed + // as the fourth argument. The next three arguments are custom labels used for + // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a + // particular button. The last two arguments are for an optional check box. + answer = promptService.select( + window, + "Boolean Value", + "Select the value, or cancel:", + 2, ["True", "False"], state + ); + } catch (e) { + answer = true; + state = confirm("Click OK for TRUE and Cancel for FALSE."); + state ? state = 0 : state = 1; + } - if (answer) { - if (state) { - obj.op_value.value = 'f'; - obj.op_value.label = 'False'; - } else { - obj.op_value.value = 't'; - obj.op_value.label = 'True'; - } + if (answer) { + if (state) { + obj.op_value.value = 'f'; + obj.op_value.label = 'False'; + } else { + obj.op_value.value = 't'; + obj.op_value.label = 'True'; } - - targetCmd.removeEventListener( 'command', __bool_value_event_handler, true ); - renderSources(true); } - __handler_cache = __bool_value_event_handler; - targetCmd.addEventListener( 'command', __bool_value_event_handler, true ); + targetCmd.removeEventListener( 'command', __bool_value_event_handler, true ); + renderSources(true); + tree.view.selection.select( item_pos ); + } - break; + __handler_cache = __bool_value_event_handler; + targetCmd.addEventListener( 'command', __bool_value_event_handler, true ); - default: + break; + default: - var promptstring = "Field does not match one of list (comma separated):"; - switch (obj.op) { - case 'not between': - promptstring = "Field value is not between (comma separated):"; - break; + var promptstring = "Field does not match one of list (comma separated):"; - case 'between': - promptstring = "Field value is between (comma separated):"; - break; + switch (obj.op) { + case 'not between': + promptstring = "Field value is not between (comma separated):"; + break; - case 'not in': - promptstring = "Field does not match one of list (comma separated):"; - break; + case 'between': + promptstring = "Field value is between (comma separated):"; + break; - case 'in': - promptstring = "Field matches one of list (comma separated):"; - break; + case 'not in': + promptstring = "Field does not match one of list (comma separated):"; + break; - default: - promptstring = "Value " + obj.op_label + ":"; - break; - } + case 'in': + promptstring = "Field matches one of list (comma separated):"; + break; + + default: + promptstring = "Value " + obj.op_label + ":"; + break; + } - function __default_value_event_handler () { - var _v; - if (_v = prompt( promptstring, obj.op_value.value || '' )) { - switch (obj.op) { - case 'between': - case 'not between': - case 'not in': - case 'in': - obj.op_value.value = _v.split(/\s*,\s*/); - break; - - default: - obj.op_value.value = _v; - break; - } - - obj.op_value.label = '"' + obj.op_value.value + '"'; + function __default_value_event_handler () { + var _v; + if (_v = prompt( promptstring, obj.op_value.value || '' )) { + switch (obj.op) { + case 'between': + case 'not between': + case 'not in': + case 'in': + obj.op_value.value = _v.split(/\s*,\s*/); + break; + + default: + obj.op_value.value = _v; + break; } - targetCmd.removeEventListener( 'command', __default_value_event_handler, true ); - renderSources(true); + obj.op_value.label = '"' + obj.op_value.value + '"'; } - __handler_cache = __default_value_event_handler; - targetCmd.addEventListener( 'command', __default_value_event_handler, true ); + targetCmd.removeEventListener( 'command', __default_value_event_handler, true ); + renderSources(true); + tree.view.selection.select( item_pos ); + } - break; - } - } + __handler_cache = __default_value_event_handler; + targetCmd.addEventListener( 'command', __default_value_event_handler, true ); - //renderSources(true); + break; + } } function populateOperatorContext () {