Merge branch '12315-exclude-child-procs'
[arvados.git] / apps / workbench / app / assets / javascripts / filterable.js
index 40df5c7174134986439d7379d1ea889311399091..e571e32db91560388167fed7c0a2725d649f678d 100644 (file)
 // data-example-attr="foo" are shown, and all others are hidden. When
 // the user selects the "Show all" option, all rows are shown.
 //
+// <input type="checkbox" data-on-value="{}" data-off-value="{}" ... />
+//
+// Merges on- or off-value with other params in query. Only works with
+// infinite-scroll.
+//
 // Notes:
 //
 // When multiple filterable-control widgets operate on the same
@@ -92,6 +97,21 @@ $(document).
             updateFilterableQueryNow($(this));
         });
     }).
+    on('change', 'input[type=checkbox].filterable-control', function(e) {
+        if (this != e.target) return;
+        var $target = $($(this).attr('data-filterable-target'));
+        var currentquery = $target.data('filterable-query');
+        if (currentquery === undefined) currentquery = '';
+        if ($target.is('[data-infinite-scroller]')) {
+            var datakey = 'infiniteContentParamsFrom'+this.id;
+            var whichvalue = $(this).is(':checked') ? 'on-value' : 'off-value';
+            if (JSON.stringify($target.data(datakey)) == JSON.stringify($(this).data(whichvalue)))
+                return;
+            $target.data(datakey, $(this).data(whichvalue));
+            updateFilterableQueryNow($target);
+            $target.trigger('refresh-content');
+        }
+    }).
     on('paste keyup input', 'input[type=text].filterable-control', function(e) {
         var regexp;
         if (this != e.target) return;