@cdc/dashboard 4.25.3 → 4.25.6-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dynamic_Data.md +79 -0
- package/Override_Data.md +39 -0
- package/dist/cdcdashboard.js +76052 -77984
- package/examples/legend-issue-data.json +1874 -0
- package/examples/legend-issue.json +749 -0
- package/examples/map.json +628 -0
- package/examples/special-classes.json +54340 -0
- package/index.html +1 -26
- package/package.json +10 -15
- package/src/CdcDashboardComponent.tsx +65 -216
- package/src/_stories/Dashboard.stories.tsx +2 -0
- package/src/_stories/_mock/api-filter-map.json +43 -1
- package/src/components/CollapsibleVisualizationRow.tsx +4 -6
- package/src/components/DashboardEditors.tsx +143 -0
- package/src/components/DashboardFilters/DashboardFilters.tsx +205 -205
- package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +286 -287
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/APIModal.tsx +129 -0
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +680 -652
- package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +198 -198
- package/src/components/DataDesignerModal.tsx +33 -14
- package/src/components/Header/Header.tsx +7 -9
- package/src/components/MultiConfigTabs/multiconfigtabs.styles.css +3 -0
- package/src/components/Row.tsx +2 -24
- package/src/components/VisualizationRow.tsx +191 -214
- package/src/helpers/getVizConfig.ts +93 -80
- package/src/helpers/getVizRowColumnLocator.ts +0 -1
- package/src/helpers/reloadURLHelpers.ts +11 -6
- package/src/helpers/shouldLoadAllFilters.ts +30 -30
- package/src/index.tsx +2 -1
- package/src/scss/main.scss +0 -5
- package/src/store/dashboard.actions.ts +61 -62
- package/src/store/dashboard.reducer.ts +15 -11
- package/src/types/ConfigRow.ts +0 -1
- package/src/types/Dashboard.ts +1 -1
- package/src/types/DashboardConfig.ts +1 -1
- package/src/types/SharedFilter.ts +2 -0
- package/examples/private/DEV-10120.json +0 -1294
- package/examples/private/DEV-10527.json +0 -845
- package/examples/private/DEV-10586.json +0 -54319
- package/examples/private/DEV-10856.json +0 -54319
- package/examples/private/DEV-9199.json +0 -606
- package/examples/private/DEV-9644.json +0 -20092
- package/examples/private/DEV-9684.json +0 -2135
- package/examples/private/DEV-9932.json +0 -95
- package/examples/private/DEV-9989.json +0 -229
- package/examples/private/art-dashboard.json +0 -18174
- package/examples/private/art-scratch.json +0 -2406
- package/examples/private/bird-flu-2.json +0 -440
- package/examples/private/bird-flu.json +0 -413
- package/examples/private/dashboard-config-ehdi.json +0 -29915
- package/examples/private/dashboard-map-filter.json +0 -815
- package/examples/private/dashboard-margins.js +0 -15
- package/examples/private/dataset.json +0 -1452
- package/examples/private/dev-10856-2.json +0 -1348
- package/examples/private/ehdi-data.json +0 -29502
- package/examples/private/exposure-source-h5-data.csv +0 -26
- package/examples/private/fatal-data.csv +0 -3159
- package/examples/private/feelings.json +0 -1
- package/examples/private/gaza-issue.json +0 -1214
- package/examples/private/markup.json +0 -115
- package/examples/private/nhis.json +0 -1792
- package/examples/private/workforce.json +0 -2041
- package/src/types/DataSet.ts +0 -11
|
@@ -1,80 +1,93 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { MultiDashboardConfig } from '../types/MultiDashboard'
|
|
3
|
-
import DataTransform from '@cdc/core/helpers/DataTransform'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import { MultiDashboardConfig } from '../types/MultiDashboard'
|
|
3
|
+
import DataTransform from '@cdc/core/helpers/DataTransform'
|
|
4
|
+
import { filterData } from './filterData'
|
|
5
|
+
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
6
|
+
|
|
7
|
+
const transform = new DataTransform()
|
|
8
|
+
|
|
9
|
+
export const getFootnotesVizConfig = (vizConfig: AnyVisualization, config: MultiDashboardConfig) => {
|
|
10
|
+
if (!vizConfig?.footnotes) return vizConfig
|
|
11
|
+
|
|
12
|
+
const data = config.datasets[vizConfig.footnotes.dataKey]?.data ?? []
|
|
13
|
+
|
|
14
|
+
const filters = config?.dashboard?.sharedFilters
|
|
15
|
+
if (filters.length === 0) return vizConfig
|
|
16
|
+
vizConfig.footnotes.data = filters.length ? filterData(filters, data) : data
|
|
17
|
+
|
|
18
|
+
return vizConfig
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const getVizConfig = (
|
|
22
|
+
visualizationKey: string,
|
|
23
|
+
rowNumber: number,
|
|
24
|
+
config: MultiDashboardConfig,
|
|
25
|
+
data: Object,
|
|
26
|
+
filteredData?: Object,
|
|
27
|
+
filteredDataOverride?: Object[],
|
|
28
|
+
multiVizColumn?: string
|
|
29
|
+
): AnyVisualization => {
|
|
30
|
+
if (rowNumber === undefined) return {} as AnyVisualization
|
|
31
|
+
const visualizationConfig = _.cloneDeep(config.visualizations[visualizationKey])
|
|
32
|
+
const rowData = config.rows[rowNumber]
|
|
33
|
+
if (visualizationConfig.footnotes?.dataKey) {
|
|
34
|
+
visualizationConfig.footnotes.data = config.datasets[visualizationConfig.footnotes.dataKey]?.data
|
|
35
|
+
}
|
|
36
|
+
if (rowData?.dataKey) {
|
|
37
|
+
// data configured on the row
|
|
38
|
+
Object.assign(visualizationConfig, _.pick(rowData, ['dataKey', 'dataDescription', 'formattedData', 'data']))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (visualizationConfig.table && config.dashboard.sharedFilters.length) {
|
|
42
|
+
// Download CSV button needs to know to include shared filter columns
|
|
43
|
+
const sharedFilterColumns = config.dashboard.sharedFilters.reduce((acc, filter) => {
|
|
44
|
+
if (!filter.usedBy?.length || filter.usedBy?.includes(visualizationKey)) {
|
|
45
|
+
const apiFilter = filter.apiFilter
|
|
46
|
+
const colName = apiFilter?.textSelector || apiFilter?.valueSelector || filter.columnName
|
|
47
|
+
acc.push(colName)
|
|
48
|
+
const subGrouping =
|
|
49
|
+
apiFilter?.subgroupTextSelector || apiFilter?.subgroupValueSelector || filter.subGrouping?.columnName
|
|
50
|
+
if (subGrouping) {
|
|
51
|
+
acc.push(subGrouping)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return acc
|
|
55
|
+
}, [])
|
|
56
|
+
visualizationConfig.table.sharedFilterColumns = sharedFilterColumns
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (visualizationConfig.formattedData) visualizationConfig.originalFormattedData = visualizationConfig.formattedData
|
|
60
|
+
const filteredVizData = filteredData?.[rowNumber] ?? filteredData?.[visualizationKey]
|
|
61
|
+
|
|
62
|
+
if (filteredVizData) {
|
|
63
|
+
visualizationConfig.data = filteredVizData || []
|
|
64
|
+
if (visualizationConfig.formattedData) {
|
|
65
|
+
visualizationConfig.formattedData = visualizationConfig.data
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
const dataKey = visualizationConfig.dataKey || 'backwards-compatibility'
|
|
69
|
+
visualizationConfig.data = data[dataKey] || []
|
|
70
|
+
if (visualizationConfig.formattedData) {
|
|
71
|
+
visualizationConfig.formattedData =
|
|
72
|
+
transform.developerStandardize(visualizationConfig.data, visualizationConfig.dataDescription) ||
|
|
73
|
+
visualizationConfig.data
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (filteredDataOverride) {
|
|
78
|
+
visualizationConfig.data = filteredDataOverride
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (visualizationConfig.footnotes) {
|
|
82
|
+
const visConfigWithFootnotes = getFootnotesVizConfig(visualizationConfig, config)
|
|
83
|
+
if (multiVizColumn && filteredDataOverride) {
|
|
84
|
+
const vizCategory = filteredDataOverride[0][multiVizColumn]
|
|
85
|
+
// the multiViz filtering filtering is applied after the dashboard filters
|
|
86
|
+
const categoryFootnote = visConfigWithFootnotes.footnotes.data.filter(d => d[multiVizColumn] === vizCategory)
|
|
87
|
+
visConfigWithFootnotes.footnotes.data = categoryFootnote
|
|
88
|
+
}
|
|
89
|
+
return visConfigWithFootnotes
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return visualizationConfig as AnyVisualization
|
|
93
|
+
}
|
|
@@ -6,6 +6,5 @@ export const getVizRowColumnLocator = (rows: ConfigRow[]): Record<string, { row:
|
|
|
6
6
|
curr.columns?.forEach((column, columnIndex) => {
|
|
7
7
|
if (column.widget !== undefined) acc[column.widget] = { row: index, column: columnIndex }
|
|
8
8
|
})
|
|
9
|
-
if (curr.footnotesId) acc[curr.footnotesId] = { row: index, column: 0 }
|
|
10
9
|
return acc
|
|
11
10
|
}, {})
|
|
@@ -5,6 +5,7 @@ import { AnyVisualization, Visualization } from '@cdc/core/types/Visualization'
|
|
|
5
5
|
import _ from 'lodash'
|
|
6
6
|
import { DashboardConfig } from '../types/DashboardConfig'
|
|
7
7
|
import { ConfigRow } from '../types/ConfigRow'
|
|
8
|
+
import { getVizRowColumnLocator } from './getVizRowColumnLocator'
|
|
8
9
|
|
|
9
10
|
export const isUpdateNeeded = (
|
|
10
11
|
filters: SharedFilter[],
|
|
@@ -30,8 +31,11 @@ type GetDatasetKeysParams = Pick<DashboardConfig, 'visualizations' | 'datasets'
|
|
|
30
31
|
export const getDatasetKeys = ({ visualizations, datasets, rows }: GetDatasetKeysParams): string[] => {
|
|
31
32
|
const vizDataKeys = Object.values(visualizations).map(viz => viz.dataKey)
|
|
32
33
|
const rowDataKeys = rows.map(row => row.dataKey)
|
|
34
|
+
const footnoteDataKeys = Object.values(visualizations)
|
|
35
|
+
.map(viz => viz.footnotes?.dataKey)
|
|
36
|
+
.filter(Boolean)
|
|
33
37
|
// ensure to only load datasets for the specific dashboard tab.
|
|
34
|
-
const datasetsUsedByDashboard = _.uniq([...vizDataKeys, ...rowDataKeys])
|
|
38
|
+
const datasetsUsedByDashboard = _.uniq([...vizDataKeys, ...rowDataKeys, ...footnoteDataKeys])
|
|
35
39
|
return Object.keys(datasets).filter(datasetKey => datasetsUsedByDashboard.includes(datasetKey))
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -110,10 +114,11 @@ export const filterUsedByDataUrl = (
|
|
|
110
114
|
) => {
|
|
111
115
|
if (!filter.usedBy || !filter.usedBy.length) return true
|
|
112
116
|
const vizUsingFilters = filter.usedBy?.map(vizOrRowKey => visualizations[vizOrRowKey] || rows[vizOrRowKey])
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
|
|
118
|
+
return vizUsingFilters?.some(viz => {
|
|
119
|
+
const usedByViz = viz?.dataKey === datasetKey
|
|
120
|
+
// datasetKey might be a key to a dynamic footnotes URL
|
|
121
|
+
const usedByVizFootnote = viz?.footnotes?.dataKey === datasetKey
|
|
122
|
+
return usedByViz || usedByVizFootnote
|
|
117
123
|
})
|
|
118
|
-
return vizUsingFilters?.some(viz => viz?.dataKey === datasetKey)
|
|
119
124
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { getQueryParam } from '@cdc/core/helpers/queryStringUtils'
|
|
2
|
-
import { Visualization } from '@cdc/core/types/Visualization'
|
|
3
|
-
|
|
4
|
-
export const shouldLoadAllFilters = (config, isEditorPanel): boolean => {
|
|
5
|
-
const autoLoad = Boolean(getQueryParam('cove-auto-load'))
|
|
6
|
-
const activeConfig = config.multiDashboards ? config.multiDashboards[config.activeDashboard] : config
|
|
7
|
-
const hasFilterByFileNameFunctionality = activeConfig.dashboard.sharedFilters?.some(
|
|
8
|
-
filter => filter.filterBy === 'File Name'
|
|
9
|
-
)
|
|
10
|
-
const isAutoLoadTab = Object.values(activeConfig.visualizations).reduce((acc, viz: Visualization) => {
|
|
11
|
-
if (acc === false) return acc
|
|
12
|
-
if (viz.visualizationType === 'dashboardFilters') {
|
|
13
|
-
if (viz.filterBehavior === 'Apply Button') return false
|
|
14
|
-
if (viz.autoLoad) {
|
|
15
|
-
return true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return acc
|
|
19
|
-
}, undefined)
|
|
20
|
-
if (autoLoad || isAutoLoadTab || hasFilterByFileNameFunctionality || isEditorPanel) {
|
|
21
|
-
const rowDataSetKeys = activeConfig.rows.map(row => row.dataKey).filter(Boolean)
|
|
22
|
-
const dataKeys = Object.values(activeConfig.visualizations)
|
|
23
|
-
.map((visualization: Visualization) => visualization.dataKey)
|
|
24
|
-
.filter(Boolean)
|
|
25
|
-
.concat(rowDataSetKeys)
|
|
26
|
-
const missingData = dataKeys.find(dataset => !config.datasets[dataset]
|
|
27
|
-
return Boolean(missingData)
|
|
28
|
-
}
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
1
|
+
import { getQueryParam } from '@cdc/core/helpers/queryStringUtils'
|
|
2
|
+
import { Visualization } from '@cdc/core/types/Visualization'
|
|
3
|
+
|
|
4
|
+
export const shouldLoadAllFilters = (config, isEditorPanel): boolean => {
|
|
5
|
+
const autoLoad = Boolean(getQueryParam('cove-auto-load'))
|
|
6
|
+
const activeConfig = config.multiDashboards ? config.multiDashboards[config.activeDashboard] : config
|
|
7
|
+
const hasFilterByFileNameFunctionality = activeConfig.dashboard.sharedFilters?.some(
|
|
8
|
+
filter => filter.filterBy === 'File Name'
|
|
9
|
+
)
|
|
10
|
+
const isAutoLoadTab = Object.values(activeConfig.visualizations).reduce((acc, viz: Visualization) => {
|
|
11
|
+
if (acc === false) return acc
|
|
12
|
+
if (viz.visualizationType === 'dashboardFilters') {
|
|
13
|
+
if (viz.filterBehavior === 'Apply Button') return false
|
|
14
|
+
if (viz.autoLoad) {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return acc
|
|
19
|
+
}, undefined)
|
|
20
|
+
if (autoLoad || isAutoLoadTab || hasFilterByFileNameFunctionality || isEditorPanel) {
|
|
21
|
+
const rowDataSetKeys = activeConfig.rows.map(row => row.dataKey).filter(Boolean)
|
|
22
|
+
const dataKeys = Object.values(activeConfig.visualizations)
|
|
23
|
+
.map((visualization: Visualization) => visualization.dataKey)
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.concat(rowDataSetKeys)
|
|
26
|
+
const missingData = dataKeys.find(dataset => !config.datasets[dataset]?.data?.length)
|
|
27
|
+
return Boolean(missingData)
|
|
28
|
+
}
|
|
29
|
+
return false
|
|
30
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import ReactDOM from 'react-dom/client'
|
|
3
3
|
|
|
4
|
-
import MultiDashboardWrapper from './CdcDashboard'
|
|
5
4
|
import '@cdc/core/styles/cove-main.scss'
|
|
6
5
|
import './coreStyles_dashboard.scss'
|
|
7
6
|
|
|
7
|
+
import MultiDashboardWrapper from './CdcDashboard'
|
|
8
|
+
|
|
8
9
|
let isEditor = window.location.href.includes('editor=true')
|
|
9
10
|
let isDebug = window.location.href.includes('debug=true')
|
|
10
11
|
|
package/src/scss/main.scss
CHANGED
|
@@ -1,62 +1,61 @@
|
|
|
1
|
-
import type { DashboardConfig as Config } from '../types/DashboardConfig'
|
|
2
|
-
import { type Action } from '@cdc/core/types/Action'
|
|
3
|
-
import { Tab } from '../types/Tab'
|
|
4
|
-
import { ConfigRow } from '../types/ConfigRow'
|
|
5
|
-
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
>
|
|
17
|
-
type
|
|
18
|
-
type
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
type
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
export default DashboardActions
|
|
1
|
+
import type { DashboardConfig as Config } from '../types/DashboardConfig'
|
|
2
|
+
import { type Action } from '@cdc/core/types/Action'
|
|
3
|
+
import { Tab } from '../types/Tab'
|
|
4
|
+
import { ConfigRow } from '../types/ConfigRow'
|
|
5
|
+
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
6
|
+
import { SharedFilter } from '../types/SharedFilter'
|
|
7
|
+
|
|
8
|
+
type ADD_VISUALIZATION = Action<'ADD_VISUALIZATION', { rowIdx: number; colIdx: number; newViz: AnyVisualization }>
|
|
9
|
+
type APPLY_CONFIG = Action<'APPLY_CONFIG', [Config, Object?]>
|
|
10
|
+
type DELETE_WIDGET = Action<'DELETE_WIDGET', { uid: string }>
|
|
11
|
+
type MOVE_VISUALIZATION = Action<
|
|
12
|
+
'MOVE_VISUALIZATION',
|
|
13
|
+
{ rowIdx: number; colIdx: number; widget: AnyVisualization & { rowIdx: number; colIdx: number } }
|
|
14
|
+
>
|
|
15
|
+
type SET_CONFIG = Action<'SET_CONFIG', Partial<Config> & { activeDashboard?: number }>
|
|
16
|
+
type UPDATE_CONFIG = Action<'UPDATE_CONFIG', [Config, Object?]>
|
|
17
|
+
type SET_DATA = Action<'SET_DATA', Record<string, any[]>>
|
|
18
|
+
type SET_LOADING = Action<'SET_LOADING', boolean>
|
|
19
|
+
type SET_PREVIEW = Action<'SET_PREVIEW', boolean>
|
|
20
|
+
type SET_FILTERED_DATA = Action<'SET_FILTERED_DATA', Object>
|
|
21
|
+
type SET_SHARED_FILTERS = Action<'SET_SHARED_FILTERS', SharedFilter[]>
|
|
22
|
+
type SET_TAB_SELECTED = Action<'SET_TAB_SELECTED', Tab>
|
|
23
|
+
type RENAME_DASHBOARD_TAB = Action<'RENAME_DASHBOARD_TAB', { current: string; new: string }>
|
|
24
|
+
type INITIALIZE_MULTIDASHBOARDS = Action<'INITIALIZE_MULTIDASHBOARDS', undefined>
|
|
25
|
+
type REMOVE_MULTIDASHBOARD_AT_INDEX = Action<'REMOVE_MULTIDASHBOARD_AT_INDEX', number>
|
|
26
|
+
type REORDER_MULTIDASHBOARDS = Action<'REORDER_MULTIDASHBOARDS', { currentIndex: number; newIndex: number }>
|
|
27
|
+
type ADD_NEW_DASHBOARD = Action<'ADD_NEW_DASHBOARD', undefined>
|
|
28
|
+
type SAVE_CURRENT_CHANGES = Action<'SAVE_CURRENT_CHANGES', undefined>
|
|
29
|
+
type SWITCH_CONFIG = Action<'SWITCH_CONFIG', number>
|
|
30
|
+
type TOGGLE_ROW = Action<'TOGGLE_ROW', { rowIndex: number; colIndex: number }>
|
|
31
|
+
type RESET_VISUALIZATION = Action<'RESET_VISUALIZATION', { vizKey: string }>
|
|
32
|
+
type UPDATE_VISUALIZATION = Action<'UPDATE_VISUALIZATION', { vizKey: string; configureData: Partial<AnyVisualization> }>
|
|
33
|
+
type UPDATE_ROW = Action<'UPDATE_ROW', { rowIndex: number; rowData: Partial<ConfigRow> }>
|
|
34
|
+
type UPDATE_TOGGLE_NAME = Action<'UPDATE_TOGGLE_NAME', { rowIndex: number; columnIndex: number; toggleName: string }>
|
|
35
|
+
|
|
36
|
+
type DashboardActions =
|
|
37
|
+
| ADD_VISUALIZATION
|
|
38
|
+
| APPLY_CONFIG
|
|
39
|
+
| ADD_NEW_DASHBOARD
|
|
40
|
+
| DELETE_WIDGET
|
|
41
|
+
| MOVE_VISUALIZATION
|
|
42
|
+
| SET_CONFIG
|
|
43
|
+
| UPDATE_CONFIG
|
|
44
|
+
| REMOVE_MULTIDASHBOARD_AT_INDEX
|
|
45
|
+
| RENAME_DASHBOARD_TAB
|
|
46
|
+
| REORDER_MULTIDASHBOARDS
|
|
47
|
+
| SAVE_CURRENT_CHANGES
|
|
48
|
+
| SET_DATA
|
|
49
|
+
| SET_LOADING
|
|
50
|
+
| SET_PREVIEW
|
|
51
|
+
| SET_FILTERED_DATA
|
|
52
|
+
| SET_SHARED_FILTERS
|
|
53
|
+
| SET_TAB_SELECTED
|
|
54
|
+
| SWITCH_CONFIG
|
|
55
|
+
| INITIALIZE_MULTIDASHBOARDS
|
|
56
|
+
| TOGGLE_ROW
|
|
57
|
+
| RESET_VISUALIZATION
|
|
58
|
+
| UPDATE_VISUALIZATION
|
|
59
|
+
| UPDATE_ROW
|
|
60
|
+
| UPDATE_TOGGLE_NAME
|
|
61
|
+
export default DashboardActions
|
|
@@ -39,17 +39,6 @@ export type DashboardState = {
|
|
|
39
39
|
|
|
40
40
|
const reducer = (state: DashboardState, action: DashboardActions): DashboardState => {
|
|
41
41
|
switch (action.type) {
|
|
42
|
-
case 'ADD_FOOTNOTE': {
|
|
43
|
-
const { id, rowIndex, config } = action.payload
|
|
44
|
-
const newRows = state.config.rows.map((row, i) => (i === rowIndex ? { ...row, footnotesId: id } : row))
|
|
45
|
-
return {
|
|
46
|
-
...state,
|
|
47
|
-
config: saveMultiChanges(
|
|
48
|
-
{ ...state.config, rows: newRows, visualizations: { ...state.config.visualizations, [id]: config } },
|
|
49
|
-
state.config.activeDashboard
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
42
|
case 'ADD_NEW_DASHBOARD': {
|
|
54
43
|
const currentMultiDashboards = state.config.multiDashboards
|
|
55
44
|
const label = 'New Dashboard ' + (currentMultiDashboards.length + 1)
|
|
@@ -195,6 +184,21 @@ const reducer = (state: DashboardState, action: DashboardActions): DashboardStat
|
|
|
195
184
|
config: saveMultiChanges({ ...state.config, rows: newRows }, state.config.activeDashboard)
|
|
196
185
|
}
|
|
197
186
|
}
|
|
187
|
+
case 'RESET_VISUALIZATION': {
|
|
188
|
+
const { vizKey } = action.payload
|
|
189
|
+
const updatedViz = { ...state.config.visualizations[vizKey] } as AnyVisualization
|
|
190
|
+
delete updatedViz.data
|
|
191
|
+
delete updatedViz.dataKey
|
|
192
|
+
delete updatedViz.dataDescription
|
|
193
|
+
delete updatedViz.formattedData
|
|
194
|
+
return {
|
|
195
|
+
...state,
|
|
196
|
+
config: saveMultiChanges(
|
|
197
|
+
{ ...state.config, visualizations: { ...state.config.visualizations, [vizKey]: updatedViz } },
|
|
198
|
+
state.config.activeDashboard
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
198
202
|
case 'UPDATE_VISUALIZATION': {
|
|
199
203
|
const { vizKey, configureData } = action.payload
|
|
200
204
|
const updatedViz = { ...state.config.visualizations[vizKey], ...configureData } as AnyVisualization
|
package/src/types/ConfigRow.ts
CHANGED
package/src/types/Dashboard.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Series } from '@cdc/core/types/Series'
|
|
2
2
|
import { Runtime } from '@cdc/core/types/Runtime'
|
|
3
|
-
import { DataSet } from '
|
|
3
|
+
import { DataSet } from '@cdc/core/types/DataSet'
|
|
4
4
|
import { ConfigRow } from './ConfigRow'
|
|
5
5
|
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
6
6
|
import { Table } from '@cdc/core/types/Table'
|
|
@@ -22,6 +22,8 @@ export type SharedFilter = FilterBase & {
|
|
|
22
22
|
datasetKey?: string
|
|
23
23
|
subGrouping: SubGrouping
|
|
24
24
|
tier?: number
|
|
25
|
+
// value to use when the filter loads
|
|
26
|
+
defaultValue?: string
|
|
25
27
|
/**
|
|
26
28
|
* How to format the end file name when filter.filterBy is set to "File Name"
|
|
27
29
|
*
|