$tmpl =~ s/{COMPLETE_TIME}/$r->{complete_time}/smog;
$tmpl =~ s/{OUTPUT_URL}/$url/smog;
+ my $tdata = OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{template}->{data} );
+ if ($$tdata{version} >= 4) {
+ $tmpl =~ s/{EXTERNAL_URL}/$$tdata{doc_url}/smog;
+ }
+
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host => $email_server]);
$sender->send($tmpl);
$tmpl =~ s/{ERROR_TEXT}/$r->{error_text}/smog;
$tmpl =~ s/{SQL}/$sql/smog;
+ my $tdata = OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{template}->{data} );
+ if ($$tdata{version} >= 4) {
+ $tmpl =~ s/{EXTERNAL_URL}/$$tdata{doc_url}/smog;
+ }
+
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host => $email_server]);
$sender->send($tmpl);
my $r = shift;
my $index = new FileHandle (">$file") or die "Cannot write to '$file'";
+
+ my $tdata = OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{template}->{data} );
# index header
print $index <<" HEADER";
<body>
<center>
<h2><u>$$r{report}{name}</u></h2>
- $$r{report}{description}<br/><br/><br/>
+ $$r{report}{description}<br/>
HEADER
+ if ($$tdata{version} >= 4 and $$tdata{doc_url}) {
+ print $index "<a target='_blank' href='$$tdata{doc_url}'>External template documentation</a><br/>";
+ }
+
+ print $index "<br/><br/>";
+
my @links;
my $br4 = '<br/>' x 4;
print $debug "<html><head><meta charset='utf-8'><title>DEBUG: $$r{report}{name}</title></head><body>";
{ no warnings;
+ if ($$tdata{version} >= 4 and $$tdata{doc_url}) {
+ print $debug "<b><a target='_blank' href='$$tdata{doc_url}'>External template documentation</a></b><br/><a href='report-data.html'>Back to output index</a><hr/>";
+ }
+
print $debug '<h1>Generated SQL</h1><pre>' . $r->{resultset}->toSQL() . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
print $debug '<h1>Template</h1><pre>' . Dumper( $r->{report}->{template} ) . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
- print $debug '<h1>Template Data</h1><pre>' . Dumper( OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{template}->{data} ) ) . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
+ print $debug '<h1>Template Data</h1><pre>' . Dumper( $tdata ) . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
print $debug '<h1>Report Parameter</h1><pre>' . Dumper( $r->{report} ) . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
- print $debug '<h1>Report Parameter Data</h1><pre>' . Dumper( OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{data} ) ) . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
+ print $debug '<h1>Report Parameter Data</h1><pre>' . Dumper( $tdata ) . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
print $debug '<h1>Report Run Time</h1><pre>' . $r->{resultset}->relative_time . "</pre><a href='report-data.html'>Back to output index</a><hr/>";
print $debug '<h1>OpenILS::Reporter::SQLBuilder::ResultSet Object</h1><pre>' . Dumper( $r->{resultset} ) . "</pre><a href='report-data.html'>Back to output index</a>";
}
{ERROR_TEXT}
+External documentation for the template is available at the following URL:
+ {EXTERNAL_URL}
+
The SQL command attempted was:
{SQL}
You can view the report at the following URL:
{OUTPUT_URL}
+
+External documentation for the template is available at the following URL:
+{EXTERNAL_URL}
"TEMPLATE_CONF_EQUALS": "Equals",
"TEMPLATE_CONF_CONFIRM_RESET": "You have already added the [${0}] field\nfrom the [${1}] source. Click OK if you\nwould like to reset this field.",
"TEMPLATE_CONF_PROMPT_CHANGE": "Change the column header to: ${0}",
+ "TEMPLATE_FIELD_DOC_PROMPT_CHANGE": "Change the field hint to:",
"TEMPLATE_CONF_BOOLEAN_VALUE": "Boolean Value",
"TEMPLATE_CONF_SELECT_CANCEL": "Select the value, or cancel:",
"TEMPLATE_CONF_TRUE": "True",
this.bold = this.display[o.classname].bold;
this.money = this.display[o.classname].money;
this.sortdata = this.display[o.classname].sortdata;
+ this.calculate = this.display[o.classname].calculate;
}
if(!this.keys && FM_TABLE_DISPLAY[o.classname])
if(!this.sortdata && FM_TABLE_DISPLAY[o.classname])
this.sortdata = FM_TABLE_DISPLAY[o.classname].sortdata;
+ if(!this.calculate && FM_TABLE_DISPLAY[o.classname])
+ this.calculate = FM_TABLE_DISPLAY[o.classname].calculate;
+
if(!this.keys) {
this.keys = fmclasses[o.classname];
sortme = true;
for( var i = 0; i < this.keys.length; i++ ) {
var td = elem('td');
- var data = obj[this.keys[i]]();
- data = this.munge(data);
- this.fleshData(td, data, this.keys[i]);
+ var data = '';
+ if (this.caclulate[i]) { // fake data! pass the object
+ td.appendChild(this.calculate[i](obj);
+ } else {
+ data = obj[this.keys[i]]();
+ data = this.munge(data);
+ this.fleshData(td, data, this.keys[i]);
+ }
+
row.appendChild(td);
}
this.tbody.appendChild(row);
fields : [
'name',
'description',
+ 'docs',
'create_time',
'owner',
],
+ calculate : {
+ docs : function (t) {
+ var d = JSON2js(t.data());
+ if (d.version >= 4 && d.doc_url) {
+ return elem(
+ 'a',
+ { href : d.doc_url, target : '_blank'},
+ 'External Documentation'
+ );
+ }
+ return text('');
+ }
+ },
sortdata : [ 'name', 1 ]
},
'rs' : {
<!ENTITY reports.oils_rpt_editor.template_name "Template Name:">
<!ENTITY reports.oils_rpt_editor.template_creator "Template Creator:">
+<!ENTITY reports.oils_rpt_editor.doc_url "Template Documentation URL:">
<!ENTITY reports.oils_rpt_editor.template_description "Template Description:">
<!ENTITY reports.oils_rpt_editor.report_name "Report Name:">
<!ENTITY reports.oils_rpt_editor.report_description "Report Description:">
<!ENTITY reports.xul.template_builder.template_config_caption.label "Template Configuration">
<!ENTITY reports.xul.template_builder.name.label "Name:">
<!ENTITY reports.xul.template_builder.description.label "Description:">
+<!ENTITY reports.xul.template_builder.doc_url.label "Documentation URL:">
<!ENTITY reports.xul.template_builder.save.label "Save">
<!ENTITY reports.xul.template_builder.displayed_fields.label "Displayed Fields">
<!ENTITY reports.xul.template_builder.base_filters.label "Base Filters">
<!ENTITY reports.xul.template_builder.change_transform.label "Change Transform">
<!ENTITY reports.xul.template_builder.change_operator.label "Change Operator">
<!ENTITY reports.xul.template_builder.change_value.label "Change value">
+<!ENTITY reports.xul.template_builder.change_field_doc.label "Change Field Hint">
<!ENTITY reports.xul.template_builder.remove_value.label "Remove value">
<!ENTITY reports.xul.template_builder.remove_selected_fields.label "Remove Selected Fields">
<!ENTITY reports.xul.template_builder.table_name.label "Table Name">
<th>&reports.oils_rpt_editor.template_description;</th>
<td><span id='oils_rpt_report_editor_template_description'></span></td>
</tr>
+ <tr id='oils_rpt_report_editor_template_doc_url_row'>
+ <th colspan=2><a target="_blank" href="" id='oils_rpt_report_editor_template_doc_url'>&reports.oils_rpt_editor.doc_url;</a></th>
+ </tr>
<tr>
<th>&reports.oils_rpt_editor.report_name;</th>
var par = params[p];
var row = oilsRptParamEditor.row.cloneNode(true);
this.tbody.appendChild(row);
- $n(row, 'column').appendChild(text(oilsRptMakeLabel(par.path)));
+ $n(row, 'column').appendChild(text(oilsRptMakeLabel(par.path, par.field_doc)));
$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'));
var par = tparams[p];
var row = oilsRptParamEditor.row.cloneNode(true);
this.tbody.appendChild(row);
- $n(row, 'column').appendChild(text(oilsRptMakeLabel(par.path)));
+ $n(row, 'column').appendChild(text(oilsRptMakeLabel(par.path, par.field_doc)));
$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'));
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 (rptObject.def.version >= 4) {
+ DOM.oils_rpt_report_editor_template_doc_url.setAttribute( 'href', rptObject.def.doc_url );
+ } else {
+ hideMe(DOM.oils_rpt_report_editor_template_doc_url_row);
+ }
appendClear(DOM.oils_rpt_report_editor_cols,'');
iterate(rptObject.def.select,
}
/* creates a label "path" based on the column path */
-function oilsRptMakeLabel(path) {
+function oilsRptMakeLabel(path, hint) {
var parts = path.split(/-/);
var str = '';
for( var i = 0; i < parts.length; i++ ) {
str += " -> "+f.label;
}
}
+
+ if (hint) {
+ str += '<br/><b><i>' + hint + '</i></b>'
+ }
+
return str;
}
var colname = item.getAttribute('idlfield');
var jointype = item.getAttribute('join');
var field_label = item.firstChild.firstChild.getAttribute('label');
+ var field_doc = item.firstChild.lastChild.getAttribute('label');
var table_name = getSourceDefinition(field_class);
params : transform && transform.getAttribute('params'),
transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
alias : field_label,
+ field_doc : field_doc,
join : jointype,
datatype : datatype,
op : (datatype == 'array') ? '= any' : '=',
params : transform && transform.getAttribute('params'),
transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
alias : field_label,
+ field_doc : field_doc,
join : jointype,
datatype : datatype,
op : '=',
return true;
}
+function changeFieldDoc () {
+ var active_tab = filterByAttribute(
+ $('used-source-fields-tabbox').getElementsByTagName('tab'),
+ 'selected',
+ 'true'
+ )[0];
+
+ var tabname = active_tab.getAttribute('id');
+
+ 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');
+
+ var field = item.firstChild.lastChild;
+ var colname = item.firstChild.firstChild.nextSibling.getAttribute('label');
+
+ var old_label = field.getAttribute("label");
+ var new_label = prompt( rpt_strings.TEMPLATE_FIELD_DOC_PROMPT_CHANGE, old_label );
+
+ if (new_label) {
+ rpt_rel_cache[relation_alias].fields[tabname][colname].field_doc = new_label;
+ renderSources(true);
+ tree.view.selection.select( item_pos );
+ tree.focus();
+ tree.click();
+ }
+
+ return true;
+}
+
function alterColumnTransform (trans) {
var transform = OILS_RPT_TRANSFORMS[trans];
fieldtree.lastChild.firstChild.appendChild(
createTreeCell({ label : op_value.label })
);
- }
+ } else {
+ fieldtree.lastChild.firstChild.appendChild(
+ createTreeCell({})
+ );
+ }
+
+ fieldtree.lastChild.firstChild.appendChild(
+ createTreeCell({ label : field_doc })
+ );
}
}
}
createTreeCell({ label : colname }),
createTreeCell({ label : datatype }),
createTreeCell({ label : transform_label }),
- createTreeCell({ label : transform })
+ createTreeCell({ label : transform }),
+ createTreeCell({ label : field_doc })
)
)
);
-
- fieldtree.lastChild.firstChild.appendChild(
- createTreeCell({ op : op, label : op_label })
- );
-
- if (op_value.value != undefined) {
- fieldtree.lastChild.firstChild.appendChild(
- createTreeCell({ label : op_value.label })
- );
- }
}
}
}
param_count = 0;
var template = {
- version : 3,
+ version : 4,
+ doc_url : $('template-doc-url').value,
core_class : $('sources-treetop').getElementsByTagName('treeitem')[0].getAttribute('idlclass'),
select : [],
from : {},
var element = {
alias : tab[field].alias,
+ field_doc : tab[field].field_doc,
column :
{ colname : field,
transform : tab[field].transform,
<vbox>
<label control="template-name" value="&reports.xul.template_builder.name.label;" style="height:2em"/>
<label control="template-description" value="&reports.xul.template_builder.description.label;"/>
+ <label control="template-doc-url" value="&reports.xul.template_builder.doc_url.label;"/>
</vbox>
<vbox flex="1">
<textbox id="template-name" flex="1"/>
<textbox id="template-description" multiline="true" flex="1" style="max-height:3em"/>
+ <textbox id="template-doc-url" flex="1"/>
</vbox>
<vbox pack="end">
<button onclick="save_template();" label="&reports.xul.template_builder.save.label;"/>
<treecol label="&reports.xul.template_builder.data_type.label;" flex="1"/>
<treecol label="&reports.xul.template_builder.field_transform.label;" flex="1"/>
<treecol label="&reports.xul.template_builder.field_transform_type.label;" hidden="true" flex="1"/>
+ <treecol label="&reports.xul.template_builder.field_doc.label;" hidden="true" flex="1"/>
</treecols>
<treechildren id="dis-col-treetop" alternatingbackground="true" />
</tree>
<button label="&reports.xul.template_builder.move_down.label;" oncommand="changeDisplayOrder('d')"/>
<spacer flex="1"/>
<button label="&reports.xul.template_builder.remove_selected_field.label;" oncommand="removeReportAtom()"/>
+ <spacer flex="1"/>
+ <button label="&reports.xul.template_builder.change_field_doc.label;" oncommand="changeFieldDoc()"/>
</hbox>
</vbox>
</tabpanel>
<treecol label="&reports.xul.template_builder.field_transform_type.label;" hidden="true" flex="1"/>
<treecol label="&reports.xul.template_builder.operator.label;" flex="1"/>
<treecol label="&reports.xul.template_builder.value.label;" flex="1"/>
+ <treecol label="&reports.xul.template_builder.field_doc.label;" hidden="true" flex="1"/>
</treecols>
<treechildren id="filter-col-treetop" alternatingbackground="true" />
</tree>
<button label="&reports.xul.template_builder.remove_value.label;" oncommand="removeTemplateFilterValue()"/>
<spacer flex="1"/>
<button label="&reports.xul.template_builder.remove_selected_fields.label;" oncommand="removeReportAtom()"/>
+ <spacer flex="1"/>
+ <button label="&reports.xul.template_builder.change_field_doc.label;" oncommand="changeFieldDoc()"/>
</hbox>
</vbox>
</tabpanel>
<treecol label="&reports.xul.template_builder.field_transform_type.label;" hidden="true" flex="1"/>
<treecol label="&reports.xul.template_builder.operator.label;" flex="1"/>
<treecol label="&reports.xul.template_builder.value.label;" flex="1"/>
+ <treecol label="&reports.xul.template_builder.field_doc.label;" hidden="true" flex="1"/>
</treecols>
<treechildren id="aggfilter-col-treetop" alternatingbackground="true" />
</tree>
<button label="&reports.xul.template_builder.remove_value.label;" oncommand="removeTemplateFilterValue()"/>
<spacer flex="1"/>
<button label="&reports.xul.template_builder.remove_selected_fields.label;" oncommand="removeReportAtom()"/>
+ <spacer flex="1"/>
+ <button label="&reports.xul.template_builder.change_field_doc.label;" oncommand="changeFieldDoc()"/>
</hbox>
</vbox>
</tabpanel>