Skip to content

Commit

Permalink
Merge pull request #5221 from dimagi/fixtures-in-graphs
Browse files Browse the repository at this point in the history
Fix bug retrieving all xpaths from a tabbed case detail
  • Loading branch information
czue committed Jan 7, 2015
2 parents d8f726f + 21c4f2c commit 7a333c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ var GraphSeries = function (original, childCaseTypes, fixtures){
} else if (source.type == 'case') {
return "instance('casedb')/casedb/case[@case_type='"+source.name+"'][index/parent=current()/@case_id][@status='open']";
} else if (source.type == 'fixture') {
return "instance('" + self.getFixtureInstanceId(source.name) + "')/tablename_list/" + source.name;
return "instance('" + self.getFixtureInstanceId(source.name) + "')/" + source.name + "_list/" + source.name;
}
};

Expand Down
13 changes: 12 additions & 1 deletion corehq/apps/app_manager/suite_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,17 @@ class Detail(IdNode):
details = NodeListField('detail', "self")
_variables = NodeField('variables', DetailVariableList)

def get_all_fields(self):
'''
Return all fields under this Detail instance and all fields under
any details that may be under this instance.
:return:
'''
all_fields = []
for detail in [self] + list(self.details):
all_fields.extend(list(detail.fields))
return all_fields

def _init_variables(self):
if self._variables is None:
self._variables = DetailVariableList()
Expand All @@ -461,7 +472,7 @@ def get_all_xpaths(self):
if self._variables:
for variable in self.variables:
result.add(variable.function)
for field in self.fields:
for field in self.get_all_fields():
try:
result.add(field.header.text.xpath_function)
result.add(field.template.text.xpath_function)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
{
"doc_type":"GraphSeries",
"y_function":"bar",
"data_path":"instance('item-list:table1')/tablename_list/table1",
"data_path":"instance('item-list:table1')/table1_list/table1",
"radius_function":null,
"x_function":"foo",
"config":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</header>
<template form="graph">
<graph type="xy">
<series nodeset="instance('item-list:table1')/tablename_list/table1">
<series nodeset="instance('item-list:table1')/table1_list/table1">
<configuration/>
<x function="foo"/>
<y function="bar"/>
Expand Down

0 comments on commit 7a333c1

Please sign in to comment.