You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/11/11 09:01:10 UTC

[GitHub] [incubator-superset] graceguo-supercat commented on a change in pull request #8521: [WIP][dashboard scoped filter] part 2: add algorithm to convert checked ids to scope object

graceguo-supercat commented on a change in pull request #8521: [WIP][dashboard scoped filter] part 2: add algorithm to convert checked ids to scope object
URL: https://github.com/apache/incubator-superset/pull/8521#discussion_r344611601
 
 

 ##########
 File path: superset/assets/src/dashboard/components/filterscope/FilterScopeSelector.jsx
 ##########
 @@ -403,100 +418,85 @@ export default class FilterScopeSelector extends React.PureComponent {
   renderFilterScopeTree() {
     const {
       filterScopeMap,
-      activeKey,
-      isSingleEditMode,
+      activeFilterField,
+      checkedFilterFields,
       searchText,
     } = this.state;
 
-    const selectedFilterId = isSingleEditMode
-      ? getChartIdAndColumnFromFilterKey(activeKey).chartId
-      : 0;
+    const key = getKeyForFilterScopeTree({
+      activeFilterField,
+      checkedFilterFields,
+    });
+
+    const selectedChartId = getSelectedChartIdForFilterScopeTree({
+      activeFilterField,
+      checkedFilterFields,
+    });
     return (
       <React.Fragment>
         <input
-          className={cx('filter-text scope-search', {
-            'multi-edit-mode': !isSingleEditMode,
-          })}
+          className="filter-text scope-search multi-edit-mode"
           placeholder={t('Search...')}
           type="text"
           value={searchText}
           onChange={this.onSearchInputChange}
         />
         <FilterScopeTree
-          nodes={filterScopeMap[activeKey].nodesFiltered}
-          checked={filterScopeMap[activeKey].checked}
-          expanded={filterScopeMap[activeKey].expanded}
+          nodes={filterScopeMap[key].nodesFiltered}
+          checked={filterScopeMap[key].checked}
+          expanded={filterScopeMap[key].expanded}
           onCheck={this.onCheckFilterScope}
           onExpand={this.onExpandFilterScope}
           // pass selectedFilterId prop to FilterScopeTree component,
           // to hide checkbox for selected filter field itself
-          selectedFilterId={selectedFilterId}
+          selectedChartId={selectedChartId}
         />
       </React.Fragment>
     );
   }
 
-  renderEditModeControl() {
-    const { isSingleEditMode } = this.state;
-    return (
-      <span
-        role="button"
-        tabIndex="0"
-        className="edit-mode-toggle"
-        onClick={this.onToggleEditMode}
-      >
-        {isSingleEditMode
-          ? t('Edit multiple filters')
-          : t('Edit individual filter')}
-      </span>
-    );
-  }
-
-  render() {
+  renderEditingFiltersName() {
     const { dashboardFilters } = this.props;
-    const { showSelector, isSingleEditMode, activeKey } = this.state;
-    const isSingleValue = activeKey.indexOf('[') === -1;
+    const { activeFilterField, checkedFilterFields } = this.state;
     const currentFilterLabels = []
-      .concat(isSingleValue ? activeKey : JSON.parse(activeKey))
+      .concat(activeFilterField || checkedFilterFields)
       .map(key => {
         const { chartId, column } = getChartIdAndColumnFromFilterKey(key);
         return dashboardFilters[chartId].labels[column] || column;
       });
 
+    return (
+      <div className="selected-fields multi-edit-mode">
+        {currentFilterLabels.length === 0 && t('No filter is selected.')}
+        {currentFilterLabels.length === 1 && t('Editing 1 filter: ')}
 
 Review comment:
   i removed trilling space. The translation function allow simple template: 
   `t('Batch editing %d filters:', currentFilterLabels.length)`
   I fixed it in #8404.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org