This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch feature--dashboard-scoped-filter
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to 
refs/heads/feature--dashboard-scoped-filter by this push:
     new 9b34327  force show filter_box as unchecked (#8587)
9b34327 is described below

commit 9b34327fcbbbdd8d87239f9d9f6df0bb1f06e947
Author: Grace Guo <grace....@airbnb.com>
AuthorDate: Fri Nov 15 14:05:09 2019 -0800

    force show filter_box as unchecked (#8587)
---
 .../components/filterscope/FilterScopeSelector.jsx    | 10 ++++++----
 .../src/dashboard/util/getRevertedFilterScope.js      | 19 +++++++++++++------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git 
a/superset/assets/src/dashboard/components/filterscope/FilterScopeSelector.jsx 
b/superset/assets/src/dashboard/components/filterscope/FilterScopeSelector.jsx
index aeab376..bbf398a 100644
--- 
a/superset/assets/src/dashboard/components/filterscope/FilterScopeSelector.jsx
+++ 
b/superset/assets/src/dashboard/components/filterscope/FilterScopeSelector.jsx
@@ -86,10 +86,12 @@ export default class FilterScopeSelector extends 
React.PureComponent {
                 selectedChartId: filterId,
               });
               const expanded = getFilterScopeParentNodes(nodes, 1);
-              // display filter_box chart as checked, but do not show checkbox
-              const chartIdsInFilterScope = getChartIdsInFilterScope({
-                filterScope: dashboardFilters[filterId].scopes[columnName],
-              });
+              // force display filter_box chart as unchecked, but show 
checkbox as disabled
+              const chartIdsInFilterScope = (
+                getChartIdsInFilterScope({
+                  filterScope: dashboardFilters[filterId].scopes[columnName],
+                }) || []
+              ).filter(id => id !== filterId);
 
               return {
                 ...mapByChartId,
diff --git a/superset/assets/src/dashboard/util/getRevertedFilterScope.js 
b/superset/assets/src/dashboard/util/getRevertedFilterScope.js
index 92e4a29..b31f275 100644
--- a/superset/assets/src/dashboard/util/getRevertedFilterScope.js
+++ b/superset/assets/src/dashboard/util/getRevertedFilterScope.js
@@ -16,6 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { getChartIdAndColumnFromFilterKey } from './getDashboardFilterKey';
+
 export default function getRevertedFilterScope({
   checked = [],
   filterFields = [],
@@ -29,14 +31,19 @@ export default function getRevertedFilterScope({
     };
   }, {});
 
-  return filterFields.reduce(
-    (map, filterField) => ({
+  return filterFields.reduce((map, filterField) => {
+    const { chartId } = getChartIdAndColumnFromFilterKey(filterField);
+    // force display filter_box chart as unchecked, but show checkbox as 
disabled
+    const updatedCheckedIds = (
+      checkedChartIdsByFilterField[filterField] || []
+    ).filter(id => id !== chartId);
+
+    return {
       ...map,
       [filterField]: {
         ...filterScopeMap[filterField],
-        checked: checkedChartIdsByFilterField[filterField],
+        checked: updatedCheckedIds,
       },
-    }),
-    {},
-  );
+    };
+  }, {});
 }

Reply via email to