Skip to content

Commit

Permalink
Merge pull request edp963#1991 from ruanhan/dev-0.3
Browse files Browse the repository at this point in the history
 feat(drill) support drill need not filters
  • Loading branch information
scottsut authored Oct 29, 2020
2 parents d0a080b + 7310be2 commit 3bcece3
Show file tree
Hide file tree
Showing 8 changed files with 1,515 additions and 798 deletions.
32 changes: 25 additions & 7 deletions webapp/app/components/DataDrill/EnhancerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,45 @@ import utilStyles from 'app/assets/less/util.less'
import styles from './datadrill.less'
import { IDataDrillProps, IEnhancerPanel } from './types'
import DataDrill from './Panel'
import {
DrillableChart,
DrillableChartNeedNotFilter
} from 'containers/Widget/config/chart/DrillableChart'

function enhancePanel<T>() {
return (WrapperComponent) => {
class EnhancerPanel extends React.PureComponent<T & IEnhancerPanel, {}> {
private isDrillableChart() {
const { chartStyle } = this.props
return DrillableChart.some((drillable) => drillable === chartStyle)
}
private isDrillableChartNeedNotFilter() {
const { chartStyle } = this.props
return DrillableChartNeedNotFilter.some(
(drillable) => drillable === chartStyle
)
}
private hide() {
let isHide = true
const {
isSelectedGroup,
isDrillableChart,
isSelectedfilter
} = this.props
const { isSelectedGroup, isSelectedfilter } = this.props
const isDrillableChart = this.isDrillableChart()
const isDrillableChartNeedNotFilter = this.isDrillableChartNeedNotFilter()
if (!isDrillableChart) {
isHide = true
return isHide
}

if (isSelectedfilter) {
if (!(isSelectedfilter && isSelectedfilter.length === 0)) {
isHide = false
return isHide
}

if (!(isSelectedGroup && isSelectedGroup.length === 0)) {
isHide = false
return isHide
}

if (isSelectedGroup) {
if (isDrillableChartNeedNotFilter) {
isHide = false
return isHide
}
Expand All @@ -57,6 +74,7 @@ function enhancePanel<T>() {
[styles.dataDrillPanel]: true,
[utilStyles.hide]: this.hide()
})

return (
<div className={dataDrillPanelClass}>
<WrapperComponent {...this.props} />
Expand Down
3 changes: 3 additions & 0 deletions webapp/app/components/DataDrill/strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ function collectKeyValue(sourceDataFilter) {
}

function mappingFilters(sourceDataFilter, group): IFilter[] {
if (!(sourceDataFilter && sourceDataFilter.length)) {
return []
}
const mappgingSource = sourceDataFilter.map((source) =>
source && source[group] ? source[group] : source
)
Expand Down
7 changes: 3 additions & 4 deletions webapp/app/components/DataDrill/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export interface ISourceDataFilter {
value: string
}


export interface IDataDrillProps {
widgetConfig: IWidgetConfig
drillHistory?: IDrillDetail[]
Expand All @@ -136,7 +135,7 @@ export interface IDataDrillProps {
}

export interface IEnhancerPanel {
isDrillableChart: boolean
isSelectedfilter: boolean | object []
isSelectedGroup: boolean | string[]
isSelectedfilter: object[]
isSelectedGroup: string[]
chartStyle: number
}
Loading

0 comments on commit 3bcece3

Please sign in to comment.