1 dojo.requireLocalization("openils.reports", "reports");
3 var rpt_strings = dojo.i18n.getLocalization("openils.reports", "reports");
5 function removeReportAtom (args) {
8 var active_tab = filterByAttribute(
9 $('used-source-fields-tabbox').getElementsByTagName('tab'),
13 var tabname = active_tab.getAttribute('id');
15 var tabpanel = $( tabname + 'panel' );
16 var tree = tabpanel.getElementsByTagName('tree')[0];
17 var fields = getSelectedItems(tree);
20 for (var i in fields) {
21 var field = fields[i];
22 var colname = field.firstChild.firstChild.nextSibling.getAttribute('label');
23 var relation_alias = field.getAttribute('relation');
25 delete rpt_rel_cache[relation_alias].fields[tabname][colname];
26 if (tabname == 'dis_tab') {
28 for each (var _o_col in rpt_rel_cache.order_by) {
29 if (_o_col.relation == relation_alias && _o_col.field == colname) continue;
30 _o_tmp.push( _o_col );
32 rpt_rel_cache.order_by = _o_tmp
35 with (rpt_rel_cache[relation_alias].fields) {
36 if ( getKeys(dis_tab).length == 0 && getKeys(filter_tab).length == 0 && getKeys(aggfilter_tab).length == 0 )
37 delete rpt_rel_cache[relation_alias];
46 function getSourceDefinition(aClass) {
47 var class_obj = getIDLClass(aClass);
48 return class_obj.getAttributeNS(persistNS,'tablename') ||
49 '(' + class_obj.getElementsByTagNameNS(persistNS,'source_definition')[0].textContent + ')';
52 function addReportAtoms () {
53 var nope = $( 'source-add' ).getAttribute('disabled');
54 if (nope == 'true') return false;
56 var class_tree = $('class-view');
57 var transform_tree = $('trans-view');
59 var active_tab = filterByAttribute(
60 $('used-source-fields-tabbox').getElementsByTagName('tab'),
65 var tabname = active_tab.getAttribute('id')
67 var items = getSelectedItems(class_tree);
68 var transform = getSelectedItems(transform_tree)[0];
70 var reltype = $('path-label').getAttribute('reltype');
71 var class_label = $('path-label').value;
72 var relation_alias = hex_md5(class_label);
74 for (var i in items) {
77 var class_path = item.getAttribute('fullpath');
78 var field_class = item.getAttribute('idlclass');
79 var datatype = item.getAttribute('datatype');
80 var colname = item.getAttribute('idlfield');
81 var jointype = item.getAttribute('join');
82 var field_label = item.firstChild.firstChild.getAttribute('label');
84 var table_name = getSourceDefinition(field_class);
86 if ( !rpt_rel_cache[relation_alias] ) {
87 rpt_rel_cache[relation_alias] =
88 { label : class_label,
89 alias : relation_alias,
93 idlclass : field_class,
95 fields : { dis_tab : {}, filter_tab : {}, aggfilter_tab : {} }
99 if ( !rpt_rel_cache[relation_alias].fields[tabname][colname] ) {
100 rpt_rel_cache[relation_alias].fields[tabname][colname] =
102 transform : (transform && transform.getAttribute('name')) || rpt_strings.TEMPLATE_CONF_BARE,
103 aggregate : transform && transform.getAttribute('aggregate'),
104 params : transform && transform.getAttribute('params'),
105 transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
109 op : (datatype == 'array') ? '= any' : '=',
110 op_label : rpt_strings.TEMPLATE_CONF_EQUALS,
114 if (!rpt_rel_cache.order_by)
115 rpt_rel_cache.order_by = [];
117 if (tabname == 'dis_tab')
118 rpt_rel_cache.order_by.push( { relation : relation_alias, field : colname } );
120 } else if (confirm(dojo.string.substitute( rpt_strings.TEMPLATE_CONF_CONFIRM_RESET, [field_label, class_label] )) ) {
121 rpt_rel_cache[relation_alias].fields[tabname][colname] =
123 transform : (transform && transform.getAttribute('name')) || rpt_strings.TEMPLATE_CONF_BARE,
124 aggregate : transform && transform.getAttribute('aggregate'),
125 params : transform && transform.getAttribute('params'),
126 transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
131 op_label : rpt_strings.TEMPLATE_CONF_EQUALS,
142 function changeDisplayOrder (dir) {
143 var active_tab = filterByAttribute(
144 $('used-source-fields-tabbox').getElementsByTagName('tab'),
149 var tabname = active_tab.getAttribute('id');
151 var tabpanel = $( tabname + 'panel' );
152 var tree = tabpanel.getElementsByTagName('tree')[0];
153 var item = getSelectedItems(tree)[0];
155 var item_pos = tree.view.selection.currentIndex;
158 if ( item.previousSibling ) {
159 item.parentNode.insertBefore( item, item.previousSibling );
162 } else if (dir == 'd') {
163 if ( item.nextSibling ) {
164 if (item.nextSibling.nextSibling ) item.parentNode.insertBefore( item, item.nextSibling.nextSibling );
165 else item.parentNode.appendChild( item );
170 rpt_rel_cache.order_by = [];
171 var ordered_list = tree.getElementsByTagName('treeitem');
172 for (var i = 0; i < ordered_list.length; i++) {
173 rpt_rel_cache.order_by.push(
174 { relation : ordered_list[i].getAttribute('relation'),
175 field : ordered_list[i].firstChild.firstChild.nextSibling.getAttribute('label')
180 tree.view.selection.select( item_pos );
184 function alterColumnLabel () {
185 var active_tab = filterByAttribute(
186 $('used-source-fields-tabbox').getElementsByTagName('tab'),
191 var tabname = active_tab.getAttribute('id');
193 var tabpanel = $( tabname + 'panel' );
194 var tree = tabpanel.getElementsByTagName('tree')[0];
195 var item_pos = tree.view.selection.currentIndex;
197 var item = getSelectedItems(tree)[0];
198 var relation_alias = item.getAttribute('relation');
200 var field = item.firstChild.firstChild;
201 var colname = field.nextSibling.getAttribute('label');
203 var new_label = prompt( dojo.string.substitute(rpt_strings.TEMPLATE_CONF_PROMPT_CHANGE, [field.getAttribute("label")]) );
206 rpt_rel_cache[relation_alias].fields[tabname][colname].alias = new_label;
208 tree.view.selection.select( item_pos );
216 function alterColumnTransform (trans) {
218 var transform = OILS_RPT_TRANSFORMS[trans];
220 var active_tab = filterByAttribute(
221 $('used-source-fields-tabbox').getElementsByTagName('tab'),
226 var tabname = active_tab.getAttribute('id');
228 var tabpanel = $( tabname + 'panel' );
229 var tree = tabpanel.getElementsByTagName('tree')[0];
230 var item_pos = tree.view.selection.currentIndex;
231 var item = getSelectedItems(tree)[0];
232 var relation_alias = item.getAttribute('relation');
234 var field = item.firstChild.firstChild;
235 var colname = field.nextSibling.getAttribute('label');
237 rpt_rel_cache[relation_alias].fields[tabname][colname].transform = trans;
238 rpt_rel_cache[relation_alias].fields[tabname][colname].aggregate = transform.aggregate;
239 rpt_rel_cache[relation_alias].fields[tabname][colname].params = transform.params;
240 rpt_rel_cache[relation_alias].fields[tabname][colname].transform_label = transform.label;
243 tree.view.selection.select( item_pos );
247 $(tabname + '_trans_menu').hidePopup();
251 function changeOperator (args) {
253 var active_tab = filterByAttribute(
254 $('used-source-fields-tabbox').getElementsByTagName('tab'),
259 var tabname = active_tab.getAttribute('id');
261 var tabpanel = $( tabname + 'panel' );
262 var tree = tabpanel.getElementsByTagName('tree')[0];
263 var item_pos = tree.view.selection.currentIndex;
264 var item = getSelectedItems(tree)[0];
266 var relation_alias = item.getAttribute('relation');
268 var field = item.firstChild.firstChild;
269 var colname = field.nextSibling.getAttribute('label');
271 rpt_rel_cache[relation_alias].fields[tabname][colname].op = args.op;
272 rpt_rel_cache[relation_alias].fields[tabname][colname].op_label = args.label;
275 tree.view.selection.select( item_pos );
279 $(tabname + '_op_menu').hidePopup();
283 function removeTemplateFilterValue () {
285 var active_tab = filterByAttribute(
286 $('used-source-fields-tabbox').getElementsByTagName('tab'),
291 var tabname = active_tab.getAttribute('id');
293 var tabpanel = $( tabname + 'panel' );
294 var tree = tabpanel.getElementsByTagName('tree')[0];
295 var item_pos = tree.view.selection.currentIndex;
296 var items = getSelectedItems(tree);
298 for (var i in items) {
300 var relation_alias = item.getAttribute('relation');
302 var field = item.firstChild.firstChild;
303 var colname = field.nextSibling.getAttribute('label');
305 rpt_rel_cache[relation_alias].fields[tabname][colname].op_value = {};
309 tree.view.selection.select( item_pos );
313 function timestampSetDate (obj, cal, date) {
314 obj.op_value.value = date;
315 obj.op_value.object = cal.date;
316 obj.op_value.label = '"' + date + '"';
324 function changeTemplateFilterValue () {
326 var active_tab = filterByAttribute(
327 $('used-source-fields-tabbox').getElementsByTagName('tab'),
332 var tabname = active_tab.getAttribute('id');
334 var tabpanel = $( tabname + 'panel' );
335 var tree = tabpanel.getElementsByTagName('tree')[0];
336 var items = getSelectedItems(tree);
338 var targetCmd = $( tabname + '_value_action' );
340 targetCmd.menu = null;
341 targetCmd.command = null;
342 targetCmd.oncommand = null;
343 targetCmd.removeEventListener( 'command', __handler_cache, true );
345 for (var i in items) {
347 var relation_alias = item.getAttribute('relation');
349 var field = item.firstChild.firstChild;
350 var colname = field.nextSibling.getAttribute('label');
352 var obj = rpt_rel_cache[relation_alias].fields[tabname][colname]
353 var operation = OILS_RPT_FILTERS[obj.op];
355 switch (obj.datatype) {
357 var cal_popup = $('calendar-widget');
359 while (cal_popup.firstChild) cal_popup.removeChild(cal_popup.lastChild);
360 var calendar = new Calendar(
363 function (cal,date) { return timestampSetDate(obj,cal,date) },
364 function (cal) { cal_popup.hidePopup(); cal.destroy(); return true; }
367 var format = OILS_RPT_TRANSFORMS[obj.transform].cal_format || '%Y-%m-%d';
369 calendar.setDateFormat(format);
370 calendar.create(cal_popup);
372 targetCmd.menu = 'calendar-widget';
378 function __bool_value_event_handler () {
382 // get a reference to the prompt service component.
383 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
384 .getService(Components.interfaces.nsIPromptService);
386 // set the buttons that will appear on the dialog. It should be
387 // a set of constants multiplied by button position constants. In this case,
388 // three buttons appear, Save, Cancel and a custom button.
389 var flags=promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
390 promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
391 promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_2;
393 // display the dialog box. The flags set above are passed
394 // as the fourth argument. The next three arguments are custom labels used for
395 // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
396 // particular button. The last two arguments are for an optional check box.
397 answer = promptService.select(
399 rpt_strings.TEMPLATE_CONF_BOOLEAN_VALUE,
400 rpt_strings.TEMPLATE_CONF_SELECT_CANCEL,
401 2, [rpt_strings.TEMPLATE_CONF_TRUE, rpt_strings.TEMPLATE_CONF_FALSE], state
405 state = confirm(rpt_strings.TEMPLATE_CONF_CONFIRM_STATE);
406 state ? state = 0 : state = 1;
411 obj.op_value.value = 'f';
412 obj.op_value.label = rpt_strings.TEMPLATE_CONF_FALSE;
414 obj.op_value.value = 't';
415 obj.op_value.label = rpt_strings.TEMPLATE_CONF_TRUE;
419 targetCmd.removeEventListener( 'command', __bool_value_event_handler, true );
421 tree.view.selection.select( item_pos );
425 __handler_cache = __bool_value_event_handler;
426 targetCmd.addEventListener( 'command', __bool_value_event_handler, true );
433 var promptstring = rpt_strings.TEMPLATE_CONF_NO_MATCH;
437 promptstring = rpt_strings.TEMPLATE_CONF_NOT_BETWEEN;
441 promptstring = rpt_strings.TEMPLATE_CONF_BETWEEN;
445 promptstring = rpt_strings.TEMPLATE_CONF_NOT_IN;
449 promptstring = rpt_strings.TEMPLATE_CONF_IN;
453 promptstring = dojo.string.substitute( rpt_strings.TEMPLATE_CONF_DEFAULT, [obj.op_label]);
457 function __default_value_event_handler () {
459 if (_v = prompt( promptstring, obj.op_value.value || '' )) {
465 obj.op_value.value = _v.split(/\s*,\s*/);
469 obj.op_value.value = _v;
473 obj.op_value.label = '"' + obj.op_value.value + '"';
476 targetCmd.removeEventListener( 'command', __default_value_event_handler, true );
478 tree.view.selection.select( item_pos );
482 __handler_cache = __default_value_event_handler;
483 targetCmd.addEventListener( 'command', __default_value_event_handler, true );
492 function populateOperatorContext () {
494 var active_tab = filterByAttribute(
495 $('used-source-fields-tabbox').getElementsByTagName('tab'),
500 var tabname = active_tab.getAttribute('id');
502 var tabpanel = $( tabname + 'panel' );
503 var tree = tabpanel.getElementsByTagName('tree')[0];
504 var items = getSelectedItems(tree);
507 for (var i in items) {
509 dtypes.push( item.getAttribute('datatype') );
512 var menu = $(tabname + '_op_menu');
513 while (menu.firstChild) menu.removeChild(menu.lastChild);
515 for (var i in OILS_RPT_FILTERS) {
516 var o = OILS_RPT_FILTERS[i];
521 onmouseup : "changeOperator({op:'"+i+"',label:'"+o.label+"'})"
528 var keys = getKeys(o.labels);
529 for ( var k in keys ) {
531 if ( grep(function(x){return key==x},dtypes).length ) {
534 { label : o.labels[key],
535 onmouseup : "changeOperator({op:'"+i+"',label:'"+o.labels[key]+"'});"
545 function populateTransformContext () {
547 var active_tab = filterByAttribute(
548 $('used-source-fields-tabbox').getElementsByTagName('tab'),
553 var tabname = active_tab.getAttribute('id');
555 var tabpanel = $( tabname + 'panel' );
556 var tree = tabpanel.getElementsByTagName('tree')[0];
557 var items = getSelectedItems(tree);
560 for (var i in items) {
562 var dtype = item.getAttribute('datatype');
563 var item_transforms = getTransforms({ datatype : dtype });
565 for (var j in item_transforms) {
566 transforms[item_transforms[j]] = OILS_RPT_TRANSFORMS[item_transforms[j]];
567 transforms[item_transforms[j]].name = item_transforms[j];
571 var transformList = [];
572 for (var i in transforms) {
573 transformList.push( transforms[i] );
576 transformList.sort( sortHashLabels );
578 var menu = $(tabname + '_trans_menu');
579 while (menu.firstChild) menu.removeChild(menu.lastChild);
581 for (var i in transformList) {
582 var t = transformList[i];
584 if (tabname.match(/filter/)) {
585 if (tabname.match(/^agg/)) {
586 if (!t.aggregate) continue;
588 if (t.aggregate) continue;
594 { aggregate : t.aggregate,
599 onmouseup : "alterColumnTransform('"+t.name+"')"
605 menu.parentNode.setAttribute('disabled','false');
606 if (menu.childNodes.length == 0) {
607 menu.parentNode.setAttribute('disabled','true');
612 function renderSources (selected) {
614 var tree = $('used-sources');
615 var sources = $('used-sources-treetop');
616 var tabs = $('used-source-fields-tabbox').getElementsByTagName('tab');
619 while (sources.firstChild) sources.removeChild(sources.lastChild);
621 selected = getSelectedItems(tree);
622 if (!selected.length) {
623 selected = undefined;
624 while (sources.firstChild) sources.removeChild(sources.lastChild);
628 for (var j = 0; j < tabs.length; j++) {
630 var tabname = tab.getAttribute('id')
631 var tabpanel = $( tab.getAttribute('id') + 'panel' );
632 var fieldtree = tabpanel.getElementsByTagName('treechildren')[0];
634 while (fieldtree.firstChild) fieldtree.removeChild(fieldtree.lastChild);
637 for (var relation_alias in rpt_rel_cache) {
638 if (!rpt_rel_cache[relation_alias].fields) continue;
644 return x.getAttribute('relation') == relation_alias;
651 $('used-sources-treetop').appendChild(
653 { relation : rpt_rel_cache[relation_alias].alias,
654 idlclass : rpt_rel_cache[relation_alias].idlclass,
655 reltype : rpt_rel_cache[relation_alias].reltype,
656 path : rpt_rel_cache[relation_alias].path
660 createTreeCell({ label : rpt_rel_cache[relation_alias].label }),
661 createTreeCell({ label : rpt_rel_cache[relation_alias].table }),
662 createTreeCell({ label : rpt_rel_cache[relation_alias].alias }),
663 createTreeCell({ label : rpt_rel_cache[relation_alias].reltype })
669 for each (var tabname in ['filter_tab','aggfilter_tab']) {
670 tabpanel = $( tabname + 'panel' );
671 fieldtree = tabpanel.getElementsByTagName('treechildren')[0];
673 for (var colname in rpt_rel_cache[relation_alias].fields[tabname]) {
674 with (rpt_rel_cache[relation_alias].fields[tabname][colname]) {
675 fieldtree.appendChild(
677 { relation : relation_alias, datatype : datatype },
680 createTreeCell({ label : alias }),
681 createTreeCell({ label : colname }),
682 createTreeCell({ label : datatype }),
683 createTreeCell({ label : transform_label }),
684 createTreeCell({ label : transform })
689 fieldtree.lastChild.firstChild.appendChild(
690 createTreeCell({ op : op, label : op_label })
693 if (op_value.value != undefined) {
694 fieldtree.lastChild.firstChild.appendChild(
695 createTreeCell({ label : op_value.label })
703 tabpanel = $( 'dis_tabpanel' );
704 fieldtree = tabpanel.getElementsByTagName('treechildren')[0];
705 for each (var order in rpt_rel_cache.order_by) {
711 return x.getAttribute('relation') == order.relation;
718 with (rpt_rel_cache[order.relation].fields.dis_tab[order.field]) {
719 fieldtree.appendChild(
721 { relation : order.relation, datatype : datatype },
724 createTreeCell({ label : alias }),
725 createTreeCell({ label : colname }),
726 createTreeCell({ label : datatype }),
727 createTreeCell({ label : transform_label }),
728 createTreeCell({ label : transform })
733 fieldtree.lastChild.firstChild.appendChild(
734 createTreeCell({ op : op, label : op_label })
737 if (op_value.value != undefined) {
738 fieldtree.lastChild.firstChild.appendChild(
739 createTreeCell({ label : op_value.label })
749 filter_tab : 'where',
750 aggfilter_tab : 'having',
754 function save_template () {
759 core_class : $('sources-treetop').getElementsByTagName('treeitem')[0].getAttribute('idlclass'),
767 for (var relname in rpt_rel_cache) {
768 var relation = rpt_rel_cache[relname];
769 if (!relation.fields) continue;
771 // first, add the where and having clauses (easier)
772 for each (var tab_name in [ 'filter_tab', 'aggfilter_tab' ]) {
773 var tab = relation.fields[tab_name];
774 for (var field in tab) {
775 fleshTemplateField( template, relation, tab_name, field );
779 // now the from clause
780 fleshFromPath( template, relation );
783 // and now for select (based on order_by)
784 for each (var order in rpt_rel_cache.order_by)
785 fleshTemplateField( template, rpt_rel_cache[order.relation], 'dis_tab', order.field );
787 template.rel_cache = rpt_rel_cache;
789 //prompt( 'template', js2JSON( template ) );
791 // and the saving throw ...
793 var session = cgi.param('ses');
794 fetchUser( session );
797 tmpl.name( $('template-name').value );
798 tmpl.description( $('template-description').value );
799 tmpl.owner(USER.id());
800 tmpl.folder(cgi.param('folder'));
801 tmpl.data(js2JSON(template));
803 if(!confirm(dojo.string.substitute( rpt_strings.TEMPLATE_CONF_CONFIRM_SAVE, [tmpl.name(), tmpl.description()] )))
806 var req = new Request('open-ils.reporter:open-ils.reporter.template.create', session, tmpl);
807 req.request.alertEvent = false;
810 var res = r.getResultObject();
811 if(checkILSEvent(res)) {
814 if( res && res != '0' ) {
815 alert(dojo.string.substitute( rpt_strings.TEMPLATE_CONF_SUCCESS_SAVE, [tmpl.name()] ));
816 _l('../oils_rpt.xhtml');
825 function fleshFromPath ( template, rel ) {
826 var table_path = rel.path.split( /\./ );
827 if (table_path.length > 1 || rel.path.indexOf('-') > -1) table_path.push( rel.idlclass );
831 var current_path = '';
832 var current_obj = template.from;
834 while (link = table_path.shift()) {
836 if (prev_link != '') {
837 var prev_class = getIDLClass( prev_link.split(/-/)[0] );
838 var prev_field = prev_link.split(/-/)[1];
840 var prev_join = prev_field;
842 prev_field = prev_field.split(/>/)[0];
843 prev_join = prev_join.split(/>/)[1];
845 var current_link = getIDLLink( prev_class, prev_field );
846 current_obj.key = current_link.getAttribute('key');
848 //console.log("prev_link in fleshFromPath is: " + prev_link);
849 //console.log("prev_join in fleshFromPath is: " + prev_join);
851 if (prev_join) current_obj.type = prev_join
854 current_link.getAttribute('reltype') != 'has_a' ||
855 prev_type == 'left' ||
856 rel.reltype != 'has_a'
858 // This disallows outer joins when the item is used in a filter
860 // getKeys(rel.fields.filter_tab).length == 0 &&
861 // getKeys(rel.fields.aggfitler_tab).length == 0
864 ) current_obj.type = 'left';
866 prev_type = current_obj.type;
870 if (current_path) current_path += '-';
871 current_path += link.split(/>/)[0];
873 var leaf = table_path.length == 0 ? true : false;
875 current_obj.path = current_path;
876 current_obj.table = getSourceDefinition( link.split(/-/)[0] );
881 var join_type = link.split(/-/)[1];
883 join_type = join_type.split(/>/)[1];
884 if (join_type && join_type != 'undefined') current_obj.type = join_type;
887 current_obj.label = rel.label;
888 current_obj.alias = rel.alias;
889 current_obj.idlclass = rel.idlclass;
890 current_obj.template_path = rel.path;
892 var current_class = getIDLClass( link.split(/-/)[0] );
893 var join_field = link.split(/-/)[1];
894 var join_type = join_field;
896 join_field = join_field.split(/>/)[0];
897 join_type = join_type.split(/>/)[1];
899 //console.log("join_field in fleshFromPath is: " + join_field);
901 var join_link = getIDLLink(current_class, join_field);
903 if (join_link.getAttribute('reltype') != 'has_a') {
904 var fields_el = current_class.getElementsByTagName('fields')[0];
906 fields_el.getAttributeNS(persistNS, 'primary') +
907 '-' + join_link.getAttribute('class') +
908 '-' + join_link.getAttribute('key');
911 if (!current_obj.alias) current_obj.alias = hex_md5( current_path ) ;
912 join_field += '-' + current_obj.alias;
914 if (!current_obj.join) current_obj.join = {};
915 if (!current_obj.join[join_field]) current_obj.join[join_field] = {};
917 if (current_obj.type == 'left') current_obj.join[join_field].type = 'left';
919 current_obj = current_obj.join[join_field];
928 function fleshTemplateField ( template, rel, tab_name, field ) {
930 if (!rel.fields[tab_name] || !rel.fields[tab_name][field]) return;
932 var tab = rel.fields[tab_name];
934 var table_path = rel.path.split( /\./ );
935 if (table_path.length > 1 || rel.path.indexOf('-') > -1)
936 table_path.push( rel.idlclass );
938 table_path.push( field );
940 var field_path = table_path.join('-');
943 alias : tab[field].alias,
946 transform : tab[field].transform,
947 transform_label : tab[field].transform_label
953 if (tab_name.match(/filter/)) {
954 element.condition = {};
955 if (tab[field].op == 'is' || tab[field].op == 'is not' || tab[field].op == 'is blank' || tab[field].op == 'is not blank') {
956 element.condition[tab[field].op] = null;
958 element.condition[tab[field].op] =
959 tab[field].op_value.value ?
960 tab[field].op_value.value :
961 '::P' + param_count++;
965 template[tab_use[tab_name]].push(element);