[extensions-web] Switch the default filter to show only compatible extensions



commit 6b754f934de9a251dca5c72c55d93bdcf237eabd
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Feb 14 12:28:49 2012 -0500

    Switch the default filter to show only compatible extensions

 sweettooth/extensions/views.py    |    5 +++--
 sweettooth/static/js/fsui.js      |   14 +++++++++-----
 sweettooth/static/js/paginator.js |    6 +++++-
 3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 0bd7084..35afea0 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -88,8 +88,9 @@ def ajax_query_params_query(request):
     query_params = {}
 
     version_strings = request.GET.getlist('shell_version')
-    if version_strings:
-        query_params['versions__shell_versions__in'] = get_versions_for_version_strings(version_strings)
+    if version_strings and version_strings != ['all']:
+        versions = set(get_versions_for_version_strings(version_strings))
+        query_params['versions__shell_versions__in'] = versions
 
     uuids = request.GET.getlist('uuid')
     if uuids:
diff --git a/sweettooth/static/js/fsui.js b/sweettooth/static/js/fsui.js
index 4a1d245..3fee191 100644
--- a/sweettooth/static/js/fsui.js
+++ b/sweettooth/static/js/fsui.js
@@ -85,17 +85,21 @@ function($, dbusProxy, hashparamutils, modal) {
                 }).appendTo($fsui);
 
             function textForFilterValue(value) {
-                if (value === undefined)
+                if (value === 'all')
                     return "All versions";
                 else if (value === dbusProxy.ShellVersion)
                     return "Current version";
-                return "GNOME Shell version " + hp.shell_version;
+                return "GNOME Shell version " + value;
             }
 
             if (dbusProxy.ShellVersion !== undefined) {
+                var shellVersion = hp.shell_version;
+                if (shellVersion === undefined)
+                    shellVersion = dbusProxy.ShellVersion;
+
                 $fsui.append('<span>Compatible with</span>');
 
-                $link = makeDropdownLink(textForFilterValue(hp.shell_version)).
+                $link = makeDropdownLink(textForFilterValue(shellVersion)).
                     click(function() {
                         var $dropdown = $('<div>', {'class': 'fsui-dropdown'}).
                             appendTo($fsui).
@@ -109,9 +113,9 @@ function($, dbusProxy, hashparamutils, modal) {
 
                         var $filterUL = $('<ul>').appendTo($dropdown);
 
-                        $.each([undefined, dbusProxy.ShellVersion], function() {
+                        $.each(['all', dbusProxy.ShellVersion], function() {
                             var $filterItem = makeLink('shell_version', this, textForFilterValue(this), closeUI).appendTo($filterUL);
-                            if (hp.shell_version === this)
+                            if (shellVersion === this)
                                 $filterItem.addClass('selected');
                         });
 
diff --git a/sweettooth/static/js/paginator.js b/sweettooth/static/js/paginator.js
index 504a2e7..6adb22a 100644
--- a/sweettooth/static/js/paginator.js
+++ b/sweettooth/static/js/paginator.js
@@ -1,6 +1,7 @@
 "use strict";
 
-define(['jquery', 'hashparamutils', 'jquery.hashchange'], function($, hashparamutils) {
+define(['jquery', 'hashparamutils',
+        'dbus!_', 'jquery.hashchange'], function($, hashparamutils, dbusProxy) {
 
     $.fn.paginatorify = function(url, context) {
         if (!this.length)
@@ -104,6 +105,9 @@ define(['jquery', 'hashparamutils', 'jquery.hashchange'], function($, hashparamu
             else
                 hashParams.page = parseInt(hashParams.page);
 
+            if (hashParams.shell_version === undefined && dbusProxy.ShellVersion !== undefined)
+                hashParams.shell_version = dbusProxy.ShellVersion;
+
             loadPage();
         });
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]