From: erickson Date: Tue, 31 Oct 2006 02:35:38 +0000 (+0000) Subject: Implemented template cloning X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c6228e04837ce2fc554c359fa1078ff2072be204;p=evergreen%2Fpines.git Implemented template cloning Added the ability to move templates/reports/outputs to different folders Broke output display into completed vs. non-completed output tables Forcing regular expressions (visually) on parameter entry when available Rearranged the report editor to hopefully make a little more sense Fixed some other small bugs git-svn-id: svn://svn.open-ils.org/ILS/trunk@6533 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/reports/oils_rpt.css b/Open-ILS/web/reports/oils_rpt.css index bf54b5043c..c470124db4 100644 --- a/Open-ILS/web/reports/oils_rpt.css +++ b/Open-ILS/web/reports/oils_rpt.css @@ -114,11 +114,20 @@ button:active { position: absolute; text-align: center; z-index: 1; - background: #E0F0F0; + /*background: #E0F0F0; */ + background: #FFCC7F; /* see FF9900 as the primary color in the color picker for complimentaries */ border: 3px groove #0033EE; padding: 10px; + + /* testing static location */ + width: 600px; + top: 60px; + left: 20px; } +.oils_rpt_tab_picker_selected { + background: #96A1C6; +} .oils_rpt_tab_table { width: 100%; @@ -128,6 +137,7 @@ button:active { border: 1px solid #808080; border-collapse: collapse; text-align: center; + font-weight: bold; } .oils_rpt_tab_table td { @@ -237,10 +247,12 @@ button:active { #oils_rpt_param_editor_table td { border: 1px solid #808080; + padding: 2px; } #oils_rpt_param_editor_table thead td { font-weight: bold; + text-align: center; } .oils_rpt_folder_tree { @@ -285,6 +297,19 @@ button:active { .oils_rpt_generic_table { width: 100%; } .oils_rpt_generic_table td { border: 1px solid #808080; padding: 5px; } +#oils_rpt_content_count_row_2 { + border-top: 2px solid #808080; + border-bottom: 1px solid #808080; + padding-top: 10px; + margin-top: 10px; +} + +#oils_rpt_editor_table tr { + border-bottom: 1px solid #D0D0D0; +} +#oils_rpt_editor_table tr td { + border-left: 1px solid #808080; +} diff --git a/Open-ILS/web/reports/oils_rpt.js b/Open-ILS/web/reports/oils_rpt.js index 32325a3f18..7754cfb3ca 100644 --- a/Open-ILS/web/reports/oils_rpt.js +++ b/Open-ILS/web/reports/oils_rpt.js @@ -69,19 +69,22 @@ function oilsReport(templateObj, reportObj) { this.params = {}; this.name = ""; - this.templateObject = templateObj; this.reportObject = reportObj; - if( templateObj ) { - this.def = JSON2js(templateObj.data()); - this.name = templateObj.name(); - } + if(templateObj) this.setTemplate(templateObj); if( reportObj ) this.params = JSON2js(reportObj.data()); if(!this.params) this.params = {}; } + +oilsReport.prototype.setTemplate = function(template) { + this.def = JSON2js(template.data()); + this.name = template.name(); + this.templateObject = template; +} + oilsReport.prototype.toString = function() { return formatJSON(js2JSON(this)); } diff --git a/Open-ILS/web/reports/oils_rpt.xhtml b/Open-ILS/web/reports/oils_rpt.xhtml index dbeb6c8b30..3b58958d20 100644 --- a/Open-ILS/web/reports/oils_rpt.xhtml +++ b/Open-ILS/web/reports/oils_rpt.xhtml @@ -82,7 +82,7 @@ - +
diff --git a/Open-ILS/web/reports/oils_rpt_builder.js b/Open-ILS/web/reports/oils_rpt_builder.js index 2debd1a393..31790e1de9 100644 --- a/Open-ILS/web/reports/oils_rpt_builder.js +++ b/Open-ILS/web/reports/oils_rpt_builder.js @@ -10,12 +10,60 @@ function oilsInitReportBuilder() { function() { hideMe(DOM.oils_rpt_tree_loading); unHideMe(DOM.oils_rpt_table); + oilsRptBuilderDrawClone(new CGI().param('ct')); } ); DOM.oils_rpt_builder_save_template.onclick = oilsReportBuilderSave; } +function oilsRptBuilderDrawClone(templateId) { + if(!templateId) return; + unHideMe(DOM.oils_rpt_builder_cloning); + + oilsRptFetchTemplate(templateId, + function(template) { oilsRptBuilderDrawClone2(template);} + ); +} + + +function oilsRptBuilderDrawClone2(template) { + //oilsRpt. + appendClear( DOM.oils_rpt_build_cloning_name, template.name() ); + DOM.oils_rpt_builder_new_name.value = template.name(); + DOM.oils_rpt_builder_new_desc.value = template.description(); + + _debug(formatJSON(template.data())); + + /* manually shove data into the display selectors */ + var def = JSON2js(template.data()); + + var table = def.from.table; + var node; + for( var i in oilsIDL ) { + node = oilsIDL[i]; + if( node.table == table ) { + setSelector(DOM.oils_rpt_builder_type_selector, node.name); + DOM.oils_rpt_builder_type_selector.onchange(); + break; + } + } + + iterate(def.select, + function(item) { + oilsAddRptDisplayItem(item.path, item.alias, item.column.transform)}); + + iterate(def.where, + function(item) { + oilsAddRptFilterItem(item.path, item.column.transform, oilsRptObjectKeys(item.condition)[0])}); + + iterate(def.having, + function(item) { + oilsAddRptHavingItem(item.path, item.column.transform, oilsRptObjectKeys(item.condition)[0])}); + + oilsRpt.setTemplate(template); +} + function oilsReportBuilderReset() { var n = (oilsRpt) ? oilsRpt.name : ""; oilsRpt = new oilsReport(); @@ -46,13 +94,18 @@ function oilsReportBuilderSave() { //return; /* XXX */ var req = new Request(OILS_RPT_CREATE_TEMPLATE, SESSION, tmpl); + req.request.alertEvent = false; req.callback( function(r) { var res = r.getResultObject(); - if( res && res != '0' ) { - oilsRptAlertSuccess(); - _l('oils_rpt.xhtml'); - } + if(checkILSEvent(res)) { + alertILSEvent(res); + } else { + if( res && res != '0' ) { + oilsRptAlertSuccess(); + _l('oils_rpt.xhtml'); + } + } } ); @@ -573,6 +626,10 @@ function oilsRptHideEditorDivs() { hideMe(DOM.oils_rpt_filter_div); hideMe(DOM.oils_rpt_agg_filter_div); hideMe(DOM.oils_rpt_order_by_div); + + removeCSSClass(DOM.oils_rpt_tform_tab.parentNode, 'oils_rpt_tab_picker_selected'); + removeCSSClass(DOM.oils_rpt_filter_tab.parentNode, 'oils_rpt_tab_picker_selected'); + removeCSSClass(DOM.oils_rpt_agg_filter_tab.parentNode, 'oils_rpt_tab_picker_selected'); } @@ -592,7 +649,10 @@ function oilsRptDrawDataWindow(path) { var div = DOM.oils_rpt_column_editor; /* set a preliminary top position so the page won't bounce around */ - div.setAttribute('style','top:'+oilsMouseX+'px'); + + + /* XXX */ + //div.setAttribute('style','top:'+oilsMouseX+'px'); /* unhide the div so we can determine the dimensions */ unHideMe(div); @@ -605,7 +665,10 @@ function oilsRptDrawDataWindow(path) { oilsRptDrawHavingWindow(path, col, cls, field); oilsRptDrawOrderByWindow(path, col, cls, field); - buildFloatingDiv(div, 600); + //buildFloatingDiv(div, 600); + + //window.scrollTo(0,0); + window.scrollTo(0, 60); /* now let them see it */ div.style.visibility='visible'; @@ -615,12 +678,27 @@ function oilsRptDrawDataWindow(path) { function oilsRptSetDataWindowActions(div) { /* give the tab links behavior */ + + DOM.oils_rpt_tform_tab.onclick = - function(){oilsRptHideEditorDivs();unHideMe(DOM.oils_rpt_tform_div)}; + function(){ + oilsRptHideEditorDivs(); + unHideMe(DOM.oils_rpt_tform_div) + addCSSClass(DOM.oils_rpt_tform_tab.parentNode, 'oils_rpt_tab_picker_selected'); + }; + DOM.oils_rpt_filter_tab.onclick = - function(){oilsRptHideEditorDivs();unHideMe(DOM.oils_rpt_filter_div)}; + function(){ + oilsRptHideEditorDivs(); + unHideMe(DOM.oils_rpt_filter_div) + addCSSClass(DOM.oils_rpt_filter_tab.parentNode, 'oils_rpt_tab_picker_selected'); + }; DOM.oils_rpt_agg_filter_tab.onclick = - function(){oilsRptHideEditorDivs();unHideMe(DOM.oils_rpt_agg_filter_div)}; + function(){ + oilsRptHideEditorDivs(); + unHideMe(DOM.oils_rpt_agg_filter_div) + addCSSClass(DOM.oils_rpt_agg_filter_tab.parentNode, 'oils_rpt_tab_picker_selected'); + }; /* DOM.oils_rpt_order_by_tab.onclick = diff --git a/Open-ILS/web/reports/oils_rpt_builder.xhtml b/Open-ILS/web/reports/oils_rpt_builder.xhtml index 73f6060570..d145589692 100644 --- a/Open-ILS/web/reports/oils_rpt_builder.xhtml +++ b/Open-ILS/web/reports/oils_rpt_builder.xhtml @@ -21,6 +21,9 @@
Reports Home + + (Cloning template "") +
@@ -80,7 +83,7 @@ - + + - + + + - + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/web/reports/oils_rpt_folder_window.js b/Open-ILS/web/reports/oils_rpt_folder_window.js index 5e902ddce4..3efef313b4 100644 --- a/Open-ILS/web/reports/oils_rpt_folder_window.js +++ b/Open-ILS/web/reports/oils_rpt_folder_window.js @@ -19,14 +19,21 @@ oilsRptFolderWindow.prototype.draw = function() { var obj = this; setSelector(DOM.oils_rpt_output_limit_selector, oilsRptOutputLimit); + setSelector(DOM.oils_rpt_output_limit_selector_2, oilsRptOutputLimit2); DOM.oils_rpt_output_limit_selector.onchange = function() { oilsRptOutputLimit = getSelectorVal(DOM.oils_rpt_output_limit_selector); obj.draw(); } + DOM.oils_rpt_output_limit_selector_2.onchange = function() { + oilsRptOutputLimit2 = getSelectorVal(DOM.oils_rpt_output_limit_selector_2); + obj.draw(); + } + + var mine = ( this.folderNode.folder.owner().id() == USER.id() ); - if( this.folderNode.folder.owner().id() == USER.id() && this.type == 'template') + if( mine && this.type == 'template') unHideMe(DOM.oils_rpt_folder_window_contents_new_template.parentNode); else hideMe(DOM.oils_rpt_folder_window_contents_new_template.parentNode); @@ -59,6 +66,12 @@ oilsRptFolderWindow.prototype.draw = function() { var x = true; for( var i = 0; i < sel.options.length; i++ ) { var opt = sel.options[i]; + + if( !mine && opt.getAttribute('value').match(/move/) ) { + hideMe(opt); + continue; + } + if( opt.getAttribute('type') == this.type ) { if(x && !opt.disabled) { opt.selected = true; @@ -79,7 +92,8 @@ oilsRptFolderWindow.prototype.drawEditActions = function() { DOM.oils_rpt_folder_window_contents_new_template.onclick = function() { var s = location.search+''; - s = s.replace(/\&folder=\d+/,''); + s = s.replace(/\&folder=\d+/g,''); + s = s.replace(/\&ct=\d+/g,''); goTo( 'oils_rpt_builder.xhtml'+s+'&folder='+obj.folderNode.folder.id()); } @@ -186,7 +200,11 @@ oilsRptFolderWindow.prototype.hideFolderActions = function() { oilsRptFolderWindow.prototype.doFolderAction = function() { - var objs = this.fmTable.getSelected(); + var objs = (this.fmTable) ? this.fmTable.getSelected() : []; + + if( this.type == 'output' && this.fmTable2 ) + objs = objs.concat( this.fmTable2.getSelected() ); + if( objs.length == 0 ) return alert('Please select an item from the list'); var action = getSelectorVal(DOM.oils_rpt_folder_contents_action_selector); @@ -225,6 +243,93 @@ oilsRptFolderWindow.prototype.doFolderAction = function() { this.deleteOutputs(objs,0, successCallback); break; + case 'move_template': + this.changeBatchFolder(objs, 'template', successCallback); + break; + + case 'move_report': + this.changeBatchFolder(objs, 'report', successCallback); + break; + + case 'move_output': + this.changeBatchFolder(objs, 'output', successCallback); + break; + + case 'clone_template': + this.cloneTemplate(objs[0]); + } +} + +oilsRptFolderWindow.prototype.changeBatchFolder = function(objs, type, callback) { + hideMe(DOM.oils_rpt_folder_window_contents_table); + unHideMe(DOM.oils_rpt_move_folder_div) + var obj = this; + this.drawFolderOptions(type, + function(folderid) { + obj.changeFolderList(objs, type, folderid, 0, callback); + hideMe(DOM.oils_rpt_move_folder_div) + unHideMe(DOM.oils_rpt_folder_window_contents_table); + } + ); +} + +oilsRptFolderWindow.prototype.cloneTemplate = function(template) { + hideMe(DOM.oils_rpt_folder_window_contents_table); + unHideMe(DOM.oils_rpt_move_folder_div) + var obj = this; + this.drawFolderOptions('template', + function(folderid) { + var s = location.search+''; + s = s.replace(/\&folder=\d+/g,''); + s = s.replace(/\&ct=\d+/g,''); + goTo('oils_rpt_builder.xhtml'+s+'&folder='+folderid+'&ct='+template.id()); + } + ); +} + + +oilsRptFolderWindow.prototype.changeFolderList = function(list, type, folderid, idx, callback, errid) { + if( idx >= list.length ) return callback(errid); + var item = list[idx]; + var obj = this; + var rcback = function(){obj.changeFolderList(list,type,folderid,++idx,callback,errid)}; + + item.folder(folderid); + + switch(type) { + case 'template': + oilsRptUpdateTemplate(item,rcback); + break; + case 'report': + oilsRptUpdateReport(item,rcback); + break; + case 'output': + oilsRptUpdateSchedule(item,rcback); + break; + } +} + +oilsRptFolderWindow.prototype.drawFolderOptions = function(type, callback) { + //var oilsRptChangeFolderTree; + var selectedFolder; + oilsRptBuildFolder( + type, + DOM.oils_rpt_move_folder_picker, + 'tree9807897', + 'Change Folders', + function(node) { + appendClear(DOM.oils_rpt_move_folder_selected, node.folder.name()); + selectedFolder = node.folder.id(); + } + ); + + DOM.oils_rpt_change_folder_submit.onclick = function() { + if(selectedFolder) callback(selectedFolder); + } + + DOM.oils_rpt_change_folder_cancel.onclick = function() { + hideMe(DOM.oils_rpt_move_folder_div) + unHideMe(DOM.oils_rpt_folder_window_contents_table); } } @@ -247,10 +352,16 @@ oilsRptFolderWindow.prototype.deleteOutputs = function(list, idx, callback, erri } oilsRptFolderWindow.prototype.showOutput = function(sched) { - oilsRptFetchReport(sched.report(), + oilsRptFetchReport(sched.report().id(), function(r) { var url = oilsRptBuildOutputLink(r.template(), r.id(), sched.id()); - goTo(url); + _debug("launching report output view at URL: " + url); + if(isXUL()) + xulG.new_tab(url,{"tab_name":"Report Output: " + r.name()},{}) + else { + //goTo(url); + var win = window.open(url,r.name(), 'resizable,width=800,height=600,scrollbars=1'); + } } ); } @@ -338,13 +449,21 @@ oilsRptFolderWindow.prototype.drawFolderDetails = function() { oilsRptFolderWindow.prototype.fetchFolderData = function(callback) { + + hideMe(DOM.oils_rpt_content_count_row_2); + hideMe(DOM.oils_rpt_content_row_2); + removeChildren(this.selector); var req = new Request(OILS_RPT_FETCH_FOLDER_DATA, SESSION, this.type, this.folderNode.folder.id(), oilsRptOutputLimit); + hideMe(DOM.oils_rpt_pending_output); + if(this.type == 'output') { + unHideMe(DOM.oils_rpt_pending_output); + /* first fetch the non-complete schedules */ req = new Request(OILS_RPT_FETCH_OUTPUT, - SESSION, this.folderNode.folder.id(), oilsRptOutputLimit); + SESSION, this.folderNode.folder.id(), oilsRptOutputLimit, 0); } var obj = this; @@ -352,9 +471,22 @@ oilsRptFolderWindow.prototype.fetchFolderData = function(callback) { req.callback( function(r) { var res = r.getResultObject(); + + if( res.length == 0 ) { + hideMe(DOM.oils_rpt_content_count_row); + hideMe(DOM.oils_rpt_content_row); + unHideMe(DOM.oils_rpt_content_row_empty); + } else { + unHideMe(DOM.oils_rpt_content_count_row); + unHideMe(DOM.oils_rpt_content_row); + hideMe(DOM.oils_rpt_content_row_empty); + } + if( obj.type == 'output' ) { - obj.fleshSchedules(res, 0); + obj.fleshSchedules(res, 0, obj.selector); } else { + + obj.fmTable = drawFMObjectTable( { dest : obj.selector, @@ -369,10 +501,41 @@ oilsRptFolderWindow.prototype.fetchFolderData = function(callback) { } ); req.send(); + + if( this.type != 'output' ) return; + + /* + unHideMe(DOM.oils_rpt_content_count_row_2); + unHideMe(DOM.oils_rpt_content_row_2); + */ + + /* now fetch the completed schedules */ + req = new Request(OILS_RPT_FETCH_OUTPUT, + SESSION, this.folderNode.folder.id(), oilsRptOutputLimit2, 1); + + _debug("TRYING: fleshing finished scheds with div: " + DOM.oils_rpt_folder_contents_selector_2); + removeChildren(DOM.oils_rpt_folder_contents_selector_2); + req.callback( + function(r) { + var res = r.getResultObject(); + + if( res.length == 0 ) { + hideMe(DOM.oils_rpt_content_count_row_2); + hideMe(DOM.oils_rpt_content_row_2); + } else { + unHideMe(DOM.oils_rpt_content_count_row_2); + unHideMe(DOM.oils_rpt_content_row_2); + } + + _debug("fleshing finished scheds with div: " + DOM.oils_rpt_folder_contents_selector_2); + obj.fleshSchedules(res, 0, DOM.oils_rpt_folder_contents_selector_2, true); + } + ); + req.send(); } -oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, table) { +oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, selector, isSecond) { if( idx >= list.length ) return; @@ -388,9 +551,10 @@ oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, table) { function(template) { sched.report().template(template); if( idx == 0 ) { - obj.fmTable = drawFMObjectTable( + _debug("drawing schedule with output: "+selector); + var t = drawFMObjectTable( { - dest : obj.selector, + dest : selector, obj : [sched], selectCol : true, selectColName : 'Select', @@ -398,10 +562,17 @@ oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, table) { selectNoneName : 'None' } ); + + if( isSecond ) obj.fmTable2 = t; + else obj.fmTable = t; + } else { - obj.fmTable.add(sched); + //obj.fmTable.add(sched); + if( isSecond ) obj.fmTable2.add(sched); + else obj.fmTable.add(sched); } - obj.fleshSchedules(list, ++idx); + + obj.fleshSchedules(list, ++idx, selector, isSecond); } ); } diff --git a/Open-ILS/web/reports/oils_rpt_folder_window.xhtml b/Open-ILS/web/reports/oils_rpt_folder_window.xhtml index 629f12f55c..e04ce8c481 100644 --- a/Open-ILS/web/reports/oils_rpt_folder_window.xhtml +++ b/Open-ILS/web/reports/oils_rpt_folder_window.xhtml @@ -13,20 +13,24 @@ - + - + + + + + + + + + + + + + + + + + +
Display ItemsDisplay Items Filters Aggregate Filters
Choose a folder to store this report definition: @@ -37,18 +49,25 @@
+
+
Output Options
  • Excel Output
  • CSV Output
  • @@ -66,67 +85,123 @@
- - - - - - - - - - - - - - - -
- Run ASAP - - or at : - - - at - -
Send completion notification to this Email address:
Choose a folder to store this report's output: -
- Selected Folder: - -
- -
+
Recurring Report: + +
Recurrence Interval: + +
+ Run ASAP + + or at: + + + at + +
Send completion notification to this Email address:
Choose a folder to store this report's output: +
+ Selected Folder: + +
+ +
Limit output to @@ -37,6 +41,7 @@ + Pending Items
@@ -45,15 +50,55 @@
No items to display
+
+ Limit output to + + Completed Items +
+
+
+
+
+
Selected Folder:
+
+
+
+ + +
+ Are you sure you wish to delete the selected item(s)? @@ -73,5 +118,10 @@ You may not delete another user's items + + You may not move another user's items + + +
diff --git a/Open-ILS/web/reports/oils_rpt_param_editor.js b/Open-ILS/web/reports/oils_rpt_param_editor.js index b29457b84d..7f522d324c 100644 --- a/Open-ILS/web/reports/oils_rpt_param_editor.js +++ b/Open-ILS/web/reports/oils_rpt_param_editor.js @@ -6,13 +6,18 @@ function oilsRptParamEditor(report, tbody) { oilsRptParamEditor.prototype.recur = function() { - var cb = $n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur'); + //var cb = $n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur'); + var cb = DOM.oils_rpt_recur; return (cb.checked) ? 't' : 'f'; } oilsRptParamEditor.prototype.recurInterval = function() { + /* var count = getSelectorVal($n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur_count')); var intvl = getSelectorVal($n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur_interval_type')); + */ + var count = getSelectorVal(DOM.oils_rpt_recur_count); + var intvl = getSelectorVal(DOM.oils_rpt_recur_interval_type); return count+''+intvl; } @@ -37,36 +42,9 @@ oilsRptParamEditor.prototype.draw = function() { $n(row, 'action').appendChild(text(OILS_RPT_FILTERS[par.op].label)); par.widget = this.buildWidget(par, $n(row, 'widget')); par.widget.draw(); - //this.buildRelWidget(par, row); } } - -/* display the time-relative options if necessary */ -/* -oilsRptParamEditor.prototype.buildRelWidget = function(par, row) { - - var field = oilsRptFindField( - oilsIDL[oilsRptPathClass(par.path)], oilsRptPathCol(par.path)); - - _debug('checking rel widget for datatype '+field.datatype); - - if(field.datatype != 'timestamp') return; - if(par.op != '=') return; - - var dom = $n(row,'reldate_div'); - unHideMe(dom); - par.relWidget = new oilsRptRelDatePicker({node:$n(dom,'reldate'),relative:true}); - par.relWidget.draw(); - var cb = $n(row,'choose_rel'); - cb.onclick = function() { - par.relWidgetChecked = false; - if( cb.checked ) par.relWidgetChecked = true; - } -} -*/ - - oilsRptParamEditor.prototype.buildWidget = function(param, node) { var transform = param.column.transform; var cls = oilsRptPathClass(param.path); @@ -80,6 +58,7 @@ oilsRptParamEditor.prototype.buildWidget = function(param, node) { var widgetArgs = {node:node}; widgetArgs.calFormat = OILS_RPT_TRANSFORMS[transform].cal_format; widgetArgs.inputSize = OILS_RPT_TRANSFORMS[transform].input_size; + widgetArgs.regex = OILS_RPT_TRANSFORMS[transform].regex; switch(transform) { case 'date': @@ -196,31 +175,8 @@ oilsRptParamEditor.prototype.buildWidget = function(param, node) { default: return new atomicWidget(widgetArgs); } - - /* - switch(param.op) { - case 'in': - case 'not in': - if( cls == 'aou' ) { - return new oilsRptOrgMultiSelect({node:node}); - } else { - return new oilsRptInputMultiWidget({node:node}); - } - case 'between': - return new oilsRptMultiInputWidget({node:node}); - - default: - switch(dtype) { - case 'timestamp': - return new oilsRptWidget({node:node}); - default: - return new oilsRptWidget({node:node}); - } - } - */ } -//oilsRptParamEditor.prototype.get = function(param, node) { diff --git a/Open-ILS/web/reports/oils_rpt_param_editor.xhtml b/Open-ILS/web/reports/oils_rpt_param_editor.xhtml index a6f54d0d55..0cc3831e29 100644 --- a/Open-ILS/web/reports/oils_rpt_param_editor.xhtml +++ b/Open-ILS/web/reports/oils_rpt_param_editor.xhtml @@ -3,6 +3,7 @@
+ @@ -50,6 +48,7 @@ + --> diff --git a/Open-ILS/web/reports/oils_rpt_report_editor.js b/Open-ILS/web/reports/oils_rpt_report_editor.js index b038ceb358..62bef6bca0 100644 --- a/Open-ILS/web/reports/oils_rpt_report_editor.js +++ b/Open-ILS/web/reports/oils_rpt_report_editor.js @@ -84,8 +84,18 @@ oilsRptReportEditor.prototype.save = function() { var par = this.paramEditor.params[p]; _debug("adding report param "+par.key+" to report data"); var val = par.widget.getValue(); + if(!val || val.length == 0 ) return alertId('oils_rpt_empty_param'); + + if( typeof val == 'object') { + for( var i = i; i < val.length; i++ ) { + _debug("looking at widget value" + val[i]); + if( val[i] == '' || val[i] == null ) + return alertId('oils_rpt_empty_param'); + } + } + data[par.key] = val; } @@ -141,10 +151,14 @@ oilsRptReportEditor.prototype.save = function() { req.callback( function(r) { var res = r.getResultObject(); - if( res && res != '0' ) { - oilsRptAlertSuccess(); - oilsRptCurrentFolderManager.draw(); - obj.folderWindow.draw(); + if(checkILSEvent(res)) { + alertILSEvent(res); + } else { + if( res && res != '0' ) { + oilsRptAlertSuccess(); + oilsRptCurrentFolderManager.draw(); + obj.folderWindow.draw(); + } } } ); diff --git a/Open-ILS/web/reports/oils_rpt_utils.js b/Open-ILS/web/reports/oils_rpt_utils.js index 0e75523405..6cf1aefd9e 100644 --- a/Open-ILS/web/reports/oils_rpt_utils.js +++ b/Open-ILS/web/reports/oils_rpt_utils.js @@ -127,14 +127,17 @@ function print_tabs(t) { function oilsRptDebug() { + if(!oilsRptDebugEnabled) return; + _debug("\n-------------------------------------\n"); _debug(oilsRpt.toString()); _debug("\n-------------------------------------\n"); - if(!oilsRptDebugEnabled) return; + + /* if(!oilsRptDebugWindow) oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1'); - oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString(); + */ } @@ -198,6 +201,8 @@ function buildFloatingDiv(div, width) { top = oilsMouseY - div.clientHeight - 10; } div.setAttribute('style', 'left:'+left+'px; top:'+top+'px; width:'+width+'px'); + //div.setAttribute('style', 'top:'+top+'px;'); + //alert(DOM.oils_rpt_filter_selector.style.top); } @@ -281,6 +286,31 @@ function oilsRptCreateFolder(folder, type, callback) { } } +function oilsRptUpdateTemplate(template, callback) { + oilsRptDoGenericUpdate(OILS_RPT_UPDATE_TEMPLATE, template, callback); +} + +function oilsRptUpdateReport(report, callback) { + oilsRptDoGenericUpdate(OILS_RPT_UPDATE_REPORT, report, callback); +} + +function oilsRptUpdateSchedule(schedule, callback) { + oilsRptDoGenericUpdate(OILS_RPT_UPDATE_SCHEDULE, schedule, callback); +} + +function oilsRptDoGenericUpdate( method, arg, callback ) { + _debug("generic update running: "+method); + var req = new Request(method, SESSION, arg); + req.callback( + function(r) { + if( r.getResultObject() > 0 ) + callback(true); + else callback(false); + } + ); + req.send(); +} + /* function oilsRptFetchReport(id, callback) { var req = new Request(OILS_RPT_FETCH_REPORT, SESSION, id); diff --git a/Open-ILS/web/reports/oils_rpt_vars.js b/Open-ILS/web/reports/oils_rpt_vars.js index 2348829501..3059786092 100644 --- a/Open-ILS/web/reports/oils_rpt_vars.js +++ b/Open-ILS/web/reports/oils_rpt_vars.js @@ -23,7 +23,9 @@ var oilsRptSharedReportFolderTree; var oilsRptSharedOutputFolderTree; var oilsRptOutputLimit = 10; +var oilsRptOutputLimit2 = 10; +var OILS_RPT_INVALID_DATA = 'oils_rpt_invalid_input'; /* URL to retrieve the IDL from */ var OILS_IDL_URL = "/reports/fm_IDL.xml"; @@ -84,6 +86,7 @@ var OILS_RPT_CREATE_TEMPLATE = 'open-ils.reporter:open-ils.reporter.template.cr var OILS_RPT_CREATE_SCHEDULE = 'open-ils.reporter:open-ils.reporter.schedule.create'; var OILS_RPT_UPDATE_REPORT = 'open-ils.reporter:open-ils.reporter.report.update'; var OILS_RPT_UPDATE_TEMPLATE = 'open-ils.reporter:open-ils.reporter.template.update'; +var OILS_RPT_UPDATE_SCHEDULE = 'open-ils.reporter:open-ils.reporter.schedule.update'; var OILS_RPT_FETCH_OUTPUT = 'open-ils.reporter:open-ils.reporter.schedule.retrieve_by_folder'; var OILS_RPT_FETCH_REPORT = 'open-ils.reporter:open-ils.reporter.report.retrieve'; var OILS_RPT_FETCH_TEMPLATE = 'open-ils.reporter:open-ils.reporter.template.retrieve'; diff --git a/Open-ILS/web/reports/oils_rpt_widget.js b/Open-ILS/web/reports/oils_rpt_widget.js index 8bc9428a0d..74eb53ba2d 100644 --- a/Open-ILS/web/reports/oils_rpt_widget.js +++ b/Open-ILS/web/reports/oils_rpt_widget.js @@ -1,250 +1,5 @@ -/* -oilsRptSetSubClass('oilsRptWidget', 'oilsRptObject'); -oilsRptWidget.OILS_RPT_TRANSFORM_WIDGET = 0; -oilsRptWidget.OILS_RPT_OPERATION_WIDGET = 1; - -function oilsRptWidget(args) { - this.initWidget(args); - this.dest = elem('input',{type:'text'}); -} - -oilsRptWidget.prototype.initWidget = function(args) { - if(!args) return; - this.init(); - this.node = args.node; - this.type = args.type; - this.action = args.action; - this.column = args.column; -} - -oilsRptWidget.prototype.getValue = function() { - return this.dest.value ; -} - -oilsRptWidget.prototype.draw = function() { - appendClear(this.node, this.dest); -} - -oilsRptSetSubClass('oilsRptMultiInputWidget', 'oilsRptWidget'); -function oilsRptMultiInputWidget(args) { - this.initInputWidget(args); -} - -oilsRptMultiInputWidget.prototype.initInputWidget = function(args) { - if(!args) return; - this.initWidget(args); - this.count = (args.count) ? args.count : 2; - this.dest = []; - for( var i = 0; i < this.count; i++ ) - this.dest.push(elem('input',{type:'text',size:10})); -} - -oilsRptMultiInputWidget.prototype.getValue = function() { - var vals = []; - for( var i = 0; i < this.dest.length; i++ ) - vals.push(this.dest[i].value); - return vals; -} - -oilsRptMultiInputWidget.prototype.draw = function() { - removeChildren(this.node); - for( var i = 0; i < this.dest.length; i++ ) { - if( this.label ) - this.node.appendChild(this.label[i]); - this.node.appendChild(this.dest[i]); - } -} - -oilsRptMultiInputWidget.prototype.setLabels = function(labels) { - this.labels = labels; -} - - - - -oilsRptSetSubClass('oilsRptMultiWidget', 'oilsRptWidget'); -function oilsRptMultiWidget(args) { - this.initMultiWidget(args); -} - -oilsRptMultiWidget.prototype.initMultiWidget = function(args) { - if(!args) return; - this.initWidget(args); - this.dest = elem('select', - {multiple:'multiple','class':'oils_rpt_small_info_selector'}); - - var obj = this; - - this.addButton = elem('input',{type:'submit',value:"Add"}) - this.addButton.onclick = this.getSourceCollector(); - this.delButton = elem('input',{type:'submit',value:"Del"}) - this.delButton.onclick = function(){obj.removeSelected()}; -} - -oilsRptMultiWidget.prototype.getValue = function() { - var vals = []; - for( var i = 0; i < this.dest.options.length; i++ ) - vals.push(this.dest.options[i].value); - return vals; -} - -oilsRptMultiWidget.prototype.removeSelected = function() { - oilsDelSelectedItems(this.dest); -} - -oilsRptMultiWidget.prototype.addItem = function(name, val) { - for( var i = 0; i < this.dest.options.length; i++ ) { - if( this.dest.options[i].value == val ) - return; - } - insertSelectorVal(this.dest, -1, name, val); -} - -oilsRptMultiWidget.prototype.setSource = function(src) { - this.source = src; -} - -oilsRptMultiWidget.prototype.drawMultiWidget = function() { - appendClear(this.node, this.source); - this.node.appendChild(elem('br')) - this.node.appendChild(this.addButton); - this.node.appendChild(this.delButton); - this.node.appendChild(elem('br')) - this.node.appendChild(this.dest); -} - -oilsRptSetSubClass('oilsRptInputMultiWidget', 'oilsRptMultiWidget'); -function oilsRptInputMultiWidget(args) { - this.initInputMultiWidget(args); -} -oilsRptInputMultiWidget.prototype.initInputMultiWidget = function(args) { - if(!args) return; - this.initMultiWidget(args); - this.setSource(elem('input',{type:'text'})); -} - -oilsRptInputMultiWidget.prototype.draw = function() { - this.drawMultiWidget(); -} - -oilsRptInputMultiWidget.prototype.getSourceCollector = function() { - var obj = this; - return function() { - obj.addItem(obj.source.value, obj.source.value); - } -} - - - -oilsRptSetSubClass('oilsRptSelectorMultiWidget', 'oilsRptMultiWidget'); -function oilsRptSelectorMultiWidget(args) { - this.initSelectorMultiWidget(args); -} -oilsRptSelectorMultiWidget.prototype.initSelectorMultiWidget = function(args) { - if(!args) return; - this.initMultiWidget(args); - this.setSource( - elem('select',{multiple:'multiple', 'class':'oils_rpt_small_info_selector'})); -} - -oilsRptSelectorMultiWidget.prototype.getSourceCollector = function() { - var obj = this; - return function() { - for( var i = 0; i < obj.source.options.length; i++ ) { - if( obj.source.options[i].selected ) - obj.addItem(obj.source.options[i].innerHTML, - obj.source.options[i].value); - } - } -} -*/ - -/* ----------------------------------------------------------- */ - -/* -oilsRptSetSubClass('oilsRptRemoteWidget', 'oilsRptSelectorMultiWidget'); -function oilsRptRemoteWidget(args) { - this.initRemoteWidget(args); -} -oilsRptRemoteWidget.prototype.initRemoteWidget = function(args) { - if(!args) return; - this.initSelectorMultiWidget(args); - this.selector = args.selector; -} - -oilsRptRemoteWidget.prototype.draw = function() { - this.fetch(); - //this.draw(); -} - -oilsRptRemoteWidget.prototype.setFetch = function(func) { - this.fetch = func; -} -*/ - - - - -/* --------------------------------------------------------------------- */ -/* -oilsRptSetSubClass('oilsRptOrgMultiSelect','oilsRptSelectorMultiWidget'); -function oilsRptOrgMultiSelect(args) { - this.initSelectorMultiWidget(args); -} -oilsRptOrgMultiSelect.prototype.draw = function(org) { - if(!org) org = globalOrgTree; - var opt = insertSelectorVal( this.source, -1, - org.shortname(), org.id(), null, findOrgDepth(org) ); - if( org.id() == oilsRptCurrentOrg ) - opt.selected = true; - if( org.children() ) { - for( var c = 0; c < org.children().length; c++ ) - this.draw(org.children()[c]); - } - this.drawMultiWidget(); -} -*/ - - - -/* --------------------------------------------------------------------- */ -/* -function oilsRptRelDatePicker(args) { - this.node = args.node; - this.relative = args.relative; - this.div = DOM.oils_rpt_relative_date_picker.cloneNode(true); -} - -oilsRptRelDatePicker.prototype.draw = function() { - this.node.appendChild(this.div); - unHideMe(this.div); -} - -oilsRptRelDatePicker.prototype.getValue = function() { - var str = - getSelectorVal($n(this.div, 'count')) + - getSelectorVal($n(this.div,'type')); - if( this.relative ) str = '-'+str; - return str; -} -*/ -/* --------------------------------------------------------------------- */ - - - - - - - - -/* --------------------------------------------------------------------- */ -/* --------------------------------------------------------------------- */ - - - - /* --------------------------------------------------------------------- - Represents a set of value, an inputWidget collects data and a + Represents a set of values, an inputWidget collects data and a multi-select displays the data and allows the user to remove items --------------------------------------------------------------------- */ function oilsRptSetWidget(args) { @@ -319,7 +74,7 @@ oilsRptSetWidget.prototype.strToObj = function(str) { /* --------------------------------------------------------------------- represents a widget that has start and end values. start and end - are gather from start/end widgets + are gathered from start/end widgets --------------------------------------------------------------------- */ function oilsRptBetweenWidget(args) { this.node = args.node; @@ -356,6 +111,7 @@ oilsRptBetweenWidget.prototype.getValue = function() { function oilsRptTextWidget(args) { this.node = args.node; this.dest = elem('input',{type:'text',size:12}); + oilsRptMonitorWidget(this.dest); } oilsRptTextWidget.prototype.draw = function() { this.node.appendChild(this.dest); @@ -401,6 +157,34 @@ oilsRptBoolWidget.prototype.getDisplayValue = function() { } +/* If you monitor a text widget with this function, it + will style the input differently to indicate the + field needs data. If a regex is provided, it will + style the field differently until the data matches + the regex. The style comes from OILS_RPT_INVALID_DATA. */ +function oilsRptMonitorWidget(input, regex) { + addCSSClass(input, OILS_RPT_INVALID_DATA); + var func = function() { + var val = input.value; + if(!val) { + addCSSClass(input, OILS_RPT_INVALID_DATA); + } else { + if( regex ) { + if( val && val.match(regex) ) + removeCSSClass(input, OILS_RPT_INVALID_DATA); + else + addCSSClass(input, OILS_RPT_INVALID_DATA); + } else { + removeCSSClass(input, OILS_RPT_INVALID_DATA); + } + } + } + + input.onkeyup = func; + input.onchange = func; +} + + /* --------------------------------------------------------------------- @@ -411,6 +195,8 @@ function oilsRptCalWidget(args) { this.calFormat = args.calFormat; this.input = elem('input',{type:'text',size:12}); + oilsRptMonitorWidget(this.input, args.regex); + if( args.inputSize ) { this.input.setAttribute('size',args.inputSize); this.input.setAttribute('maxlength',args.inputSize); @@ -470,7 +256,7 @@ oilsRptOrgSelector.prototype.draw = function(org) { oilsRptOrgSelector.prototype.getValue = function() { var vals = []; - iterate(this.selector, + iterate(this.selector, /* XXX this.selector.options?? */ function(o){ if( o.selected ) vals.push(o.getAttribute('value')) @@ -501,8 +287,12 @@ function oilsRptAgeWidget(args) { } oilsRptAgeWidget.prototype.draw = function() { + + //insertSelectorVal(this.count, -1, ' -- Select One -- ', ''); for( var i = 1; i < 25; i++ ) insertSelectorVal(this.count, -1, i, i); + + //insertSelectorVal(this.type, -1, ' -- Select One -- ', ''); insertSelectorVal(this.type, -1, 'Day(s)', 'days'); insertSelectorVal(this.type, -1, 'Month(s)', 'months'); insertSelectorVal(this.type, -1, 'Year(s)', 'years'); @@ -537,29 +327,17 @@ function oilsRptNumberWidget(args) { this.node = args.node; this.size = args.size || 32; this.start = args.start; - /* - var len = new String(this.size).length; - _debug('length = ' + len); - this.input = elem('input',{type:'text',size: len}); - */ this.selector = elem('select'); } oilsRptNumberWidget.prototype.draw = function() { + //insertSelectorVal(this.selector, -1, ' -- Select One -- ', ''); for( var i = this.start; i < (this.size + this.start); i++ ) insertSelectorVal(this.selector, -1, i, i); this.node.appendChild(this.selector); - //this.node.appendChild(this.input); var obj = this; - /* - this.selector.onchange = function() { - obj.input.value = getSelectorVal(obj.selector); - } - this.input.value = getSelectorVal(this.selector); - */ } oilsRptNumberWidget.prototype.getValue = function() { - //return this.input.value; return getSelectorVal(this.selector); }