changeset 1048:eacf25f071c0

Enable/Disable favorites checkbox whether user has query favorites or not.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 29 Feb 2016 15:10:17 +0100
parents fc6bf0e2444e
children 981339d774b8
files app/controller/Filter.js
diffstat 1 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- 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)]);
     },

http://lada.wald.intevation.org