@devgateway/dvz-wp-commons 1.1.0 → 1.2.0

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,49 +1,26 @@
1
- import React from "react";
2
- import { Component } from "@wordpress/element";
3
- import { Measure, Dimension, Filter, Category, Categories } from "./types";
4
- type APIConfigProps = {
5
- allDimensions: Dimension[];
6
- allFilters: Filter[];
7
- allMeasures: Measure[];
8
- allCategories: Categories;
9
- setAttributes: (attributes: any) => void;
10
- attributes: {
11
- measures: Measure[];
12
- filters: Filter[];
13
- categories: Category[];
14
- dimension1: string;
15
- dimension2: string;
16
- type: string;
17
- swap: boolean;
18
- manualColors: Record<string, Record<string, string>>;
19
- scheme: string;
20
- colorBy: string;
21
- barColor: string;
22
- app: string;
23
- csv: string;
24
- includeOverall: boolean;
25
- types: any[];
26
- };
27
- };
28
- export declare class APIConfig extends Component<APIConfigProps> {
29
- constructor(props: APIConfigProps);
30
- cleanSelection(prevState: any): void;
1
+ export class APIConfig extends Component<any, any, any> {
2
+ constructor(props: any);
3
+ onMeasuresChange(value: any): void;
4
+ onSetSingleMeasure(value: any): void;
5
+ addFilter(): void;
31
6
  updateFilterParam(param: any, idx: any): void;
32
7
  updateFilterValue(value: any, idx: any): void;
33
8
  setFilterValue(value: any, idx: any): void;
34
- addFilter(): void;
35
9
  removeFilter(f: any): void;
36
- componentDidUpdate(prevProps: any): void;
37
- onSetSingleMeasure(value: any): void;
10
+ items(type: any): any;
38
11
  onFormatChange(format: any, field: any): void;
12
+ onCustomLabelToggleChange(value: any): void;
13
+ onCustomLabelChange(value: any, customLabel: any): void;
39
14
  onUseCustomAxisFormatChange(value: any): void;
40
- onMeasuresChange(value: string): void;
41
- onCustomLabelToggleChange(value: string): void;
42
- onCustomLabelChange(value: string, customLabel: string): void;
43
- items(type: string): {
44
- value: string;
45
- id: number;
46
- }[] | null;
47
- render(): React.JSX.Element[];
15
+ state: {
16
+ measures: never[];
17
+ dimensions: never[];
18
+ filters: never[];
19
+ categories: never[];
20
+ };
21
+ cleanSelection(prevState: any): void;
22
+ componentDidUpdate(prevProps: any): void;
23
+ render(): import("react").JSX.Element[];
48
24
  }
49
- export {};
25
+ export default APIConfig;
26
+ import { Component } from "@wordpress/element";
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { Component } from "@wordpress/element";
3
2
  import { __ } from "@wordpress/i18n";
4
3
  import { Button, PanelBody, PanelRow, SelectControl, ToggleControl, } from "@wordpress/components";
@@ -22,7 +21,7 @@ const FilterSelector = ({ param, index, options, onUpdateFilterParam }) => {
22
21
  const CategoricalFilter = ({ value, index, items, onUpdateFilterValue }) => {
23
22
  if (items) {
24
23
  const sortedItems = items.sort(function (a, b) {
25
- if (a.position !== undefined && b.position !== undefined) {
24
+ if (a.position !== undefined && b.position !== undefined && a.position !== b.position) {
26
25
  return a.position - b.position;
27
26
  }
28
27
  let aValue = a.value ? a.value.toLowerCase() : "";
@@ -39,6 +38,11 @@ const CategoricalFilter = ({ value, index, items, onUpdateFilterValue }) => {
39
38
  return null;
40
39
  }
41
40
  };
41
+ /*let types = [
42
+ {label: 'Bar', value: 'bar', supports: {singleMeasure: false, singleDimension: false}},
43
+ {label: 'Pie', value: 'pie', supports: {singleMeasure: true, singleDimension: false}},
44
+ {label: 'Line', value: 'line', supports: {singleMeasure: false, singleDimension: true}},
45
+ {label: 'Map', value: 'map', supports: {singleMeasure: true, singleDimension: false}}]*/
42
46
  export class APIConfig extends Component {
43
47
  constructor(props) {
44
48
  super(props);
@@ -205,16 +209,16 @@ export class APIConfig extends Component {
205
209
  }
206
210
  /*
207
211
  onCustomMeasureFieldChange(measureName, field, value) {
208
-
212
+
209
213
  const {setAttributes, attributes: {measures}} = this.props
210
214
  const uMs = Object.assign({}, {...measures})
211
-
215
+
212
216
  if (uMs[measureName]) {
213
217
  uMs[measureName][field] = value
214
218
  } else {
215
219
  uMs[measureName] = {allowSelection: false, field: value, selected: false}
216
220
  }
217
-
221
+
218
222
  setAttributes({measures: uMs})
219
223
  }
220
224
  */
@@ -258,12 +262,12 @@ export class APIConfig extends Component {
258
262
  let items = null;
259
263
  if (type === "Boolean") {
260
264
  items = [
261
- { value: "Yes", id: 1 },
262
- { value: "No", id: 0 },
265
+ { value: "Yes", id: true },
266
+ { value: "No", id: false },
263
267
  ];
264
268
  }
265
269
  else if (cat) {
266
- items = cat.items.map((item) => ({ value: item.value, id: item.id }));
270
+ items = cat.items;
267
271
  }
268
272
  return items;
269
273
  }
@@ -275,17 +279,17 @@ export class APIConfig extends Component {
275
279
  return [
276
280
  React.createElement(PanelBody, { initialOpen: false, title: __(type == "map" ? "Fields" : `Dimensions`) },
277
281
  React.createElement(PanelRow, null,
278
- React.createElement(SelectControl, { multiple: false, label: __(type == "map" ? "Matching Field" : "First Dimension"), value: dimension1, onChange: (value) => {
282
+ React.createElement(SelectControl, { label: __(type == "map" ? "Matching Field" : "First Dimension"), value: [dimension1], onChange: (value) => {
279
283
  setAttributes({
280
284
  dimension1: value,
281
285
  dimension2: value == "none" ? "none" : dimension2,
282
286
  });
283
287
  }, options: allDimensions })),
284
- type != "line" && type != "radar" && (React.createElement(PanelRow, null,
285
- React.createElement(SelectControl, { multiple: false, label: __(type == "map" ? "Breakdown Field" : "Second Dimension"), value: dimension2, onChange: (value) => {
288
+ type != "radar" && (React.createElement(PanelRow, null,
289
+ React.createElement(SelectControl, { label: __(type == "map" ? "Breakdown Field" : "Second Dimension"), value: [dimension2], onChange: (value) => {
286
290
  setAttributes({ dimension2: value });
287
291
  }, options: allDimensions, disabled: dimension1 == "none" })))),
288
- React.createElement(Measures, { ...this.props, onFormatChange: this.onFormatChange, onUseCustomAxisFormatChange: this.onUseCustomAxisFormatChange, onSetSingleMeasure: this.onSetSingleMeasure, onMeasuresChange: this.onMeasuresChange, onCustomLabelToggleChange: this.onCustomLabelToggleChange, onCustomLabelChange: this.onCustomLabelChange, currentType: currentType }),
292
+ React.createElement(Measures, { onFormatChange: this.onFormatChange, onUseCustomAxisFormatChange: this.onUseCustomAxisFormatChange, onSetSingleMeasure: this.onSetSingleMeasure, onMeasuresChange: this.onMeasuresChange, onCustomLabelToggleChange: this.onCustomLabelToggleChange, onCustomLabelChange: this.onCustomLabelChange, ...this.props, currentType: currentType }),
289
293
  React.createElement(React.Fragment, null,
290
294
  React.createElement(PanelBody, { initialOpen: false, title: __("Filters") },
291
295
  filters.map((f, index) => {
@@ -299,3 +303,4 @@ export class APIConfig extends Component {
299
303
  ];
300
304
  }
301
305
  }
306
+ export default APIConfig;
@@ -1,4 +1,4 @@
1
- export declare const getTranslatedOptions: (options: any[]) => any[];
2
- export declare const getTranslation: (translatable: any) => any;
3
- export declare const isSupersetAPI: (app: string, apps: any[]) => any;
1
+ export function getTranslatedOptions(options: any): any[];
2
+ export function getTranslation(translatable: any): any;
3
+ export function isSupersetAPI(app: any, apps: any): any;
4
4
  export default getTranslatedOptions;
package/build/APIutils.js CHANGED
@@ -1,11 +1,15 @@
1
1
  export const getTranslatedOptions = (options) => {
2
2
  const currentLocale = (window._user_locale ? window._user_locale : '').toUpperCase();
3
3
  if (options && options instanceof Array) {
4
+ debugger;
4
5
  return options.map(o => {
5
6
  let { label, value, labels } = o;
6
7
  if (labels && labels[currentLocale]) {
7
8
  label = labels[currentLocale];
8
9
  }
10
+ if (!label) {
11
+ label = value;
12
+ }
9
13
  return { ...o, label, value };
10
14
  });
11
15
  }
package/build/Blocks.d.ts CHANGED
@@ -1,51 +1,31 @@
1
- import React from 'react';
2
- import { Component } from '@wordpress/element';
3
- import { Taxonomies, Taxonomy, Wp_Types } from './types';
4
- export interface SizeConfigProps {
5
- height: number;
6
- setAttributes: (attributes: any) => void;
1
+ export function SizeConfig({ height, setAttributes, panelStatus, initialOpen }: {
2
+ height: any;
3
+ setAttributes: any;
7
4
  panelStatus: any;
8
- initialOpen?: boolean;
9
- }
10
- export declare const SizeConfig: ({ height, setAttributes, panelStatus, initialOpen }: SizeConfigProps) => React.JSX.Element;
11
- export type ComponentWithSettingsProps = {
12
- attributes: any;
13
- setAttributes: (attributes: any) => void;
14
- };
15
- export type ComponentWithSettingsState = {
16
- react_ui_url?: string;
17
- react_api_url?: string | null;
18
- apache_superset_url?: string | boolean | null;
19
- site_language?: string;
20
- current_language?: string;
21
- previewMode?: string;
22
- };
23
- export declare class ComponentWithSettings<T extends ComponentWithSettingsProps, U extends ComponentWithSettingsState> extends Component<T, U> {
24
- iframe: React.RefObject<HTMLIFrameElement>;
25
- unsubscribe: () => void;
26
- constructor(props: T);
5
+ initialOpen: any;
6
+ }): import("react").JSX.Element;
7
+ export class ComponentWithSettings extends Component<any, any, any> {
8
+ constructor(props: any);
9
+ state: {
10
+ react_ui_url: string;
11
+ };
12
+ iframe: import("react").RefObject<any>;
13
+ unsubscribe: any;
27
14
  componentDidUpdate(prevProps: any, prevState: any, snapshot: any): void;
28
15
  componentDidMount(): void;
29
16
  componentWillUnmount(): void;
30
17
  }
31
- export type BlockEditWithFiltersProps = {
32
- attributes: any;
33
- setAttributes: (attributes: any) => void;
34
- };
35
- export interface BlockEditWithFiltersState extends ComponentWithSettingsState {
36
- taxonomyValues: Taxonomy[] | null;
37
- types: Wp_Types[] | null;
38
- taxonomies: Taxonomies | null;
39
- loading: boolean;
40
- }
41
- export declare class BlockEditWithFilters<T extends BlockEditWithFiltersProps = BlockEditWithFiltersProps, S extends BlockEditWithFiltersState = BlockEditWithFiltersState> extends ComponentWithSettings<T, S> {
42
- constructor(props: T);
43
- componentDidUpdate(prevProps: any, prevState: any, snapshot: any): void;
44
- componentDidMount(): void;
18
+ export class BlockEditWithFilters extends ComponentWithSettings {
19
+ state: {
20
+ taxonomyValues: never[];
21
+ types: null;
22
+ taxonomies: null;
23
+ loading: boolean;
24
+ };
45
25
  onTypeChanged(value: any): void;
46
26
  onTaxonomyChanged(value: any): void;
47
- onCategoryChanged(checked: any, value: any): void;
48
27
  getTaxonomyValues(): void;
28
+ onCategoryChanged(checked: any, value: any): void;
49
29
  getTaxonomies(): void;
50
30
  getTypes(): void;
51
31
  typeOptions(): {
@@ -55,36 +35,20 @@ export declare class BlockEditWithFilters<T extends BlockEditWithFiltersProps =
55
35
  }[];
56
36
  taxonomyOptions(): {
57
37
  label: string;
58
- value: string;
38
+ value: any;
59
39
  }[];
60
40
  categoriesOptions(): {
61
- label: string;
62
- value: number;
41
+ label: any;
42
+ value: any;
63
43
  }[];
64
- renderFilters(): React.JSX.Element;
44
+ renderFilters(): import("react").JSX.Element;
65
45
  }
66
- export type BlockEditWithAPIMetadataProps = {
67
- attributes: {
68
- app: string;
69
- dvzProxyDatasetId?: string;
70
- };
71
- setAttributes: (attributes: any) => void;
72
- };
73
- export type BlockEditWithAPIMetadataState = {
74
- apps: any[];
75
- datasets?: any[];
76
- dimensions?: any[];
77
- filters?: any[];
78
- measures?: any[];
79
- categories?: any[];
80
- } & ComponentWithSettingsState;
81
- export declare class BlockEditWithAPIMetadata<T extends BlockEditWithAPIMetadataProps = BlockEditWithAPIMetadataProps, S extends BlockEditWithAPIMetadataState = BlockEditWithAPIMetadataState> extends ComponentWithSettings<T, S> {
82
- constructor(props: T);
83
- componentDidMount(): void;
84
- componentDidUpdate(prevProps: BlockEditWithAPIMetadataProps, prevState: any, snapshot?: any): void;
46
+ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
47
+ componentDidUpdate(prevProps: any): void;
85
48
  evictSuperSetCache(): void;
86
49
  loadDatasets(app: any): void;
87
- loadMetadata(app: string, dvzProxyDatasetId?: string): void;
88
- fetchData(url: string, stateKey: string, transformData: (data: any) => any): void;
50
+ loadMetadata(app: any, dvzProxyDatasetId: any): void;
51
+ fetchData(url: any, stateKey: any, transformData: any): void;
89
52
  }
90
53
  export default SizeConfig;
54
+ import { Component } from '@wordpress/element';
package/build/Blocks.js CHANGED
@@ -1,39 +1,32 @@
1
- import React from 'react';
2
1
  import { __ } from '@wordpress/i18n';
3
2
  import { CheckboxControl, PanelBody, PanelRow, SelectControl, TextControl } from '@wordpress/components';
4
3
  import { Component } from '@wordpress/element';
5
4
  import apiFetch from '@wordpress/api-fetch';
6
- import { togglePanel } from './Util';
7
- import { getTranslatedOptions, isSupersetAPI } from './APIutils';
8
- import { subscribe, select } from '@wordpress/data';
9
- export const SizeConfig = ({ height, setAttributes, panelStatus, initialOpen = false }) => {
10
- return (React.createElement(PanelBody, { initialOpen: panelStatus ? panelStatus["SIZE"] : initialOpen, onToggle: () => togglePanel("SIZE", panelStatus, setAttributes), title: __("Size") },
5
+ import { togglePanel } from "./Util";
6
+ import { getTranslatedOptions } from './APIutils';
7
+ import { isSupersetAPI } from "./APIutils";
8
+ export const SizeConfig = ({ height, setAttributes, panelStatus, initialOpen }) => {
9
+ return (React.createElement(PanelBody, { initialOpen: panelStatus ? panelStatus["SIZE"] : initialOpen, onToggle: e => togglePanel("SIZE", panelStatus, setAttributes), title: __("Size") },
11
10
  React.createElement(PanelRow, null,
12
11
  React.createElement(TextControl, { size: 10, label: "Height", value: height, onChange: (height) => setAttributes({ height: height ? parseInt(height) : 0 }) }))));
13
12
  };
14
13
  export class ComponentWithSettings extends Component {
15
- iframe;
16
- unsubscribe;
17
14
  constructor(props) {
18
15
  super(props);
19
16
  this.state = {
20
- react_ui_url: '',
21
- react_api_url: null,
22
- apache_superset_url: null,
23
- site_language: '',
24
- current_language: '',
17
+ react_ui_url: ''
25
18
  };
26
19
  window.addEventListener("message", (event) => {
27
20
  if (event.data.type === 'componentReady' && event.data.value === true) {
28
21
  if (this.iframe.current) {
29
22
  console.log("-----------Sending message -----------");
30
- this.iframe.current.contentWindow?.postMessage(({ messageType: 'component-attributes', ...this.props.attributes }), "*");
23
+ this.iframe.current.contentWindow.postMessage(({ messageType: 'component-attributes', ...this.props.attributes }), "*");
31
24
  }
32
25
  }
33
26
  }, false);
34
27
  this.iframe = React.createRef();
35
- this.unsubscribe = subscribe(() => {
36
- const newPreviewMode = select("core/editor").getDeviceType();
28
+ this.unsubscribe = wp.data.subscribe(() => {
29
+ const newPreviewMode = wp.data.select("core/editor").getDeviceType();
37
30
  if (newPreviewMode !== this.state.previewMode) {
38
31
  this.setState({ previewMode: newPreviewMode });
39
32
  }
@@ -51,7 +44,7 @@ export class ComponentWithSettings extends Component {
51
44
  react_api_url: data["react_api_url"],
52
45
  apache_superset_url: data["apache_superset_url"],
53
46
  site_language: data["site_language"],
54
- current_language: new URLSearchParams(document.location.search).get("edit_lang") || ''
47
+ current_language: new URLSearchParams(document.location.search).get("edit_lang")
55
48
  });
56
49
  });
57
50
  }
@@ -65,15 +58,7 @@ export class BlockEditWithFilters extends ComponentWithSettings {
65
58
  constructor(props) {
66
59
  super(props);
67
60
  this.state = {
68
- react_ui_url: '',
69
- react_api_url: null,
70
- apache_superset_url: null,
71
- site_language: '',
72
- current_language: '',
73
- taxonomyValues: [],
74
- types: null,
75
- taxonomies: null,
76
- loading: true
61
+ taxonomyValues: [], types: null, taxonomies: null, loading: true
77
62
  };
78
63
  this.onTypeChanged = this.onTypeChanged.bind(this);
79
64
  this.onTaxonomyChanged = this.onTaxonomyChanged.bind(this);
@@ -81,7 +66,7 @@ export class BlockEditWithFilters extends ComponentWithSettings {
81
66
  this.onCategoryChanged = this.onCategoryChanged.bind(this);
82
67
  }
83
68
  componentDidUpdate(prevProps, prevState, snapshot) {
84
- const { attributes: { type, taxonomy }, } = this.props;
69
+ const { setAttributes, attributes: { type, taxonomy, count }, } = this.props;
85
70
  super.componentDidUpdate(prevProps, prevState, snapshot);
86
71
  if (prevProps.attributes) {
87
72
  if (type != prevProps.attributes.type) {
@@ -95,7 +80,7 @@ export class BlockEditWithFilters extends ComponentWithSettings {
95
80
  super.componentDidMount();
96
81
  this.getTypes();
97
82
  this.getTaxonomies();
98
- const { attributes: { taxonomy }, } = this.props;
83
+ const { setAttributes, attributes: { type, taxonomy, count }, } = this.props;
99
84
  if (taxonomy != 'none') {
100
85
  this.getTaxonomyValues();
101
86
  }
@@ -123,15 +108,15 @@ export class BlockEditWithFilters extends ComponentWithSettings {
123
108
  }
124
109
  }
125
110
  getTaxonomyValues() {
126
- const { attributes: { taxonomy }, } = this.props;
127
- apiFetch({
128
- path: '/wp/v2/taxonomies/' + taxonomy + '?per_page=100',
111
+ const { setAttributes, attributes: { type, taxonomy, count }, } = this.props;
112
+ wp.apiFetch({
113
+ path: '/wp/v2/' + taxonomy + '?per_page=100',
129
114
  }).then(data => {
130
115
  this.setState({ taxonomyValues: data });
131
116
  });
132
117
  }
133
118
  getTaxonomies() {
134
- apiFetch({
119
+ wp.apiFetch({
135
120
  path: '/wp/v2/taxonomies?per_page=100',
136
121
  }).then(data => {
137
122
  this.setState({
@@ -140,16 +125,18 @@ export class BlockEditWithFilters extends ComponentWithSettings {
140
125
  });
141
126
  }
142
127
  getTypes() {
143
- apiFetch({
128
+ wp.apiFetch({
144
129
  path: '/wp/v2/types?per_page=100',
145
130
  }).then(data => {
131
+ const types = data;
146
132
  this.setState({
147
133
  types: data, loading: false
148
134
  });
149
135
  });
150
136
  }
151
137
  typeOptions() {
152
- const { types } = this.state;
138
+ const { setAttributes, attributes: { count, type, taxonomy, category }, } = this.props;
139
+ const { types, taxonomies, taxonomyValues } = this.state;
153
140
  const typeOptions = types ? Object.keys(types)
154
141
  .filter(k => ['page', 'attachment', 'wp_block']
155
142
  .indexOf(k) == -1).map(k => ({
@@ -159,7 +146,7 @@ export class BlockEditWithFilters extends ComponentWithSettings {
159
146
  }
160
147
  taxonomyOptions() {
161
148
  const { attributes: { type, }, } = this.props;
162
- const { types, taxonomies } = this.state;
149
+ const { types, taxonomies, taxonomyValues } = this.state;
163
150
  let slug;
164
151
  if (types) {
165
152
  slug = this.typeOptions().filter(t => t.value == type)[0].slug;
@@ -174,9 +161,9 @@ export class BlockEditWithFilters extends ComponentWithSettings {
174
161
  }
175
162
  }
176
163
  categoriesOptions() {
177
- const { taxonomyValues } = this.state;
164
+ const { types, taxonomies, taxonomyValues } = this.state;
178
165
  const taxonomyValuesOptions = taxonomyValues && taxonomyValues.map(t => ({ label: t.name, value: t.id }));
179
- return taxonomyValuesOptions || [];
166
+ return taxonomyValuesOptions;
180
167
  }
181
168
  renderFilters() {
182
169
  const { attributes: { type, taxonomy, categories, } } = this.props;
@@ -185,7 +172,7 @@ export class BlockEditWithFilters extends ComponentWithSettings {
185
172
  React.createElement(SelectControl, { label: __("Post Type"), options: this.typeOptions(), value: type, onChange: this.onTypeChanged })),
186
173
  React.createElement(PanelRow, null,
187
174
  React.createElement(SelectControl, { label: __("Use a taxonomy filter "), options: this.taxonomyOptions(), value: taxonomy, onChange: this.onTaxonomyChanged })),
188
- (taxonomy != 'none' && this.categoriesOptions().length > 0) && this.categoriesOptions().map(o => {
175
+ taxonomy != 'none' && this.categoriesOptions().map(o => {
189
176
  return React.createElement(PanelRow, null,
190
177
  React.createElement(CheckboxControl, { label: o.label, onChange: (checked) => this.onCategoryChanged(checked, o.value), checked: categories.indexOf(o.value) > -1 }));
191
178
  })));
@@ -204,7 +191,7 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
204
191
  'Accept': 'application/json',
205
192
  },
206
193
  })
207
- .then((response) => response.json())
194
+ .then(response => response.json())
208
195
  .then(data => {
209
196
  const apps = data.applications ? [...data.applications.application
210
197
  .filter(a => a.instance[0].metadata.type === 'data')
@@ -220,7 +207,7 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
220
207
  react_api_url: settingsData["react_api_url"],
221
208
  apache_superset_url: settingsData["apache_superset_url"],
222
209
  site_language: settingsData["site_language"],
223
- current_language: new URLSearchParams(document.location.search).get("edit_lang") || "",
210
+ current_language: new URLSearchParams(document.location.search).get("edit_lang"),
224
211
  apps
225
212
  }, () => {
226
213
  const { app, dvzProxyDatasetId } = this.props.attributes;
@@ -237,8 +224,8 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
237
224
  });
238
225
  });
239
226
  }
240
- componentDidUpdate(prevProps, prevState, snapshot) {
241
- super.componentDidUpdate(prevProps, prevState, snapshot);
227
+ componentDidUpdate(prevProps) {
228
+ super.componentDidUpdate(prevProps);
242
229
  const { attributes: { app, dvzProxyDatasetId } } = this.props;
243
230
  const { attributes: { dvzProxyDatasetId: prevDvzProxyDatasetId, app: prevAPP } } = prevProps;
244
231
  if (app != prevAPP) { //if app changes we shoudl reload metadta
@@ -249,7 +236,7 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
249
236
  }
250
237
  }
251
238
  else {
252
- this.loadMetadata(app, dvzProxyDatasetId);
239
+ this.loadMetadata(app);
253
240
  }
254
241
  }
255
242
  else { //app wasn't changed
@@ -304,7 +291,7 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
304
291
  dimensions: [{ "label": __("None"), "value": "none" }, ...getTranslatedOptions(data)]
305
292
  });
306
293
  })
307
- .catch(function () {
294
+ .catch(function (response) {
308
295
  console.log("Error when loading dimensions");
309
296
  });
310
297
  fetch(filtersUrl)
@@ -332,7 +319,7 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
332
319
  sessionStorage.setItem(`measures_${app}`, JSON.stringify(getTranslatedOptions(data)));
333
320
  this.setState({ measures: getTranslatedOptions(data) });
334
321
  })
335
- .catch(function () {
322
+ .catch(function (response) {
336
323
  console.log("Error when loading measures");
337
324
  });
338
325
  fetch(categoriesUrl)
@@ -360,8 +347,6 @@ export class BlockEditWithAPIMetadata extends ComponentWithSettings {
360
347
  return response.json();
361
348
  })
362
349
  .then(data => {
363
- // TODO: Check if the data is an array
364
- // @ts-ignore
365
350
  this.setState({
366
351
  [stateKey]: transformData(data)
367
352
  });
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- export declare const CSVConfig: ({ attributes: { csv, panelStatus, measures, type }, setAttributes }: {
1
+ export function CSVConfig({ attributes: { csv, panelStatus, measures, type }, setAttributes }: {
3
2
  attributes: {
4
3
  csv: any;
5
4
  panelStatus: any;
@@ -7,5 +6,5 @@ export declare const CSVConfig: ({ attributes: { csv, panelStatus, measures, typ
7
6
  type: any;
8
7
  };
9
8
  setAttributes: any;
10
- }) => React.JSX.Element[];
9
+ }): import("react").JSX.Element[];
11
10
  export default CSVConfig;
@@ -1,20 +1,21 @@
1
- import React from 'react';
2
1
  import { PanelBody, PanelRow, TextareaControl } from '@wordpress/components';
3
2
  import { __ } from '@wordpress/i18n';
4
3
  import Format from "./Format";
5
4
  import { togglePanel } from "./Util";
6
5
  const defaultFormat = {
7
- "style": "percent",
8
- "minimumFractionDigits": 1,
9
- "maximumFractionDigits": 1,
10
- "currency": "USD"
6
+ "style": "percent", "minimumFractionDigits": 1, "maximumFractionDigits": 1, "currency": "USD"
11
7
  };
12
8
  export const CSVConfig = ({ attributes: { csv, panelStatus, measures, type }, setAttributes }) => {
13
9
  const onFormatChange = (format, field) => {
14
10
  const app = "csv";
15
11
  const uMs = measures ? JSON.parse(JSON.stringify(measures)) : {};
16
12
  if (!uMs[app]) {
17
- uMs[app] = { allowSelection: false, format: Object.assign({}, defaultFormat), customFormat: Object.assign({}, { ...defaultFormat }), selected: false };
13
+ uMs[app] = {
14
+ allowSelection: false,
15
+ format: Object.assign({}, defaultFormat),
16
+ customFormat: Object.assign({}, { ...defaultFormat }),
17
+ selected: false
18
+ };
18
19
  }
19
20
  uMs[app][field] = format;
20
21
  setAttributes({ measures: uMs });
@@ -30,7 +31,12 @@ export const CSVConfig = ({ attributes: { csv, panelStatus, measures, type }, se
30
31
  setAttributes({ measures: uMs });
31
32
  }
32
33
  else {
33
- uMs[app] = { allowSelection: false, format: Object.assign({}, { ...defaultFormat }), customFormat: Object.assign({}, { ...defaultFormat }), selected: false };
34
+ uMs[app] = {
35
+ allowSelection: false,
36
+ format: Object.assign({}, { ...defaultFormat }),
37
+ customFormat: Object.assign({}, { ...defaultFormat }),
38
+ selected: false
39
+ };
34
40
  uMs[app].useCustomAxisFormat = value;
35
41
  setAttributes({ measures: uMs });
36
42
  }
@@ -42,7 +48,6 @@ export const CSVConfig = ({ attributes: { csv, panelStatus, measures, type }, se
42
48
  onFormatChange(newFormat, field);
43
49
  }, onUseCustomAxisFormatChange: value => {
44
50
  onUseCustomAxisFormatChange(value);
45
- } }))
46
- ]);
51
+ } }))]);
47
52
  };
48
53
  export default CSVConfig;
@@ -1,55 +1,14 @@
1
- import React from "react";
2
- import { Categories, Dimension, Filter, Measure } from "./types";
3
- export declare const categorical: {
1
+ export const categorical: {
4
2
  value: string;
5
3
  label: string;
6
4
  }[];
7
- export declare const sequential: {
5
+ export const sequential: {
8
6
  value: string;
9
7
  label: string;
10
8
  }[];
11
- export declare const diverging: {
9
+ export const diverging: {
12
10
  value: string;
13
11
  label: string;
14
12
  }[];
15
- export type ChartColorsProps = {
16
- allDimensions?: Dimension[];
17
- allFilters?: Filter[];
18
- allMeasures?: Measure[];
19
- allCategories?: Categories;
20
- allApps?: any[];
21
- setAttributes: (attributes: {
22
- swap: boolean;
23
- measures: Record<string, {
24
- selected: boolean;
25
- }>;
26
- manualColors?: Record<string, Record<string, string>>;
27
- scheme: string;
28
- colorBy: string;
29
- dimension1: string;
30
- dimension2: string;
31
- barColor: string | null;
32
- type: string;
33
- app: string;
34
- csv: string;
35
- includeOverall: boolean;
36
- }) => void;
37
- attributes: {
38
- swap: boolean;
39
- measures: Record<string, {
40
- selected: boolean;
41
- }>;
42
- manualColors: Record<string, Record<string, string>>;
43
- scheme: string;
44
- colorBy: string;
45
- dimension1: string;
46
- dimension2: string;
47
- barColor: string;
48
- type: string;
49
- app: string;
50
- csv: string;
51
- includeOverall: boolean;
52
- };
53
- };
54
- export declare const ChartColors: (props: ChartColorsProps) => (string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined)[] | null;
13
+ export function ChartColors(props: any): (false | import("react").JSX.Element)[] | null;
55
14
  export default ChartColors;