@dhis2/analytics 24.10.0 → 25.0.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/CHANGELOG.md +19 -0
- package/build/cjs/__demo__/CalculationModal.stories.js +448 -0
- package/build/cjs/api/analytics/AnalyticsRequest.js +12 -1
- package/build/cjs/api/dimensions.js +1 -1
- package/build/cjs/api/expression.js +67 -0
- package/build/cjs/assets/DimensionItemIcons/CalculationIcon.js +25 -0
- package/build/cjs/assets/FormulaIcon.js +40 -0
- package/build/cjs/components/DataDimension/Calculation/CalculationModal.js +447 -0
- package/build/cjs/components/DataDimension/Calculation/DataElementOption.js +77 -0
- package/build/cjs/components/DataDimension/Calculation/DataElementSelector.js +306 -0
- package/build/cjs/components/DataDimension/Calculation/DndContext.js +213 -0
- package/build/cjs/components/DataDimension/Calculation/DragHandleIcon.js +23 -0
- package/build/cjs/components/DataDimension/Calculation/DraggingItem.js +58 -0
- package/build/cjs/components/DataDimension/Calculation/DropZone.js +58 -0
- package/build/cjs/components/DataDimension/Calculation/FormulaField.js +121 -0
- package/build/cjs/components/DataDimension/Calculation/FormulaItem.js +232 -0
- package/build/cjs/components/DataDimension/Calculation/MathOperatorSelector.js +57 -0
- package/build/cjs/components/DataDimension/Calculation/Operator.js +81 -0
- package/build/cjs/components/DataDimension/Calculation/styles/CalculationModal.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/DataElementOption.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/DataElementSelector.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/DraggingItem.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/DropZone.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/FormulaField.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/FormulaItem.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/MathOperatorSelector.style.js +13 -0
- package/build/cjs/components/DataDimension/Calculation/styles/Operator.style.js +13 -0
- package/build/cjs/components/DataDimension/DataDimension.js +22 -6
- package/build/cjs/components/DataDimension/DataTypeSelector.js +5 -3
- package/build/cjs/components/DataDimension/ItemSelector.js +111 -73
- package/build/cjs/components/TransferOption.js +13 -4
- package/build/cjs/components/styles/DimensionSelector.style.js +2 -2
- package/build/cjs/components/styles/TransferOption.style.js +2 -2
- package/build/cjs/index.js +6 -0
- package/build/cjs/locales/en/translations.json +32 -7
- package/build/cjs/modules/__tests__/expressions.spec.js +139 -0
- package/build/cjs/modules/__tests__/hash.spec.js +92 -0
- package/build/cjs/modules/__tests__/parseExpression.spec.js +46 -0
- package/build/cjs/modules/dataTypes.js +8 -1
- package/build/cjs/modules/dimensionListItem.js +82 -0
- package/build/cjs/modules/expressions.js +164 -0
- package/build/cjs/modules/hash.js +28 -0
- package/build/cjs/visualizations/config/generators/dhis/singleValue.js +2 -2
- package/build/es/__demo__/CalculationModal.stories.js +440 -0
- package/build/es/api/analytics/AnalyticsRequest.js +11 -1
- package/build/es/api/dimensions.js +1 -1
- package/build/es/api/expression.js +57 -0
- package/build/es/assets/DimensionItemIcons/CalculationIcon.js +13 -0
- package/build/es/assets/FormulaIcon.js +30 -0
- package/build/es/components/DataDimension/Calculation/CalculationModal.js +418 -0
- package/build/es/components/DataDimension/Calculation/DataElementOption.js +60 -0
- package/build/es/components/DataDimension/Calculation/DataElementSelector.js +280 -0
- package/build/es/components/DataDimension/Calculation/DndContext.js +194 -0
- package/build/es/components/DataDimension/Calculation/DragHandleIcon.js +11 -0
- package/build/es/components/DataDimension/Calculation/DraggingItem.js +40 -0
- package/build/es/components/DataDimension/Calculation/DropZone.js +43 -0
- package/build/es/components/DataDimension/Calculation/FormulaField.js +98 -0
- package/build/es/components/DataDimension/Calculation/FormulaItem.js +207 -0
- package/build/es/components/DataDimension/Calculation/MathOperatorSelector.js +41 -0
- package/build/es/components/DataDimension/Calculation/Operator.js +64 -0
- package/build/es/components/DataDimension/Calculation/styles/CalculationModal.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/DataElementOption.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/DataElementSelector.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/DraggingItem.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/DropZone.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/FormulaField.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/FormulaItem.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/MathOperatorSelector.style.js +4 -0
- package/build/es/components/DataDimension/Calculation/styles/Operator.style.js +4 -0
- package/build/es/components/DataDimension/DataDimension.js +21 -6
- package/build/es/components/DataDimension/DataTypeSelector.js +6 -4
- package/build/es/components/DataDimension/ItemSelector.js +111 -73
- package/build/es/components/TransferOption.js +14 -5
- package/build/es/components/styles/DimensionSelector.style.js +2 -2
- package/build/es/components/styles/TransferOption.style.js +2 -2
- package/build/es/index.js +1 -1
- package/build/es/locales/en/translations.json +32 -7
- package/build/es/modules/__tests__/expressions.spec.js +136 -0
- package/build/es/modules/__tests__/hash.spec.js +88 -0
- package/build/es/modules/__tests__/parseExpression.spec.js +43 -0
- package/build/es/modules/dataTypes.js +6 -0
- package/build/es/modules/dimensionListItem.js +61 -0
- package/build/es/modules/expressions.js +131 -0
- package/build/es/modules/hash.js +12 -0
- package/build/es/visualizations/config/generators/dhis/singleValue.js +2 -2
- package/package.json +6 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
import { Tooltip } from '@dhis2/ui';
|
|
6
|
+
import { useSortable } from '@dnd-kit/sortable';
|
|
7
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
8
|
+
import cx from 'classnames';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
11
|
+
import { DIMENSION_TYPE_DATA_ELEMENT } from '../../../modules/dataTypes.js';
|
|
12
|
+
import { getIcon } from '../../../modules/dimensionListItem.js';
|
|
13
|
+
import { EXPRESSION_TYPE_NUMBER, EXPRESSION_TYPE_DATA } from '../../../modules/expressions.js';
|
|
14
|
+
import DragHandleIcon from './DragHandleIcon.js';
|
|
15
|
+
import styles from './styles/FormulaItem.style.js';
|
|
16
|
+
const BEFORE = 'BEFORE';
|
|
17
|
+
const AFTER = 'AFTER';
|
|
18
|
+
const maxMsBetweenClicks = 300;
|
|
19
|
+
const TAG_INPUT = 'INPUT';
|
|
20
|
+
|
|
21
|
+
const FormulaItem = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
id,
|
|
24
|
+
label,
|
|
25
|
+
value = '',
|
|
26
|
+
type,
|
|
27
|
+
isLast,
|
|
28
|
+
isHighlighted,
|
|
29
|
+
overLastDropZone,
|
|
30
|
+
onChange,
|
|
31
|
+
onClick,
|
|
32
|
+
onDoubleClick,
|
|
33
|
+
hasFocus
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
attributes,
|
|
37
|
+
listeners,
|
|
38
|
+
index,
|
|
39
|
+
isDragging,
|
|
40
|
+
over,
|
|
41
|
+
active,
|
|
42
|
+
setNodeRef,
|
|
43
|
+
transform,
|
|
44
|
+
transition
|
|
45
|
+
} = useSortable({
|
|
46
|
+
id,
|
|
47
|
+
data: {
|
|
48
|
+
label,
|
|
49
|
+
type,
|
|
50
|
+
value
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const inputRef = useRef(null);
|
|
54
|
+
const [clickTimeoutId, setClickTimeoutId] = useState(null);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (hasFocus && inputRef.current) {
|
|
57
|
+
// setTimeout seems to be needed in order for the cursor
|
|
58
|
+
// to remain in the input. Without it, the cursor disappears
|
|
59
|
+
// even though the input still has the focus.
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
inputRef.current.focus();
|
|
62
|
+
}, 50);
|
|
63
|
+
}
|
|
64
|
+
}, [inputRef, hasFocus]);
|
|
65
|
+
const activeIndex = (active === null || active === void 0 ? void 0 : active.data.current.sortable.index) || -1;
|
|
66
|
+
const style = transform ? {
|
|
67
|
+
transform: active ? undefined : CSS.Translate.toString({
|
|
68
|
+
x: transform.x,
|
|
69
|
+
y: transform.y,
|
|
70
|
+
scaleX: 1,
|
|
71
|
+
scaleY: 1
|
|
72
|
+
}),
|
|
73
|
+
transition
|
|
74
|
+
} : undefined;
|
|
75
|
+
let insertPosition;
|
|
76
|
+
|
|
77
|
+
if ((over === null || over === void 0 ? void 0 : over.id) === id) {
|
|
78
|
+
// This item is being hovered over by the item being dragged
|
|
79
|
+
if (activeIndex === -1) {
|
|
80
|
+
//The item being dragged came from the expression options
|
|
81
|
+
// so we will insert after
|
|
82
|
+
insertPosition = AFTER;
|
|
83
|
+
} else {
|
|
84
|
+
// The item being dragged is being moved in the formula
|
|
85
|
+
// so if the item is before the item being dragged, use the
|
|
86
|
+
// BEFORE position. Otherwise use the AFTER position
|
|
87
|
+
insertPosition = index > activeIndex ? AFTER : BEFORE;
|
|
88
|
+
}
|
|
89
|
+
} else if (isLast && overLastDropZone) {
|
|
90
|
+
insertPosition = AFTER;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const handleClick = e => {
|
|
94
|
+
const tagname = e.target.tagName;
|
|
95
|
+
clearTimeout(clickTimeoutId);
|
|
96
|
+
const to = setTimeout(function () {
|
|
97
|
+
if (tagname !== TAG_INPUT) {
|
|
98
|
+
onClick(id);
|
|
99
|
+
} else {
|
|
100
|
+
inputRef.current && inputRef.current.focus();
|
|
101
|
+
}
|
|
102
|
+
}, maxMsBetweenClicks);
|
|
103
|
+
setClickTimeoutId(to);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const handleDoubleClick = e => {
|
|
107
|
+
clearTimeout(clickTimeoutId);
|
|
108
|
+
setClickTimeoutId(null);
|
|
109
|
+
|
|
110
|
+
if (e.target.tagName !== TAG_INPUT) {
|
|
111
|
+
onDoubleClick(id);
|
|
112
|
+
} else {
|
|
113
|
+
inputRef.current && inputRef.current.focus();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleChange = e => onChange({
|
|
118
|
+
itemId: id,
|
|
119
|
+
value: e.target.value
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const getContent = () => {
|
|
123
|
+
if (type === EXPRESSION_TYPE_NUMBER) {
|
|
124
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
className: "jsx-".concat(styles.__hash) + " " + (cx('content', 'number', {
|
|
126
|
+
highlighted: isHighlighted
|
|
127
|
+
}) || "")
|
|
128
|
+
}, DragHandleIcon, /*#__PURE__*/React.createElement("span", {
|
|
129
|
+
className: "jsx-".concat(styles.__hash) + " " + "number-positioner"
|
|
130
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
131
|
+
"aria-hidden": "true",
|
|
132
|
+
className: "jsx-".concat(styles.__hash) + " " + "number-width"
|
|
133
|
+
}, value), /*#__PURE__*/React.createElement("input", {
|
|
134
|
+
id: id,
|
|
135
|
+
name: label,
|
|
136
|
+
onChange: handleChange,
|
|
137
|
+
value: value,
|
|
138
|
+
type: "number",
|
|
139
|
+
ref: inputRef,
|
|
140
|
+
className: "jsx-".concat(styles.__hash) + " " + "input"
|
|
141
|
+
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
142
|
+
id: styles.__hash
|
|
143
|
+
}, styles));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (type === EXPRESSION_TYPE_DATA) {
|
|
147
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
148
|
+
content: label,
|
|
149
|
+
placement: "bottom"
|
|
150
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
className: "jsx-".concat(styles.__hash) + " " + (cx('content', 'data', {
|
|
152
|
+
highlighted: isHighlighted
|
|
153
|
+
}) || "")
|
|
154
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
155
|
+
className: "jsx-".concat(styles.__hash) + " " + "icon"
|
|
156
|
+
}, getIcon(DIMENSION_TYPE_DATA_ELEMENT)), /*#__PURE__*/React.createElement("span", {
|
|
157
|
+
className: "jsx-".concat(styles.__hash) + " " + "label"
|
|
158
|
+
}, label), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
159
|
+
id: styles.__hash
|
|
160
|
+
}, styles)));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
164
|
+
className: "jsx-".concat(styles.__hash) + " " + (cx('content', 'operator', {
|
|
165
|
+
highlighted: isHighlighted
|
|
166
|
+
}) || "")
|
|
167
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
168
|
+
className: "jsx-".concat(styles.__hash) + " " + "label"
|
|
169
|
+
}, label), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
170
|
+
id: styles.__hash
|
|
171
|
+
}, styles));
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
ref: setNodeRef,
|
|
176
|
+
style: style,
|
|
177
|
+
className: "jsx-".concat(styles.__hash) + " " + (cx({
|
|
178
|
+
'last-item': isLast
|
|
179
|
+
}) || "")
|
|
180
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, attributes, listeners, {
|
|
181
|
+
onClick: handleClick,
|
|
182
|
+
onDoubleClick: handleDoubleClick,
|
|
183
|
+
"data-test": "formula-item-".concat(id),
|
|
184
|
+
className: "jsx-".concat(styles.__hash) + " " + (cx('formula-item', {
|
|
185
|
+
inactive: !isDragging,
|
|
186
|
+
insertBefore: insertPosition === BEFORE,
|
|
187
|
+
insertAfter: insertPosition === AFTER
|
|
188
|
+
}) || "")
|
|
189
|
+
}), getContent())), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
190
|
+
id: styles.__hash
|
|
191
|
+
}, styles));
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
FormulaItem.propTypes = {
|
|
195
|
+
id: PropTypes.string.isRequired,
|
|
196
|
+
label: PropTypes.string.isRequired,
|
|
197
|
+
type: PropTypes.string.isRequired,
|
|
198
|
+
onChange: PropTypes.func.isRequired,
|
|
199
|
+
onClick: PropTypes.func.isRequired,
|
|
200
|
+
onDoubleClick: PropTypes.func.isRequired,
|
|
201
|
+
hasFocus: PropTypes.bool,
|
|
202
|
+
isHighlighted: PropTypes.bool,
|
|
203
|
+
isLast: PropTypes.bool,
|
|
204
|
+
overLastDropZone: PropTypes.bool,
|
|
205
|
+
value: PropTypes.string
|
|
206
|
+
};
|
|
207
|
+
export default FormulaItem;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import i18n from '../../../locales/index.js';
|
|
5
|
+
import { getOperators } from '../../../modules/expressions.js';
|
|
6
|
+
import DraggableOperator from './Operator.js';
|
|
7
|
+
import styles from './styles/MathOperatorSelector.style.js';
|
|
8
|
+
|
|
9
|
+
const MathOperatorSelector = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
onDoubleClick
|
|
12
|
+
} = _ref;
|
|
13
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "jsx-".concat(styles.__hash) + " " + "wrapper"
|
|
15
|
+
}, /*#__PURE__*/React.createElement("h4", {
|
|
16
|
+
className: "jsx-".concat(styles.__hash) + " " + "sub-header"
|
|
17
|
+
}, i18n.t('Math operators')), /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "jsx-".concat(styles.__hash) + " " + "operators"
|
|
19
|
+
}, getOperators().map((_ref2, index) => {
|
|
20
|
+
let {
|
|
21
|
+
label,
|
|
22
|
+
value,
|
|
23
|
+
type
|
|
24
|
+
} = _ref2;
|
|
25
|
+
return /*#__PURE__*/React.createElement(DraggableOperator, {
|
|
26
|
+
key: "".concat(label, "-").concat(index),
|
|
27
|
+
label: label,
|
|
28
|
+
value: value,
|
|
29
|
+
type: type,
|
|
30
|
+
index: index,
|
|
31
|
+
onDoubleClick: onDoubleClick
|
|
32
|
+
});
|
|
33
|
+
}))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
34
|
+
id: styles.__hash
|
|
35
|
+
}, styles));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
MathOperatorSelector.propTypes = {
|
|
39
|
+
onDoubleClick: PropTypes.func.isRequired
|
|
40
|
+
};
|
|
41
|
+
export default MathOperatorSelector;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
import { useSortable } from '@dnd-kit/sortable';
|
|
6
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
7
|
+
import cx from 'classnames';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { EXPRESSION_TYPE_NUMBER, EXPRESSION_TYPE_OPERATOR } from '../../../modules/expressions.js';
|
|
11
|
+
import formulaItemStyles from './styles/FormulaItem.style.js';
|
|
12
|
+
import styles from './styles/Operator.style.js';
|
|
13
|
+
|
|
14
|
+
const Operator = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
label,
|
|
17
|
+
value,
|
|
18
|
+
type,
|
|
19
|
+
onDoubleClick
|
|
20
|
+
} = _ref;
|
|
21
|
+
const data = {
|
|
22
|
+
label,
|
|
23
|
+
value,
|
|
24
|
+
type
|
|
25
|
+
};
|
|
26
|
+
const {
|
|
27
|
+
attributes,
|
|
28
|
+
listeners,
|
|
29
|
+
setNodeRef,
|
|
30
|
+
transform
|
|
31
|
+
} = useSortable({
|
|
32
|
+
id: "operator-".concat(label),
|
|
33
|
+
data
|
|
34
|
+
});
|
|
35
|
+
const style = {
|
|
36
|
+
transform: CSS.Translate.toString(transform)
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, attributes, listeners, {
|
|
39
|
+
ref: setNodeRef,
|
|
40
|
+
style: style,
|
|
41
|
+
className: "jsx-".concat(formulaItemStyles.__hash, " jsx-").concat(styles.__hash) + " " + (listeners && listeners.className != null && listeners.className || attributes && attributes.className != null && attributes.className || "")
|
|
42
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
"data-test": "operator",
|
|
44
|
+
onDoubleClick: () => onDoubleClick(data),
|
|
45
|
+
className: "jsx-".concat(formulaItemStyles.__hash, " jsx-").concat(styles.__hash) + " " + (cx('content', {
|
|
46
|
+
operator: type === EXPRESSION_TYPE_OPERATOR,
|
|
47
|
+
number: type === EXPRESSION_TYPE_NUMBER
|
|
48
|
+
}) || "")
|
|
49
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
50
|
+
className: "jsx-".concat(formulaItemStyles.__hash, " jsx-").concat(styles.__hash)
|
|
51
|
+
}, label)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
52
|
+
id: formulaItemStyles.__hash
|
|
53
|
+
}, formulaItemStyles), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
54
|
+
id: styles.__hash
|
|
55
|
+
}, styles));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Operator.propTypes = {
|
|
59
|
+
label: PropTypes.string.isRequired,
|
|
60
|
+
type: PropTypes.string.isRequired,
|
|
61
|
+
value: PropTypes.string.isRequired,
|
|
62
|
+
onDoubleClick: PropTypes.func.isRequired
|
|
63
|
+
};
|
|
64
|
+
export default Operator;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".header.jsx-1005744271{background:".concat(colors.grey200, ";padding:").concat(spacers.dp16, ";font-weight:normal;}"), ".header-icon.jsx-1005744271{padding:0 ".concat(spacers.dp8, ";vertical-align:text-bottom;line-height:14px;}"), ".actions-wrapper.jsx-1005744271{margin-top:".concat(spacers.dp16, ";margin-bottom:").concat(spacers.dp16, ";margin-left:").concat(spacers.dp4, ";}"), ".button-container.jsx-1005744271{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".validate-button.jsx-1005744271{margin-bottom:".concat(spacers.dp4, ";}"), ".remove-button.jsx-1005744271{margin-right:".concat(spacers.dp8, ";}"), ".delete-button.jsx-1005744271{margin-right:".concat(spacers.dp8, ";}"), ".content.jsx-1005744271{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".left-section.jsx-1005744271{width:45%;}", ".right-section.jsx-1005744271{width:55%;padding-left:".concat(spacers.dp8, ";font-size:14px;}"), ".validation-message.jsx-1005744271{margin-left:".concat(spacers.dp8, ";}"), ".validation-error.jsx-1005744271{color:".concat(colors.red500, ";}"), ".validation-success.jsx-1005744271{color:".concat(colors.green500, ";}"), ".name-input.jsx-1005744271{margin-top:".concat(spacers.dp12, ";}")];
|
|
3
|
+
_defaultExport.__hash = "1005744271";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { spacers, colors } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".wrapper.jsx-2286537164{margin-top:".concat(spacers.dp4, ";}"), ".wrapper.jsx-2286537164:last-child{margin-bottom:".concat(spacers.dp4, ";}"), ".draggable-item.jsx-2286537164{cursor:pointer;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".chip.jsx-2286537164{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;background:".concat(colors.grey200, ";font-size:14px;padding:2px ").concat(spacers.dp8, " 2px 2px;border-radius:3px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), ".chip.jsx-2286537164:hover{background:".concat(colors.grey300, ";}"), ".icon.jsx-2286537164,.label.jsx-2286537164{line-height:18px;}", ".icon.jsx-2286537164{margin-right:2px;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom;padding-top:1px;}"];
|
|
3
|
+
_defaultExport.__hash = "2286537164";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".dimension-list-container.jsx-4262244129{position:relative;}", ".dimension-list-scrollbox.jsx-4262244129{position:relative;width:100%;height:337px;overflow:hidden;overflow-y:auto;border:1px solid ".concat(colors.grey400, ";}"), ".dimension-list-scroller.jsx-4262244129{position:relative;min-height:1px;padding:0 ".concat(spacers.dp4, ";}"), ".dimension-list-scroller.loading.jsx-4262244129{-webkit-filter:blur(2px);filter:blur(2px);}", ".scroll-detector.jsx-4262244129{boxsizing:border-box;width:100%;height:100px;position:absolute;bottom:0;left:0;z-index:-1;}", ".dimension-list-overlay.jsx-4262244129{position:absolute;width:100%;height:100%;z-index:2;top:0;left:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".filter-wrapper.jsx-4262244129{padding:".concat(spacers.dp8, ";border:1px solid ").concat(colors.grey400, ";border-bottom:0;}"), ".selector-wrapper.jsx-4262244129{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(spacers.dp4, ";}"), ".sub-header.jsx-4262244129{font-size:14px;font-weight:normal;margin:0 0 ".concat(spacers.dp4, ";}"), ".group-select.jsx-4262244129{width:50%;margin-top:".concat(spacers.dp4, ";}"), ".empty-list.jsx-4262244129{text-align:center;font-size:14px;line-height:16px;margin:".concat(spacers.dp24, " 0 0;color:").concat(colors.grey700, ";}")];
|
|
3
|
+
_defaultExport.__hash = "4262244129";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".dragging.jsx-2818590818{border:2px solid ".concat(colors.blue500, ";cursor:-webkit-grab;cursor:-moz-grab;cursor:grab;}"), ".number.jsx-2818590818{padding:0 ".concat(spacers.dp8, ";}")];
|
|
3
|
+
_defaultExport.__hash = "2818590818";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".first-dropzone.jsx-3773517794{position:absolute;top:0;left:0;z-index:-1;width:24px;height:28px;background-color:transparent;}", ".dragging-over.jsx-3773517794{z-index:100;}", ".empty.jsx-3773517794{position:relative;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;z-index:100;margin-left:-10px;margin-top:-4px;}", ".dragging-over.jsx-3773517794::before,.dragging-over.jsx-3773517794::after{content:'';position:absolute;}", ".dragging-over.jsx-3773517794::before{top:10px;width:4px;left:4px;height:18px;background-color:".concat(colors.blue500, ";}"), ".dragging-over.jsx-3773517794::after{top:0;left:0;width:12px;height:12px;border:4px solid ".concat(colors.blue500, ";background:transparent;border-radius:12px;}")];
|
|
3
|
+
_defaultExport.__hash = "3773517794";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".formula-field.jsx-926760428{border-right:2px solid ".concat(colors.grey200, ";height:180px;overflow:auto;padding:6px 12px;position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:").concat(spacers.dp4, " ").concat(spacers.dp8, ";width:100%;}"), ".container.jsx-926760428{position:relative;}", ".border.jsx-926760428{position:absolute;top:0;left:6px;height:180px;width:calc(100% - 6px);border-left:2px solid ".concat(colors.grey200, ";border-top:2px solid ").concat(colors.grey200, ";border-bottom:2px solid ").concat(colors.grey200, ";}"), ".placeholder.jsx-926760428{height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:".concat(spacers.dp8, ";-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;margin-top:-28px;padding:0 ").concat(spacers.dp32, ";}"), ".help-text.jsx-926760428{color:".concat(colors.grey600, ";font-size:14px;line-height:19px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}")];
|
|
3
|
+
_defaultExport.__hash = "926760428";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers, theme } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".formula-item.jsx-255634210{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;}", ".formula-item.jsx-255634210:not(.inactive){opacity:0.5;}", ".content.jsx-255634210{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;height:24px;font-size:14px;border-radius:3px;background:".concat(colors.grey200, ";}"), ".icon.jsx-255634210{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;margin-right:2px;}", ".operator.jsx-255634210{padding:0;width:24px;}", ".data.jsx-255634210,.number.jsx-255634210{padding:0 ".concat(spacers.dp8, " 0 2px;}"), ".operator.jsx-255634210 .label.jsx-255634210{margin-bottom:1px;}", ".data.jsx-255634210 .label.jsx-255634210{max-width:280px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}", ".number-positioner.jsx-255634210{position:relative;line-height:18px;}", ".number-width.jsx-255634210{padding:0 24px 0 0;visibility:hidden;}", ".input.jsx-255634210{position:absolute;width:100%;left:0;background-color:transparent;border:1px dashed #a0adba;padding:0 0 0 2px;}", ".input.jsx-255634210:hover,.input.jsx-255634210:focus{background:white;border:1px solid rgba(0,0,0,0.2);}", ".highlighted.jsx-255634210{background:".concat(theme.secondary800, ";color:").concat(colors.white, ";}"), ".highlighted.jsx-255634210 .input.jsx-255634210{color:".concat(colors.white, ";}"), ".highlighted.jsx-255634210 .input.jsx-255634210:hover,.highlighted.jsx-255634210 .input.jsx-255634210:active,.highlighted.jsx-255634210 .input.jsx-255634210:focus{color:".concat(colors.grey900, ";}"), ".highlighted.jsx-255634210 .icon path{fill:".concat(colors.white, ";}"), ".inactive.insertBefore.jsx-255634210 .content.jsx-255634210::before,.inactive.insertAfter.jsx-255634210 .content.jsx-255634210::before,.inactive.insertBefore.jsx-255634210 .content.jsx-255634210::after,.inactive.insertAfter.jsx-255634210 .content.jsx-255634210::after{content:'';position:absolute;z-index:100;}", ".content.jsx-255634210::before{top:6px;bottom:0;width:4px;background-color:".concat(colors.blue500, ";}"), ".content.jsx-255634210::after{top:-4px;width:12px;height:12px;border:4px solid ".concat(colors.blue500, ";background:transparent;border-radius:12px;}"), ".last-item.jsx-255634210{-webkit-flex:1;-ms-flex:1;flex:1;}", ".insertBefore.jsx-255634210 .content.jsx-255634210::before{left:-6px;}", ".insertBefore.jsx-255634210 .content.jsx-255634210::after{left:-10px;}", ".insertAfter.jsx-255634210 .content.jsx-255634210::before{right:-6px;}", ".insertAfter.jsx-255634210 .content.jsx-255634210::after{right:-10px;}"];
|
|
3
|
+
_defaultExport.__hash = "255634210";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".wrapper.jsx-1314592703{border:1px solid ".concat(colors.grey400, ";margin-top:").concat(spacers.dp8, ";}"), ".operators.jsx-1314592703{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:".concat(spacers.dp4, ";padding:").concat(spacers.dp4, ";border-top:1px solid ").concat(colors.grey400, ";}"), ".sub-header.jsx-1314592703{font-size:14px;font-weight:normal;margin:".concat(spacers.dp4, " ").concat(spacers.dp8, ";}")];
|
|
3
|
+
_defaultExport.__hash = "1314592703";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
+
const _defaultExport = [".number.jsx-2117397001{padding:0 ".concat(spacers.dp8, ";}"), ".operator.jsx-2117397001:hover,.number.jsx-2117397001:hover{background:".concat(colors.grey300, ";}")];
|
|
3
|
+
_defaultExport.__hash = "2117397001";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useConfig } from '@dhis2/app-runtime';
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { DIMENSION_ID_DATA } from '../../modules/predefinedDimensions.js';
|
|
@@ -8,15 +9,21 @@ const DataDimension = _ref => {
|
|
|
8
9
|
onSelect,
|
|
9
10
|
selectedDimensions,
|
|
10
11
|
displayNameProp,
|
|
11
|
-
infoBoxMessage
|
|
12
|
+
infoBoxMessage,
|
|
13
|
+
onCalculationSave
|
|
12
14
|
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
serverVersion
|
|
17
|
+
} = useConfig();
|
|
18
|
+
const supportsEDI = "".concat(serverVersion.major, ".").concat(serverVersion.minor, ".").concat(serverVersion.patch || 0) >= '2.40.0';
|
|
13
19
|
|
|
14
20
|
const onSelectItems = selectedItem => onSelect({
|
|
15
21
|
dimensionId: DIMENSION_ID_DATA,
|
|
16
22
|
items: selectedItem.map(item => ({
|
|
17
23
|
id: item.value,
|
|
18
24
|
name: item.label,
|
|
19
|
-
type: item.type
|
|
25
|
+
type: item.type,
|
|
26
|
+
expression: item.expression
|
|
20
27
|
}))
|
|
21
28
|
});
|
|
22
29
|
|
|
@@ -25,23 +32,31 @@ const DataDimension = _ref => {
|
|
|
25
32
|
value: item.id,
|
|
26
33
|
label: item.name,
|
|
27
34
|
isActive: item.isActive,
|
|
28
|
-
type: item.type
|
|
35
|
+
type: item.type,
|
|
36
|
+
expression: item.expression,
|
|
37
|
+
access: item.access
|
|
29
38
|
})),
|
|
30
39
|
onSelect: onSelectItems,
|
|
31
40
|
displayNameProp: displayNameProp,
|
|
32
41
|
infoBoxMessage: infoBoxMessage,
|
|
33
|
-
dataTest: 'data-dimension'
|
|
42
|
+
dataTest: 'data-dimension',
|
|
43
|
+
supportsEDI: supportsEDI,
|
|
44
|
+
onEDISave: onCalculationSave
|
|
34
45
|
});
|
|
35
46
|
};
|
|
36
47
|
|
|
37
48
|
DataDimension.propTypes = {
|
|
38
49
|
displayNameProp: PropTypes.string.isRequired,
|
|
39
50
|
selectedDimensions: PropTypes.arrayOf(PropTypes.shape({
|
|
51
|
+
expression: PropTypes.string,
|
|
40
52
|
id: PropTypes.string,
|
|
41
|
-
|
|
53
|
+
isActive: PropTypes.bool,
|
|
54
|
+
name: PropTypes.string,
|
|
55
|
+
type: PropTypes.string
|
|
42
56
|
})).isRequired,
|
|
43
57
|
onSelect: PropTypes.func.isRequired,
|
|
44
|
-
infoBoxMessage: PropTypes.string
|
|
58
|
+
infoBoxMessage: PropTypes.string,
|
|
59
|
+
onCalculationSave: PropTypes.func
|
|
45
60
|
};
|
|
46
61
|
DataDimension.defaultProps = {
|
|
47
62
|
selectedDimensions: [],
|
|
@@ -3,7 +3,7 @@ import { SingleSelectField, SingleSelectOption } from '@dhis2/ui';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import i18n from '../../locales/index.js';
|
|
6
|
-
import { DIMENSION_TYPE_ALL, dataTypeMap as dataTypes } from '../../modules/dataTypes.js';
|
|
6
|
+
import { DIMENSION_TYPE_ALL, dataTypeMap as dataTypes, DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM } from '../../modules/dataTypes.js';
|
|
7
7
|
import styles from './styles/DataTypeSelector.style.js';
|
|
8
8
|
|
|
9
9
|
const DataTypeSelector = _ref => {
|
|
@@ -12,7 +12,8 @@ const DataTypeSelector = _ref => {
|
|
|
12
12
|
let {
|
|
13
13
|
currentDataType,
|
|
14
14
|
onChange,
|
|
15
|
-
dataTest
|
|
15
|
+
dataTest,
|
|
16
|
+
includeCalculations
|
|
16
17
|
} = _ref;
|
|
17
18
|
return /*#__PURE__*/React.createElement("div", {
|
|
18
19
|
className: "jsx-".concat(styles.__hash) + " " + "container"
|
|
@@ -27,7 +28,7 @@ const DataTypeSelector = _ref => {
|
|
|
27
28
|
key: DIMENSION_TYPE_ALL,
|
|
28
29
|
label: i18n.t('All types'),
|
|
29
30
|
dataTest: "".concat(dataTest, "-option-all")
|
|
30
|
-
}), Object.values(dataTypes).map(type => /*#__PURE__*/React.createElement(SingleSelectOption, {
|
|
31
|
+
}), Object.values(dataTypes).filter(type => type.id !== DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM || includeCalculations).map(type => /*#__PURE__*/React.createElement(SingleSelectOption, {
|
|
31
32
|
value: type.id,
|
|
32
33
|
key: type.id,
|
|
33
34
|
label: type.getName(),
|
|
@@ -40,6 +41,7 @@ const DataTypeSelector = _ref => {
|
|
|
40
41
|
DataTypeSelector.propTypes = {
|
|
41
42
|
currentDataType: PropTypes.string.isRequired,
|
|
42
43
|
onChange: PropTypes.func.isRequired,
|
|
43
|
-
dataTest: PropTypes.string
|
|
44
|
+
dataTest: PropTypes.string,
|
|
45
|
+
includeCalculations: PropTypes.bool
|
|
44
46
|
};
|
|
45
47
|
export default DataTypeSelector;
|