@devgateway/dvz-wp-commons 1.2.0 → 1.3.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.
- package/build/APIConfig.cjs +479 -0
- package/build/APIConfig.d.ts +12 -0
- package/build/APIConfig.js +367 -283
- package/build/APIutils.cjs +54 -0
- package/build/APIutils.js +7 -1
- package/build/Blocks.cjs +672 -0
- package/build/Blocks.d.ts +14 -1
- package/build/Blocks.js +523 -330
- package/build/CSVSourceConfig.cjs +99 -0
- package/build/CSVSourceConfig.js +63 -46
- package/build/ChartColors.cjs +593 -0
- package/build/ChartColors.d.ts +0 -1
- package/build/ChartColors.js +430 -366
- package/build/ChartLegends.cjs +157 -0
- package/build/ChartLegends.d.ts +0 -1
- package/build/ChartLegends.js +173 -54
- package/build/ChartMeasures.cjs +192 -0
- package/build/ChartMeasures.d.ts +0 -1
- package/build/ChartMeasures.js +197 -109
- package/build/Constants.cjs +21 -0
- package/build/Constants.js +3 -1
- package/build/DataFilters.cjs +176 -0
- package/build/DataFilters.js +100 -89
- package/build/Format.cjs +1038 -0
- package/build/Format.js +428 -378
- package/build/MapCSVSourceConfig.cjs +36 -0
- package/build/MapCSVSourceConfig.js +19 -8
- package/build/Measures.cjs +196 -0
- package/build/Measures.js +204 -108
- package/build/MobileConfigUtils.cjs +92 -0
- package/build/MobileConfigUtils.js +19 -8
- package/build/Tooltip.cjs +63 -0
- package/build/Tooltip.d.ts +1 -3
- package/build/Tooltip.js +27 -51
- package/build/Util.cjs +29 -0
- package/build/Util.js +7 -7
- package/build/hooks/index.cjs +1 -0
- package/build/hooks/index.js +0 -3
- package/build/icons/Chart.cjs +49 -0
- package/build/icons/Chart.d.ts +1 -2
- package/build/icons/Chart.js +10 -11
- package/build/icons/Generic.cjs +24 -0
- package/build/icons/Generic.d.ts +1 -2
- package/build/icons/Generic.js +25 -4
- package/build/icons/index.cjs +19 -0
- package/build/icons/index.js +2 -2
- package/build/index.cjs +225 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +47 -16
- package/package.json +16 -7
- package/build/tsconfig.tsbuildinfo +0 -1
package/build/APIConfig.js
CHANGED
|
@@ -1,306 +1,390 @@
|
|
|
1
1
|
import { Component } from "@wordpress/element";
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
PanelBody,
|
|
6
|
+
PanelRow,
|
|
7
|
+
SelectControl,
|
|
8
|
+
ToggleControl
|
|
9
|
+
} from "@wordpress/components";
|
|
10
|
+
import { Measures } from "./Measures.js";
|
|
5
11
|
const defaultFormat = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
style: "percent",
|
|
13
|
+
minimumFractionDigits: 1,
|
|
14
|
+
maximumFractionDigits: 1,
|
|
15
|
+
currency: "USD"
|
|
10
16
|
};
|
|
11
|
-
const FilterSelector = ({ param, index, options, onUpdateFilterParam }) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return a.position - b.position;
|
|
26
|
-
}
|
|
27
|
-
let aValue = a.value ? a.value.toLowerCase() : "";
|
|
28
|
-
let bValue = b.value ? b.value.toLowerCase() : "";
|
|
29
|
-
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
|
30
|
-
});
|
|
31
|
-
return sortedItems.map((v) => (React.createElement(PanelRow, null,
|
|
32
|
-
" ",
|
|
33
|
-
React.createElement(ToggleControl, { label: v.value, checked: value.indexOf(v.id) > -1, onChange: (e) => {
|
|
34
|
-
onUpdateFilterValue(v.id, index);
|
|
35
|
-
} }))));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return null;
|
|
17
|
+
export const FilterSelector = ({ param, index, options, onUpdateFilterParam }) => {
|
|
18
|
+
const sortedOptions = options.sort(function(a, b) {
|
|
19
|
+
var aLabel = a.label ? a.label.toLowerCase() : "";
|
|
20
|
+
var bLabel = b.label ? b.label.toLowerCase() : "";
|
|
21
|
+
return aLabel < bLabel ? -1 : aLabel > bLabel ? 1 : 0;
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ React.createElement(
|
|
24
|
+
SelectControl,
|
|
25
|
+
{
|
|
26
|
+
onChange: (value) => {
|
|
27
|
+
onUpdateFilterParam(value, index);
|
|
28
|
+
},
|
|
29
|
+
value: param,
|
|
30
|
+
options: sortedOptions
|
|
39
31
|
}
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
export const CategoricalFilter = ({ value, index, items, onUpdateFilterValue }) => {
|
|
35
|
+
if (items) {
|
|
36
|
+
const sortedItems = items.sort(function(a, b) {
|
|
37
|
+
if (a.position !== void 0 && b.position !== void 0 && a.position !== b.position) {
|
|
38
|
+
return a.position - b.position;
|
|
39
|
+
}
|
|
40
|
+
let aValue = a.value ? a.value.toLowerCase() : "";
|
|
41
|
+
let bValue = b.value ? b.value.toLowerCase() : "";
|
|
42
|
+
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
|
43
|
+
});
|
|
44
|
+
return sortedItems.map((v) => /* @__PURE__ */ React.createElement(PanelRow, null, " ", /* @__PURE__ */ React.createElement(
|
|
45
|
+
ToggleControl,
|
|
46
|
+
{
|
|
47
|
+
label: v.value,
|
|
48
|
+
checked: value.indexOf(v.id) > -1,
|
|
49
|
+
onChange: (e) => {
|
|
50
|
+
onUpdateFilterValue(v.id, index);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)));
|
|
54
|
+
} else {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
40
57
|
};
|
|
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}}]*/
|
|
46
58
|
export class APIConfig extends Component {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
constructor(props) {
|
|
60
|
+
super(props);
|
|
61
|
+
this.onMeasuresChange = this.onMeasuresChange.bind(this);
|
|
62
|
+
this.onSetSingleMeasure = this.onSetSingleMeasure.bind(this);
|
|
63
|
+
this.addFilter = this.addFilter.bind(this);
|
|
64
|
+
this.updateFilterParam = this.updateFilterParam.bind(this);
|
|
65
|
+
this.updateFilterValue = this.updateFilterValue.bind(this);
|
|
66
|
+
this.setFilterValue = this.setFilterValue.bind(this);
|
|
67
|
+
this.removeFilter = this.removeFilter.bind(this);
|
|
68
|
+
this.items = this.items.bind(this);
|
|
69
|
+
this.onFormatChange = this.onFormatChange.bind(this);
|
|
70
|
+
this.onCustomLabelToggleChange = this.onCustomLabelToggleChange.bind(this);
|
|
71
|
+
this.onCustomLabelChange = this.onCustomLabelChange.bind(this);
|
|
72
|
+
this.onUseCustomAxisFormatChange = this.onUseCustomAxisFormatChange.bind(this);
|
|
73
|
+
this.state = {
|
|
74
|
+
measures: [],
|
|
75
|
+
dimensions: [],
|
|
76
|
+
filters: [],
|
|
77
|
+
categories: []
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
cleanSelection(prevState) {
|
|
81
|
+
const { setAttributes } = this.props;
|
|
82
|
+
setAttributes({ measures: [], filters: [] });
|
|
83
|
+
}
|
|
84
|
+
updateFilterParam(param, idx) {
|
|
85
|
+
const {
|
|
86
|
+
attributes: { filters },
|
|
87
|
+
setAttributes,
|
|
88
|
+
allFilters
|
|
89
|
+
} = this.props;
|
|
90
|
+
const newFilters = filters.slice();
|
|
91
|
+
const selected = allFilters.filter((f) => f.param === param)[0];
|
|
92
|
+
newFilters[idx] = { ...selected, value: [] };
|
|
93
|
+
setAttributes({ filters: newFilters });
|
|
94
|
+
}
|
|
95
|
+
updateFilterValue(value, idx) {
|
|
96
|
+
const {
|
|
97
|
+
attributes: { filters },
|
|
98
|
+
setAttributes,
|
|
99
|
+
allFilters
|
|
100
|
+
} = this.props;
|
|
101
|
+
const selected = filters[idx];
|
|
102
|
+
let values = selected.value;
|
|
103
|
+
if (values.indexOf(value) > -1) {
|
|
104
|
+
values = values.filter((v) => v != value);
|
|
105
|
+
} else {
|
|
106
|
+
values.push(value);
|
|
69
107
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
108
|
+
const newFilters = filters.slice();
|
|
109
|
+
newFilters[idx].value = values;
|
|
110
|
+
setAttributes({ filters: newFilters });
|
|
111
|
+
}
|
|
112
|
+
setFilterValue(value, idx) {
|
|
113
|
+
const {
|
|
114
|
+
attributes: { filters },
|
|
115
|
+
setAttributes,
|
|
116
|
+
allFilters
|
|
117
|
+
} = this.props;
|
|
118
|
+
const selected = filters[idx];
|
|
119
|
+
let values = selected.value;
|
|
120
|
+
values = value.split(",");
|
|
121
|
+
const newFilters = filters.slice();
|
|
122
|
+
newFilters[idx].value = values;
|
|
123
|
+
setAttributes({ filters: newFilters });
|
|
124
|
+
}
|
|
125
|
+
addFilter() {
|
|
126
|
+
const {
|
|
127
|
+
attributes: { filters },
|
|
128
|
+
setAttributes,
|
|
129
|
+
allFilters
|
|
130
|
+
} = this.props;
|
|
131
|
+
let index = filters.length > allFilters.length ? allFilters.length : filters.length;
|
|
132
|
+
const newFilter = allFilters && allFilters.length > 0 ? {
|
|
133
|
+
...allFilters[index],
|
|
134
|
+
value: []
|
|
135
|
+
} : null;
|
|
136
|
+
let newFilters = filters.slice();
|
|
137
|
+
newFilters.push(newFilter);
|
|
138
|
+
setAttributes({ filters: newFilters });
|
|
139
|
+
}
|
|
140
|
+
removeFilter(f) {
|
|
141
|
+
const {
|
|
142
|
+
attributes: { filters },
|
|
143
|
+
setAttributes,
|
|
144
|
+
allFilters
|
|
145
|
+
} = this.props;
|
|
146
|
+
let newFilters = filters.slice(0, -1);
|
|
147
|
+
setAttributes({ filters: newFilters });
|
|
148
|
+
}
|
|
149
|
+
componentDidUpdate(prevProps) {
|
|
150
|
+
const {
|
|
151
|
+
setAttributes,
|
|
152
|
+
attributes: { type, colorBy, dimension2, types, measures, app }
|
|
153
|
+
} = this.props;
|
|
154
|
+
const {
|
|
155
|
+
attributes: { type: prevType, dimension2: prevDimension2 }
|
|
156
|
+
} = prevProps;
|
|
157
|
+
const prevTypeObject = types.filter((t) => t.value === prevType).length > 0 ? types.filter((t) => t.value === prevType)[0] : null;
|
|
158
|
+
if (dimension2 != prevDimension2) {
|
|
159
|
+
const uMs = Object.assign({}, measures);
|
|
160
|
+
if (dimension2 != "none") {
|
|
161
|
+
let i = 0;
|
|
162
|
+
if (uMs[app]) {
|
|
163
|
+
const selected = Object.keys(uMs[app]).map(
|
|
164
|
+
(k) => uMs[app][k].selected
|
|
165
|
+
).length;
|
|
166
|
+
if (selected > 1) {
|
|
167
|
+
Object.keys(uMs[app]).forEach((k) => {
|
|
168
|
+
if (uMs[app][k].selected) {
|
|
169
|
+
uMs[app][k].prevSelected = true;
|
|
170
|
+
uMs[app][k].selected = i > 0 ? false : true;
|
|
171
|
+
} else {
|
|
172
|
+
uMs[app][k].prevSelected = false;
|
|
173
|
+
}
|
|
174
|
+
i++;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
90
177
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
setAttributes({ filters: newFilters });
|
|
178
|
+
setAttributes({ measures: uMs });
|
|
179
|
+
}
|
|
180
|
+
if (dimension2 == "none" && uMs[app]) {
|
|
181
|
+
Object.keys(uMs[app]).forEach((k) => {
|
|
182
|
+
if (uMs[app][k].prevSelected) {
|
|
183
|
+
uMs[app][k].selected = true;
|
|
184
|
+
uMs[app][k].prevSelected = false;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
setAttributes({ measures: uMs });
|
|
188
|
+
}
|
|
103
189
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let newFilters = filters.slice();
|
|
114
|
-
newFilters.push(newFilter);
|
|
115
|
-
setAttributes({ filters: newFilters });
|
|
190
|
+
}
|
|
191
|
+
onSetSingleMeasure(value) {
|
|
192
|
+
const {
|
|
193
|
+
setAttributes,
|
|
194
|
+
attributes: { app, measures }
|
|
195
|
+
} = this.props;
|
|
196
|
+
const uMs = Object.assign({}, measures);
|
|
197
|
+
if (!uMs[app]) {
|
|
198
|
+
uMs[app] = {};
|
|
116
199
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
200
|
+
Object.keys(uMs[app]).filter((k) => typeof uMs[app][k] !== "boolean").forEach((k) => uMs[app][k].selected = false);
|
|
201
|
+
if (uMs[app][value]) {
|
|
202
|
+
uMs[app][value].selected = uMs[app][value].selected ? false : true;
|
|
203
|
+
} else {
|
|
204
|
+
uMs[app][value] = { selected: true, format: defaultFormat };
|
|
121
205
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (uMs[app][k].selected) {
|
|
138
|
-
uMs[app][k].prevSelected = true; //can be used to recover measures
|
|
139
|
-
uMs[app][k].selected = i > 0 ? false : true;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
uMs[app][k].prevSelected = false;
|
|
143
|
-
}
|
|
144
|
-
i++;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
setAttributes({ measures: uMs });
|
|
149
|
-
}
|
|
150
|
-
if (dimension2 == "none" && uMs[app]) {
|
|
151
|
-
Object.keys(uMs[app]).forEach((k) => {
|
|
152
|
-
if (uMs[app][k].prevSelected) {
|
|
153
|
-
uMs[app][k].selected = true; //can be used to recover measures
|
|
154
|
-
uMs[app][k].prevSelected = false;
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
setAttributes({ measures: uMs });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
206
|
+
setAttributes({ measures: uMs });
|
|
207
|
+
}
|
|
208
|
+
onFormatChange(format, field) {
|
|
209
|
+
const {
|
|
210
|
+
setAttributes,
|
|
211
|
+
attributes: { app, measures }
|
|
212
|
+
} = this.props;
|
|
213
|
+
const uMs = Object.assign({}, { ...measures });
|
|
214
|
+
if (!uMs[app]) {
|
|
215
|
+
uMs[app] = {
|
|
216
|
+
allowSelection: false,
|
|
217
|
+
format,
|
|
218
|
+
customFormat: format,
|
|
219
|
+
selected: false
|
|
220
|
+
};
|
|
160
221
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
222
|
+
uMs[app][field] = format;
|
|
223
|
+
setAttributes({ measures: uMs });
|
|
224
|
+
}
|
|
225
|
+
onUseCustomAxisFormatChange(value) {
|
|
226
|
+
const {
|
|
227
|
+
setAttributes,
|
|
228
|
+
attributes: { app, measures }
|
|
229
|
+
} = this.props;
|
|
230
|
+
const uMs = Object.assign({}, { ...measures });
|
|
231
|
+
if (uMs[app]) {
|
|
232
|
+
uMs[app].useCustomAxisFormat = value;
|
|
233
|
+
setAttributes({ measures: uMs });
|
|
234
|
+
} else {
|
|
235
|
+
uMs[app] = {
|
|
236
|
+
allowSelection: false,
|
|
237
|
+
format: defaultFormat,
|
|
238
|
+
customFormat: defaultFormat,
|
|
239
|
+
selected: false,
|
|
240
|
+
useCustomAxisFormat: value
|
|
241
|
+
};
|
|
242
|
+
setAttributes({ measures: uMs });
|
|
177
243
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
244
|
+
}
|
|
245
|
+
/*
|
|
246
|
+
onCustomMeasureFieldChange(measureName, field, value) {
|
|
247
|
+
|
|
248
|
+
const {setAttributes, attributes: {measures}} = this.props
|
|
249
|
+
const uMs = Object.assign({}, {...measures})
|
|
250
|
+
|
|
251
|
+
if (uMs[measureName]) {
|
|
252
|
+
uMs[measureName][field] = value
|
|
253
|
+
} else {
|
|
254
|
+
uMs[measureName] = {allowSelection: false, field: value, selected: false}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
setAttributes({measures: uMs})
|
|
188
258
|
}
|
|
189
|
-
|
|
190
|
-
|
|
259
|
+
*/
|
|
260
|
+
onMeasuresChange(value) {
|
|
261
|
+
const {
|
|
262
|
+
setAttributes,
|
|
263
|
+
attributes: { app, measures }
|
|
264
|
+
} = this.props;
|
|
265
|
+
const uMs = Object.assign({}, measures);
|
|
266
|
+
if (!uMs[app]) {
|
|
267
|
+
uMs[app] = {};
|
|
191
268
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
uMs[app].useCustomAxisFormat = value;
|
|
197
|
-
setAttributes({ measures: uMs });
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
uMs[app] = {
|
|
201
|
-
allowSelection: false,
|
|
202
|
-
format: defaultFormat,
|
|
203
|
-
customFormat: defaultFormat,
|
|
204
|
-
selected: false,
|
|
205
|
-
useCustomAxisFormat: value,
|
|
206
|
-
};
|
|
207
|
-
setAttributes({ measures: uMs });
|
|
208
|
-
}
|
|
269
|
+
if (uMs[app][value]) {
|
|
270
|
+
uMs[app][value].selected = uMs[app][value].selected ? false : true;
|
|
271
|
+
} else {
|
|
272
|
+
uMs[app][value] = { selected: true, format: defaultFormat };
|
|
209
273
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
setAttributes({measures: uMs})
|
|
223
|
-
}
|
|
224
|
-
*/
|
|
225
|
-
onMeasuresChange(value) {
|
|
226
|
-
const { setAttributes, attributes: { app, measures }, } = this.props;
|
|
227
|
-
const uMs = Object.assign({}, measures);
|
|
228
|
-
if (!uMs[app]) {
|
|
229
|
-
uMs[app] = {};
|
|
230
|
-
}
|
|
231
|
-
if (uMs[app][value]) {
|
|
232
|
-
uMs[app][value].selected = uMs[app][value].selected ? false : true;
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
uMs[app][value] = { selected: true, format: defaultFormat };
|
|
236
|
-
}
|
|
237
|
-
setAttributes({ measures: uMs });
|
|
274
|
+
setAttributes({ measures: uMs });
|
|
275
|
+
}
|
|
276
|
+
onCustomLabelToggleChange(value) {
|
|
277
|
+
const {
|
|
278
|
+
setAttributes,
|
|
279
|
+
attributes: { app, measures }
|
|
280
|
+
} = this.props;
|
|
281
|
+
const uMs = Object.assign({}, measures);
|
|
282
|
+
if (uMs[app] && uMs[app][value]) {
|
|
283
|
+
uMs[app][value].hasCustomLabel = uMs[app][value].hasCustomLabel ? false : true;
|
|
284
|
+
setAttributes({ measures: uMs });
|
|
238
285
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
286
|
+
}
|
|
287
|
+
onCustomLabelChange(value, customLabel) {
|
|
288
|
+
const {
|
|
289
|
+
setAttributes,
|
|
290
|
+
attributes: { app, measures }
|
|
291
|
+
} = this.props;
|
|
292
|
+
const uMs = Object.assign({}, measures);
|
|
293
|
+
if (uMs[app] && uMs[app][value] && uMs[app][value].hasCustomLabel) {
|
|
294
|
+
uMs[app][value].customLabel = customLabel;
|
|
295
|
+
setAttributes({ measures: uMs });
|
|
248
296
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
297
|
+
}
|
|
298
|
+
items(type) {
|
|
299
|
+
const values = this.props.allCategories ? this.props.allCategories.filter((c) => c.type === type) : [];
|
|
300
|
+
const cat = values.length > 0 ? values[0] : null;
|
|
301
|
+
let items = null;
|
|
302
|
+
if (type === "Boolean") {
|
|
303
|
+
items = [
|
|
304
|
+
{ value: "Yes", id: true },
|
|
305
|
+
{ value: "No", id: false }
|
|
306
|
+
];
|
|
307
|
+
} else if (cat) {
|
|
308
|
+
items = cat.items;
|
|
256
309
|
}
|
|
257
|
-
items
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
310
|
+
return items;
|
|
311
|
+
}
|
|
312
|
+
render() {
|
|
313
|
+
const {
|
|
314
|
+
allDimensions,
|
|
315
|
+
allFilters,
|
|
316
|
+
allMeasures,
|
|
317
|
+
setAttributes,
|
|
318
|
+
attributes: { measures, filters, dimension1, dimension2, type, types }
|
|
319
|
+
} = this.props;
|
|
320
|
+
const currentType = types.filter((t) => t.value === type).length > 0 ? types.filter((t) => t.value === type)[0] : null;
|
|
321
|
+
return [
|
|
322
|
+
/* @__PURE__ */ React.createElement(
|
|
323
|
+
PanelBody,
|
|
324
|
+
{
|
|
325
|
+
initialOpen: false,
|
|
326
|
+
title: __(type == "map" ? "Fields" : `Dimensions`)
|
|
327
|
+
},
|
|
328
|
+
/* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
329
|
+
SelectControl,
|
|
330
|
+
{
|
|
331
|
+
label: __(type == "map" ? "Matching Field" : "First Dimension"),
|
|
332
|
+
value: [dimension1],
|
|
333
|
+
onChange: (value) => {
|
|
334
|
+
setAttributes({
|
|
335
|
+
dimension1: value,
|
|
336
|
+
dimension2: value == "none" ? "none" : dimension2
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
options: allDimensions
|
|
340
|
+
}
|
|
341
|
+
)),
|
|
342
|
+
!["radar"].includes(type) && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
343
|
+
SelectControl,
|
|
344
|
+
{
|
|
345
|
+
label: __(type == "map" ? "Breakdown Field" : "Second Dimension"),
|
|
346
|
+
value: [dimension2],
|
|
347
|
+
onChange: (value) => {
|
|
348
|
+
setAttributes({ dimension2: value });
|
|
349
|
+
},
|
|
350
|
+
options: allDimensions,
|
|
351
|
+
disabled: dimension1 == "none"
|
|
352
|
+
}
|
|
353
|
+
))
|
|
354
|
+
),
|
|
355
|
+
/* @__PURE__ */ React.createElement(
|
|
356
|
+
Measures,
|
|
357
|
+
{
|
|
358
|
+
onFormatChange: this.onFormatChange,
|
|
359
|
+
onUseCustomAxisFormatChange: this.onUseCustomAxisFormatChange,
|
|
360
|
+
onSetSingleMeasure: this.onSetSingleMeasure,
|
|
361
|
+
onMeasuresChange: this.onMeasuresChange,
|
|
362
|
+
onCustomLabelToggleChange: this.onCustomLabelToggleChange,
|
|
363
|
+
onCustomLabelChange: this.onCustomLabelChange,
|
|
364
|
+
...this.props,
|
|
365
|
+
currentType
|
|
271
366
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
React.createElement(PanelBody, { initialOpen: false, title: __("Filters") },
|
|
295
|
-
filters.map((f, index) => {
|
|
296
|
-
return (React.createElement(PanelBody, { initialOpen: true, title: __(`Filter - ${f.label}`) },
|
|
297
|
-
React.createElement(FilterSelector, { param: f.param, index: index, options: allFilters, onUpdateFilterParam: this.updateFilterParam }),
|
|
298
|
-
React.createElement(CategoricalFilter, { value: f.value, index: index, items: this.items(f.type), onUpdateFilterValue: this.updateFilterValue })));
|
|
299
|
-
}),
|
|
300
|
-
React.createElement(PanelRow, null,
|
|
301
|
-
React.createElement(Button, { variant: "link", onClick: this.addFilter }, __("Add Filter")),
|
|
302
|
-
React.createElement(Button, { variant: "link", onClick: this.removeFilter }, __("Remove"))))),
|
|
303
|
-
];
|
|
304
|
-
}
|
|
367
|
+
),
|
|
368
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Filters") }, filters.map((f, index) => {
|
|
369
|
+
return /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: true, title: __(`Filter - ${f.label}`) }, /* @__PURE__ */ React.createElement(
|
|
370
|
+
FilterSelector,
|
|
371
|
+
{
|
|
372
|
+
param: f.param,
|
|
373
|
+
index,
|
|
374
|
+
options: allFilters,
|
|
375
|
+
onUpdateFilterParam: this.updateFilterParam
|
|
376
|
+
}
|
|
377
|
+
), /* @__PURE__ */ React.createElement(
|
|
378
|
+
CategoricalFilter,
|
|
379
|
+
{
|
|
380
|
+
value: f.value,
|
|
381
|
+
index,
|
|
382
|
+
items: this.items(f.type),
|
|
383
|
+
onUpdateFilterValue: this.updateFilterValue
|
|
384
|
+
}
|
|
385
|
+
));
|
|
386
|
+
}), /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(Button, { variant: "link", onClick: this.addFilter }, __("Add Filter")), /* @__PURE__ */ React.createElement(Button, { variant: "link", onClick: this.removeFilter }, __("Remove")))))
|
|
387
|
+
];
|
|
388
|
+
}
|
|
305
389
|
}
|
|
306
390
|
export default APIConfig;
|