@agilemotion/oui-react-js 1.8.4 → 1.8.5
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/dist/ApplicationManager.js +9 -0
- package/dist/DynamicJS.js +32 -8
- package/dist/RestService.js +1 -3
- package/dist/Utils.js +17 -8
- package/dist/components/Button.js +8 -1
- package/dist/components/Calendar.js +30 -23
- package/dist/components/DataGrid.js +44 -8
- package/dist/components/DocumentTemplateDesignerComponent.js +169 -0
- package/dist/components/DocumentTemplateDesignerComponent2.js +585 -0
- package/dist/components/Icon.js +10 -0
- package/dist/components/TableCellContent.js +35 -23
- package/dist/components/Toolbar.js +10 -1
- package/dist/components/form/BaseField.js +50 -27
- package/dist/components/form/Checkbox.js +3 -0
- package/dist/components/form/CurrencyField.js +109 -0
- package/dist/components/form/DatePicker.js +1 -0
- package/dist/components/form/FieldSet.js +18 -3
- package/dist/components/form/Form.js +14 -3
- package/dist/components/form/GridField.js +34 -25
- package/dist/components/form/LookupField.js +5 -4
- package/dist/components/form/RadioGroup.js +22 -9
- package/dist/components/form/SelectItem.js +9 -5
- package/dist/components/form/TransferList.js +2 -2
- package/dist/components/layout/CollapsiblePanel.css +9 -9
- package/dist/components/layout/View.css +68 -68
- package/dist/components/layout/ViewContainer.js +11 -2
- package/dist/components/layout/Window.js +2 -0
- package/dist/components/loader.css +36 -36
- package/dist/components/media/TrainingRoom.js +5 -0
- package/dist/components/media/Video.css +4 -4
- package/dist/components/signatures/ResponsiveTable.css +91 -91
- package/dist/components/signatures/widgets.css +126 -126
- package/dist/js/Validators.js +73 -2
- package/dist/view/Dashboard.js +13 -13
- package/package.json +10 -2
|
@@ -9,22 +9,22 @@ var _Utils = _interopRequireDefault(require("../Utils"));
|
|
|
9
9
|
var _Error = _interopRequireDefault(require("@mui/icons-material/Error"));
|
|
10
10
|
var _Tooltip = _interopRequireDefault(require("./Tooltip"));
|
|
11
11
|
var _Form = _interopRequireDefault(require("./form/Form"));
|
|
12
|
+
var _DynamicJS = _interopRequireDefault(require("../DynamicJS"));
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
14
15
|
const [contentType] = _react.default.useState(props.contentType);
|
|
15
16
|
const [refresher, setRefresher] = _react.default.useState(true);
|
|
16
17
|
const [editor, setEditor] = _react.default.useState(null);
|
|
17
18
|
const editorValue = _react.default.useRef(null);
|
|
19
|
+
const formatter = new Intl.NumberFormat("en-ZA", {
|
|
20
|
+
style: "currency",
|
|
21
|
+
currency: "ZAR",
|
|
22
|
+
minimumFractionDigits: 2,
|
|
23
|
+
maximumFractionDigits: 2
|
|
24
|
+
});
|
|
18
25
|
const validate = value => {
|
|
19
26
|
if (props.editor) {
|
|
20
27
|
let validator = props.validator;
|
|
21
|
-
let errors = props.row.errors;
|
|
22
|
-
if (!_Utils.default.isNull(errors)) {
|
|
23
|
-
errors = errors.filter(error => {
|
|
24
|
-
return error.column !== props.dataBinding;
|
|
25
|
-
});
|
|
26
|
-
props.row.errors = errors;
|
|
27
|
-
}
|
|
28
28
|
if (!_Utils.default.isNull(validator)) {
|
|
29
29
|
let required = false;
|
|
30
30
|
if (!_Utils.default.isNull(validator.nullable)) {
|
|
@@ -32,25 +32,27 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
32
32
|
required = !_Utils.default.evaluateBooleanExpression(nullableExpression, props.dataBinding);
|
|
33
33
|
}
|
|
34
34
|
let formValue = {};
|
|
35
|
-
formValue[props.editor.id] = value;
|
|
35
|
+
formValue[props.editor.dataBinding || props.editor.id] = value;
|
|
36
36
|
let validation = _Utils.default.validateField(props.dataBinding, required, formValue, value, validator);
|
|
37
37
|
if (!validation.valid) {
|
|
38
38
|
let error = {};
|
|
39
39
|
error.column = props.dataBinding;
|
|
40
40
|
error.message = validation.message;
|
|
41
|
-
if (_Utils.default.isNull(errors)) {
|
|
42
|
-
errors = [];
|
|
43
|
-
props.row.errors = errors;
|
|
44
|
-
}
|
|
45
|
-
props.row.errors.push(error);
|
|
46
41
|
return error;
|
|
47
42
|
}
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
45
|
return null;
|
|
51
46
|
};
|
|
47
|
+
function updateErrors(error) {
|
|
48
|
+
if (error) {
|
|
49
|
+
props.onRowError(props.dataBinding, error, props.dataBinding);
|
|
50
|
+
} else {
|
|
51
|
+
props.onRowError(props.dataBinding, null, props.dataBinding);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
52
54
|
const valueChangeHandler = value => {
|
|
53
|
-
validate(value);
|
|
55
|
+
updateErrors(validate(value));
|
|
54
56
|
props.valueChangeHandler(props.row.id, props.dataBinding, value);
|
|
55
57
|
};
|
|
56
58
|
_react.default.useEffect(() => {
|
|
@@ -62,7 +64,8 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
62
64
|
}, [ref.current]);
|
|
63
65
|
_react.default.useEffect(() => {
|
|
64
66
|
if (props.editor && props.row) {
|
|
65
|
-
|
|
67
|
+
let value = _Utils.default.readNestedProperty(props.row, props.dataBinding);
|
|
68
|
+
editorValue.current = value;
|
|
66
69
|
}
|
|
67
70
|
}, [props.row, props.editor]);
|
|
68
71
|
_react.default.useEffect(() => {
|
|
@@ -85,7 +88,7 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
85
88
|
e.attributes.containerStyle.minWidth = e.attributes.containerStyle.minWidth ? e.attributes.containerStyle.minWidth : 0;
|
|
86
89
|
setEditor(e);
|
|
87
90
|
// This forces the editable grid to validate its initial value
|
|
88
|
-
let value = props.row
|
|
91
|
+
let value = _Utils.default.readNestedProperty(props.row, props.dataBinding);
|
|
89
92
|
valueChangeHandler(_Utils.default.isNull(value) ? null : value);
|
|
90
93
|
}
|
|
91
94
|
}, [props.editor]);
|
|
@@ -94,7 +97,7 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
94
97
|
let contentValue;
|
|
95
98
|
let tokens = props.dataBinding.split('.');
|
|
96
99
|
if (tokens.length === 1) {
|
|
97
|
-
contentValue = props.row
|
|
100
|
+
contentValue = _Utils.default.readNestedProperty(props.row, props.dataBinding);
|
|
98
101
|
} else {
|
|
99
102
|
let parent = props.row;
|
|
100
103
|
for (let i = 0; i < tokens.length - 1; i++) {
|
|
@@ -107,8 +110,8 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
107
110
|
contentValue = parent[tokens[tokens.length - 1]];
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
|
-
if (props.columnConfig.cellFormat === '
|
|
111
|
-
return _Utils.default.isNull(contentValue) ? '' : contentValue.toFixed(2);
|
|
113
|
+
if (props.columnConfig.cellFormat === 'CURRENCY' || props.columnConfig.cellFormat === 'NUMBER') {
|
|
114
|
+
return props.cellFormatter ? _DynamicJS.default.executeScriptFunction(props.cellFormatter, contentValue) : _Utils.default.isNull(contentValue) ? '' : props.columnConfig.cellFormat === 'CURRENCY' ? formatter.format(contentValue) : contentValue.toFixed(2);
|
|
112
115
|
} else {
|
|
113
116
|
if (_Utils.default.isNull(contentValue)) {
|
|
114
117
|
displayValue = '';
|
|
@@ -128,6 +131,9 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
128
131
|
displayValue = contentValue;
|
|
129
132
|
}
|
|
130
133
|
}
|
|
134
|
+
if (props.cellFormatter) {
|
|
135
|
+
displayValue = _DynamicJS.default.executeScriptFunction(props.cellFormatter, contentValue);
|
|
136
|
+
}
|
|
131
137
|
return displayValue;
|
|
132
138
|
}
|
|
133
139
|
};
|
|
@@ -139,7 +145,7 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
139
145
|
//props.formValues[props.editor.id] = props.row[props.dataBinding];
|
|
140
146
|
|
|
141
147
|
let formValue = {};
|
|
142
|
-
formValue[props.editor.id] = editorValue.current;
|
|
148
|
+
formValue[props.editor.dataBinding || props.editor.id] = editorValue.current;
|
|
143
149
|
let formConfig = {
|
|
144
150
|
type: "form",
|
|
145
151
|
id: props.editor.id + "_form",
|
|
@@ -162,7 +168,7 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
162
168
|
handle: props.handle,
|
|
163
169
|
values: formValue,
|
|
164
170
|
valueChangeHandler: value => {
|
|
165
|
-
editorValue.current = value[editor.id];
|
|
171
|
+
editorValue.current = value[editor.dataBinding || editor.id];
|
|
166
172
|
valueChangeHandler(editorValue.current);
|
|
167
173
|
},
|
|
168
174
|
viewId: props.viewId
|
|
@@ -173,7 +179,9 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
173
179
|
}
|
|
174
180
|
};
|
|
175
181
|
const render = () => {
|
|
176
|
-
let
|
|
182
|
+
let value = _Utils.default.readNestedProperty(props.row, props.dataBinding);
|
|
183
|
+
let error = validate(value);
|
|
184
|
+
updateErrors(error);
|
|
177
185
|
let hasError = !_Utils.default.isNull(error);
|
|
178
186
|
return /*#__PURE__*/_react.default.createElement("table", {
|
|
179
187
|
className: 'tableCellContentContainer',
|
|
@@ -200,10 +208,14 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
200
208
|
}, doRender()))));
|
|
201
209
|
};
|
|
202
210
|
const api = {
|
|
211
|
+
set value(val) {
|
|
212
|
+
alert('Mbulu ya nga');
|
|
213
|
+
},
|
|
203
214
|
refresh: () => {
|
|
204
215
|
setRefresher(!refresher);
|
|
205
216
|
if (_Utils.default.isNull(props.editor)) {
|
|
206
|
-
|
|
217
|
+
let value = _Utils.default.readNestedProperty(props.row, props.dataBinding);
|
|
218
|
+
valueChangeHandler(value);
|
|
207
219
|
}
|
|
208
220
|
}
|
|
209
221
|
};
|
|
@@ -66,6 +66,7 @@ const Toolbar = props => {
|
|
|
66
66
|
const [buttonVisibility, setButtonVisibility] = (0, _react.useState)({});
|
|
67
67
|
const [allButtonsVisible, setAllButtonsVisible] = (0, _react.useState)(false);
|
|
68
68
|
const [allItems] = (0, _react.useState)([]);
|
|
69
|
+
const [visible, setVisible] = _react.default.useState(true);
|
|
69
70
|
const [open, setOpen] = _react.default.useState(false);
|
|
70
71
|
const anchorRef = _react.default.useRef(null);
|
|
71
72
|
const sectionContainerRef = (0, _react.useRef)();
|
|
@@ -227,6 +228,14 @@ const Toolbar = props => {
|
|
|
227
228
|
children.push(itemHandle);
|
|
228
229
|
}
|
|
229
230
|
return children;
|
|
231
|
+
},
|
|
232
|
+
set visible(visible) {
|
|
233
|
+
setVisible(visible);
|
|
234
|
+
},
|
|
235
|
+
refresh() {
|
|
236
|
+
let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
|
|
237
|
+
setVisible(_Utils.default.evaluateBooleanExpression(parsedConfig.visible, parsedConfig.id, true));
|
|
238
|
+
let requiredNewVal = !_Utils.default.isNull(parsedConfig.validator) ? !_Utils.default.evaluateBooleanExpression(parsedConfig.validator.nullable, parsedConfig.id, true) || _Utils.default.evaluateBooleanExpression(parsedConfig.validator.required, parsedConfig.id, false) : false;
|
|
230
239
|
}
|
|
231
240
|
};
|
|
232
241
|
};
|
|
@@ -315,7 +324,7 @@ const Toolbar = props => {
|
|
|
315
324
|
})))));
|
|
316
325
|
}));
|
|
317
326
|
}
|
|
318
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
327
|
+
return visible && /*#__PURE__*/_react.default.createElement("div", {
|
|
319
328
|
id: props.config.id,
|
|
320
329
|
style: _Utils.default.mergeStyles({
|
|
321
330
|
borderBottom: '1px solid #e2e2e2',
|
|
@@ -28,6 +28,7 @@ const BaseField = props => {
|
|
|
28
28
|
const [visible, setVisible] = _react.default.useState(false);
|
|
29
29
|
const [required, setRequired] = _react.default.useState(null);
|
|
30
30
|
const validateOnChange = _react.default.useRef();
|
|
31
|
+
const ref = _react.default.useRef(null);
|
|
31
32
|
const valid = _react.default.useRef(false);
|
|
32
33
|
_react.default.useEffect(() => {
|
|
33
34
|
let value = valueObject[valueProperty];
|
|
@@ -48,31 +49,34 @@ const BaseField = props => {
|
|
|
48
49
|
// Change the required value and re-validate field if necessary
|
|
49
50
|
_react.default.useEffect(() => {
|
|
50
51
|
if (!_Utils.default.isNull(config) && validateOnChange.current === true) {
|
|
51
|
-
props.form().validateParent(config.id, doValidation(props.values, value));
|
|
52
|
+
props.form().validateParent(config.dataBinding || config.id, doValidation(props.values, value));
|
|
52
53
|
}
|
|
53
54
|
validateOnChange.current = null;
|
|
54
55
|
}, [required]);
|
|
55
56
|
const doValidation = (values, currentValue) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
if (config) {
|
|
58
|
+
let path = props.form().getValuePath(config.dataBinding || config.id);
|
|
59
|
+
let result = {
|
|
60
|
+
valid: true
|
|
61
|
+
};
|
|
62
|
+
if (!_Utils.default.isNull(config.validator) && !_Utils.default.isNull(config.validator.script)) {
|
|
63
|
+
result = _DynamicJS.default.executeScriptObject(`${config.id}Validator`, config.validator.script);
|
|
64
|
+
if (!result.valid) {
|
|
65
|
+
result.message = result.message ? result.message : config.validator.message;
|
|
66
|
+
}
|
|
64
67
|
}
|
|
68
|
+
if (result.valid) {
|
|
69
|
+
result = _Utils.default.validateField(path.valueProperty, required, path.valueObject, currentValue, config.validator);
|
|
70
|
+
}
|
|
71
|
+
setErrorMessage(_ApplicationManager.default.isFormMarkersEnabled() || result.forceMarker ? result.message : '');
|
|
72
|
+
setHasError(!result.valid && (_ApplicationManager.default.isFormMarkersEnabled() || result.forceMarker));
|
|
73
|
+
valid.current = result.valid && (_ApplicationManager.default.isFormMarkersEnabled() || result.forceMarker);
|
|
74
|
+
if (_ApplicationManager.default.isFormMarkersEnabled()) {
|
|
75
|
+
props.form().setFieldError(config.id, typeof result.message === 'undefined' ? null : result.message);
|
|
76
|
+
}
|
|
77
|
+
return result.valid;
|
|
65
78
|
}
|
|
66
|
-
|
|
67
|
-
result = _Utils.default.validateField(path.valueProperty, required, path.valueObject, currentValue, config.validator);
|
|
68
|
-
}
|
|
69
|
-
setErrorMessage(_ApplicationManager.default.isFormMarkersEnabled() ? result.message : '');
|
|
70
|
-
setHasError(!result.valid && _ApplicationManager.default.isFormMarkersEnabled());
|
|
71
|
-
valid.current = result.valid && _ApplicationManager.default.isFormMarkersEnabled();
|
|
72
|
-
if (_ApplicationManager.default.isFormMarkersEnabled()) {
|
|
73
|
-
props.form().setFieldError(config.id, typeof result.message === 'undefined' ? null : result.message);
|
|
74
|
-
}
|
|
75
|
-
return result.valid;
|
|
79
|
+
return false;
|
|
76
80
|
};
|
|
77
81
|
_react.default.useEffect(() => {
|
|
78
82
|
props.handle.api = api();
|
|
@@ -91,7 +95,7 @@ const BaseField = props => {
|
|
|
91
95
|
}, []);
|
|
92
96
|
_react.default.useEffect(() => {
|
|
93
97
|
if (!_Utils.default.isNull(props.values) && !_Utils.default.isNull(config)) {
|
|
94
|
-
let path = props.form().getValuePath(config.id, props.values);
|
|
98
|
+
let path = props.form().getValuePath(config.dataBinding || config.id, props.values);
|
|
95
99
|
if (!_Utils.default.isNull(path.valueObject)) {
|
|
96
100
|
setValueObject(path.valueObject);
|
|
97
101
|
setValueProperty(path.valueProperty);
|
|
@@ -103,14 +107,14 @@ const BaseField = props => {
|
|
|
103
107
|
valueObject[valueProperty] = val;
|
|
104
108
|
setValue(val);
|
|
105
109
|
valueRef.current = val;
|
|
106
|
-
props.form().handleChange(config.id, val);
|
|
110
|
+
props.form().handleChange(config.dataBinding || config.id, val);
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
}, [props.values, config]);
|
|
111
115
|
_react.default.useEffect(() => {
|
|
112
116
|
if (loadingRef.current === true && !_Utils.default.isNull(config)) {
|
|
113
|
-
let field = props.form().addField(config.id, props.handle, props.parentId, props.bindValueToForm);
|
|
117
|
+
let field = props.form().addField(config.dataBinding || config.id, props.handle, props.parentId, props.bindValueToForm);
|
|
114
118
|
if (!_Utils.default.isNull(field) && !_Utils.default.isNull(field.error)) {
|
|
115
119
|
if (field.error.length > 0) {
|
|
116
120
|
setHasError(true);
|
|
@@ -123,7 +127,7 @@ const BaseField = props => {
|
|
|
123
127
|
return () => {
|
|
124
128
|
if (!_Utils.default.isNull(props.form())) {
|
|
125
129
|
_Observable.default.clearComponentEventListeners(props.handle);
|
|
126
|
-
props.form().removeField(props.config.id);
|
|
130
|
+
props.form().removeField(props.config.dataBinding || props.config.id);
|
|
127
131
|
}
|
|
128
132
|
};
|
|
129
133
|
}, []);
|
|
@@ -152,8 +156,9 @@ const BaseField = props => {
|
|
|
152
156
|
let id = props.config.dataBinding ? props.config.dataBinding : props.config.id;
|
|
153
157
|
_ApplicationManager.default.enableFormMarkers(true);
|
|
154
158
|
if (props.config.fieldType === 'SELECT') {
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
let selectItemChange = props.form().handleSelectItemChange(id, selectOptions, newValue);
|
|
160
|
+
setValue(selectItemChange);
|
|
161
|
+
valueRef.current = selectItemChange;
|
|
157
162
|
for (const selectOption of selectOptions) {
|
|
158
163
|
if (selectOption.id === newValue) {
|
|
159
164
|
newValue = selectOption;
|
|
@@ -175,6 +180,9 @@ const BaseField = props => {
|
|
|
175
180
|
const api = () => {
|
|
176
181
|
return {
|
|
177
182
|
validate: (values, currentValue) => {
|
|
183
|
+
if (props.config.id === 'needAnalysisItems') {
|
|
184
|
+
console.log('\n\n\n==============Validate fireeee');
|
|
185
|
+
}
|
|
178
186
|
return doValidation(values, currentValue);
|
|
179
187
|
},
|
|
180
188
|
parseValue: (value, inbound) => {
|
|
@@ -189,6 +197,9 @@ const BaseField = props => {
|
|
|
189
197
|
get id() {
|
|
190
198
|
return props.config.id;
|
|
191
199
|
},
|
|
200
|
+
get rows() {
|
|
201
|
+
return props.rowsHandler ? props.rowsHandler() : null;
|
|
202
|
+
},
|
|
192
203
|
getValidationGroup: () => {
|
|
193
204
|
return !_Utils.default.isNull(config.validator) ? config.validator.group : null;
|
|
194
205
|
},
|
|
@@ -198,6 +209,14 @@ const BaseField = props => {
|
|
|
198
209
|
props.clearHandler();
|
|
199
210
|
}
|
|
200
211
|
},
|
|
212
|
+
scrollTo: () => {
|
|
213
|
+
if (ref.current) {
|
|
214
|
+
ref.current.scrollIntoView({
|
|
215
|
+
behavior: "smooth",
|
|
216
|
+
block: "center"
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
},
|
|
201
220
|
get value() {
|
|
202
221
|
if (!_Utils.default.isNull(valueObject) && !_Utils.default.isNull(valueProperty) && !_Utils.default.isNull(valueObject[valueProperty])) {
|
|
203
222
|
return !_Utils.default.isNull(props.valueParser) ? props.valueParser(valueObject[valueProperty], false) : valueObject[valueProperty];
|
|
@@ -229,13 +248,16 @@ const BaseField = props => {
|
|
|
229
248
|
let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
|
|
230
249
|
setVisible(_Utils.default.evaluateBooleanExpression(parsedConfig.visible, parsedConfig.id, true));
|
|
231
250
|
setDisabled(_Utils.default.evaluateBooleanExpression(parsedConfig.disabled, parsedConfig.id));
|
|
232
|
-
let requiredNewVal = !_Utils.default.isNull(parsedConfig.validator) ? !_Utils.default.evaluateBooleanExpression(parsedConfig.validator.nullable, parsedConfig.id, true) : false;
|
|
251
|
+
let requiredNewVal = !_Utils.default.isNull(parsedConfig.validator) ? !_Utils.default.evaluateBooleanExpression(parsedConfig.validator.nullable, parsedConfig.id, true) || _Utils.default.evaluateBooleanExpression(parsedConfig.validator.required, parsedConfig.id, false) : false;
|
|
233
252
|
validateOnChange.current = required !== null && required !== requiredNewVal && loadingRef.current === false;
|
|
234
253
|
setRequired(requiredNewVal);
|
|
235
254
|
},
|
|
236
255
|
get required() {
|
|
237
256
|
return required;
|
|
238
257
|
},
|
|
258
|
+
set required(isRequired) {
|
|
259
|
+
setRequired(isRequired);
|
|
260
|
+
},
|
|
239
261
|
setFieldRequired(newVal) {
|
|
240
262
|
let validate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
241
263
|
validateOnChange.current = validate;
|
|
@@ -255,11 +277,12 @@ const BaseField = props => {
|
|
|
255
277
|
};
|
|
256
278
|
};
|
|
257
279
|
return config ? /*#__PURE__*/_react.default.createElement("div", {
|
|
280
|
+
ref: ref,
|
|
258
281
|
className: "col-*-*",
|
|
259
282
|
key: config.id,
|
|
260
283
|
style: {
|
|
261
284
|
textAlign: 'left',
|
|
262
|
-
marginLeft: !_Utils.default.isNull(props.config.attributes?.style?.marginLeft) ? props.config.attributes?.style?.marginLeft : '
|
|
285
|
+
marginLeft: !_Utils.default.isNull(props.config.attributes?.style?.marginLeft) ? props.config.attributes?.style?.marginLeft : props.config.index === 0 ? 0 : '8px',
|
|
263
286
|
display: !visible || _Utils.default.getComponentAttribute(config, 'hidden', false) === true ? 'none' : 'block'
|
|
264
287
|
}
|
|
265
288
|
}, /*#__PURE__*/_react.default.createElement("span", null, props.children({
|
|
@@ -14,6 +14,9 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
14
14
|
const CheckboxWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
15
15
|
const base = props.base;
|
|
16
16
|
return /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, {
|
|
17
|
+
style: {
|
|
18
|
+
marginBottom: 0
|
|
19
|
+
},
|
|
17
20
|
control: /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
18
21
|
checked: base.value || false,
|
|
19
22
|
style: _Utils.default.mergeStyles({}, props.config),
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
9
|
+
var _InputAdornment = _interopRequireDefault(require("@mui/material/InputAdornment"));
|
|
10
|
+
var _BaseField = require("./BaseField");
|
|
11
|
+
var _Utils = _interopRequireDefault(require("../../Utils"));
|
|
12
|
+
var _reactRedux = require("react-redux");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
const CurrencyFieldWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
18
|
+
const base = props.base;
|
|
19
|
+
const width = !_Utils.default.isNull(props.config.attributes?.style?.width) ? props.config.attributes.style.width : "100%";
|
|
20
|
+
const maxWidth = !_Utils.default.isNull(props.config.attributes?.style?.maxWidth) ? props.config.attributes.style.maxWidth : null;
|
|
21
|
+
const minWidth = !_Utils.default.isNull(props.config.attributes?.style?.minWidth) ? props.config.attributes.style.minWidth : "240px";
|
|
22
|
+
const height = !_Utils.default.isNull(props.config.attributes?.style?.height) ? props.config.attributes.style.height : null;
|
|
23
|
+
const currency = !_Utils.default.isNull(props.config.attributes?.currency) ? props.config.attributes.currency : "ZAR";
|
|
24
|
+
const currencySymbol = !_Utils.default.isNull(props.config.attributes?.currencySymbol) ? props.config.attributes.currencySymbol : "R";
|
|
25
|
+
const textRef = (0, _react.useRef)(null);
|
|
26
|
+
const [displayValue, setDisplayValue] = (0, _react.useState)("");
|
|
27
|
+
const formatter = new Intl.NumberFormat("en-ZA", {
|
|
28
|
+
style: "currency",
|
|
29
|
+
currency: currency,
|
|
30
|
+
minimumFractionDigits: 2,
|
|
31
|
+
maximumFractionDigits: 2
|
|
32
|
+
});
|
|
33
|
+
function formatNumberWithCommas(input) {
|
|
34
|
+
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
35
|
+
}
|
|
36
|
+
(0, _react.useEffect)(() => {
|
|
37
|
+
if (base.value === null || base.value === undefined) {
|
|
38
|
+
setDisplayValue("");
|
|
39
|
+
} else {
|
|
40
|
+
setDisplayValue(currencySymbol + formatNumberWithCommas(base.value));
|
|
41
|
+
}
|
|
42
|
+
}, [base.value]);
|
|
43
|
+
const handleInputChange = event => {
|
|
44
|
+
const raw = event.target.value.replace(/[^\d.-]/g, "");
|
|
45
|
+
const parts = raw.split('.');
|
|
46
|
+
if (parts.length === 2 && parts[1].length > 2 || _Utils.default.isNull(raw.match("^\\d+(\\.\\d{0,2})?$"))) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
} else {
|
|
49
|
+
const numeric = parseFloat(raw);
|
|
50
|
+
if (!isNaN(numeric)) {
|
|
51
|
+
base.handleValueChange(numeric);
|
|
52
|
+
} else {
|
|
53
|
+
base.handleValueChange(0);
|
|
54
|
+
}
|
|
55
|
+
console.log("TARGET VAL : " + event.target.value);
|
|
56
|
+
setDisplayValue(event.target.value);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const handleBlur = () => {
|
|
60
|
+
if (base.value) {
|
|
61
|
+
setDisplayValue(formatter.format(base.value));
|
|
62
|
+
} else {
|
|
63
|
+
setDisplayValue("");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_TextField.default, {
|
|
67
|
+
id: props.id,
|
|
68
|
+
type: props.type,
|
|
69
|
+
required: base.required,
|
|
70
|
+
inputRef: textRef,
|
|
71
|
+
label: !_Utils.default.isNull(props.config.attributes) ? props.config.attributes['label'] : null,
|
|
72
|
+
onKeyUp: props.keyHandler,
|
|
73
|
+
error: base.hasError,
|
|
74
|
+
helperText: base.errorMessage,
|
|
75
|
+
margin: "dense",
|
|
76
|
+
disabled: base.disabled,
|
|
77
|
+
size: "small",
|
|
78
|
+
style: {
|
|
79
|
+
minWidth: minWidth,
|
|
80
|
+
width: width,
|
|
81
|
+
maxWidth: maxWidth,
|
|
82
|
+
height: height,
|
|
83
|
+
color: 'secondary'
|
|
84
|
+
},
|
|
85
|
+
variant: "outlined",
|
|
86
|
+
value: displayValue,
|
|
87
|
+
onChange: handleInputChange,
|
|
88
|
+
onBlur: handleBlur
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
91
|
+
const CurrencyField = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_BaseField.BaseField, _extends({}, props, {
|
|
93
|
+
handle: props.handle,
|
|
94
|
+
valueParser: (value, inbound) => {
|
|
95
|
+
if (value === null || value === undefined || value === '') {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (inbound) {
|
|
99
|
+
const numValue = parseFloat(value);
|
|
100
|
+
return isNaN(numValue) ? null : numValue;
|
|
101
|
+
} else {
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}), base => /*#__PURE__*/_react.default.createElement(CurrencyFieldWrapper, _extends({
|
|
106
|
+
base: base
|
|
107
|
+
}, props)));
|
|
108
|
+
}));
|
|
109
|
+
var _default = exports.default = CurrencyField;
|
|
@@ -76,6 +76,7 @@ const CustomDatePickerComponent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/
|
|
|
76
76
|
}, /*#__PURE__*/_react.default.createElement(_demo.DemoContainer, {
|
|
77
77
|
components: ['DatePicker', 'DatePicker']
|
|
78
78
|
}, /*#__PURE__*/_react.default.createElement(_xDatePickers.DatePicker, {
|
|
79
|
+
disabled: base.disabled,
|
|
79
80
|
label: props.config.attributes['label'],
|
|
80
81
|
value: base.value ? (0, _dayjs.default)(base.value) : null,
|
|
81
82
|
className: props.className,
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _Utils = _interopRequireDefault(require("../../Utils"));
|
|
9
9
|
var _Observable = _interopRequireDefault(require("../../event/Observable"));
|
|
10
10
|
var _TextField = _interopRequireDefault(require("./TextField"));
|
|
11
|
+
var _CurrencyField = _interopRequireDefault(require("./CurrencyField"));
|
|
11
12
|
var _AddressSearch = _interopRequireDefault(require("./AddressSearch"));
|
|
12
13
|
var _LookupField = _interopRequireDefault(require("./LookupField"));
|
|
13
14
|
var _SelectItem = _interopRequireDefault(require("./SelectItem"));
|
|
@@ -80,7 +81,9 @@ const FieldSet = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.fo
|
|
|
80
81
|
let properties = Object.getOwnPropertyNames(componentHandles);
|
|
81
82
|
for (const property of properties) {
|
|
82
83
|
let componentHandle = componentHandles[property];
|
|
83
|
-
componentHandle.api
|
|
84
|
+
if (componentHandle.api) {
|
|
85
|
+
componentHandle.api.refresh();
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
function renderComponent(component) {
|
|
@@ -119,6 +122,17 @@ const FieldSet = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.fo
|
|
|
119
122
|
values: props.values,
|
|
120
123
|
viewId: props.viewId
|
|
121
124
|
});
|
|
125
|
+
case 'CURRENCY':
|
|
126
|
+
return /*#__PURE__*/_react.default.createElement(_CurrencyField.default, {
|
|
127
|
+
keyHandler: props.keyHandler,
|
|
128
|
+
config: component,
|
|
129
|
+
valueChangeHandler: () => fireChangeEvent(),
|
|
130
|
+
form: props.form,
|
|
131
|
+
parentId: props.parentId,
|
|
132
|
+
handle: createComponentHandle(component),
|
|
133
|
+
values: props.values,
|
|
134
|
+
viewId: props.viewId
|
|
135
|
+
});
|
|
122
136
|
case 'PASSWORD':
|
|
123
137
|
return /*#__PURE__*/_react.default.createElement(_TextField.default, {
|
|
124
138
|
keyHandler: props.keyHandler,
|
|
@@ -484,12 +498,13 @@ const FieldSet = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.fo
|
|
|
484
498
|
minWidth: '320px',
|
|
485
499
|
width: width + '%'
|
|
486
500
|
};
|
|
501
|
+
field.index = index;
|
|
487
502
|
let style = field.attributes?.containerStyle ? _Utils.default.mergeObjects(field.attributes?.containerStyle, containerStyle) : containerStyle;
|
|
488
503
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
489
|
-
key: index,
|
|
504
|
+
key: (i + 1) * index,
|
|
490
505
|
className: "col-*-*",
|
|
491
506
|
style: style
|
|
492
|
-
}, renderComponent(field
|
|
507
|
+
}, renderComponent(field));
|
|
493
508
|
}));
|
|
494
509
|
}));
|
|
495
510
|
}
|
|
@@ -131,12 +131,16 @@ const Form = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwar
|
|
|
131
131
|
if (_Utils.default.isNull(map.id)) {
|
|
132
132
|
map.id = values.current.id;
|
|
133
133
|
}
|
|
134
|
+
let firstInvalidField = null;
|
|
134
135
|
for (const field of fields) {
|
|
135
136
|
if (field.bindValueToForm === false) {
|
|
136
137
|
continue;
|
|
137
138
|
}
|
|
138
139
|
let fieldValid = field.handle.api.validate(values.current, null);
|
|
139
|
-
if (fieldValid === false) {
|
|
140
|
+
if (fieldValid === false || _Utils.default.isNull(fieldValid)) {
|
|
141
|
+
if (firstInvalidField == null) {
|
|
142
|
+
firstInvalidField = field;
|
|
143
|
+
}
|
|
140
144
|
doValidateParent(field, !fieldValid, false);
|
|
141
145
|
valid = false;
|
|
142
146
|
} else if (valid) {
|
|
@@ -145,6 +149,9 @@ const Form = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwar
|
|
|
145
149
|
path.valueObject[path.valueProperty] = field.handle.api.parseValue(path.valueObject[path.valueProperty], false);
|
|
146
150
|
}
|
|
147
151
|
}
|
|
152
|
+
if (firstInvalidField) {
|
|
153
|
+
firstInvalidField.handle.api.scrollTo();
|
|
154
|
+
}
|
|
148
155
|
data = values.current;
|
|
149
156
|
if (!_Utils.default.isNull(containerErrorCallback.current) && _ApplicationManager.default.isFormMarkersEnabled()) {
|
|
150
157
|
containerErrorCallback.current(fieldParentErrors);
|
|
@@ -576,10 +583,13 @@ const Form = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwar
|
|
|
576
583
|
}
|
|
577
584
|
return field;
|
|
578
585
|
};
|
|
579
|
-
const handleSelectItemChange = (name, options,
|
|
586
|
+
const handleSelectItemChange = (name, options, selection) => {
|
|
587
|
+
if (typeof selection === 'object' && (_Utils.default.isNull(options) || options.length === 0)) {
|
|
588
|
+
return selection;
|
|
589
|
+
}
|
|
580
590
|
let selectedValue = null;
|
|
581
591
|
for (let i = 0; i < options.length; i++) {
|
|
582
|
-
if (options[i].id ===
|
|
592
|
+
if (options[i].id === selection) {
|
|
583
593
|
selectedValue = options[i];
|
|
584
594
|
}
|
|
585
595
|
}
|
|
@@ -615,6 +625,7 @@ const Form = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwar
|
|
|
615
625
|
}
|
|
616
626
|
return visible && /*#__PURE__*/_react.default.createElement("div", {
|
|
617
627
|
className: props.className,
|
|
628
|
+
id: props.config.id,
|
|
618
629
|
style: props.className === 'defaultForm' ? _Utils.default.mergeStyles({
|
|
619
630
|
padding: '16px 0',
|
|
620
631
|
margin: '0',
|