Skip to content

Commit

Permalink
Merge pull request #41 from edp963/dev-0.3
Browse files Browse the repository at this point in the history
merge from edp963/davinci dev-0.3
  • Loading branch information
xxxllluuu authored Oct 29, 2020
2 parents 4272405 + 567412d commit 1e8bc49
Show file tree
Hide file tree
Showing 12 changed files with 1,529 additions and 808 deletions.
2 changes: 1 addition & 1 deletion webapp/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import zh_CN from 'antd/es/locale/zh_CN'
import LanguageProvider from 'containers/LanguageProvider'
import { translationMessages } from './i18n'
import moment from 'moment'
import 'moment/src/locale/zh-cn'
import 'moment/dist/locale/zh-cn'
moment.locale('zh-cn')

import '!file-loader?name=[name].[ext]!./favicon.ico'
Expand Down
19 changes: 11 additions & 8 deletions webapp/app/components/Control/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function getVariableParams(
case ControlTypes.NumberRange:
case ControlTypes.Slider:
params = value.reduce((arr, val, index) => {
if (val !== '' && !isNaN(val)) {
if (fieldsVariables[index] && val !== '' && !isNaN(val)) {
const { name, valueType } = fieldsVariables[index]
return arr.concat({
name,
Expand Down Expand Up @@ -183,13 +183,16 @@ export function getVariableParams(
break
case ControlTypes.DateRange:
if (value.length) {
params = value.map((v, index) => {
const { name } = fieldsVariables[index]
return {
name,
value: `'${moment(v).format(dateFormat)}'`
}
})
params = value
.map((v, index) => {
return fieldsVariables[index]
? {
name: fieldsVariables[index].name,
value: `'${moment(v).format(dateFormat)}'`
}
: null
})
.filter((p) => p)
}
break
default:
Expand Down
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 1e8bc49

Please sign in to comment.