@cdc/editor 1.4.4 → 9.22.9

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.
@@ -1,4 +1,5 @@
1
- STATE,Rate,Location,URL
1
+ STATE,Rate,Location,URL
2
+ Overall,55,Vehicle,https://www.cdc.gov
2
3
  Alabama,130,Vehicle,https://www.cdc.gov/
3
4
  Alaska,40,Work,https://www.cdc.gov/
4
5
  American Samoa,55,Home,https://www.cdc.gov/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/editor",
3
- "version": "1.4.4",
3
+ "version": "9.22.9",
4
4
  "main": "dist/cdceditor",
5
5
  "bugs": {
6
6
  "url": "https://github.com/CDCgov/cdc-open-viz/issues"
@@ -18,13 +18,13 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.12.5",
21
- "@cdc/chart": "^1.3.4",
22
- "@cdc/core": "^1.1.4",
23
- "@cdc/dashboard": "^1.1.4",
24
- "@cdc/data-bite": "^1.1.4",
25
- "@cdc/map": "^2.6.4",
26
- "@cdc/markup-include": "^1.0.2",
27
- "@cdc/waffle-chart": "^1.0.2",
21
+ "@cdc/chart": "^9.22.9",
22
+ "@cdc/core": "^9.22.9",
23
+ "@cdc/dashboard": "^9.22.9",
24
+ "@cdc/data-bite": "^9.22.9",
25
+ "@cdc/map": "^9.22.9",
26
+ "@cdc/markup-include": "^9.22.9",
27
+ "@cdc/waffle-chart": "^9.22.9",
28
28
  "axios": "^0.21.1",
29
29
  "d3": "^7.0.0",
30
30
  "html-react-parser": "1.4.9",
@@ -40,5 +40,5 @@
40
40
  "resolutions": {
41
41
  "@types/react": "17.x"
42
42
  },
43
- "gitHead": "ff89a7aea74c533413c62ef8859cc011e6b3cbfa"
43
+ "gitHead": "90faf22c91ca0062432607e4599598f9e67c848a"
44
44
  }
package/src/CdcEditor.js CHANGED
@@ -33,6 +33,54 @@ export default function CdcEditor({ config: configObj = {newViz: true}, hostname
33
33
  startingTab = 2
34
34
  }
35
35
 
36
+ // Legacy support - dashboards using a single dataset
37
+ if(config.type === 'dashboard'){
38
+ let legacyUpdateNeeded = false;
39
+ let newConfig;
40
+
41
+ if(config.data || config.dataUrl){
42
+ legacyUpdateNeeded = true;
43
+ newConfig = {...config};
44
+
45
+ newConfig.datasets = {};
46
+ newConfig.datasets[config.dataFileName || 'dataset-1'] = {
47
+ data: config.data,
48
+ dataUrl: config.dataUrl,
49
+ dataFileName: config.dataFileName || 'dataset-1',
50
+ dataFileSourceType: config.dataFileSourceType
51
+ };
52
+
53
+ Object.keys(newConfig.visualizations).forEach(vizKey => {
54
+ newConfig.visualizations[vizKey].dataKey = config.dataFileName || 'dataset-1';
55
+ newConfig.visualizations[vizKey].dataDescription = newConfig.dataDescription;
56
+ newConfig.visualizations[vizKey].formattedData = newConfig.formattedData;
57
+ });
58
+
59
+ delete newConfig.data;
60
+ delete newConfig.dataUrl,
61
+ delete newConfig.dataFileName;
62
+ delete newConfig.dataFileSourceType;
63
+ delete newConfig.dataDescription;
64
+ delete newConfig.formattedData;
65
+ }
66
+
67
+ if(config.dashboard && config.dashboard.filters){
68
+ legacyUpdateNeeded = true;
69
+ newConfig = {...config};
70
+
71
+ newConfig.dashboard.sharedFilters = newConfig.dashboard.sharedFilters || [];
72
+ newConfig.dashboard.filters.forEach(filter => {
73
+ newConfig.dashboard.sharedFilters.push({...filter, key: filter.label, showDropdown: true, usedBy: Object.keys(newConfig.visualizations)});
74
+ });
75
+
76
+ delete newConfig.dashboard.filters;
77
+ }
78
+
79
+ if(legacyUpdateNeeded){
80
+ setConfig(newConfig);
81
+ }
82
+ }
83
+
36
84
  const [globalActive, setGlobalActive] = useState(startingTab);
37
85
 
38
86
  const resizeObserver = new ResizeObserver(([ container ]) => {
@@ -101,18 +149,31 @@ export default function CdcEditor({ config: configObj = {newViz: true}, hostname
101
149
  sharepath
102
150
  }
103
151
 
152
+ let configureDisabled = true;
153
+
154
+ if(config.type !== 'dashboard'){
155
+ if(config.formattedData){
156
+ configureDisabled = false;
157
+ }
158
+ } else {
159
+ if(config.datasets && Object.keys(config.datasets).length > 0){
160
+ configureDisabled = false;
161
+ }
162
+ }
163
+
104
164
  return (
105
165
  <GlobalContextProvider>
106
166
  <GlobalState.Provider value={state}>
107
- <div className={`cdc-open-viz-module cdc-editor ${currentViewport}`} ref={outerContainerRef} >
167
+ <div className={`cdc-open-viz-module cdc-editor ${currentViewport}`} ref={outerContainerRef}>
108
168
  <Tabs className="top-level" startingTab={globalActive}>
109
- <TabPane title="1. Import Data" className="data-designer">
110
- <DataImport />
111
- </TabPane>
112
- <TabPane title="2. Choose Visualization Type" className="choose-type" disableRule={!config.data && !config.formattedData}>
169
+ <TabPane title="1. Choose Visualization Type" className="choose-type">
113
170
  <ChooseTab />
114
171
  </TabPane>
115
- <TabPane title="3. Configure" className="configure" disableRule={null === config.data || !config.type}>
172
+ <TabPane title="2. Import Data" className="data-designer" disableRule={!config.type}>
173
+ <DataImport />
174
+ </TabPane>
175
+
176
+ <TabPane title="3. Configure" className="configure" disableRule={configureDisabled}>
116
177
  <ConfigureTab containerEl={containerEl }/>
117
178
  </TabPane>
118
179
  </Tabs>
@@ -4,19 +4,18 @@ import '../scss/choose-vis-tab.scss'
4
4
  import GlobalState from '../context'
5
5
  import Tooltip from '@cdc/core/components/ui/Tooltip'
6
6
 
7
- import DashboardIcon from '../assets/icons/dashboard.svg'
8
- import BarIcon from '@cdc/core/assets/chart-bar-solid.svg'
9
- import LineIcon from '@cdc/core/assets/chart-line-solid.svg'
10
- import PieIcon from '@cdc/core/assets/chart-pie-solid.svg'
11
- import GlobeIcon from '@cdc/core/assets/world-graphic.svg'
12
- import UsaIcon from '@cdc/core/assets/usa-graphic.svg'
7
+ import DashboardIcon from '@cdc/core/assets/icon-dashboard.svg'
8
+ import BarIcon from '@cdc/core/assets/icon-chart-bar.svg'
9
+ import LineIcon from '@cdc/core/assets/icon-chart-line.svg'
10
+ import PieIcon from '@cdc/core/assets/icon-chart-pie.svg'
11
+ import GlobeIcon from '@cdc/core/assets/icon-map-world.svg'
12
+ import UsaIcon from '@cdc/core/assets/icon-map-usa.svg'
13
13
  import UsaRegionIcon from '@cdc/core/assets/usa-region-graphic.svg'
14
- import DataBiteIcon from '@cdc/core/assets/data-bite-graphic.svg'
14
+ import DataBiteIcon from '@cdc/core/assets/icon-databite.svg'
15
15
  import WaffleChartIcon from '@cdc/core/assets/icon-grid.svg'
16
- import MarkupIncludeIcon from '@cdc/core/assets/icon-code.svg'
17
- import AlabamaGraphic from '@cdc/core/assets/alabama-graphic.svg'
18
- import PairedBarIcon from '@cdc/core/assets/paired-bar.svg'
19
- import HorizontalStackIcon from '@cdc/core/assets/horizontal-stacked-bar.svg'
16
+ import AlabamaGraphic from '@cdc/core/assets/icon-map-alabama.svg'
17
+ import PairedBarIcon from '@cdc/core/assets/icon-chart-bar-paired.svg'
18
+ import HorizontalStackIcon from '@cdc/core/assets/icon-chart-bar-stacked.svg'
20
19
 
21
20
  export default function ChooseTab() {
22
21
  const { config, setConfig, setGlobalActive, tempConfig, setTempConfig } = useContext(GlobalState)
@@ -46,7 +45,7 @@ export default function ChooseTab() {
46
45
  isHorizontalStackedChart = (orientation === config.orientation && stacked === true)
47
46
  }
48
47
 
49
- if (type === 'dashboard' || type === 'data-bite' || type === 'waffle-chart' || type === 'markup-include') isSubType = true
48
+ if(type === 'dashboard' || type === 'data-bite' || type === 'waffle-chart' || type === 'markup-include') isSubType = true;
50
49
 
51
50
  // TODO: sorry, we should refactor this at some point.
52
51
  // trying to get this out for 4.22.5 - this is so stacked horizontal and bar charts aren't highlighted at the same time.
@@ -63,34 +62,35 @@ export default function ChooseTab() {
63
62
 
64
63
 
65
64
  let setTypes = () => {
66
- // Only take the data/data source properties from existing config. Covers case of selecting a new visualization.
67
- let newConfig = {
68
- data: [ ...config.data ],
69
- dataFileName: config.dataFileName,
70
- dataFileSourceType: config.dataFileSourceType,
71
- dataDescription: config.dataDescription,
72
- dataUrl: config.dataUrl,
73
- newViz: true,
74
- type,
75
- orientation: orientation ? orientation : null,
76
- visualizationSubType: label === 'Horizontal Bar (Stacked)' ? 'stacked' : null
77
- }
78
-
79
- if (config.formattedData) {
80
- newConfig.formattedData = config.formattedData
81
- }
82
-
83
- if (type === 'map') {
84
- newConfig.general = {
85
- ...newConfig.general,
86
- geoType: subType
65
+ if(type === config.type){
66
+ if(subType !== config.visualizationType){
67
+ setConfig({...config, newViz: true, visualizationType: subType})
87
68
  }
69
+
70
+ setGlobalActive(1)
88
71
  } else {
89
- newConfig.visualizationType = subType
72
+ let confirmation = !config.type || window.confirm('Changing visualization type will clear configuration settings. Do you want to continue?');
73
+
74
+ if(confirmation){
75
+ let newConfig = {
76
+ newViz: true,
77
+ datasets: {},
78
+ type
79
+ }
80
+
81
+ if(type === 'map') {
82
+ newConfig.general = {
83
+ ...newConfig.general,
84
+ geoType: subType
85
+ }
86
+ } else {
87
+ newConfig.visualizationType = subType
88
+ }
89
+
90
+ setConfig(newConfig);
91
+ setGlobalActive(1)
92
+ }
90
93
  }
91
-
92
- setConfig(newConfig)
93
- setGlobalActive(2)
94
94
  }
95
95
 
96
96
  return (<button className={classNames} onClick={() => setTypes()} aria-label={label}>{icon}<span