[Lada-commits] [PATCH] Enable/Disable favorites checkbox whether user has query favorites or not

Wald Commits scm-commit at wald.intevation.org
Mon Feb 29 15:10:22 CET 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1456755017 -3600
# Node ID eacf25f071c0e20fc4b267298bed357756c346fd
# Parent  fc6bf0e2444e3bd2e4eb2023431f3e7ab6a8dcb8
Enable/Disable favorites checkbox whether user has query favorites or not.

diff -r fc6bf0e2444e -r eacf25f071c0 app/controller/Filter.js
--- a/app/controller/Filter.js	Mon Feb 29 11:18:16 2016 +0100
+++ b/app/controller/Filter.js	Mon Feb 29 15:10:17 2016 +0100
@@ -447,26 +447,28 @@
         else {
             return;
         }
-        if (fav.checked) {
-            entries = store.queryBy(function(record) {
-                if (record.get('favorite')) {
-                    return true;
-                }
-            });
-            if (entries.getCount() === 0) {
+        var allEntries = store.queryBy(function() {
+            return true;
+        });
+        var favorites = store.queryBy(function(record) {
+            if (record.get('favorite')) {
+                return true;
+            }
+        });
+        combobox.store.removeAll();
+        if (fav.checked && favorites.getCount() > 0) {
+            combobox.store.add(favorites.items);
+        }
+        else {
+            combobox.store.add(allEntries.items);
+            if (favorites.getCount() === 0) {
                 fav.setValue(false);
-                entries = store.queryBy(function() {
-                    return true;
-                });
+                fav.disable();
+            }
+            else {
+                fav.enable();
             }
         }
-        else {
-            entries = store.queryBy(function() {
-                return true;
-            });
-        }
-        combobox.store.removeAll();
-        combobox.store.add(entries.items);
         combobox.select(combobox.store.getAt(0));
         combobox.fireEvent('select', combobox, [combobox.store.getAt(0)]);
     },


More information about the Lada-commits mailing list