team.filters returns the filterSet object, not its list.
[mkws-moved-to-github.git] / src / mkws-team.js
index 72d2d96..2bf3bcb 100644 (file)
@@ -40,7 +40,7 @@ function team($, teamName) {
     that.currentPage = function() { return m_currentPage; };
     that.currentRecordId = function() { return m_currentRecordId; };
     that.currentRecordData = function() { return m_currentRecordData; };
-    that.filters = function() { return m_filterSet.list(); };
+    that.filters = function() { return m_filterSet; };
     that.config = function() { return m_config; };
 
     // Accessor methods for individual widgets: writers
@@ -260,40 +260,19 @@ function team($, teamName) {
        resetPage();
        queue("navi").publish();
 
-       var pp2filter = "";
-       var pp2limit = limit || "";
 
        // Continue to use previous query/sort-order unless new ones are specified
-       if (query) {
-           m_query = query;
-       }
-       if (sortOrder) {
-           m_sortOrder = sortOrder;
-       }
-       if (perpage) {
-           m_perpage = perpage;
-       }
-       if (targets) {
-           m_filterSet.add(filter(id, id));
-       }
+       if (query) m_query = query;
+       if (sortOrder) m_sortOrder = sortOrder;
+       if (perpage) m_perpage = perpage;
+       if (targets) m_filterSet.add(filter(id, id));
 
-       pp2filter = m_filterSet.pp2filter();
-       for (var i in m_filterSet.list()) {
-           var filter = m_filterSet.list()[i];
-           if (!filter.id) {
-               if (pp2limit)
-                   pp2limit += ",";
-               pp2limit += filter.field + "=" + filter.value.replace(/[\\|,]/g, '\\$&');
-           }
-       }
+       var pp2filter = m_filterSet.pp2filter();
+       var pp2limit = m_filterSet.pp2limit(limit);
 
        var params = {};
-       if (pp2limit) {
-           params.limit = pp2limit;
-       }
-       if (maxrecs) {
-           params.maxrecs = maxrecs;
-       }
+       if (pp2limit) params.limit = pp2limit;
+       if (maxrecs) params.maxrecs = maxrecs;
        if (torusquery) {
            if (!mkws.config.use_service_proxy)
                alert("can't narrow search by torusquery when Service Proxy is not in use");
@@ -303,8 +282,6 @@ function team($, teamName) {
        log("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filterSet.list()) + ", " +
            "pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
 
-       // We can use: params.torusquery = "udb=NAME"
-       // Note: that won't work when running against raw pazpar2
        m_paz.search(m_query, m_perpage, m_sortOrder, pp2filter, undefined, params);
     }