Generate category limits correctly -- thanks to NE!
[mkws-moved-to-github.git] / src / mkws-team.js
index 7a9015e..08f67b3 100644 (file)
@@ -185,7 +185,9 @@ function team($, teamName) {
 
     that.limitCategory = function(id) {
        log("limitCategory(id=" + id + ")");
-       m_filterSet.add(categoryFilter(id));
+        // Only one category filter at a time
+       m_filterSet.removeMatching(function(f) { return f.type === 'category' });        
+        if (id !== '') m_filterSet.add(categoryFilter(id));
         if (m_query) triggerSearch();
        return false;
     };
@@ -249,7 +251,7 @@ function team($, teamName) {
            return;
        }
 
-       m_filterSet = filterSet(that);
+       m_filterSet.removeMatching(function(f) { return f.type !== 'category' });
        triggerSearch(query, sortOrder, maxrecs, perpage, limit, targets, torusquery);
        switchView('records'); // In case it's configured to start off as hidden
        m_submitted = true;
@@ -261,7 +263,6 @@ function team($, teamName) {
        resetPage();
        queue("navi").publish();
 
-
        // Continue to use previous query/sort-order unless new ones are specified
        if (query) m_query = query;
        if (sortOrder) m_sortOrder = sortOrder;
@@ -270,6 +271,10 @@ function team($, teamName) {
 
        var pp2filter = m_filterSet.pp2filter();
        var pp2limit = m_filterSet.pp2limit(limit);
+        var pp2catLimit = m_filterSet.pp2catLimit();
+       if (pp2catLimit) {
+            pp2filter = pp2filter ? pp2filter + "," + pp2catLimit : pp2catLimit;
+        }
 
        var params = {};
        if (pp2limit) params.limit = pp2limit;