-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature dev-8490 dashboard filter refactor
- Loading branch information
Showing
35 changed files
with
995 additions
and
907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
packages/core/components/Layout/components/Visualization/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,71 @@ | ||
import _ from 'lodash' | ||
|
||
const mapUpdates = newConfig => { | ||
// When switching between old version of equal number, and the revised equal number opt in, roundToPlace needs to be set. | ||
// There wasn't an initial value set for this, and legends would return NaN if it wasn't set. ie. 0 - NAN instead of 0 - 1 | ||
const equalNumberRoundingPatch = newConfig => { | ||
if (newConfig.type === 'map') { | ||
if (newConfig.columns.primary.roundToPlace === undefined) { | ||
newConfig.columns.primary.roundToPlace = 0 | ||
} | ||
} | ||
} | ||
|
||
equalNumberRoundingPatch(newConfig) | ||
|
||
return newConfig | ||
} | ||
|
||
const update_4_24_7 = config => { | ||
const ver = '4.24.7' | ||
|
||
const newConfig = _.cloneDeep(config) | ||
|
||
mapUpdates(newConfig) | ||
newConfig.version = ver | ||
return newConfig | ||
} | ||
export default update_4_24_7 | ||
import _ from 'lodash' | ||
import { DashboardFilters } from '@cdc/dashboard/src/types/DashboardFilters' | ||
import { MultiDashboardConfig } from '@cdc/dashboard/src/types/MultiDashboard' | ||
|
||
const dashboardFiltersMigrate = config => { | ||
if (!config.dashboard) return config | ||
const dashboardConfig = config as MultiDashboardConfig | ||
const newVisualizations = {} | ||
// autoload was removed from APIFilter type | ||
const newSharedFilters = (dashboardConfig.dashboard.sharedFilters || []).map(sf => { | ||
if (sf.apiFilter?.autoLoad !== undefined) { | ||
delete sf.apiFilter.autoLoad | ||
} | ||
if (sf.apiFilter?.defaultValue !== undefined) { | ||
delete sf.apiFilter.defaultValue | ||
} | ||
return sf | ||
}) | ||
config.dashboard.sharedFilters = newSharedFilters | ||
|
||
Object.keys(dashboardConfig.visualizations).forEach(vizKey => { | ||
const viz = dashboardConfig.visualizations[vizKey] as DashboardFilters | ||
// hide was removed from visualizations | ||
if (viz.hide !== undefined) { | ||
viz.sharedFilterIndexes = newSharedFilters.map((_sf, i) => i).filter(i => !viz.hide.includes(i)) | ||
viz.type = 'dashboardFilters' | ||
if (viz.autoLoad) { | ||
viz.filterBehavior = 'Filter Change' | ||
} else { | ||
viz.filterBehavior = 'Apply Button' | ||
} | ||
|
||
delete viz.hide | ||
} | ||
// 'filter-dropdowns' was renamed to 'dashboardFilters' for clarity | ||
if (viz.type === 'filter-dropdowns') viz.type = 'dashboardFilters' | ||
if (viz.visualizationType === 'filter-dropdowns') viz.visualizationType = 'dashboardFilters' | ||
newVisualizations[vizKey] = viz | ||
}) | ||
// if there's no dashboardFilters visualization but there are sharedFilters create a visualization and update rows. | ||
|
||
config.visualizations = newVisualizations | ||
} | ||
|
||
const mapUpdates = newConfig => { | ||
// When switching between old version of equal number, and the revised equal number opt in, roundToPlace needs to be set. | ||
// There wasn't an initial value set for this, and legends would return NaN if it wasn't set. ie. 0 - NAN instead of 0 - 1 | ||
const equalNumberRoundingPatch = newConfig => { | ||
if (newConfig.type === 'map') { | ||
if (newConfig.columns.primary.roundToPlace === undefined) { | ||
newConfig.columns.primary.roundToPlace = 0 | ||
} | ||
} | ||
} | ||
|
||
equalNumberRoundingPatch(newConfig) | ||
|
||
return newConfig | ||
} | ||
|
||
const update_4_24_7 = config => { | ||
const ver = '4.24.7' | ||
|
||
const newConfig = _.cloneDeep(config) | ||
|
||
mapUpdates(newConfig) | ||
dashboardFiltersMigrate(newConfig) | ||
newConfig.version = ver | ||
return newConfig | ||
} | ||
export default update_4_24_7 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.