"REPORT_EDITOR_OUTPUT_FOLDERS": "Output Folders",
"REPORT_EDITOR_PROVIDE_FOLDER_ALERT": "Please provide a report folder",
"REPORT_EDITOR_ENTER_NAME_ALERT": "Please enter a report name",
+ "REPORT_EDITOR_ENTER_NEW_NAME_ALERT": "Please change the report name",
"REPORT_EDITOR_INVALID_DATE_ALERT": "invalid start date - YYYY-MM-DD",
"REPORT_EDITOR_PROVIDE_OUTPUT_ALERT": "Please provide an output folder",
'recur',
'recurrence',
'owner',
+ 'edit',
],
- sortdata : [ 'name', 1 ]
+ sortdata : [ 'name', 1 ],
+ calculate : {
+ 'edit' : function(r) {
+ // DOM pulled from oils_rpt_folder_window.xhtml
+ var node = dojo.byId(
+ 'oils_rpt_view_edit_report_links').cloneNode(true);
+ dojo.removeClass(node, 'hide_me');
+ var view = dojo.query('[name=view]', node)[0];
+ var edit = dojo.query('[name=edit]', node)[0];
+ view.onclick = function() {oilsRptViewReport(r); return false};
+ if (PERMS.RUN_REPORTS == -1) {
+ node.removeChild(edit);
+ } else {
+ edit.onclick = function() {oilsRptEditReport(r); return false};
+ }
+ return node;
+ }
+ }
},
'rt' : {
name : 'name',
var key = keys[i];
while( key.length < 12 ) key += ' ';
var val = obj[keys[i]]();
- if( typeof val == 'object' ) {
+ if( typeof val == 'object' && val !== null ) {
_debug(key+' :=\n');
- _debugFMObject(val);
+ debugFMObject(val);
} else {
_debug(key+' = ' +val);
}
<!ENTITY reports.oils_rpt_editor.noon "Noon">
<!ENTITY reports.oils_rpt_editor.storage_folder_for_output "Choose a folder to store this report's output:">
<!ENTITY reports.oils_rpt_editor.save_report "Save Report">
+<!ENTITY reports.oils_rpt_editor.apply_changes "Apply Changes">
+<!ENTITY reports.oils_rpt_editor.save_report_new "Save As New">
+<!ENTITY reports.oils_rpt_editor.confirm_sched "Changes will be applied to pending reports that have not yet run. Do you want to continue with modifying those pending reports?">
+<!ENTITY reports.oils_rpt_editor.cancel "Cancel">
+<!ENTITY reports.oils_rpt_editor.exit_report "Return">
<!ENTITY reports.oils_rpt_editor.empty_parameter "One or more of the user-defined parameters has been left empty. Please fill in all fields.">
<!ENTITY reports.oils_rpt_editor.same_name "There is already a report in this folder with the given name.">
<!ENTITY reports.oils_rpt_folder_window.delete_template "Delete selected template(s)">
<!ENTITY reports.oils_rpt_folder_window.clone_report "Clone report">
<!ENTITY reports.oils_rpt_folder_window.schedule_report "Schedule report">
+<!ENTITY reports.oils_rpt_folder_window.view_report "View">
+<!ENTITY reports.oils_rpt_folder_window.edit_report "Edit">
<!ENTITY reports.oils_rpt_folder_window.delete_reports "Delete selected report(s)">
<!ENTITY reports.oils_rpt_folder_window.view_report_output "View report output">
<!ENTITY reports.oils_rpt_folder_window.delete_output "Delete selected output(s)">
padding-left: 5px;
}
+#oils_rpt_editor_sched_confirm {
+ margin-top: 10px;
+}
+#oils_rpt_editor_sched_confirm > div {
+ padding: 10px;
+}
+#oils_rpt_editor_sched_confirm:first-child {
+ font-size: 110%;
+}
<tr>
<td colspan='2'>
- <input id='oils_rpt_report_editor_save' type='submit' value='&reports.oils_rpt_editor.save_report;'/>
+ <input id='oils_rpt_report_editor_save' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.save_report;'/>
+
+ <input id='oils_rpt_report_editor_save_new' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.save_report_new;'/>
+
+ <!-- use input/submit instead of <button> for consistent styling -->
+ <input id='oils_rpt_report_editor_exit' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.exit_report;'/>
+
+ <input id='oils_rpt_report_editor_cancel' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.cancel;'/>
</td>
</tr>
</tbody>
</table>
+ <div id='oils_rpt_editor_sched_confirm' style='width:100%' class='hide_me'>
+ <div>&reports.oils_rpt_editor.confirm_sched;</div>
+ <div>
+ <!-- use input/submit instead of <button> for consistent styling -->
+ <input id='oils_rpt_report_editor_sched_apply' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.apply_changes;'/>
+
+ <input id='oils_rpt_report_editor_sched_asnew' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.save_report_new;'/>
+
+ <input id='oils_rpt_report_editor_sched_cancel' style='margin-right:10px;'
+ type='submit' value='&reports.oils_rpt_editor.cancel;'/>
+ </div>
+ </div>
+
<span id='oils_rpt_empty_param' class='hide_me'>
&reports.oils_rpt_editor.empty_parameter;
</span>
this.selector = DOM.oils_rpt_folder_contents_selector;
this.folderNode = node;
this.type = type;
+ this.folderId = folderId;
+ oilsRptFolderWindow.folderIdMap[folderId] = this;
}
+// maps folder IDs to their containing oilsRptFolderWindow objects
+oilsRptFolderWindow.folderIdMap = {};
oilsRptFolderWindow.prototype.draw = function() {
);
}
+function oilsRptViewEditReport(report, readonly) {
+
+
+ var folderWindow = oilsRptFolderWindow.folderIdMap[report.folder()];
+
+ var req = new Request(
+ 'open-ils.reporter:open-ils.reporter.report.fleshed.retrieve',
+ SESSION, report.id()
+ );
+
+ req.callback(function(r) {
+
+ hideMe(DOM.oils_rpt_folder_table_right_td);
+ unHideMe(DOM.oils_rpt_folder_table_alt_td);
+ unHideMe(DOM.oils_rpt_editor_div);
+
+ report = r.getResultObject();
+
+ new oilsRptReportEditor(
+ new oilsReport(report.template(), report), folderWindow, readonly);
+ });
+
+ req.send();
+}
+
+function oilsRptViewReport(report) {
+ oilsRptViewEditReport(report, true);
+}
+
+function oilsRptEditReport(report) {
+ oilsRptViewEditReport(report);
+}
+
&reports.oils_rpt_folder_window.delete_all_attached_outputs;
</span>
+ <span class='hide_me' id='oils_rpt_view_edit_report_links'>
+ <a href='' name='view'>&reports.oils_rpt_folder_window.view_report;</a> /
+ <a href='' name='edit'>&reports.oils_rpt_folder_window.edit_report;</a>
+ </span>
</div>
/* this only works if the initial folder tree has been drawn
if defined, "action" must be a function pointer that takes the
- folder node as the param */
+ folder node as the param
+
+ eachFolder - optional callback called with each folder
+ node after its added to the folder list.
+*/
var __someid;
-function oilsRptBuildFolder(type, node, treeVar, rootName, action, shared) {
+function oilsRptBuildFolder(type, node, treeVar, rootName, action, shared, eachFolder) {
removeChildren(node);
var tree = new SlimTree(node, treeVar);
this.treeId = oilsNextId();
}
tree.addNode(tid, pid, f.name(), __setFolderCB(tree, tid, action, cache[c]));
+
+ if (eachFolder) eachFolder(cache[c]);
}
eval(treeVar +' = tree;');
}
oilsRptSetSubClass('oilsRptParamEditor','oilsRptObject');
-function oilsRptParamEditor(report, tbody) {
+function oilsRptParamEditor(report, tbody, readonly) {
this.tbody = tbody;
this.report = report;
+ this.readonly = readonly;
}
}
$n(row, 'transform').appendChild(text(OILS_RPT_TRANSFORMS[par.column.transform].label));
$n(row, 'action').appendChild(text(OILS_RPT_FILTERS[par.op].label));
- par.widget = this.buildWidget(par, $n(row, 'widget'));
+ par.widget = this.buildWidget(par, $n(row, 'widget'), true);
par.widget.draw();
}
}
-oilsRptParamEditor.prototype.buildWidget = function(param, node) {
+oilsRptParamEditor.prototype.buildWidget = function(param, node, fromTemplate) {
var transform = param.column.transform;
var cls = oilsRptPathClass(param.path);
var field = oilsRptFindField(oilsIDL[cls], oilsRptPathCol(param.path));
widgetArgs.inputSize = OILS_RPT_TRANSFORMS[transform].input_size;
widgetArgs.regex = OILS_RPT_TRANSFORMS[transform].regex;
widgetArgs.value = param.value;
+ widgetArgs.readonly = this.readonly;
switch(transform) {
case 'date':
break;
}
- if(widgetArgs.value != undefined)
+ // oilsRptTemplateWidget's are pre-set read-only values
+ if(fromTemplate && widgetArgs.value != undefined)
return new oilsRptTemplateWidget(widgetArgs);
oilsRptSetSubClass('oilsRptReportEditor', 'oilsRptObject');
var oilsRptReportEditorFolderTree;
-function oilsRptReportEditor(rptObject, folderWindow) {
+function oilsRptReportEditor(rptObject, folderWindow, readonly) {
var tmpl = rptObject.templateObject;
var rpt = rptObject.reportObject;
this.folderWindow = folderWindow;
+ this.readonly = readonly;
this.template = tmpl;
this.report = rpt;
+ if (rpt && rpt.runs() && rpt.runs().length)
+ this.last_run = rpt.runs()[rpt.runs().length - 1];
+
appendClear(DOM.oils_rpt_report_editor_template_name, tmpl.name());
appendClear(DOM.oils_rpt_report_editor_template_creator, tmpl.owner().usrname());
appendClear(DOM.oils_rpt_report_editor_template_description, tmpl.description());
if( rpt ) {
+ // populate the report edit form w/ report data
+
+ this.orig_rpt_name = rpt.name();
+
DOM.oils_rpt_report_editor_name.value = rpt.name();
- DOM.oils_rpt_report_editor_description.value = rpt.description();
+ DOM.oils_rpt_report_editor_name.onchange(); // validation
+ DOM.oils_rpt_report_editor_desc.value = rpt.description();
+
+ if (rpt.recur() == 't') {
+ DOM.oils_rpt_recur.checked = true;
+ DOM.oils_rpt_recur.onclick(); // enable recurrance selector
+ }
+
+ if (rpt.recurrence()) {
+ var parts = rpt.recurrence().split(/ /);
+ setSelector(DOM.oils_rpt_recur_count, parts[0]);
+ setSelector(DOM.oils_rpt_recur_interval_type, parts[1]);
+ }
+
+ if (run = this.last_run) {
+ DOM.oils_rpt_report_editor_name.disabled = true;
+ DOM.oils_rpt_report_editor_desc.disabled = true;
+ DOM.oils_rpt_format_csv.checked = run.csv_format() == 't';
+ DOM.oils_rpt_format_excel.checked = run.excel_format() == 't';
+ DOM.oils_rpt_format_html.checked = run.html_format() == 't';
+ DOM.oils_rpt_format_chart_bar.checked = run.chart_bar() == 't';
+ DOM.oils_rpt_format_chart_line.checked = run.chart_line() == 't';
+ }
}
+ if (this.readonly) {
+ DOM.oils_rpt_report_editor_name.disabled = true;
+ DOM.oils_rpt_report_editor_desc.disabled = true;
+ DOM.oils_rpt_recur.disabled = true;
+ DOM.oils_rpt_recur_count.disabled = true;
+ DOM.oils_rpt_recur_interval_type.disabled = true;
+ DOM.oils_rpt_report_editor_run_now.disabled = true;
+ DOM.oils_rpt_format_csv.disabled = true;
+ DOM.oils_rpt_format_excel.disabled = true;
+ DOM.oils_rpt_format_html.disabled = true;
+ DOM.oils_rpt_format_chart_bar.disabled = true;
+ DOM.oils_rpt_format_chart_line.disabled = true;
+ DOM.oils_rpt_param_editor_sched_email.disabled = true;
+
+ hideMe(DOM.oils_rpt_report_editor_save);
+ hideMe(DOM.oils_rpt_report_editor_save_new);
+ hideMe(DOM.oils_rpt_report_editor_cancel);
+ unHideMe(DOM.oils_rpt_report_editor_exit);
+
+ } else {
+ // these DOM elements are shared across instances
+ // of the UI. Re-enable everything.
+ DOM.oils_rpt_report_editor_name.disabled = false;
+ DOM.oils_rpt_report_editor_desc.disabled = false;
+ DOM.oils_rpt_recur.disabled = false;
+ DOM.oils_rpt_recur_count.disabled = false;
+ DOM.oils_rpt_recur_interval_type.disabled = false;
+ DOM.oils_rpt_report_editor_run_now.disabled = false;
+ DOM.oils_rpt_format_csv.disabled = false;
+ DOM.oils_rpt_format_excel.disabled = false;
+ DOM.oils_rpt_format_html.disabled = false;
+ DOM.oils_rpt_format_chart_bar.disabled = false;
+ DOM.oils_rpt_format_chart_line.disabled = false;
+ DOM.oils_rpt_param_editor_sched_email.disabled = false;
+ DOM.oils_rpt_report_editor_save.disabled = false;
+
+ unHideMe(DOM.oils_rpt_report_editor_save);
+ unHideMe(DOM.oils_rpt_report_editor_save_new);
+ unHideMe(DOM.oils_rpt_report_editor_cancel);
+ hideMe(DOM.oils_rpt_report_editor_exit);
+ }
+
this.paramEditor = new oilsRptParamEditor(
- rptObject, DOM.oils_rpt_param_editor_tbody);
+ rptObject, DOM.oils_rpt_param_editor_tbody, this.readonly);
this.paramEditor.draw();
removeChildren(DOM.oils_rpt_report_editor_selected_folder);
rpt_strings.REPORT_EDITOR_REPORT_FOLDERS,
function(node) {
appendClear(DOM.oils_rpt_report_editor_selected_folder, node.folder.name());
- obj.selectedFolder = node; });
-
+ obj.selectedFolder = node;
+ },
+ null,
+ function(node) {
+ // apply the previously selected report folder
+ if (rpt && rpt.folder() == node.folder.id()) {
+ appendClear(DOM.oils_rpt_report_editor_selected_folder, node.folder.name());
+ obj.selectedFolder = node;
+ }
+ }
+ );
oilsRptBuildFolder(
'output',
rpt_strings.REPORT_EDITOR_OUTPUT_FOLDERS,
function(node) {
appendClear(DOM.oils_rpt_output_selected_folder, node.folder.name());
- obj.selectedOutputFolder = node; });
+ obj.selectedOutputFolder = node;
+ },
+ null,
+ function(node) {
+ // apply the previously selected output folder
+ if (obj.last_run && obj.last_run.folder() == node.folder.id()) {
+ appendClear(DOM.oils_rpt_output_selected_folder, node.folder.name());
+ obj.selectedOutputFolder = node;
+ }
+ }
+ );
var obj = this;
DOM.oils_rpt_report_editor_save.onclick = function(){obj.save();}
- DOM.oils_rpt_param_editor_sched_email.value = USER.email();
+ DOM.oils_rpt_report_editor_save_new.onclick = function(){obj.save({save_new : true});}
+ DOM.oils_rpt_report_editor_exit.onclick = function(){obj.exit();}
+ DOM.oils_rpt_report_editor_cancel.onclick = function(){obj.exit();}
+
+ DOM.oils_rpt_param_editor_sched_email.value =
+ this.last_run ? this.last_run.email() : USER.email();
+
DOM.oils_rpt_param_editor_sched_start_date.value = mkYearMonDay();
_debug("fleshing template:\n" + tmpl.name() + '\n' + formatJSON(tmpl.data()));
}
-oilsRptReportEditor.prototype.save = function() {
- var report = new rr();
+// options.save_new : save as a new report, even if we
+// were editing an exitingn report.
+//
+// options.modify_schedule : update the pending schedule
+// object instead of creating a new one.
+oilsRptReportEditor.prototype.save = function(options) {
+ if (!options) options = {};
if(!this.selectedFolder)
return alert(rpt_strings.REPORT_EDITOR_PROVIDE_FOLDER_ALERT);
if(!DOM.oils_rpt_report_editor_name.value)
return alert(rpt_strings.REPORT_EDITOR_ENTER_NAME_ALERT);
- report.owner( USER.id() );
- report.template( this.template.id() );
+ if(!this.selectedOutputFolder)
+ return alert(rpt_strings.REPORT_EDITOR_PROVIDE_OUTPUT_ALERT);
+
+ var report = this.report;
+
+ if (report && options.save_new) {
+ // user is saving an existing report as a new report.
+ // The new report must have a different name.
+ if (DOM.oils_rpt_report_editor_name.value == this.orig_rpt_name)
+ return alert(rpt_strings.REPORT_EDITOR_ENTER_NEW_NAME_ALERT);
+
+ report = null;
+ }
+
+ if (!report) {
+ report = new rr();
+ report.isnew(true);
+ report.owner( USER.id() );
+ report.template( this.template.id() );
+ }
+
report.folder( this.selectedFolder.folder.id() );
report.name( DOM.oils_rpt_report_editor_name.value );
report.description( DOM.oils_rpt_report_editor_desc.value );
report.recur(this.paramEditor.recur());
report.recurrence(this.paramEditor.recurInterval());
-
/* collect the param data */
var data = {};
for( var p in this.paramEditor.params ) {
_debug("built run_time "+time);
}
- if(!this.selectedOutputFolder)
- return alert(rpt_strings.REPORT_EDITOR_PROVIDE_OUTPUT_ALERT);
+ // if the last run has yet to actually start, then we update it
+ // instead of creating a new one.
+ var schedule = options.save_new ? null : this.last_run;
+
+ if (schedule && !schedule.start_time()) {
+ if (!options.modify_schedule) {
+ // warn the user that this action will modify an existing
+ // schedule object if they continue
+ return this.showPendingScheduleDialog();
+ }
+ } else {
+ // no schedules exist or the most recent one has already
+ // started. Create a new one.
+ schedule = new rs();
+ schedule.isnew(true);
+ }
- var schedule = new rs();
schedule.folder(this.selectedOutputFolder.folder.id());
schedule.email(DOM.oils_rpt_param_editor_sched_email.value);
schedule.run_time(time);
schedule.chart_bar((DOM.oils_rpt_format_chart_bar.checked) ? 't' : 'f');
schedule.chart_line((DOM.oils_rpt_format_chart_line.checked) ? 't' : 'f');
-
debugFMObject(report);
debugFMObject(schedule);
- //return;
+ if (report.isnew()) {
+ this.createReport(report, schedule);
+ } else {
+ this.updateReport(report, schedule);
+ }
+}
+
+// Modify an existing report.
+// Modify or create the schedule depending on isnew()
+oilsRptReportEditor.prototype.updateReport = function(report, schedule) {
+ var this_ = this;
+ function success() {
+ oilsRptAlertSuccess();
+ this_.exit();
+ }
+
+ oilsRptUpdateReport(report, function(ok) {
+ if (!ok) return oilsRptAlertFailure();
+
+ if (schedule.isnew()) {
+
+ var req = new Request(OILS_RPT_CREATE_SCHEDULE, SESSION, schedule);
+ req.callback(function(res) {
+ if(checkILSEvent(res))
+ return alertILSEvent(res);
+ success();
+ });
+ req.send()
+
+ } else {
+
+ oilsRptUpdateSchedule(schedule, function(ok2) {
+ if (ok2) return success();
+ _debug("schedule update failed " + js2JSON(schedule));
+ oilsRptAlertFailure();
+ });
+ }
+ });
+}
+
+oilsRptReportEditor.prototype.createReport = function(report, schedule) {
var obj = this;
var folderReq = new Request(OILS_RPT_REPORT_EXISTS, SESSION, report);
folderReq.callback(
} else {
if( res && res != '0' ) {
oilsRptAlertSuccess();
- oilsRptCurrentFolderManager.draw();
- obj.folderWindow.draw();
+ obj.exit();
}
}
}
folderReq.send();
}
+oilsRptReportEditor.prototype.showPendingScheduleDialog = function() {
+ hideMe(DOM.oils_rpt_editor_table);
+ unHideMe(DOM.oils_rpt_editor_sched_confirm);
+
+ function close() {
+ unHideMe(DOM.oils_rpt_editor_table);
+ hideMe(DOM.oils_rpt_editor_sched_confirm);
+ }
+
+ var this_ = this;
+ DOM.oils_rpt_report_editor_sched_apply.onclick = function() {
+ close();
+ this_.save({modify_schedule : true});
+ }
+
+ DOM.oils_rpt_report_editor_sched_asnew.onclick = function() {
+
+ if (DOM.oils_rpt_report_editor_name.value == this_.orig_rpt_name) {
+ // user is saving as new but has not yet modified the name
+ // Prompt for a new name, then udpate the name entry so save()
+ // will see it. Don't let them escape until they comply.
+ var new_name;
+ while (true) {
+
+ new_name = prompt(
+ rpt_strings.REPORT_EDITOR_ENTER_NEW_NAME_ALERT,
+ this_.orig_rpt_name
+ );
+
+ if (new_name && new_name != this_.orig_rpt_name)
+ break;
+ }
+
+ DOM.oils_rpt_report_editor_name.value = new_name;
+ }
+
+ close();
+ this_.save({save_new : true})
+ }
+ DOM.oils_rpt_report_editor_sched_cancel.onclick = close;
+}
+
+oilsRptReportEditor.prototype.exit = function() {
+ oilsRptCurrentFolderManager.draw();
+ this.folderWindow.draw();
+}
r.send();
}
-
function oilsRptAlertSuccess() { alertId('oils_rpt_generic_success'); }
function oilsRptAlertFailure() { alertId('oils_rpt_generic_failure'); }
function oilsRptSetWidget(args) {
this.node = args.node;
this.inputWidget = new args.inputWidget(args);
+ this.readonly = Boolean(args.readonly);
this.dest = elem('select',
{multiple:'multiple','class':'oils_rpt_small_info_selector'});
+ this.dest.disabled = this.readonly;
}
oilsRptSetWidget.prototype.draw = function() {
this.addButton = elem('input',{type:'submit',value:"Add"})
this.delButton = elem('input',{type:'submit',value:"Del"})
+ this.addButton.disabled = this.readonly;
+ this.delButton.disabled = this.readonly;
var obj = this;
this.addButton.onclick = function() {
this.node.appendChild(this.delButton);
this.node.appendChild(elem('br'))
this.node.appendChild(this.dest);
+
+ // propagate the values from the input widget into the our display.
+ if (this.inputWidget.seedValue)
+ this.addButton.onclick();
}
oilsRptSetWidget.prototype.addDisplayItems = function(list) {
--------------------------------------------------------------------- */
function oilsRptTextWidget(args) {
this.node = args.node;
+ this.seedValue = args.value;
this.dest = elem('input',{type:'text',size:12});
+ this.dest.disabled = Boolean(args.readonly);
oilsRptMonitorWidget(this.dest);
}
oilsRptTextWidget.prototype.draw = function() {
this.node.appendChild(this.dest);
+ // TODO: untested
+ if (this.seedValue) {
+ this.dest.value = this.seedValue;
+ this.dest.onchange(); // validation
+ }
}
/* returns the "real" value for the widget */
--------------------------------------------------------------------- */
function oilsRptBoolWidget(args) {
this.node = args.node;
+ this.seedValue = arg.value;
this.selector = elem('select');
insertSelectorVal(this.selector, -1,'True','t');
insertSelectorVal(this.selector, -1,'False','f');
+ this.selector.disabled = Boolean(args.readonly);
}
oilsRptBoolWidget.prototype.draw = function() {
this.node.appendChild(this.selector);
+ if (this.seedValue) // TODO: untested
+ setSelector(this.selector, this.seedValue);
}
/* returns the "real" value for the widget */
this.node = args.node;
this.calFormat = args.calFormat;
this.input = elem('input',{type:'text',size:12});
+ this.seedValue = args.value;
+ this.input.disabled = Boolean(args.readonly);
oilsRptMonitorWidget(this.input, args.regex);
align : "Tl",
singleClick : true
});
+
+ if (this.seedValue) {
+ this.input.value = this.seedValue;
+ this.input.onchange(); // validation
+ }
}
oilsRptCalWidget.prototype.getValue = function() {
--------------------------------------------------------------------- */
function oilsRptOrgSelector(args) {
this.node = args.node;
+ this.seedValue = args.value;
this.selector = elem('select',
{multiple:'multiple','class':'oils_rpt_small_info_selector'});
+ this.selector.disabled = Boolean(args.readonly);
}
oilsRptOrgSelector.prototype.draw = function(org) {
this.draw(org.children()[c]);
}
this.node.appendChild(this.selector);
+
+ if (this.seedValue) {
+ if (dojo.isArray(this.seedValue)) {
+ for (var i = 0; i < this.selector.options.length; i++) {
+ var opt = this.selector.options[i];
+ if (this.seedValue.indexOf(opt.value) > -1)
+ opt.selected = true;
+ }
+ } else {
+ setSelector(this.selector, this.seedValue);
+ }
+ }
}
oilsRptOrgSelector.prototype.getValue = function() {
--------------------------------------------------------------------- */
function oilsRptAgeWidget(args) {
this.node = args.node;
+ this.seedValue = args.value;
this.count = elem('select');
this.type = elem('select');
+ this.count.disabled = Boolean(args.readonly);
+ this.type.disabled = Boolean(args.readonly);
}
oilsRptAgeWidget.prototype.draw = function() {
insertSelectorVal(this.type, -1, rpt_strings.WIDGET_YEARS, 'years');
this.node.appendChild(this.count);
this.node.appendChild(this.type);
+
+ if (this.seedValue) { // TODO: test me
+ var parts = this.seedValue.split(/ /);
+ setSelector(this.count, parts[0]);
+ setSelector(this.type, parts[1]);
+ }
}
oilsRptAgeWidget.prototype.getValue = function() {
--------------------------------------------------------------------- */
function oilsRptSubstrWidget(args) {
this.node = args.node
+ this.seedValue = args.value;
this.data = elem('input',{type:'text',size:12})
this.offset = elem('input',{type:'text',size:5})
this.length = elem('input',{type:'text',size:5})
+ this.offset.disabled = Boolean(args.readonly);
+ this.length.disabled = Boolean(args.readonly);
}
oilsRptSubstrWidget.prototype.draw = function() {
this.node.appendChild(elem('br'));
this.node.appendChild(text('length: '))
this.node.appendChild(this.length);
+
+ if (this.seedValue) {
+ // TODO: unested; substring currently not supported.
+ this.data.value = this.seedValue[0];
+ this.offset.value = this.seedValue[1];
+ this.length.value = this.seedValue[2];
+ }
}
oilsRptSubstrWidget.prototype.getValue = function() {
--------------------------------------------------------------------- */
function oilsRptNumberWidget(args) {
this.node = args.node;
+ this.seedValue = args.value;
this.size = args.size || 32;
this.start = args.start;
this.selector = elem('select');
+ this.selector.disabled = Boolean(args.readonly);
}
oilsRptNumberWidget.prototype.draw = function() {
//insertSelectorVal(this.selector, -1, ' -- Select One -- ', '');
insertSelectorVal(this.selector, -1, i, i);
this.node.appendChild(this.selector);
var obj = this;
+
+ if (this.seedValue) // TODO: test me
+ setSelector(this.selector, this.seedValue);
}
oilsRptNumberWidget.prototype.getValue = function() {
return { label : this.getValue(), value : this.getValue() };
}
-
-/* ---------------------------------------------------------------------
- Relative dates widget
- -------------------------------------------------------------------- */
-
function oilsRptNullWidget(args) {
this.node = args.node;
this.type = args.type;
function oilsRptTruncPicker(args) {
this.node = args.node;
this.type = args.type;
+ this.seedValue = args.value; // TODO: FINISH
this.realSpan = elem('span');
this.relSpan = elem('span');
hideMe(this.relSpan);
this.selector = elem('select');
insertSelectorVal(this.selector,-1,rpt_strings.WIDGET_REAL_DATE,1);
insertSelectorVal(this.selector,-1,rpt_strings.WIDGET_RELATIVE_DATE,2);
+ this.selector.disabled = Boolean(args.readonly);
this.numberPicker =
- new oilsRptNumberWidget({node:this.relSpan,size:90,start:1});
+ new oilsRptNumberWidget(
+ {node:this.relSpan,size:90,start:1,readonly:args.readonly});
this.label = 'Day(s)';
if(this.type == 'month') this.label = rpt_strings.WIDGET_MONTHS;
this.column = args.column;
this.source = elem('select',
{multiple:'multiple','class':'oils_rpt_small_info_selector'});
+ this.source.disabled = Boolean(args.readonly);
}
oilsRptRemoteWidget.prototype.draw = function() {