Xavier (Open ERP) has proposed merging 
lp:~openerp-dev/openerp-web/trunk-optgroups-xmo into lp:openerp-web.

Requested reviews:
  Nicolas Vanhoren (OpenERP) (niv-openerp)
  Fabien Meghazi (OpenERP) (fme)
  OpenERP R&D Web Team (openerp-dev-web)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-optgroups-xmo/+merge/83270

Small improvement to filters dropdown: use optgroup for the section titles 
(filters and actions) so they don't have to be filtered out anymore (simpler 
code).

Drawback?: dropdown empty by default
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-optgroups-xmo/+merge/83270
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-optgroups-xmo.
=== modified file 'addons/web/static/src/js/search.js'
--- addons/web/static/src/js/search.js	2011-11-23 21:53:56 +0000
+++ addons/web/static/src/js/search.js	2011-11-24 10:25:33 +0000
@@ -198,18 +198,23 @@
         var self = this;
         var select = this.$element.find(".oe_search-view-filters-management");
         var val = select.val();
-        
-        if (val.slice(0,1) == "_") { // useless action
-            select.val("_filters");
-            return;
-        }
-        if (val.slice(0, "get:".length) == "get:") {
-            val = val.slice("get:".length);
-            val = parseInt(val);
-            var filter = this.managed_filters[val];
-            this.on_search([filter.domain], [filter.context], []);
-        } else if (val == "save_filter") {
-            select.val("_filters");
+        switch(val) {
+        case 'add_to_dashboard':
+            this.on_add_to_dashboard();
+            break;
+        case 'manage_filters':
+            this.do_action({
+                res_model: 'ir.filters',
+                views: [[false, 'list'], [false, 'form']],
+                type: 'ir.actions.act_window',
+                context: {"search_default_user_id": this.session.uid,
+                "search_default_model_id": this.dataset.model},
+                target: "current",
+                limit : 80,
+                auto_search : true
+            });
+            break;
+        case 'save_filter':
             var data = this.build_search_data();
             var context = new openerp.web.CompoundContext();
             _.each(data.contexts, function(x) {
@@ -242,20 +247,15 @@
                     }}
                 ]
             });
-        } else if (val == "add_to_dashboard") {
-            this.on_add_to_dashboard();
-        } else { // manage_filters
-            select.val("_filters");
-            this.do_action({
-                res_model: 'ir.filters',
-                views: [[false, 'list'], [false, 'form']],
-                type: 'ir.actions.act_window',
-                context: {"search_default_user_id": this.session.uid,
-                "search_default_model_id": this.dataset.model},
-                target: "current",
-                limit : 80,
-                auto_search : true
-            });
+            break;
+        }
+        if (val.slice(0, 4) == "get:") {
+            val = val.slice(4);
+            val = parseInt(val, 10);
+            var filter = this.managed_filters[val];
+            this.on_search([filter.domain], [filter.context], []);
+        } else {
+            select.val('');
         }
     },
     on_add_to_dashboard: function() {

=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml	2011-11-23 21:53:56 +0000
+++ addons/web/static/src/xml/base.xml	2011-11-24 10:25:33 +0000
@@ -1127,16 +1127,17 @@
     </form>
 </t>
 <t t-name="SearchView.managed-filters">
-    <option value="_filters">-- Filters --</option>
-    <t t-set="i" t-value="0"/>
-    <t t-foreach="filters" t-as="filter">
-        <option t-att-value="'get:' + i"><t t-esc="filter.name"/></option>
-        <t t-set="i" t-value="i+1"/>
-    </t>
-    <option value="_actions">-- Actions --</option>
-    <option value="save_filter">Save Filter</option>
-    <option value="add_to_dashboard">Add to Dashboard</option>
-    <option value="manage_filters">Manage Filters</option>
+    <option/>
+    <optgroup label="-- Filters --">
+        <t t-foreach="filters" t-as="filter">
+            <option t-attf-value="get:#{filter_index}"><t t-esc="filter.name"/></option>
+        </t>
+    </optgroup>
+    <optgroup label="-- Actions --">
+        <option value="save_filter">Save Filter</option>
+        <option value="add_to_dashboard">Add to Dashboard</option>
+        <option value="manage_filters">Manage Filters</option>
+    </optgroup>
 </t>
 <t t-name="SearchView.managed-filters.add">
     <div>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to