[Erp5-dev] [PATCH] ListBox filtered notification todo support domain selection write tests

Boris Kocherov bk at raskon.org
Mon Dec 19 19:19:02 CET 2011


---
 .../erp5_xhtml_style/ListBox_asHTML.xml            |    1 +
 .../erp5_xhtml_style/ListBox_asHTMLLibrary.xml     |   14 +++++++-
 .../erp5_xhtml_style/erp5_listbox.css.xml          |    6 +++
 product/ERP5Form/ListBox.py                        |   34 +++++++++++++++----
 product/ERP5Form/Selection.py                      |    2 +-
 5 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTML.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTML.xml
index db5ddb1..21cccc1 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTML.xml
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTML.xml
@@ -57,6 +57,7 @@
               show_select_column here/showSelectColumn;\n
               show_anchor_column here/showAnchorColumn;\n
               show_search_line here/showSearchLine;\n
+              global is_filtered python: show_search_line and not here.isNotFiltered();\n
               is_web_mode real_context/isWebMode | nothing;\n
               is_dialog_mode request/dialog_mode | nothing;\n
               display_style_list here/getDisplayStyleList;\n
diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTMLLibrary.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTMLLibrary.xml
index 8a4cbe6..5abe15d 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTMLLibrary.xml
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ListBox_asHTMLLibrary.xml
@@ -177,8 +177,10 @@
           tal:attributes="class class"\n
           tal:content="here/getTitle" />\n
   </tal:block>\n
-  <tal:block tal:condition="not: is_web_mode">:</tal:block>\n
-\n
+  <tal:block tal:condition="not: is_web_mode">:<span id="filter-note"\n
+          i18n:translate=""\n
+          i18n:domain="ui"\n
+          tal:condition="is_filtered">! filtered !</span></tal:block>\n
 </div>\n
 \n
 <!-- Listbox navigation -->\n
@@ -353,6 +355,10 @@
             <value> <string>text/html</string> </value>
         </item>
         <item>
+            <key> <string>expand</string> </key>
+            <value> <int>1</int> </value>
+        </item>
+        <item>
             <key> <string>id</string> </key>
             <value> <string>ListBox_asHTMLLibrary</string> </value>
         </item>
@@ -360,6 +366,10 @@
             <key> <string>output_encoding</string> </key>
             <value> <string>iso-8859-15</string> </value>
         </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <unicode></unicode> </value>
+        </item>
       </dictionary>
     </pickle>
   </record>
diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_listbox.css.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_listbox.css.xml
index 7e6238a..416839e 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_listbox.css.xml
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_listbox.css.xml
@@ -470,6 +470,12 @@ div.listbox-head-content{\n
   color: black;\n
 }\n
 \n
+#filter-note{\n
+  font-weight: bold;\n
+  color: red;\n
+  margin-left: 0.6em;\n
+}\n
+\n
 div.listbox-head div.listbox-head-title{\n
   float:left;\n
   width:auto;\n
diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index 5f507dd..62d3cf4 100644
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -724,22 +724,42 @@ class ListBoxRenderer:
       # we show all rows and do not care to hide anything
       return 0
 
+    # ignore_hide_rows parameter force to display the content
+    ignore_hide_rows = REQUEST.get('ignore_hide_rows', 0)
+    if ignore_hide_rows:
+      return 0
+
+    return self.isNotFiltered()
+
+  isHideRowsOnNoSearchCriterion = lazyMethod(isHideRowsOnNoSearchCriterion)
+
+  def isFiltered(self):
+    """Return True if listbox content filtered
+    """
+    return not self.isNotFiltered()
+
+  isFiltered = lazyMethod(isFiltered)
+
+  def isNotFiltered(self):
+    """Return False if listbox content filtered
+    """
+
     # Always display lines in report mode
     if self.isReportTreeMode():
       return 0
 
     # In domain mode, returns lines only if a domain is selected
-    if self.isDomainTreeMode():
-      if self.getDomainSelection():
-        return 0
+    domain_selection = self.getDomainSelection()
+    if domain_selection and (len(domain_selection) > 0):
+      return 0
 
-    # ignore_hide_rows parameter force to display the content
-    ignore_hide_rows = REQUEST.get('ignore_hide_rows', 0)
-    if ignore_hide_rows:
+    # Always display lines in invert mode (filter by checked uids)
+    if self.getSelection().isInvertMode():
       return 0
 
     # we could hide rows only if missing in request or selection search criterions
     selection_params = self.getSelection().getParams()
+    REQUEST = self.request
 
     # Try to get workflow state parameter, in order to always allow worklist display
     # guess all column names from catalog schema
@@ -765,7 +785,7 @@ class ListBoxRenderer:
         return 0
     return 1
 
-  isHideRowsOnNoSearchCriterion = lazyMethod(isHideRowsOnNoSearchCriterion)
+  isNotFiltered = lazyMethod(isNotFiltered)
 
   def showStat(self):
     """Return a boolean that represents whether a stat line is displayed or not.
diff --git a/product/ERP5Form/Selection.py b/product/ERP5Form/Selection.py
index 29a2999..388d1c2 100644
--- a/product/ERP5Form/Selection.py
+++ b/product/ERP5Form/Selection.py
@@ -423,7 +423,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
           setattr(self, k, v)
 
   def __len__(self):
-    return len(self.domain_dict)
+    return len([1 for i in  self.domain_dict if i is not None])
 
   security.declarePublic('getCategoryList')
   def getCategoryList(self):
-- 
1.7.8.rc3




More information about the Erp5-dev mailing list