Make cell-click filter in table viz optional (#1762)

* Make cell-click filter in table viz optional
 - Added table_filter checkbox in table viz
 - If set to false, clicking on a cell in table will not apply filter to
   dashboard

* Fix codeclimate issue

* Change default to false
This commit is contained in:
vera-liu 2016-12-05 17:17:31 -08:00 committed by GitHub
parent 69702e3a19
commit 43f2a379a1
4 changed files with 16 additions and 3 deletions

View File

@ -264,7 +264,7 @@ export const visTypes = {
['table_timestamp_format'], ['table_timestamp_format'],
['row_limit'], ['row_limit'],
['page_length'], ['page_length'],
['include_search'], ['include_search', 'table_filter'],
], ],
}, },
], ],
@ -1462,6 +1462,13 @@ export const fields = {
description: 'Whether to include a client side search box', description: 'Whether to include a client side search box',
}, },
table_filter: {
type: 'CheckboxField',
label: 'Table Filter',
default: false,
description: 'Whether to apply filter when table cell is clicked',
},
show_bubbles: { show_bubbles: {
type: 'CheckboxField', type: 'CheckboxField',
label: 'Show Bubbles', label: 'Show Bubbles',

View File

@ -106,7 +106,7 @@ function tableVis(slice) {
return (d.isMetric) ? d.val : null; return (d.isMetric) ? d.val : null;
}) })
.on('click', function (d) { .on('click', function (d) {
if (!d.isMetric) { if (!d.isMetric && fd.table_filter) {
const td = d3.select(this); const td = d3.select(this);
if (td.classed('filtered')) { if (td.classed('filtered')) {
slice.removeFilter(d.col, [d.val]); slice.removeFilter(d.col, [d.val]);

View File

@ -784,6 +784,12 @@ class FormFactory(object):
"description": _( "description": _(
"Whether to include a client side search box") "Whether to include a client side search box")
}), }),
'table_filter': (BetterBooleanField, {
"label": _("Table Filter"),
"default": False,
"description": _(
"Whether to apply filter when table cell is clicked")
}),
'show_bubbles': (BetterBooleanField, { 'show_bubbles': (BetterBooleanField, {
"label": _("Show Bubbles"), "label": _("Show Bubbles"),
"default": False, "default": False,

View File

@ -421,7 +421,7 @@ class TableViz(BaseViz):
'table_timestamp_format', 'table_timestamp_format',
'row_limit', 'row_limit',
'page_length', 'page_length',
('include_search', None), ('include_search', 'table_filter'),
) )
}) })
form_overrides = ({ form_overrides = ({