Commit c5537190 authored by Yusei Tahara's avatar Yusei Tahara

Fixed report tree bug which occurs when column name is 'title'.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16942 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 63f01287
...@@ -108,7 +108,7 @@ class ReportSection: ...@@ -108,7 +108,7 @@ class ReportSection:
""" """
def __init__(self, is_summary = False, object_list = (), object_list_len = 0, def __init__(self, is_summary = False, object_list = (), object_list_len = 0,
is_open = False, selection_domain = None, context = None, offset = 0, is_open = False, selection_domain = None, context = None, offset = 0,
depth = 0): depth = 0, domain_title = None):
self.is_summary = is_summary self.is_summary = is_summary
self.object_list = object_list self.object_list = object_list
self.object_list_len = object_list_len self.object_list_len = object_list_len
...@@ -117,6 +117,7 @@ class ReportSection: ...@@ -117,6 +117,7 @@ class ReportSection:
self.context = context self.context = context
self.offset = offset self.offset = offset
self.depth = depth self.depth = depth
self.domain_title = domain_title
class ListBoxWidget(Widget.Widget): class ListBoxWidget(Widget.Widget):
""" """
...@@ -1492,6 +1493,8 @@ class ListBoxRenderer: ...@@ -1492,6 +1493,8 @@ class ListBoxRenderer:
# Query the stat. # Query the stat.
stat_brain = selection(method = stat_method, context = context, REQUEST = self.request) stat_brain = selection(method = stat_method, context = context, REQUEST = self.request)
domain_title = report_tree.obj.getTitle()# XXX Yusei Keep original domain title before overriding
stat_result = {} stat_result = {}
for index, (k, v) in enumerate(self.getSelectedColumnList()): for index, (k, v) in enumerate(self.getSelectedColumnList()):
try: try:
...@@ -1507,7 +1510,8 @@ class ListBoxRenderer: ...@@ -1507,7 +1510,8 @@ class ListBoxRenderer:
report_section_list.append(ReportSection(is_summary = True, object_list = [stat_context], report_section_list.append(ReportSection(is_summary = True, object_list = [stat_context],
object_list_len = 1, is_open = report_tree.is_open, object_list_len = 1, is_open = report_tree.is_open,
selection_domain = report_tree.selection_domain, selection_domain = report_tree.selection_domain,
context = stat_context, depth = report_tree.depth)) context = stat_context, depth = report_tree.depth,
domain_title = domain_title))
else: else:
selection.edit(params = param_dict) selection.edit(params = param_dict)
...@@ -1685,11 +1689,15 @@ class ListBoxRenderer: ...@@ -1685,11 +1689,15 @@ class ListBoxRenderer:
else: else:
index = i index = i
#LOG('ListBox', 0, 'current_section.__dict__ = %r' % (current_section.__dict__,)) #LOG('ListBox', 0, 'current_section.__dict__ = %r' % (current_section.__dict__,))
line = line_class(renderer = self, obj = current_section.object_list[offset], line = line_class(renderer = self,
index = index, is_summary = current_section.is_summary, obj = current_section.object_list[offset],
context = current_section.context, is_open = current_section.is_open, index = index,
is_summary = current_section.is_summary,
context = current_section.context,
is_open = current_section.is_open,
selection_domain = current_section.selection_domain, selection_domain = current_section.selection_domain,
depth = current_section.depth) depth = current_section.depth,
domain_title = current_section.domain_title)
line_list.append(line) line_list.append(line)
except IndexError: except IndexError:
# If the report section list is empty, nothing to do. # If the report section list is empty, nothing to do.
...@@ -1712,7 +1720,7 @@ class ListBoxRendererLine: ...@@ -1712,7 +1720,7 @@ class ListBoxRendererLine:
"""This class describes a line in a ListBox to assist ListBoxRenderer. """This class describes a line in a ListBox to assist ListBoxRenderer.
""" """
def __init__(self, renderer = None, obj = None, index = 0, is_summary = False, context = None, def __init__(self, renderer = None, obj = None, index = 0, is_summary = False, context = None,
is_open = False, selection_domain = None, depth = 0): is_open = False, selection_domain = None, depth = 0, domain_title=None):
"""In reality, the object is a brain or a brain-like object. """In reality, the object is a brain or a brain-like object.
""" """
self.renderer = renderer self.renderer = renderer
...@@ -1723,6 +1731,7 @@ class ListBoxRendererLine: ...@@ -1723,6 +1731,7 @@ class ListBoxRendererLine:
self.is_open = is_open self.is_open = is_open
self.selection_domain = selection_domain self.selection_domain = selection_domain
self.depth = depth self.depth = depth
self.domain_title = domain_title
# Because it is not easy to pass an instance object implicitly to a method # Because it is not easy to pass an instance object implicitly to a method
# with no side effect, tweak VolatileCachingMethod objects here for this instance. # with no side effect, tweak VolatileCachingMethod objects here for this instance.
...@@ -1780,6 +1789,17 @@ class ListBoxRendererLine: ...@@ -1780,6 +1789,17 @@ class ListBoxRendererLine:
""" """
return getattr(self.getContext(), 'domain_url', '') return getattr(self.getContext(), 'domain_url', '')
def getDomainTitle(self):
"""Return original title of domain"""
if self.domain_title is not None:
return self.domain_title
else:
context = self.getContext()
if context is not None:
return context.getTitleOrId() or ''
return ''
def getDepth(self): def getDepth(self):
"""Return the depth of a domain. Used only for a summary line. """Return the depth of a domain. Used only for a summary line.
""" """
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
tal:attributes="id string:${field_id}_data_line_${repeat/line/index}; class css"> tal:attributes="id string:${field_id}_data_line_${repeat/line/index}; class css">
<td tal:condition="is_report_tree_mode" class="DataA" align="left" valign="middle" <td tal:condition="is_report_tree_mode" class="DataA" align="left" valign="middle"
tal:attributes="class css" tal:attributes="class css"
tal:define="section_name python: line.getContext() is not None and line.getContext().getTitleOrId() or ''"> tal:define="section_name python: line.getDomainTitle()">
<a tal:condition="section_name" <a tal:condition="section_name"
tal:define="method_id python: line.isOpen() and 'foldReport' or 'unfoldReport'" tal:define="method_id python: line.isOpen() and 'foldReport' or 'unfoldReport'"
tal:attributes="href string:${method_id}?report_url=${line/getDomainUrl}&amp;form_id=${form_id}&amp;list_selection_name=${selection_name}" tal:attributes="href string:${method_id}?report_url=${line/getDomainUrl}&amp;form_id=${form_id}&amp;list_selection_name=${selection_name}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment