@evoke-platform/ui-components 1.0.0-dev.226 → 1.0.0-dev.228
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/published/components/core/Accordion/Accordion.js +1 -1
- package/dist/published/components/core/Accordion/AccordionActions/AccordionActions.js +1 -1
- package/dist/published/components/core/Accordion/AccordionDetails/AccordionDetails.js +1 -1
- package/dist/published/components/core/Accordion/AccordionSummary/AccordionSummary.js +1 -1
- package/dist/published/components/core/Alert/Alert.js +8 -9
- package/dist/published/components/core/AlertTitle/AlertTitle.js +1 -1
- package/dist/published/components/core/AppBar/AppBar.js +1 -1
- package/dist/published/components/core/Autocomplete/Autocomplete.js +33 -15
- package/dist/published/components/core/Autocomplete/Autocomplete.test.js +1 -1
- package/dist/published/components/core/Avatar/Avatar.js +7 -4
- package/dist/published/components/core/Backdrop/Backdrop.js +1 -1
- package/dist/published/components/core/Badge/Badge.js +1 -1
- package/dist/published/components/core/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/published/components/core/Button/Button.js +1 -1
- package/dist/published/components/core/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/published/components/core/Card/Card.js +1 -1
- package/dist/published/components/core/Checkbox/Checkbox.js +1 -1
- package/dist/published/components/core/Chip/Chip.js +1 -1
- package/dist/published/components/core/CircularProgress/CircularProgress.js +1 -1
- package/dist/published/components/core/Collapse/Collapse.js +1 -1
- package/dist/published/components/core/DatePicker/DatePicker.js +4 -16
- package/dist/published/components/core/DateTimePicker/DateTimePicker.js +3 -15
- package/dist/published/components/core/Dialog/Dialog.js +1 -1
- package/dist/published/components/core/Dialog/DialogActions/DialogActions.js +2 -13
- package/dist/published/components/core/Dialog/DialogContent/DialogContent.js +1 -1
- package/dist/published/components/core/Dialog/DialogContentText/DialogContentText.js +1 -1
- package/dist/published/components/core/Dialog/DialogTitle/DialogTitle.js +1 -1
- package/dist/published/components/core/Divider/Divider.js +1 -1
- package/dist/published/components/core/Drawer/Drawer.js +1 -1
- package/dist/published/components/core/FieldError/FieldError.js +1 -2
- package/dist/published/components/core/FormElements/FormControl/FormControl.js +1 -1
- package/dist/published/components/core/FormElements/FormControlLabel/FormControlLabel.js +1 -1
- package/dist/published/components/core/FormElements/FormGroup/FormGroup.js +1 -1
- package/dist/published/components/core/FormElements/FormHelperText/FormHelperText.js +1 -1
- package/dist/published/components/core/FormElements/FormLabel/FormLabel.js +1 -1
- package/dist/published/components/core/IconButton/IconButton.js +1 -1
- package/dist/published/components/core/LinearProgress/LinearProgress.js +1 -1
- package/dist/published/components/core/Link/Link.js +1 -1
- package/dist/published/components/core/List/List.js +1 -1
- package/dist/published/components/core/List/ListItem.js +1 -1
- package/dist/published/components/core/List/ListItemText/ListItemText.js +1 -1
- package/dist/published/components/core/LoadingButton/LoadingButton.js +1 -1
- package/dist/published/components/core/LocalizationProvider/LocalizationProvider.js +3 -14
- package/dist/published/components/core/Menu/Menu.js +1 -1
- package/dist/published/components/core/Menu/MenuItem/MenuItem.js +1 -1
- package/dist/published/components/core/Paper/Paper.js +1 -1
- package/dist/published/components/core/Popover/Popover.js +1 -1
- package/dist/published/components/core/Popper/Popper.js +1 -1
- package/dist/published/components/core/RadioGroup/Radio.js +1 -1
- package/dist/published/components/core/RadioGroup/RadioGroup.js +1 -1
- package/dist/published/components/core/Select/Select.js +11 -4
- package/dist/published/components/core/Skeleton/Skeleton.js +1 -1
- package/dist/published/components/core/Snackbar/Snackbar.js +2 -2
- package/dist/published/components/core/StaticDatePicker/StaticDatePicker.js +3 -15
- package/dist/published/components/core/Stepper/Step/Step.js +1 -1
- package/dist/published/components/core/Stepper/StepButton/StepButton.js +1 -1
- package/dist/published/components/core/Stepper/StepConnector/StepConnector.js +1 -1
- package/dist/published/components/core/Stepper/StepContent/StepContent.js +1 -1
- package/dist/published/components/core/Stepper/StepIcon/StepIcon.js +1 -1
- package/dist/published/components/core/Stepper/StepLabel/StepLabel.js +1 -1
- package/dist/published/components/core/Stepper/Stepper.js +1 -1
- package/dist/published/components/core/Switch/Switch.js +1 -1
- package/dist/published/components/core/Table/Table.js +1 -1
- package/dist/published/components/core/Tabs/Tab/Tab.js +1 -1
- package/dist/published/components/core/Tabs/Tabs.js +1 -1
- package/dist/published/components/core/TextField/TextField.js +12 -6
- package/dist/published/components/core/ToggleButton/ToggleButton.js +1 -1
- package/dist/published/components/core/ToggleButtonGroup/ToggleButtonGroup.js +1 -1
- package/dist/published/components/core/Tooltip/Tooltip.js +15 -2
- package/dist/published/components/core/Typography/index.js +1 -1
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +33 -29
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +1 -2
- package/dist/published/components/custom/BuilderGrid/EmptyContent.js +4 -5
- package/dist/published/components/custom/BuilderGrid/EmptyContentIllustration.js +6 -1
- package/dist/published/components/custom/BuilderGrid/ToolbarActions.js +3 -1
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +46 -27
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.test.js +12 -21
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +27 -34
- package/dist/published/components/custom/DataGrid/DataGrid.js +38 -33
- package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +3 -5
- package/dist/published/components/custom/DataGrid/Toolbar.js +3 -4
- package/dist/published/components/custom/ErrorComponent/ErrorComponent.js +11 -1
- package/dist/published/components/custom/Form/Common/Form.js +106 -80
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +20 -11
- package/dist/published/components/custom/Form/FormComponents/ButtonComponent.js +9 -20
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +10 -20
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +24 -28
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.js +49 -64
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +109 -34
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.d.ts +2 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +13 -25
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts +3 -1
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js +30 -9
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js +26 -31
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts +5 -4
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js +70 -22
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +93 -75
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.d.ts +2 -2
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +17 -26
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.js +20 -24
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +22 -33
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +12 -9
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +105 -82
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +8 -6
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts +3 -1
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.js +55 -12
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +32 -30
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +12 -9
- package/dist/published/components/custom/Form/types.d.ts +5 -5
- package/dist/published/components/custom/Form/utils.js +611 -446
- package/dist/published/components/custom/FormField/AddressFieldComponent/AddressFieldComponent.test.js +41 -54
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +7 -8
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +5 -14
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.test.js +12 -21
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.test.js +12 -21
- package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +10 -11
- package/dist/published/components/custom/FormField/FormField.js +10 -10
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +22 -30
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.test.js +8 -17
- package/dist/published/components/custom/FormField/Select/Select.js +5 -6
- package/dist/published/components/custom/FormField/Select/Select.test.js +18 -27
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +4 -4
- package/dist/published/components/custom/HistoryLog/DisplayedProperty.js +12 -13
- package/dist/published/components/custom/HistoryLog/HistoryData.js +49 -45
- package/dist/published/components/custom/HistoryLog/HistoryLoading.js +5 -5
- package/dist/published/components/custom/HistoryLog/index.js +5 -6
- package/dist/published/components/custom/Menubar/Menubar.js +2 -2
- package/dist/published/components/custom/MultiSelect/MultiSelect.js +38 -50
- package/dist/published/components/custom/MultiSelect/SortableItem.js +1 -1
- package/dist/published/components/custom/RepeatableField/RepeatableField.js +14 -16
- package/dist/published/components/custom/UserAvatar/UserAvatar.js +12 -5
- package/dist/published/components/custom/util.js +1 -1
- package/dist/published/components/layout/Box/Box.js +1 -1
- package/dist/published/components/layout/Container/Container.js +1 -1
- package/dist/published/components/layout/Grid/Grid.js +1 -1
- package/dist/published/components/layout/Stack/Stack.js +1 -1
- package/dist/published/icons/custom/FileWithExtension.js +8 -4
- package/dist/published/icons/custom/Inherited.js +8 -6
- package/dist/published/icons/custom/Overrides.js +9 -7
- package/dist/published/icons/custom/TrashCan.js +10 -8
- package/dist/published/icons/custom/UploadCloud.js +9 -7
- package/dist/published/stories/Accordion.stories.js +2 -2
- package/dist/published/stories/Alert.stories.js +1 -1
- package/dist/published/stories/AlertTitle.stories.js +1 -1
- package/dist/published/stories/Autocomplete.stories.js +2 -2
- package/dist/published/stories/Avatar.stories.js +1 -1
- package/dist/published/stories/Backdrop.stories.js +1 -1
- package/dist/published/stories/Badge.stories.js +1 -1
- package/dist/published/stories/Box.stories.js +2 -2
- package/dist/published/stories/Breadcrumbs.stories.js +1 -1
- package/dist/published/stories/Button.stories.js +1 -1
- package/dist/published/stories/ButtonGroup.stories.js +1 -1
- package/dist/published/stories/Card.stories.js +1 -1
- package/dist/published/stories/Checkbox.stories.js +1 -1
- package/dist/published/stories/Chip.stories.js +1 -1
- package/dist/published/stories/CircularProgress.stories.js +1 -1
- package/dist/published/stories/Collapse.stories.js +1 -1
- package/dist/published/stories/Container.stories.js +1 -1
- package/dist/published/stories/CriteriaBuilder.stories.js +7 -3
- package/dist/published/stories/DataGrid.stories.js +3 -3
- package/dist/published/stories/DatePicker.stories.js +3 -14
- package/dist/published/stories/Dialog.stories.js +1 -1
- package/dist/published/stories/Divider.stories.js +1 -1
- package/dist/published/stories/Drawer.stories.js +2 -2
- package/dist/published/stories/FormControl.stories.js +1 -1
- package/dist/published/stories/FormControlLabel.stories.js +1 -1
- package/dist/published/stories/FormField.stories.js +3 -12
- package/dist/published/stories/FormGroup.stories.js +1 -1
- package/dist/published/stories/FormHelperText.stories.js +1 -1
- package/dist/published/stories/FormLabel.stories.js +1 -1
- package/dist/published/stories/Grid.stories.js +1 -1
- package/dist/published/stories/HistoryLog.stories.js +1 -1
- package/dist/published/stories/IconButton.stories.js +4 -4
- package/dist/published/stories/LinearProgress.stories.js +1 -1
- package/dist/published/stories/Link.stories.js +1 -1
- package/dist/published/stories/List.stories.js +2 -2
- package/dist/published/stories/Menu.stories.js +2 -2
- package/dist/published/stories/MenuBar.stories.js +1 -1
- package/dist/published/stories/MultiSelect.stories.js +3 -3
- package/dist/published/stories/Palette.stories.js +11 -11
- package/dist/published/stories/Paper.stories.js +1 -1
- package/dist/published/stories/RadioGroup.stories.js +1 -1
- package/dist/published/stories/RepeatableField.stories.js +6 -7
- package/dist/published/stories/RichTextViewer.stories.js +1 -1
- package/dist/published/stories/Skeleton.stories.js +1 -1
- package/dist/published/stories/Snackbar.stories.js +1 -1
- package/dist/published/stories/Stack.stories.js +1 -1
- package/dist/published/stories/StaticDatePicker.stories.js +3 -14
- package/dist/published/stories/Stepper.stories.js +3 -3
- package/dist/published/stories/Switch.stories.js +1 -1
- package/dist/published/stories/Table.stories.js +2 -2
- package/dist/published/stories/Tabs.stories.js +6 -17
- package/dist/published/stories/TextField.stories.js +1 -1
- package/dist/published/stories/TimePicker.stories.js +3 -14
- package/dist/published/stories/TimePickerSelect.stories.js +3 -14
- package/dist/published/stories/ToggleButton.stories.js +4 -4
- package/dist/published/theme/UIThemeProvider.js +1 -2
- package/package.json +1 -1
@@ -1,12 +1,3 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
1
|
import { camelCase, get, isArray, isEmpty, isNil, isObject, isUndefined, pick, startCase, transform, uniq, } from 'lodash';
|
11
2
|
import { DateTime } from 'luxon';
|
12
3
|
import { nanoid } from 'nanoid';
|
@@ -26,7 +17,7 @@ export function determineComponentType(properties, parameter) {
|
|
26
17
|
const property = properties.find((property) => property.id === parameter.id);
|
27
18
|
if (!property)
|
28
19
|
return undefined;
|
29
|
-
return
|
20
|
+
return property?.manyToManyPropertyId ? 'ManyToManyRepeatableField' : 'RepeatableField';
|
30
21
|
}
|
31
22
|
case 'document':
|
32
23
|
return 'Document';
|
@@ -73,12 +64,12 @@ export function determineParameterType(componentType) {
|
|
73
64
|
export function getFlattenEntries(entries) {
|
74
65
|
return entries.reduce((acc, entry) => {
|
75
66
|
if (entry.type === 'sections') {
|
76
|
-
const subEntries = entry.sections.flatMap((s) =>
|
77
|
-
return acc.concat(getFlattenEntries(subEntries
|
67
|
+
const subEntries = entry.sections.flatMap((s) => s.entries ?? []);
|
68
|
+
return acc.concat(getFlattenEntries(subEntries ?? []));
|
78
69
|
}
|
79
70
|
else if (entry.type === 'columns') {
|
80
|
-
const subEntries = entry.columns.flatMap((c) =>
|
81
|
-
return acc.concat(getFlattenEntries(subEntries
|
71
|
+
const subEntries = entry.columns.flatMap((c) => c.entries ?? []);
|
72
|
+
return acc.concat(getFlattenEntries(subEntries ?? []));
|
82
73
|
}
|
83
74
|
else if (entry.type === 'content') {
|
84
75
|
return acc;
|
@@ -91,24 +82,20 @@ export function getFlattenEntries(entries) {
|
|
91
82
|
export function convertFormToComponents(entries, parameters, object) {
|
92
83
|
return entries
|
93
84
|
.map((entry) => {
|
94
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
|
95
85
|
if (entry.type === 'sections') {
|
96
86
|
return {
|
97
87
|
type: 'Section',
|
98
88
|
key: nanoid(),
|
99
89
|
verticalLayout: true,
|
100
90
|
label: 'Section',
|
101
|
-
components: entry.sections.map((section) => {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
});
|
110
|
-
}),
|
111
|
-
conditional: typeof entry.visibility !== 'string' && ((_b = (_a = entry.visibility) === null || _a === void 0 ? void 0 : _a.conditions) === null || _b === void 0 ? void 0 : _b.length)
|
91
|
+
components: entry.sections.map((section) => ({
|
92
|
+
key: nanoid(),
|
93
|
+
label: section.label,
|
94
|
+
components: section.entries?.length
|
95
|
+
? convertFormToComponents(section.entries, parameters, object)
|
96
|
+
: [],
|
97
|
+
})),
|
98
|
+
conditional: typeof entry.visibility !== 'string' && entry.visibility?.conditions?.length
|
112
99
|
? {
|
113
100
|
show: entry.visibility.conditions[0].operator === 'eq',
|
114
101
|
when: entry.visibility.conditions[0].property,
|
@@ -124,13 +111,15 @@ export function convertFormToComponents(entries, parameters, object) {
|
|
124
111
|
type: 'Columns',
|
125
112
|
key: nanoid(),
|
126
113
|
label: 'Columns',
|
127
|
-
columns: entry.columns.map((column) => {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
114
|
+
columns: entry.columns.map((column) => ({
|
115
|
+
...column,
|
116
|
+
size: 'md',
|
117
|
+
currentWidth: column.width,
|
118
|
+
components: column.entries?.length
|
119
|
+
? convertFormToComponents(column.entries, parameters, object)
|
120
|
+
: [],
|
121
|
+
})),
|
122
|
+
conditional: typeof entry.visibility !== 'string' && entry.visibility?.conditions?.length
|
134
123
|
? {
|
135
124
|
show: entry.visibility.conditions[0].operator === 'eq',
|
136
125
|
when: entry.visibility.conditions[0].property,
|
@@ -146,7 +135,7 @@ export function convertFormToComponents(entries, parameters, object) {
|
|
146
135
|
type: 'Content',
|
147
136
|
key: nanoid(),
|
148
137
|
html: entry.html,
|
149
|
-
conditional: typeof entry.visibility !== 'string' &&
|
138
|
+
conditional: typeof entry.visibility !== 'string' && entry.visibility?.conditions?.length
|
150
139
|
? {
|
151
140
|
show: entry.visibility.conditions[0].operator === 'eq',
|
152
141
|
when: entry.visibility.conditions[0].property,
|
@@ -163,190 +152,190 @@ export function convertFormToComponents(entries, parameters, object) {
|
|
163
152
|
if (!parameter) {
|
164
153
|
return;
|
165
154
|
}
|
166
|
-
let property =
|
155
|
+
let property = object.properties?.find((p) => p.id === entry.parameterId) ?? {
|
167
156
|
id: entry.parameterId,
|
168
157
|
};
|
169
|
-
if (
|
170
|
-
const topLevelProperty =
|
158
|
+
if (property.id?.includes('.')) {
|
159
|
+
const topLevelProperty = object.properties?.find((p) => p.id === property.id?.split('.')[0] && (p.type === 'address' || p.type === 'user'));
|
171
160
|
property = {
|
172
161
|
id: property.id,
|
173
|
-
name:
|
162
|
+
name: topLevelProperty?.name
|
174
163
|
? `${topLevelProperty.name} ${startCase(property.id.split('.')[1])}`
|
175
164
|
: startCase(property.id.split('.')[1]),
|
176
165
|
};
|
177
166
|
}
|
178
|
-
const type = determineComponentType(
|
167
|
+
const type = determineComponentType(object.properties ?? [], parameter);
|
179
168
|
if (!type) {
|
180
169
|
return;
|
181
170
|
}
|
182
|
-
return
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
171
|
+
return {
|
172
|
+
...pick(displayOptions, 'label', 'description', 'tooltip', 'prefix', 'suffix', 'readOnly', 'mode'),
|
173
|
+
initialValue: type === 'Object'
|
174
|
+
? typeof displayOptions?.defaultValue === 'string'
|
175
|
+
? displayOptions.defaultValue
|
176
|
+
: undefined
|
177
|
+
: displayOptions?.defaultValue,
|
178
|
+
isMultiLineText: parameter.type === 'string' && displayOptions?.rowCount ? true : false,
|
179
|
+
rows: displayOptions?.rowCount,
|
180
|
+
key: parameter.id,
|
181
|
+
type,
|
182
|
+
multiple: ['array', 'document'].includes(parameter.type),
|
183
|
+
data: {
|
189
184
|
values: entry.enumWithLabels,
|
190
|
-
},
|
185
|
+
},
|
186
|
+
property: property,
|
187
|
+
defaultToCurrentTime: displayOptions?.defaultValue === 'currentTime' && parameter.type === 'time' ? true : false,
|
188
|
+
defaultToCurrentDate: displayOptions?.defaultValue === 'currentDate' && parameter.type === 'date' ? true : false,
|
189
|
+
defaultValueCriteria: parameter.type === 'object' &&
|
190
|
+
displayOptions?.defaultValue &&
|
191
|
+
typeof displayOptions.defaultValue !== 'string'
|
191
192
|
? displayOptions.defaultValue.criteria
|
192
|
-
: undefined,
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
?
|
197
|
-
: undefined,
|
198
|
-
|
199
|
-
|
200
|
-
|
193
|
+
: undefined,
|
194
|
+
sortBy: parameter.type === 'object' &&
|
195
|
+
displayOptions?.defaultValue &&
|
196
|
+
typeof displayOptions.defaultValue !== 'string'
|
197
|
+
? displayOptions.defaultValue?.sortBy
|
198
|
+
: undefined,
|
199
|
+
orderBy: parameter.type === 'object' &&
|
200
|
+
displayOptions?.defaultValue &&
|
201
|
+
typeof displayOptions.defaultValue !== 'string'
|
202
|
+
? displayOptions.defaultValue.orderBy
|
203
|
+
: undefined,
|
204
|
+
inputMask: parameter.type === 'string' ? parameter.validation?.mask : undefined,
|
205
|
+
inputMaskPlacholderChar: displayOptions?.placeholderChar,
|
206
|
+
placeholder: displayOptions?.placeholder,
|
207
|
+
tableView: false,
|
208
|
+
displayOption: parameter.type === 'object' ? displayOptions?.relatedObjectDisplay : undefined,
|
209
|
+
labelPosition: 'top',
|
210
|
+
dataSrc: property.enum?.length ? 'values' : undefined,
|
211
|
+
showCharCount: displayOptions?.charCount,
|
212
|
+
objectId: object.id,
|
213
|
+
validate: {
|
214
|
+
required: displayOptions?.required,
|
215
|
+
criteria: ['collection', 'object'].includes(parameter.type ?? '')
|
216
|
+
? parameter.validation?.criteria
|
201
217
|
: undefined,
|
202
218
|
regexes: parameter.type === 'string'
|
203
|
-
?
|
204
|
-
|
205
|
-
|
206
|
-
})
|
219
|
+
? parameter.validation?.rules?.map((rule) => ({
|
220
|
+
...rule,
|
221
|
+
errorMessage: rule.errorMessage ?? 'Property is not in a valid format',
|
222
|
+
}))
|
207
223
|
: [],
|
208
|
-
operator:
|
224
|
+
operator: parameter.validation?.operator ?? 'any',
|
209
225
|
minLength: parameter.type === 'string'
|
210
|
-
?
|
226
|
+
? parameter.validation?.minLength
|
211
227
|
: undefined,
|
212
228
|
maxLength: parameter.type === 'string'
|
213
|
-
?
|
229
|
+
? parameter.validation?.maxLength
|
214
230
|
: undefined,
|
215
|
-
minDate: parameter.type === 'date' ?
|
216
|
-
maxDate: parameter.type === 'date' ?
|
217
|
-
minTime: parameter.type === 'time' ?
|
218
|
-
maxTime: parameter.type === 'time' ?
|
219
|
-
min: ['integer', 'number'].includes(
|
220
|
-
?
|
231
|
+
minDate: parameter.type === 'date' ? parameter.validation?.from : undefined,
|
232
|
+
maxDate: parameter.type === 'date' ? parameter.validation?.to : undefined,
|
233
|
+
minTime: parameter.type === 'time' ? parameter.validation?.from : undefined,
|
234
|
+
maxTime: parameter.type === 'time' ? parameter.validation?.to : undefined,
|
235
|
+
min: ['integer', 'number'].includes(parameter.type ?? '')
|
236
|
+
? parameter.validation?.minimum
|
221
237
|
: undefined,
|
222
|
-
max: ['integer', 'number'].includes(
|
223
|
-
?
|
238
|
+
max: ['integer', 'number'].includes(parameter.type ?? '')
|
239
|
+
? parameter.validation?.maximum
|
224
240
|
: undefined,
|
225
241
|
minDocuments: parameter.type === 'document'
|
226
|
-
?
|
242
|
+
? parameter.validation?.minDocuments
|
227
243
|
: undefined,
|
228
244
|
maxDocuments: parameter.type === 'document'
|
229
|
-
?
|
245
|
+
? parameter.validation?.maxDocuments
|
230
246
|
: undefined,
|
231
|
-
customMessage: ['integer', 'number', 'date', 'time', 'document'].includes(
|
232
|
-
?
|
247
|
+
customMessage: ['integer', 'number', 'date', 'time', 'document'].includes(parameter.type ?? '')
|
248
|
+
? parameter.validation
|
249
|
+
?.errorMessage
|
233
250
|
: '',
|
234
|
-
},
|
251
|
+
},
|
252
|
+
id: nanoid(7),
|
253
|
+
isAddressLine1: property.id?.split('.')[1] === 'line1' ? true : false,
|
254
|
+
addressPropertyId: property.id?.split('.')[1] === 'line1' ? property.id?.split('.')[0] : undefined,
|
255
|
+
input: true,
|
256
|
+
widget: (parameter.type === 'string' && parameter.enum) || parameter.type === 'array'
|
235
257
|
? 'choicejs'
|
236
|
-
: undefined,
|
237
|
-
|
238
|
-
|
258
|
+
: undefined,
|
259
|
+
conditional: displayOptions?.visibility &&
|
260
|
+
typeof displayOptions?.visibility !== 'string' &&
|
261
|
+
displayOptions.visibility.conditions?.length
|
239
262
|
? {
|
240
|
-
show:
|
241
|
-
when: displayOptions
|
242
|
-
eq: displayOptions
|
263
|
+
show: displayOptions?.visibility.conditions[0].operator === 'eq',
|
264
|
+
when: displayOptions?.visibility.conditions[0].property,
|
265
|
+
eq: displayOptions?.visibility.conditions[0].value,
|
243
266
|
}
|
244
267
|
: {
|
245
|
-
json: displayOptions
|
246
|
-
},
|
268
|
+
json: displayOptions?.visibility,
|
269
|
+
},
|
270
|
+
viewLayout: displayOptions?.viewLayout,
|
271
|
+
};
|
247
272
|
}
|
248
273
|
})
|
249
274
|
.filter((item) => item);
|
250
275
|
}
|
251
276
|
export function convertComponentsToForm(components) {
|
252
277
|
return components.map((component) => {
|
253
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
254
278
|
if (component.type === 'Section') {
|
255
|
-
return
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
})
|
263
|
-
(
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
+
return {
|
280
|
+
type: 'sections',
|
281
|
+
label: component.label,
|
282
|
+
sections: component.components?.map((section) => ({
|
283
|
+
key: nanoid(),
|
284
|
+
label: section.label,
|
285
|
+
entries: section.components?.length ? convertComponentsToForm(section.components) : [],
|
286
|
+
})),
|
287
|
+
...(component.conditional?.json ||
|
288
|
+
(component.conditional?.when && !isUndefined(component.conditional?.show) && component.conditional?.eq)
|
289
|
+
? {
|
290
|
+
visibility: component.conditional.json
|
291
|
+
? component.conditional.json
|
292
|
+
: {
|
293
|
+
operator: 'all',
|
294
|
+
conditions: [
|
295
|
+
{
|
296
|
+
property: component.conditional.when,
|
297
|
+
operator: component.conditional.show ? 'eq' : 'ne',
|
298
|
+
value: component.conditional.eq,
|
299
|
+
},
|
300
|
+
],
|
301
|
+
},
|
302
|
+
}
|
303
|
+
: {}),
|
304
|
+
};
|
279
305
|
}
|
280
306
|
else if (component.type === 'Columns') {
|
281
|
-
return Object.assign({ type: 'columns', label: component.label, columns: (_f = component.columns) === null || _f === void 0 ? void 0 : _f.map((column) => {
|
282
|
-
var _a;
|
283
|
-
return ({
|
284
|
-
width: column.width,
|
285
|
-
entries: ((_a = column.components) === null || _a === void 0 ? void 0 : _a.length) ? convertComponentsToForm(column.components) : [],
|
286
|
-
});
|
287
|
-
}) }, (((_g = component.conditional) === null || _g === void 0 ? void 0 : _g.json) ||
|
288
|
-
(((_h = component.conditional) === null || _h === void 0 ? void 0 : _h.when) && !isUndefined((_j = component.conditional) === null || _j === void 0 ? void 0 : _j.show) && ((_k = component.conditional) === null || _k === void 0 ? void 0 : _k.eq))
|
289
|
-
? {
|
290
|
-
visibility: component.conditional.json
|
291
|
-
? component.conditional.json
|
292
|
-
: {
|
293
|
-
operator: 'all',
|
294
|
-
conditions: [
|
295
|
-
{
|
296
|
-
property: component.conditional.when,
|
297
|
-
operator: component.conditional.show ? 'eq' : 'ne',
|
298
|
-
value: component.conditional.eq,
|
299
|
-
},
|
300
|
-
],
|
301
|
-
},
|
302
|
-
}
|
303
|
-
: {}));
|
304
|
-
}
|
305
|
-
else if (component.type === 'Content') {
|
306
|
-
return Object.assign({ type: 'content', html: (_l = component.html) !== null && _l !== void 0 ? _l : '' }, (((_m = component.conditional) === null || _m === void 0 ? void 0 : _m.json) ||
|
307
|
-
(((_o = component.conditional) === null || _o === void 0 ? void 0 : _o.when) && !isUndefined((_p = component.conditional) === null || _p === void 0 ? void 0 : _p.show) && ((_q = component.conditional) === null || _q === void 0 ? void 0 : _q.eq))
|
308
|
-
? {
|
309
|
-
visibility: component.conditional.json
|
310
|
-
? component.conditional.json
|
311
|
-
: {
|
312
|
-
operator: 'all',
|
313
|
-
conditions: [
|
314
|
-
{
|
315
|
-
property: component.conditional.when,
|
316
|
-
operator: component.conditional.show ? 'eq' : 'ne',
|
317
|
-
value: component.conditional.eq,
|
318
|
-
},
|
319
|
-
],
|
320
|
-
},
|
321
|
-
}
|
322
|
-
: {}));
|
323
|
-
}
|
324
|
-
else {
|
325
307
|
return {
|
326
|
-
type: '
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
308
|
+
type: 'columns',
|
309
|
+
label: component.label,
|
310
|
+
columns: component.columns?.map((column) => ({
|
311
|
+
width: column.width,
|
312
|
+
entries: column.components?.length ? convertComponentsToForm(column.components) : [],
|
313
|
+
})),
|
314
|
+
...(component.conditional?.json ||
|
315
|
+
(component.conditional?.when && !isUndefined(component.conditional?.show) && component.conditional?.eq)
|
332
316
|
? {
|
333
|
-
|
334
|
-
?
|
335
|
-
:
|
336
|
-
|
337
|
-
:
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
317
|
+
visibility: component.conditional.json
|
318
|
+
? component.conditional.json
|
319
|
+
: {
|
320
|
+
operator: 'all',
|
321
|
+
conditions: [
|
322
|
+
{
|
323
|
+
property: component.conditional.when,
|
324
|
+
operator: component.conditional.show ? 'eq' : 'ne',
|
325
|
+
value: component.conditional.eq,
|
326
|
+
},
|
327
|
+
],
|
328
|
+
},
|
343
329
|
}
|
344
|
-
: {})
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
330
|
+
: {}),
|
331
|
+
};
|
332
|
+
}
|
333
|
+
else if (component.type === 'Content') {
|
334
|
+
return {
|
335
|
+
type: 'content',
|
336
|
+
html: component.html ?? '',
|
337
|
+
...(component.conditional?.json ||
|
338
|
+
(component.conditional?.when && !isUndefined(component.conditional?.show) && component.conditional?.eq)
|
350
339
|
? {
|
351
340
|
visibility: component.conditional.json
|
352
341
|
? component.conditional.json
|
@@ -361,8 +350,72 @@ export function convertComponentsToForm(components) {
|
|
361
350
|
],
|
362
351
|
},
|
363
352
|
}
|
364
|
-
: {})
|
365
|
-
|
353
|
+
: {}),
|
354
|
+
};
|
355
|
+
}
|
356
|
+
else {
|
357
|
+
return {
|
358
|
+
type: 'input',
|
359
|
+
parameterId: component.key,
|
360
|
+
display: {
|
361
|
+
...(component.label ? { label: component.label } : {}),
|
362
|
+
...(component.description ? { description: component.description } : {}),
|
363
|
+
...(component.tooltip ? { tooltip: component.tooltip } : {}),
|
364
|
+
...(component.placeholder ? { placeholder: component.placeholder } : {}),
|
365
|
+
...(component.prefix ? { prefix: component.prefix } : {}),
|
366
|
+
...(component.suffix ? { suffix: component.suffix } : {}),
|
367
|
+
...(component.readOnly ? { readOnly: component.readOnly } : {}),
|
368
|
+
...(component.mode ? { mode: component.mode } : {}),
|
369
|
+
...(component.validate?.required ? { required: component.validate?.required } : {}),
|
370
|
+
...(component.displayOption ? { relatedObjectDisplay: component.displayOption } : {}),
|
371
|
+
...(component.defaultToCurrentDate ||
|
372
|
+
component.defaultToCurrentTime ||
|
373
|
+
component.initialValue ||
|
374
|
+
component.defaultValueCriteria
|
375
|
+
? {
|
376
|
+
defaultValue: component.defaultToCurrentDate
|
377
|
+
? 'currentDate'
|
378
|
+
: component.defaultToCurrentTime
|
379
|
+
? 'currentTime'
|
380
|
+
: component.defaultValueCriteria
|
381
|
+
? {
|
382
|
+
criteria: component.defaultValueCriteria,
|
383
|
+
...(component.sortBy ? { sortBy: component.sortBy } : {}),
|
384
|
+
...(component.orderBy ? { sortBy: component.orderBy } : {}),
|
385
|
+
}
|
386
|
+
: isArray(component.initialValue)
|
387
|
+
? component.initialValue.map((c) => c.value)
|
388
|
+
: component.initialValue?.value
|
389
|
+
? component.initialValue?.value
|
390
|
+
: component.initialValue,
|
391
|
+
}
|
392
|
+
: {}),
|
393
|
+
...(component.rows ? { rowCount: component.rows } : {}),
|
394
|
+
...(component.inputMaskPlaceholderChar
|
395
|
+
? { placeholderChar: component.inputMaskPlaceholderChar }
|
396
|
+
: {}),
|
397
|
+
...(component.showCharCount ? { charCount: true } : {}),
|
398
|
+
...(component.conditional?.json ||
|
399
|
+
(component.conditional?.when &&
|
400
|
+
!isUndefined(component.conditional?.show) &&
|
401
|
+
component.conditional?.eq)
|
402
|
+
? {
|
403
|
+
visibility: component.conditional.json
|
404
|
+
? component.conditional.json
|
405
|
+
: {
|
406
|
+
operator: 'all',
|
407
|
+
conditions: [
|
408
|
+
{
|
409
|
+
property: component.conditional.when,
|
410
|
+
operator: component.conditional.show ? 'eq' : 'ne',
|
411
|
+
value: component.conditional.eq,
|
412
|
+
},
|
413
|
+
],
|
414
|
+
},
|
415
|
+
}
|
416
|
+
: {}),
|
417
|
+
},
|
418
|
+
enumWithLabels: component.data?.values,
|
366
419
|
};
|
367
420
|
}
|
368
421
|
});
|
@@ -370,7 +423,7 @@ export function convertComponentsToForm(components) {
|
|
370
423
|
// The following functions are used to support the many-to-many relationship collection property.
|
371
424
|
export function getMiddleObjectFilter(property, instance) {
|
372
425
|
const filterProperty = `${property.relatedPropertyId}.id`;
|
373
|
-
const filter = { where: { [filterProperty]: instance
|
426
|
+
const filter = { where: { [filterProperty]: instance?.id } };
|
374
427
|
return filter;
|
375
428
|
}
|
376
429
|
export function getMiddleObject(instance, property, endObjectId, endObjectName) {
|
@@ -389,7 +442,7 @@ export function getMiddleObject(instance, property, endObjectId, endObjectName)
|
|
389
442
|
}
|
390
443
|
}
|
391
444
|
export function getMiddleInstance(instanceId, property, middleObjectInstances) {
|
392
|
-
return middleObjectInstances.find((o) =>
|
445
|
+
return middleObjectInstances.find((o) => property.manyToManyPropertyId && o[property.manyToManyPropertyId]?.id === instanceId);
|
393
446
|
}
|
394
447
|
// The following function is used to prefix the URL with the appropriate path.
|
395
448
|
export function getPrefixedUrl(url) {
|
@@ -408,245 +461,327 @@ export function getPrefixedUrl(url) {
|
|
408
461
|
return `/accessManagement${url}`;
|
409
462
|
if (workflowMatchers.some((endpoint) => url.startsWith(endpoint)))
|
410
463
|
return `/workflow${url}`;
|
464
|
+
console.error('Invalid URL');
|
411
465
|
return url;
|
412
466
|
}
|
413
467
|
// The following function adds the object properties to the form components.
|
414
468
|
// This function is used when there is no form configured in the form builder.
|
415
|
-
export function addObjectPropertiesToComponentProps(properties,
|
469
|
+
export async function addObjectPropertiesToComponentProps(properties,
|
416
470
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
417
471
|
formComponents, instance, objectPropertyInputProps, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight) {
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
{
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
{
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
{
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
{
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
{
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
{
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
];
|
458
|
-
}
|
459
|
-
return property;
|
460
|
-
})
|
461
|
-
.find((property) => property.id === component.key);
|
462
|
-
const id = (_b = property === null || property === void 0 ? void 0 : property.id) !== null && _b !== void 0 ? _b : component.key;
|
463
|
-
if (component.type === 'Content') {
|
464
|
-
return component;
|
472
|
+
return [
|
473
|
+
...(await Promise.all(formComponents
|
474
|
+
?.filter((component) => !isUndefined(component) && !isNil(component))
|
475
|
+
?.map(async (component) => {
|
476
|
+
const property = properties
|
477
|
+
.flatMap((property) => {
|
478
|
+
if (property.type === 'address') {
|
479
|
+
return [
|
480
|
+
{
|
481
|
+
id: `${property.id}.line1`,
|
482
|
+
name: `${property.name} Line 1`,
|
483
|
+
type: 'string',
|
484
|
+
},
|
485
|
+
{
|
486
|
+
id: `${property.id}.line2`,
|
487
|
+
name: `${property.name} Line 2`,
|
488
|
+
type: 'string',
|
489
|
+
},
|
490
|
+
{
|
491
|
+
id: `${property.id}.city`,
|
492
|
+
name: `${property.name} City`,
|
493
|
+
type: 'string',
|
494
|
+
},
|
495
|
+
{
|
496
|
+
id: `${property.id}.county`,
|
497
|
+
name: `${property.name} County`,
|
498
|
+
type: 'string',
|
499
|
+
},
|
500
|
+
{
|
501
|
+
id: `${property.id}.state`,
|
502
|
+
name: `${property.name} State`,
|
503
|
+
type: 'string',
|
504
|
+
},
|
505
|
+
{
|
506
|
+
id: `${property.id}.zipCode`,
|
507
|
+
name: `${property.name} Zip Code`,
|
508
|
+
type: 'string',
|
509
|
+
},
|
510
|
+
];
|
465
511
|
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
512
|
+
return property;
|
513
|
+
})
|
514
|
+
.find((property) => property.id === component.key);
|
515
|
+
const id = property?.id ?? component.key;
|
516
|
+
if (component.type === 'Content') {
|
517
|
+
return component;
|
518
|
+
}
|
519
|
+
else if (component.type === 'Date') {
|
520
|
+
if (component.initialValue && !/^{{.*}}/.test(component.initialValue)) {
|
521
|
+
component.initialValue =
|
522
|
+
component.initialValue === 'currentDate'
|
523
|
+
? DateTime.now().toISODate()
|
524
|
+
: DateTime.fromISO(component.initialValue).toISODate();
|
474
525
|
}
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
// This will overwrite the default value
|
480
|
-
if (component.defaultToCurrentDate) {
|
481
|
-
component.initialValue = DateTime.now().toISO();
|
482
|
-
}
|
526
|
+
// @Deprecrated
|
527
|
+
// This will overwrite the default value
|
528
|
+
if (component.defaultToCurrentDate) {
|
529
|
+
component.initialValue = DateTime.now().toISODate();
|
483
530
|
}
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
// This will overwrite the default value
|
492
|
-
if (component.defaultToCurrentTime) {
|
493
|
-
component.initialValue = DateTime.now().toISOTime({
|
494
|
-
includeOffset: false,
|
495
|
-
suppressMilliseconds: true,
|
496
|
-
});
|
497
|
-
}
|
531
|
+
}
|
532
|
+
else if (component.type === 'DateTime') {
|
533
|
+
if (component.initialValue && !/^{{.*}}/.test(component.initialValue)) {
|
534
|
+
component.initialValue =
|
535
|
+
component.initialValue === 'currentDateTime'
|
536
|
+
? DateTime.now().toISO()
|
537
|
+
: DateTime.fromISO(component.initialValue).toISO();
|
498
538
|
}
|
499
|
-
//
|
500
|
-
|
501
|
-
|
502
|
-
component.
|
539
|
+
// @Deprecrated
|
540
|
+
// This will overwrite the default value
|
541
|
+
if (component.defaultToCurrentDate) {
|
542
|
+
component.initialValue = DateTime.now().toISO();
|
503
543
|
}
|
504
|
-
|
505
|
-
|
506
|
-
if (
|
507
|
-
|
508
|
-
|
509
|
-
|
544
|
+
}
|
545
|
+
else if (component.type === 'Time') {
|
546
|
+
if (component.initialValue && !/^{{.*}}/.test(component.initialValue)) {
|
547
|
+
component.initialValue =
|
548
|
+
component.initialValue === 'currentTime'
|
549
|
+
? DateTime.now().toISOTime({
|
550
|
+
includeOffset: false,
|
551
|
+
suppressMilliseconds: true,
|
552
|
+
})
|
553
|
+
: DateTime.fromISO(component.initialValue).toISOTime({
|
554
|
+
includeOffset: false,
|
555
|
+
suppressMilliseconds: true,
|
556
|
+
});
|
510
557
|
}
|
511
|
-
|
512
|
-
|
558
|
+
// @Deprecrated
|
559
|
+
// This will overwrite the default value
|
560
|
+
if (component.defaultToCurrentTime) {
|
561
|
+
component.initialValue = DateTime.now().toISOTime({
|
562
|
+
includeOffset: false,
|
563
|
+
suppressMilliseconds: true,
|
564
|
+
});
|
513
565
|
}
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
566
|
+
}
|
567
|
+
// if a conditional date is in a format other than yyyy-mm-dd, convert it to that format
|
568
|
+
if (component.conditional &&
|
569
|
+
formComponents.find((formComponent) => formComponent.key === component.conditional.when)
|
570
|
+
?.type === 'Date') {
|
571
|
+
component.conditional.eq = new Date(component.conditional.eq).toISOString().split('T')[0];
|
572
|
+
}
|
573
|
+
const [propertyId, nestedPropertyId] = id.split('.');
|
574
|
+
let instanceValue;
|
575
|
+
if (nestedPropertyId) {
|
576
|
+
instanceValue = instance?.[propertyId]
|
577
|
+
? instance[propertyId][nestedPropertyId]
|
578
|
+
: undefined;
|
579
|
+
}
|
580
|
+
else {
|
581
|
+
instanceValue = instance && id ? instance[id] : undefined;
|
582
|
+
}
|
583
|
+
// only add fieldComponents if the property exists on the sanitized object
|
584
|
+
if (property) {
|
585
|
+
if (property.manyToManyPropertyId &&
|
586
|
+
apiServices &&
|
587
|
+
!component.middleObject &&
|
588
|
+
!component.initialMiddleObjectInstances) {
|
589
|
+
const getMiddleObjectInstances = async () => {
|
590
|
+
const filter = instance ? getMiddleObjectFilter(property, instance) : {};
|
591
|
+
try {
|
592
|
+
return await apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/instances`), { params: { filter: JSON.stringify(filter) } });
|
593
|
+
}
|
594
|
+
catch (err) {
|
595
|
+
console.log(err);
|
596
|
+
return [];
|
597
|
+
}
|
598
|
+
};
|
599
|
+
const middleObject = await apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/effective?sanitizedVersion=true`), {
|
600
|
+
params: { filter: { fields: ['properties', 'actions', 'rootObjectId'] } },
|
601
|
+
});
|
602
|
+
const initialMiddleObjectInstances = await getMiddleObjectInstances();
|
603
|
+
const defaultValue = getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue, component?.data?.values);
|
604
|
+
return {
|
605
|
+
...component,
|
606
|
+
...(component.type === 'Object' && objectPropertyInputProps),
|
607
|
+
defaultValue,
|
608
|
+
property,
|
609
|
+
type: `${readOnly ? 'ViewOnly' : ''}${component.type}`,
|
610
|
+
readOnly: component.readOnly || readOnly || property?.formula,
|
611
|
+
multiple: ['array', 'document'].includes(property.type),
|
612
|
+
instance: instance,
|
613
|
+
fromFormBuilder: true,
|
614
|
+
apiServices: objectPropertyInputProps?.apiServices,
|
615
|
+
user: objectPropertyInputProps?.user,
|
616
|
+
autoSave,
|
617
|
+
fieldHeight,
|
618
|
+
customDefaultValue: component.type === 'Select'
|
546
619
|
? () => getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue)
|
547
|
-
: undefined,
|
620
|
+
: undefined,
|
621
|
+
queryAddresses: component.isAddressLine1 || ['collection', 'object'].includes(property?.type)
|
548
622
|
? queryAddresses
|
549
|
-
: undefined,
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
}
|
556
|
-
: undefined, getOptionLabel: component.type === 'Select' || component.type === 'MultiSelect'
|
557
|
-
? (option) => {
|
558
|
-
var _a, _b, _c;
|
559
|
-
if (option) {
|
560
|
-
return (_c = (_b = (_a = component.data) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.find((op) => op.value ===
|
561
|
-
(typeof option === 'string' ? option : option.value))) === null || _c === void 0 ? void 0 : _c.label;
|
562
|
-
}
|
563
|
-
}
|
564
|
-
: undefined, isModal });
|
565
|
-
}
|
566
|
-
if (component.columns) {
|
567
|
-
for (const column of component.columns) {
|
568
|
-
column.components = yield addObjectPropertiesToComponentProps(properties, column.components, instance, objectPropertyInputProps, autoSave, readOnly, undefined, undefined, queryAddresses, apiServices, isModal, fieldHeight);
|
569
|
-
}
|
570
|
-
return component;
|
623
|
+
: undefined,
|
624
|
+
initialMiddleObjectInstances,
|
625
|
+
middleObject,
|
626
|
+
getMiddleObjectInstances,
|
627
|
+
isModal,
|
628
|
+
};
|
571
629
|
}
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
630
|
+
const defaultValue = getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue, component?.data?.values);
|
631
|
+
return {
|
632
|
+
...component,
|
633
|
+
...(component.type === 'Object' && objectPropertyInputProps),
|
634
|
+
type: `${readOnly ? 'ViewOnly' : ''}${component.type}`,
|
635
|
+
defaultValue,
|
636
|
+
property,
|
637
|
+
readOnly: component.readOnly || readOnly || property?.formula,
|
638
|
+
multiple: ['array', 'document'].includes(property.type),
|
639
|
+
instance: instance,
|
640
|
+
fromFormBuilder: true,
|
641
|
+
apiServices: objectPropertyInputProps?.apiServices,
|
642
|
+
user: objectPropertyInputProps?.user,
|
643
|
+
fieldHeight,
|
644
|
+
autoSave,
|
645
|
+
customDefaultValue: component.type === 'Select'
|
646
|
+
? () => getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue)
|
647
|
+
: undefined,
|
648
|
+
queryAddresses: component.isAddressLine1 || ['collection', 'object'].includes(property?.type)
|
649
|
+
? queryAddresses
|
650
|
+
: undefined,
|
651
|
+
isOptionEqualToValue: component.type === 'Select' || component.type === 'MultiSelect'
|
652
|
+
? (option, value) => {
|
653
|
+
if (typeof value === 'object' && 'value' in value) {
|
654
|
+
return option.value === value.value;
|
587
655
|
}
|
656
|
+
return option.value === value;
|
588
657
|
}
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
item.apiServices = objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.apiServices;
|
597
|
-
item.user = objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user;
|
598
|
-
item.defaultPages = defaultPages;
|
599
|
-
item.navigateTo = navigateTo;
|
600
|
-
item.isModal = isModal;
|
601
|
-
item.fieldHeight = fieldHeight;
|
602
|
-
if (item.addressPropertyId) {
|
603
|
-
item.queryAddresses = queryAddresses;
|
658
|
+
: undefined,
|
659
|
+
getOptionLabel: component.type === 'Select' || component.type === 'MultiSelect'
|
660
|
+
? (option) => {
|
661
|
+
if (option) {
|
662
|
+
return component.data?.values?.find((op) => op.value ===
|
663
|
+
(typeof option === 'string' ? option : option.value))?.label;
|
664
|
+
}
|
604
665
|
}
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
666
|
+
: undefined,
|
667
|
+
isModal,
|
668
|
+
};
|
669
|
+
}
|
670
|
+
if (component.columns) {
|
671
|
+
for (const column of component.columns) {
|
672
|
+
column.components = await addObjectPropertiesToComponentProps(properties, column.components, instance, objectPropertyInputProps, autoSave, readOnly, undefined, undefined, queryAddresses, apiServices, isModal, fieldHeight);
|
673
|
+
}
|
674
|
+
return component;
|
675
|
+
}
|
676
|
+
if (component.components) {
|
677
|
+
for (const item of component.components) {
|
678
|
+
const nestedFieldProperty = properties.find((property) => property.id === item.key);
|
679
|
+
if (item.type) {
|
680
|
+
item.defaultValue = getDefaultValue(!instance || isNil(get(instance, item.key))
|
681
|
+
? item.initialValue
|
682
|
+
: get(instance, item.key), item?.data?.values);
|
683
|
+
item.customDefaultValue =
|
684
|
+
item.type === 'Select'
|
685
|
+
? () => getDefaultValue(!instance || isNil(instance[item?.key])
|
686
|
+
? item.initialValue
|
687
|
+
: instance[item.key], undefined)
|
688
|
+
: undefined;
|
689
|
+
if (item.type.includes('RepeatableField') && !!instance) {
|
690
|
+
item.instance = instance;
|
620
691
|
}
|
621
692
|
}
|
622
|
-
|
623
|
-
|
693
|
+
if (nestedFieldProperty) {
|
694
|
+
item.type = `${readOnly ? 'ViewOnly' : ''}${item.type}`;
|
695
|
+
item.property = nestedFieldProperty;
|
696
|
+
}
|
697
|
+
item.instance = instance;
|
698
|
+
item.readOnly = item.readOnly || readOnly;
|
699
|
+
item.autoSave = autoSave;
|
700
|
+
item.apiServices = objectPropertyInputProps?.apiServices;
|
701
|
+
item.user = objectPropertyInputProps?.user;
|
702
|
+
item.defaultPages = defaultPages;
|
703
|
+
item.navigateTo = navigateTo;
|
704
|
+
item.isModal = isModal;
|
705
|
+
item.fieldHeight = fieldHeight;
|
706
|
+
if (item.addressPropertyId) {
|
707
|
+
item.queryAddresses = queryAddresses;
|
708
|
+
}
|
709
|
+
if (item.property?.manyToManyPropertyId &&
|
710
|
+
apiServices &&
|
711
|
+
!item.middleObject &&
|
712
|
+
!item.initialMiddleObjectInstances) {
|
713
|
+
const getMiddleObjectInstances = async () => {
|
714
|
+
const filter = instance ? getMiddleObjectFilter(item.property, instance) : {};
|
715
|
+
return await apiServices.get(getPrefixedUrl(`/objects/${item.property.objectId}/instances`), { params: { filter: JSON.stringify(filter) } });
|
716
|
+
};
|
717
|
+
const middleObject = await apiServices.get(getPrefixedUrl(`/objects/${item.property.objectId}/effective?sanitizedVersion=true`), {
|
718
|
+
params: { filter: { fields: ['properties', 'actions', 'rootObjectId'] } },
|
719
|
+
});
|
720
|
+
const initialMiddleObjectInstances = await getMiddleObjectInstances();
|
721
|
+
item.initialMiddleObjectInstances = initialMiddleObjectInstances;
|
722
|
+
item.middleObject = middleObject;
|
723
|
+
item.getMiddleObjectInstances = getMiddleObjectInstances;
|
724
|
+
}
|
624
725
|
}
|
625
|
-
|
626
|
-
|
627
|
-
|
726
|
+
return {
|
727
|
+
components: await addObjectPropertiesToComponentProps(properties, component.components, instance, objectPropertyInputProps, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight),
|
728
|
+
...component,
|
729
|
+
...(component.type === 'Object' && objectPropertyInputProps),
|
730
|
+
type: `${readOnly ? 'ViewOnly' : ''}${component.type}`,
|
731
|
+
properties: properties,
|
732
|
+
property,
|
733
|
+
instance: instance,
|
734
|
+
fromFormBuilder: true,
|
735
|
+
apiServices: apiServices,
|
736
|
+
user: objectPropertyInputProps?.user,
|
737
|
+
autoSave,
|
738
|
+
queryAddresses: component.isAddressLine1 ? queryAddresses : undefined,
|
739
|
+
isModal,
|
740
|
+
fieldHeight,
|
741
|
+
};
|
742
|
+
}
|
743
|
+
}))).filter((component) => !!component),
|
744
|
+
];
|
628
745
|
}
|
629
746
|
export function getDefaultValue(initialValue, selectOptions) {
|
630
|
-
var _a;
|
631
747
|
if (!isEmpty(initialValue) || (initialValue !== undefined && typeof initialValue === 'number')) {
|
632
748
|
if (Array.isArray(initialValue)) {
|
633
|
-
return initialValue
|
749
|
+
return initialValue
|
750
|
+
.map((option) => {
|
634
751
|
if (option && typeof option === 'object' && 'value' in option) {
|
635
752
|
return option.value;
|
636
753
|
}
|
637
754
|
else {
|
638
755
|
return option;
|
639
756
|
}
|
640
|
-
})
|
757
|
+
})
|
758
|
+
.filter((option) => !/^{{.*}}$/.test(option));
|
641
759
|
}
|
642
|
-
else if (initialValue &&
|
643
|
-
return initialValue
|
760
|
+
else if (initialValue && isObject(initialValue) && 'value' in initialValue) {
|
761
|
+
return initialValue.value;
|
644
762
|
}
|
645
763
|
else {
|
646
|
-
if (selectOptions
|
647
|
-
return
|
764
|
+
if (selectOptions?.length) {
|
765
|
+
return selectOptions?.find((option) => option.value === initialValue)?.label;
|
766
|
+
}
|
767
|
+
if (initialValue === 'currentDate') {
|
768
|
+
return DateTime.now().toISODate();
|
769
|
+
}
|
770
|
+
else if (initialValue === 'currentDateTime') {
|
771
|
+
return DateTime.now().toISO();
|
772
|
+
}
|
773
|
+
else if (initialValue === 'currentTime') {
|
774
|
+
return DateTime.now().toISOTime({
|
775
|
+
includeOffset: false,
|
776
|
+
suppressMilliseconds: true,
|
777
|
+
});
|
778
|
+
}
|
779
|
+
else if (/^{{.*}}$/.test(initialValue)) {
|
780
|
+
return undefined;
|
781
|
+
}
|
782
|
+
else {
|
783
|
+
return initialValue;
|
648
784
|
}
|
649
|
-
return initialValue;
|
650
785
|
}
|
651
786
|
}
|
652
787
|
return undefined;
|
@@ -690,7 +825,6 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
690
825
|
};
|
691
826
|
properties = properties.filter((property) => property.type !== 'collection');
|
692
827
|
return properties.flatMap((property) => {
|
693
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
694
828
|
if (property.type === 'address') {
|
695
829
|
const type = readOnly ? 'ViewOnlyTextField' : 'TextField';
|
696
830
|
return [
|
@@ -699,10 +833,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
699
833
|
key: `${property.id}.line1`,
|
700
834
|
label: `${property.name} Line 1`,
|
701
835
|
inputMask: property.mask,
|
702
|
-
readOnly: !hasActionPermissions || readOnly || !!
|
836
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
703
837
|
instance: instance,
|
704
|
-
defaultValue: instance ?
|
705
|
-
user: objectPropertyInputProps
|
838
|
+
defaultValue: instance ? instance[property.id]?.[`line1`] : undefined,
|
839
|
+
user: objectPropertyInputProps?.user,
|
706
840
|
property: {
|
707
841
|
id: `${property.id}.line1`,
|
708
842
|
name: `${property.name} Line 1`,
|
@@ -723,10 +857,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
723
857
|
key: `${property.id}.line2`,
|
724
858
|
label: `${property.name} Line 2`,
|
725
859
|
inputMask: property.mask,
|
726
|
-
readOnly: !hasActionPermissions || readOnly || !!
|
860
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
727
861
|
instance: instance,
|
728
|
-
defaultValue: instance ?
|
729
|
-
user: objectPropertyInputProps
|
862
|
+
defaultValue: instance ? instance[property.id]?.[`line2`] : undefined,
|
863
|
+
user: objectPropertyInputProps?.user,
|
730
864
|
property: {
|
731
865
|
id: `${property.id}.line2`,
|
732
866
|
name: `${property.name} Line 2`,
|
@@ -741,10 +875,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
741
875
|
key: `${property.id}.city`,
|
742
876
|
label: `${property.name} City`,
|
743
877
|
inputMask: property.mask,
|
744
|
-
readOnly: !hasActionPermissions || readOnly || !!
|
878
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
745
879
|
instance: instance,
|
746
|
-
defaultValue: instance ?
|
747
|
-
user: objectPropertyInputProps
|
880
|
+
defaultValue: instance ? instance[property.id]?.[`city`] : undefined,
|
881
|
+
user: objectPropertyInputProps?.user,
|
748
882
|
property: {
|
749
883
|
id: `${property.id}.city`,
|
750
884
|
name: `${property.name} City`,
|
@@ -762,10 +896,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
762
896
|
key: `${property.id}.county`,
|
763
897
|
label: `${property.name} County`,
|
764
898
|
inputMask: property.mask,
|
765
|
-
readOnly: !hasActionPermissions || readOnly || !!
|
899
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
766
900
|
instance: instance,
|
767
|
-
defaultValue: instance ?
|
768
|
-
user: objectPropertyInputProps
|
901
|
+
defaultValue: instance ? instance[property.id]?.[`county`] : undefined,
|
902
|
+
user: objectPropertyInputProps?.user,
|
769
903
|
property: {
|
770
904
|
id: `${property.id}.county`,
|
771
905
|
name: `${property.name} County`,
|
@@ -779,10 +913,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
779
913
|
key: `${property.id}.state`,
|
780
914
|
label: `${property.name} State`,
|
781
915
|
inputMask: property.mask,
|
782
|
-
readOnly: !hasActionPermissions || readOnly || !!
|
916
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
783
917
|
instance: instance,
|
784
|
-
defaultValue: instance ?
|
785
|
-
user: objectPropertyInputProps
|
918
|
+
defaultValue: instance ? instance[property.id]?.[`state`] : undefined,
|
919
|
+
user: objectPropertyInputProps?.user,
|
786
920
|
property: {
|
787
921
|
id: `${property.id}.state`,
|
788
922
|
name: `${property.name} State`,
|
@@ -800,10 +934,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
800
934
|
key: `${property.id}.zipCode`,
|
801
935
|
label: `${property.name} Zip Code`,
|
802
936
|
inputMask: property.mask,
|
803
|
-
readOnly: !hasActionPermissions || readOnly || !!
|
937
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
804
938
|
instance: instance,
|
805
|
-
defaultValue: instance ?
|
806
|
-
user: objectPropertyInputProps
|
939
|
+
defaultValue: instance ? instance[property.id]?.[`zipCode`] : undefined,
|
940
|
+
user: objectPropertyInputProps?.user,
|
807
941
|
property: {
|
808
942
|
id: `${property.id}.zipCode`,
|
809
943
|
name: `${property.name} Zip Code`,
|
@@ -818,8 +952,8 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
818
952
|
},
|
819
953
|
];
|
820
954
|
}
|
821
|
-
let minDate =
|
822
|
-
let maxDate =
|
955
|
+
let minDate = property.validation?.from ?? '';
|
956
|
+
let maxDate = property.validation?.to ?? '';
|
823
957
|
if (minDate && /^{{.*}}$/.test(minDate)) {
|
824
958
|
const fragments = minDate.split(/\s/);
|
825
959
|
if (fragments.length === 1) {
|
@@ -852,43 +986,70 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
|
|
852
986
|
.join(' ');
|
853
987
|
}
|
854
988
|
}
|
855
|
-
return
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
property.
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
989
|
+
return {
|
990
|
+
type: `${readOnly ? 'ViewOnly' : ''}${matchType(property.type)}`,
|
991
|
+
key: property.id,
|
992
|
+
label: property.name,
|
993
|
+
inputMask: property.mask,
|
994
|
+
multiple: ['array', 'document'].includes(property.type),
|
995
|
+
readOnly: !hasActionPermissions || readOnly || !!property?.formula,
|
996
|
+
instance: instance,
|
997
|
+
validate: {
|
998
|
+
required: property.required,
|
999
|
+
...(property.type === 'date' &&
|
1000
|
+
property.validation && {
|
1001
|
+
minDate,
|
1002
|
+
maxDate,
|
1003
|
+
customMessage: property.validation.errorMessage,
|
1004
|
+
}),
|
1005
|
+
...(property.type === 'date-time' &&
|
1006
|
+
property.validation && {
|
1007
|
+
minTime: property.validation.from,
|
1008
|
+
maxTime: property.validation.to,
|
1009
|
+
customMessage: (property?.validation).errorMessage,
|
1010
|
+
}),
|
1011
|
+
...(property.type === 'time' &&
|
1012
|
+
property.validation && {
|
1013
|
+
minTime: property.validation.from,
|
1014
|
+
maxTime: property.validation.to,
|
1015
|
+
customMessage: (property?.validation).errorMessage,
|
1016
|
+
}),
|
1017
|
+
...((property.type === 'integer' || property.type === 'number') &&
|
1018
|
+
property.validation && {
|
1019
|
+
min: property.validation.minimum,
|
1020
|
+
max: property.validation.maximum,
|
1021
|
+
customMessage: property.validation.errorMessage,
|
1022
|
+
}),
|
1023
|
+
...(property.type === 'string' &&
|
1024
|
+
property.validation &&
|
1025
|
+
Object.hasOwnProperty.call(property.validation, 'rules') && {
|
1026
|
+
operator: property.validation.operator,
|
1027
|
+
regexes: property.validation.rules?.map((rule) => ({
|
1028
|
+
...rule,
|
1029
|
+
errorMessage: rule.errorMessage?.length
|
882
1030
|
? rule.errorMessage
|
883
|
-
: 'Property is not in a valid format'
|
1031
|
+
: 'Property is not in a valid format',
|
1032
|
+
})),
|
884
1033
|
}),
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
1034
|
+
...(property.type === 'document' &&
|
1035
|
+
property.validation && {
|
1036
|
+
minDocuments: property.validation.minDocuments,
|
1037
|
+
maxDocuments: property.validation.maxDocuments,
|
1038
|
+
customMessage: property.validation.errorMessage,
|
1039
|
+
}),
|
1040
|
+
...property.validation,
|
1041
|
+
},
|
1042
|
+
objectId,
|
1043
|
+
...(property.type === 'object' && objectPropertyInputProps),
|
1044
|
+
defaultValue: instance ? instance[property.id] : undefined,
|
1045
|
+
user: objectPropertyInputProps?.user,
|
1046
|
+
apiServices: objectPropertyInputProps?.apiServices,
|
1047
|
+
property: property,
|
1048
|
+
fieldHeight,
|
1049
|
+
autoSave,
|
1050
|
+
queryAddresses: ['collection', 'object'].includes(property?.type) ? queryAddresses : undefined,
|
1051
|
+
isModal,
|
1052
|
+
};
|
892
1053
|
});
|
893
1054
|
};
|
894
1055
|
// The following function is used to build the form components from the document properties.
|
@@ -934,7 +1095,6 @@ export function transformToWhere(mongoQuery) {
|
|
934
1095
|
});
|
935
1096
|
}
|
936
1097
|
export function updateCriteriaInputs(criteria, field, fieldValue, isInputField) {
|
937
|
-
var _a;
|
938
1098
|
for (const [key, value] of Object.entries(criteria)) {
|
939
1099
|
if (isArray(value)) {
|
940
1100
|
for (const index in value) {
|
@@ -944,8 +1104,10 @@ export function updateCriteriaInputs(criteria, field, fieldValue, isInputField)
|
|
944
1104
|
else {
|
945
1105
|
value[index] =
|
946
1106
|
typeof value[index] === 'string'
|
947
|
-
?
|
948
|
-
|
1107
|
+
? value[index]
|
1108
|
+
?.replaceAll(!isInputField ? `{{{${field}}}}` : `{{{input.${field}}}}`, fieldValue ?? '')
|
1109
|
+
.trim() || undefined
|
1110
|
+
: value ?? undefined;
|
949
1111
|
}
|
950
1112
|
}
|
951
1113
|
}
|
@@ -955,8 +1117,10 @@ export function updateCriteriaInputs(criteria, field, fieldValue, isInputField)
|
|
955
1117
|
else {
|
956
1118
|
criteria[key] =
|
957
1119
|
typeof value === 'string'
|
958
|
-
?
|
959
|
-
|
1120
|
+
? value
|
1121
|
+
?.replaceAll(!isInputField ? `{{{${field}}}}` : `{{{input.${field}}}}`, fieldValue ?? '')
|
1122
|
+
.trim() || undefined
|
1123
|
+
: value ?? undefined;
|
960
1124
|
}
|
961
1125
|
}
|
962
1126
|
}
|
@@ -987,7 +1151,7 @@ export function getAllCriteriaInputs(criteria) {
|
|
987
1151
|
return uniq(result.map((item) => item.replace('{{{input.', '').replace('}}}', '')));
|
988
1152
|
}
|
989
1153
|
export function isPropertyVisible(conditional, formData) {
|
990
|
-
const isConditional = !!
|
1154
|
+
const isConditional = !!conditional?.when;
|
991
1155
|
if (!isConditional) {
|
992
1156
|
return true;
|
993
1157
|
}
|
@@ -1004,9 +1168,10 @@ export function normalizeDateTime(dateTime) {
|
|
1004
1168
|
return new Date(dateTime.toString()).toISOString();
|
1005
1169
|
}
|
1006
1170
|
export function normalizeDates(instances, object) {
|
1007
|
-
var _a, _b;
|
1008
1171
|
const dateProps = ['date', 'date-time', 'time'];
|
1009
|
-
const properties =
|
1172
|
+
const properties = object?.properties
|
1173
|
+
?.filter((property) => dateProps.includes(property.type))
|
1174
|
+
.reduce((agg, property) => Object.assign(agg, { [property.id]: property.type }), {}) ?? {};
|
1010
1175
|
const propKeys = Object.keys(properties);
|
1011
1176
|
instances.forEach((instance) => {
|
1012
1177
|
Object.keys(instance).forEach((key) => {
|