Skip to content

Commit

Permalink
Added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogball committed Dec 17, 2017
1 parent 0f6a243 commit 9fff984
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions superset/assets/javascripts/dashboard/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ export const dashboard = function (state = {}, action) {
'__time_grain', '__time_origin', '__granularity'];
if (filterKeys.indexOf(col) >= 0 ||
selectedSlice.formData.groupby.indexOf(col) !== -1) {

let newFilter = {};
if (!(sliceId in filters)) {
newFilter = { [col]: vals }
// Straight up set the filters if none existed for the slice
newFilter = { [col]: vals };
} else if (filters[sliceId] && !(col in filters[sliceId]) || !merge) {
newFilter = { ...filters[sliceId], [col]: vals };
// d3.merge pass in array of arrays while some value form filter components
Expand All @@ -169,9 +169,11 @@ export const dashboard = function (state = {}, action) {
[actions.REMOVE_FILTER]() {
const { sliceId, col, vals, refresh } = action;
const excluded = new Set(vals);
const valFilter = (val) => !excluded.has(val);
const valFilter = val => !excluded.has(val);

let filters = state.filters;
// Have to be careful not to modify the dashboard state so that
// the render actually triggers
if (sliceId in state.filters && col in state.filters[sliceId]) {
const newFilter = filters[sliceId][col].filter(valFilter);
filters = { ...filters, [sliceId]: newFilter };
Expand Down
7 changes: 6 additions & 1 deletion superset/assets/visualizations/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ function tableVis(slice, payload) {
.attr('data-sort', function (d) {
return (d.isMetric) ? d.val : null;
})
.classed('filtered', d => filters && filters[d.col] && filters[d.col].indexOf(d.val) >= 0)
// Check if the dashboard currently has a filter for each row
.classed('filtered', d =>
filters &&
filters[d.col] &&
filters[d.col].indexOf(d.val) >= 0,
)
.on('click', function (d) {
if (!d.isMetric && fd.table_filter) {
const td = d3.select(this);
Expand Down

0 comments on commit 9fff984

Please sign in to comment.