Add boolean target_filtered() function.
authorMike Taylor <mike@indexdata.com>
Wed, 12 Feb 2014 16:19:47 +0000 (16:19 +0000)
committerMike Taylor <mike@indexdata.com>
Wed, 12 Feb 2014 16:20:04 +0000 (16:20 +0000)
When true, no facet action is generated.
Fixes bug MKWS-111.

tools/htdocs/mkws.js

index 2abcfca..7b6041e 100644 (file)
@@ -329,11 +329,13 @@ function team($, teamName) {
        for (var i = 0; i < data.length && i < max; i++) {
            acc.push('<div class="term">');
             acc.push('<a href="#" ');
-           var action;
+           var action = '';
            if (!pzIndex) {
                // Special case: target selection
                acc.push('target_id='+data[i].id+' ');
-               action = 'mkws.limitTarget(\'' + m_teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
+               if (!target_filtered(data[i].id)) {
+                   action = 'mkws.limitTarget(\'' + m_teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
+               }
            } else {
                action = 'mkws.limitQuery(\'' + m_teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
            }
@@ -345,6 +347,18 @@ function team($, teamName) {
     }
 
 
+    function target_filtered(id) {
+       debug("target_filtered(" + id + ")");
+       for (var i = 0; i < m_filters.length; i++) {
+           if (m_filters[i].id === id ||
+               m_filters[i].id === 'pz:id=' + id) {
+               return true;
+           }
+       }
+       return false;
+    }
+
+
     function my_onrecord(data, args, teamName) {
        debug("record: teamName=" + teamName + ", m_teamName=" + m_teamName);
        // FIXME: record is async!!