[open-ils-commits] r12510 - in trunk: Open-ILS/web/reports/xul build/i18n/po/en-US (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Mar 13 17:40:06 EDT 2009
Author: miker
Date: 2009-03-13 17:40:01 -0400 (Fri, 13 Mar 2009)
New Revision: 12510
Modified:
trunk/Open-ILS/web/reports/xul/source-browse.js
trunk/Open-ILS/web/reports/xul/source-setup.js
trunk/Open-ILS/web/reports/xul/template-config.js
trunk/Open-ILS/web/reports/xul/template_builder.xul
trunk/build/i18n/po/en-US/reports.js.pot
Log:
adding "Enable nullability selection" switch to allow complete control over join types in templates
Modified: trunk/Open-ILS/web/reports/xul/source-browse.js
===================================================================
--- trunk/Open-ILS/web/reports/xul/source-browse.js 2009-03-13 12:27:40 UTC (rev 12509)
+++ trunk/Open-ILS/web/reports/xul/source-browse.js 2009-03-13 21:40:01 UTC (rev 12510)
@@ -48,11 +48,14 @@
findAnscestorStack( item, 'treeitem', pathList );
var fullpath = '';
+
for (var j in pathList.reverse()) {
var n = pathList[j].getAttribute('idlclass');
var f = pathList[j].getAttribute('field');
+ var j = pathList[j].getAttribute('join');
if (f) fullpath += "-" + f;
+ if (f && j != 'undefined') fullpath += '>' + j;
if (fullpath) fullpath += ".";
fullpath += n;
@@ -63,6 +66,7 @@
subtreeList.push(
{ name : name,
+ nullable : 'Default',
idlclass : idlclass,
map : map,
key : key,
@@ -72,6 +76,68 @@
fullpath : fullpath
}
);
+
+ if ($('nullable-source-control').checked) {
+ if (reltype == 'has_a') {
+ subtreeList.push(
+ { name : name,
+ nullable : 'Parent', //rpt_strings.LINK_NULLABLE_RIGHT,
+ idlclass : idlclass,
+ map : map,
+ key : key,
+ join : 'right',
+ field : field.getAttribute('name'),
+ reltype : reltype,
+ link : link,
+ fullpath : fullpath + '>right'
+ }
+ );
+
+ subtreeList.push(
+ { name : name,
+ nullable : 'None', //rpt_strings.LINK_NULLABLE_NONE
+ idlclass : idlclass,
+ map : map,
+ key : key,
+ join : 'inner',
+ field : field.getAttribute('name'),
+ reltype : reltype,
+ link : link,
+ fullpath : fullpath + '>inner'
+ }
+ );
+
+ } else{
+ subtreeList.push(
+ { name : name,
+ nullable : 'Child', //rpt_strings.LINK_NULLABLE_LEFT,
+ idlclass : idlclass,
+ map : map,
+ key : key,
+ join : 'left',
+ field : field.getAttribute('name'),
+ reltype : reltype,
+ link : link,
+ fullpath : fullpath + '>left'
+ }
+ );
+
+ subtreeList.push(
+ { name : name,
+ nullable : 'None', //rpt_strings.LINK_NULLABLE_NONE
+ idlclass : idlclass,
+ map : map,
+ key : key,
+ join : 'inner',
+ field : field.getAttribute('name'),
+ reltype : reltype,
+ link : link,
+ fullpath : fullpath + '>inner'
+ }
+ );
+
+ }
+ }
}
populateSourcesSubtree( item.lastChild, subtreeList );
Modified: trunk/Open-ILS/web/reports/xul/source-setup.js
===================================================================
--- trunk/Open-ILS/web/reports/xul/source-setup.js 2009-03-13 12:27:40 UTC (rev 12509)
+++ trunk/Open-ILS/web/reports/xul/source-setup.js 2009-03-13 21:40:01 UTC (rev 12510)
@@ -195,6 +195,7 @@
},
createTreeRow(
{ },
+ createTreeCell( { label : '' } ),
createTreeCell( { label : name } )
),
createTreeChildren( { alternatingbackground : true } )
@@ -218,11 +219,13 @@
key : obj.key,
field : obj.field,
link : obj.link,
+ join : obj['join'],
reltype : obj.reltype,
fullpath : obj.fullpath
},
createTreeRow(
{ },
+ createTreeCell( { label : obj.nullable } ),
createTreeCell( { label : obj.name } )
),
createTreeChildren( { alternatingbackground : true } )
@@ -257,12 +260,28 @@
var _label = _cname;
if (atom.length > 1 && k == steps.length - 1) {
- var _f = getIDLField(classNode, atom[1]);
+ var field_name = atom[1];
+ var join_type = field_name;
+
+ field_name = field_name.split(/>/)[0];
+ join_type = join_type.split(/>/)[1];
+
+ var _f = getIDLField(classNode, field_name);
var _fname = _f.getAttributeNS(rptNS, 'label');
if (!_fname) _fname = _f.getAttribute('name');
if (_fname) _label += ' :: ' + _fname;
- }
+ if (join_type) _label += ' (' + join_type + ')';
+
+ } else if (atom[1]){
+ var field_name = atom[1];
+ var join_type = field_name;
+ field_name = field_name.split(/>/)[0];
+ join_type = join_type.split(/>/)[1];
+
+ if (join_type) _label += ' (' + join_type + ')';
+ }
+
path_label.push(_label);
}
Modified: trunk/Open-ILS/web/reports/xul/template-config.js
===================================================================
--- trunk/Open-ILS/web/reports/xul/template-config.js 2009-03-13 12:27:40 UTC (rev 12509)
+++ trunk/Open-ILS/web/reports/xul/template-config.js 2009-03-13 21:40:01 UTC (rev 12510)
@@ -77,19 +77,21 @@
var field_class = item.getAttribute('idlclass');
var datatype = item.getAttribute('datatype');
var colname = item.getAttribute('idlfield');
+ var jointype = item.getAttribute('join');
var field_label = item.firstChild.firstChild.getAttribute('label');
var table_name = getSourceDefinition(field_class);
if ( !rpt_rel_cache[relation_alias] ) {
rpt_rel_cache[relation_alias] =
- { label : class_label,
- alias : relation_alias,
- path : class_path,
- reltype : reltype,
+ { label : class_label,
+ alias : relation_alias,
+ path : class_path,
+ join : jointype,
+ reltype : reltype,
idlclass : field_class,
- table : table_name,
- fields: { dis_tab : {}, filter_tab : {}, aggfilter_tab : {} }
+ table : table_name,
+ fields : { dis_tab : {}, filter_tab : {}, aggfilter_tab : {} }
};
}
@@ -101,6 +103,7 @@
params : transform && transform.getAttribute('params'),
transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
alias : field_label,
+ join : jointype,
datatype : datatype,
op : '=',
op_label : rpt_strings.TEMPLATE_CONF_EQUALS,
@@ -121,6 +124,7 @@
params : transform && transform.getAttribute('params'),
transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
alias : field_label,
+ join : jointype,
datatype : datatype,
op : '=',
op_label : rpt_strings.TEMPLATE_CONF_EQUALS,
@@ -824,36 +828,58 @@
var current_obj = template.from;
var link;
while (link = table_path.shift()) {
- if (current_path) current_path += '-';
- current_path += link;
- var leaf = table_path.length == 0 ? true : false;
-
- current_obj.path = current_path;
- current_obj.table = getSourceDefinition( link.split(/-/)[0] );
-
if (prev_link != '') {
var prev_class = getIDLClass( prev_link.split(/-/)[0] );
var prev_field = prev_link.split(/-/)[1];
+ var prev_join = prev_field;
+
+ prev_field = prev_field.split(/>/)[0];
+ prev_join = prev_join.split(/>/)[1];
+
var current_link = getIDLLink( prev_class, prev_field );
current_obj.key = current_link.getAttribute('key');
- if (
+ //console.log("prev_link in fleshFromPath is: " + prev_link);
+ //console.log("prev_join in fleshFromPath is: " + prev_join);
+
+ if (prev_join) current_obj.type = prev_join
+ else if (
(
current_link.getAttribute('reltype') != 'has_a' ||
prev_type == 'left' ||
rel.reltype != 'has_a'
+
+// This disallows outer joins when the item is used in a filter
// ) && (
// getKeys(rel.fields.filter_tab).length == 0 &&
// getKeys(rel.fields.aggfitler_tab).length == 0
+
)
) current_obj.type = 'left';
prev_type = current_obj.type;
+
}
+ if (current_path) current_path += '-';
+ current_path += link.split(/>/)[0];
+
+ var leaf = table_path.length == 0 ? true : false;
+
+ current_obj.path = current_path;
+ current_obj.table = getSourceDefinition( link.split(/-/)[0] );
+
+
if (leaf) {
+
+ var join_type = link.split(/-/)[1];
+ if (join_type) {
+ join_type = join_type.split(/>/)[1];
+ if (join_type && join_type != 'undefined') current_obj.type = join_type;
+ }
+
current_obj.label = rel.label;
current_obj.alias = rel.alias;
current_obj.idlclass = rel.idlclass;
@@ -861,6 +887,13 @@
} else {
var current_class = getIDLClass( link.split(/-/)[0] );
var join_field = link.split(/-/)[1];
+ var join_type = join_field;
+
+ join_field = join_field.split(/>/)[0];
+ join_type = join_type.split(/>/)[1];
+
+ //console.log("join_field in fleshFromPath is: " + join_field);
+
var join_link = getIDLLink(current_class, join_field);
if (join_link.getAttribute('reltype') != 'has_a') {
Modified: trunk/Open-ILS/web/reports/xul/template_builder.xul
===================================================================
--- trunk/Open-ILS/web/reports/xul/template_builder.xul 2009-03-13 12:27:40 UTC (rev 12509)
+++ trunk/Open-ILS/web/reports/xul/template_builder.xul 2009-03-13 21:40:01 UTC (rev 12510)
@@ -76,10 +76,12 @@
ondblclick="sourceTreeHandlerDblClick(event)"
>
<treecols>
+ <treecol label="Nullable" flex="0"/>
<treecol primary="true" label="&reports.xul.template_builder.source_name.label;" flex="1"/>
</treecols>
<treechildren id="sources-treetop" alternatingbackground="true" />
</tree>
+ <checkbox id="nullable-source-control" label="Enable nullability seletion"/>
</vbox>
</hbox>
Modified: trunk/build/i18n/po/en-US/reports.js.pot
===================================================================
--- trunk/build/i18n/po/en-US/reports.js.pot 2009-03-13 12:27:40 UTC (rev 12509)
+++ trunk/build/i18n/po/en-US/reports.js.pot 2009-03-13 21:40:01 UTC (rev 12510)
@@ -400,3 +400,19 @@
#: reports.js:TEMPLATE_CONF_NOT_IN reports.js:TEMPLATE_CONF_NO_MATCH
msgid "Field does not match one of list (comma separated):"
msgstr ""
+
+#: reports.js:LINK_NULLABLE_LEFT
+msgid "Child"
+msgstr ""
+
+#: reports.js:LINK_NULLABLE_RIGHT
+msgid "Parent"
+msgstr ""
+
+#: reports.js:LINK_NULLABLE_BOTH
+msgid "Both"
+msgstr ""
+
+#: reports.js:LINK_NULLABLE_NONE
+msgid "None"
+msgstr ""
More information about the open-ils-commits
mailing list