@evoke-platform/ui-components 1.6.0-dev.3 → 1.6.0-dev.31
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/SwipeableDrawer/SwipeableDrawer.d.ts +4 -0
- package/dist/published/components/core/SwipeableDrawer/SwipeableDrawer.js +8 -0
- package/dist/published/components/core/SwipeableDrawer/index.d.ts +3 -0
- package/dist/published/components/core/SwipeableDrawer/index.js +3 -0
- package/dist/published/components/core/index.d.ts +1 -0
- package/dist/published/components/core/index.js +1 -0
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +1 -1
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +2 -2
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +87 -57
- package/dist/published/components/custom/Form/tests/Form.test.js +1 -1
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +3 -3
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +6 -3
- package/dist/published/components/custom/FormField/Select/Select.js +17 -5
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +13 -3
- package/dist/published/components/custom/FormV2/FormRenderer.d.ts +19 -0
- package/dist/published/components/custom/FormV2/FormRenderer.js +183 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.js +131 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.d.ts +19 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.js +106 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.d.ts +24 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.js +100 -0
- package/dist/published/components/custom/FormV2/components/FormContext.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormContext.js +8 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.js +50 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.d.ts +14 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.js +88 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.js +140 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.js +233 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.d.ts +40 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.js +95 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +526 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.js +93 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.js +73 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.js +179 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.js +108 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.js +129 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.d.ts +15 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.js +226 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.js +439 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.d.ts +29 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.js +74 -0
- package/dist/published/components/custom/FormV2/components/FormSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormSections.js +104 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.d.ts +2 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.js +209 -0
- package/dist/published/components/custom/FormV2/components/TabNav.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/TabNav.js +23 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.d.ts +3 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.js +176 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.js +45 -0
- package/dist/published/components/custom/FormV2/components/types.d.ts +122 -0
- package/dist/published/components/custom/FormV2/components/types.js +1 -0
- package/dist/published/components/custom/FormV2/components/utils.d.ts +47 -0
- package/dist/published/components/custom/FormV2/components/utils.js +434 -0
- package/dist/published/components/custom/FormV2/index.d.ts +1 -0
- package/dist/published/components/custom/FormV2/index.js +1 -0
- package/dist/published/components/custom/HistoryLog/HistoryData.d.ts +1 -0
- package/dist/published/components/custom/HistoryLog/HistoryData.js +14 -6
- package/dist/published/components/custom/HistoryLog/HistoryLoading.d.ts +4 -1
- package/dist/published/components/custom/HistoryLog/HistoryLoading.js +14 -8
- package/dist/published/components/custom/HistoryLog/index.d.ts +2 -0
- package/dist/published/components/custom/HistoryLog/index.js +4 -4
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.d.ts +33 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.js +140 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.d.ts +1 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.js +100 -0
- package/dist/published/components/custom/ResponsiveOverflow/index.d.ts +4 -0
- package/dist/published/components/custom/ResponsiveOverflow/index.js +3 -0
- package/dist/published/components/custom/index.d.ts +2 -0
- package/dist/published/components/custom/index.js +2 -0
- package/dist/published/index.d.ts +1 -1
- package/dist/published/index.js +1 -1
- package/dist/published/stories/ResponsiveOverflow.stories.d.ts +8 -0
- package/dist/published/stories/ResponsiveOverflow.stories.js +91 -0
- package/dist/published/theme/hooks.d.ts +7 -0
- package/dist/published/theme/hooks.js +9 -0
- package/package.json +4 -2
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { LocalDateTime } from '@js-joda/core';
|
|
2
|
+
import jsonLogic from 'json-logic-js';
|
|
3
|
+
import { get, isArray, isObject, omit, startCase, transform } from 'lodash';
|
|
4
|
+
import { DateTime } from 'luxon';
|
|
5
|
+
import Handlebars from 'no-eval-handlebars';
|
|
6
|
+
import { defaultRuleProcessorMongoDB, formatQuery, parseMongoDB } from 'react-querybuilder';
|
|
7
|
+
export const scrollIntoViewWithOffset = (el, offset, container) => {
|
|
8
|
+
const elementRect = el.getBoundingClientRect();
|
|
9
|
+
const containerRect = container ? container.getBoundingClientRect() : document.body.getBoundingClientRect();
|
|
10
|
+
const topPosition = elementRect.top - containerRect.top + (container?.scrollTop || 0) - offset;
|
|
11
|
+
if (container) {
|
|
12
|
+
container.scrollTo({
|
|
13
|
+
behavior: 'smooth',
|
|
14
|
+
top: topPosition,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
window.scrollTo({
|
|
19
|
+
behavior: 'smooth',
|
|
20
|
+
top: topPosition,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const normalizeDateTime = (dateTime) => new Date(dateTime.toString()).toISOString();
|
|
25
|
+
const evaluateCondition = (condition, formValues, instance) => {
|
|
26
|
+
if (typeof condition !== 'object') {
|
|
27
|
+
console.error('Invalid condition format: ', condition);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (isArray(condition)) {
|
|
31
|
+
const firstCondition = condition[0];
|
|
32
|
+
const { property, value, operator } = firstCondition;
|
|
33
|
+
let fieldValue = firstCondition.isInstanceProperty ? get(instance, property) : get(formValues, property);
|
|
34
|
+
if (typeof fieldValue === 'object' && fieldValue !== null) {
|
|
35
|
+
if (fieldValue instanceof LocalDateTime) {
|
|
36
|
+
fieldValue = normalizeDateTime(fieldValue);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
fieldValue = Object.values(fieldValue).includes(value)
|
|
40
|
+
? value
|
|
41
|
+
: Object.values(fieldValue).find((val) => val !== undefined && val !== null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
switch (operator) {
|
|
45
|
+
case 'ne':
|
|
46
|
+
return fieldValue != value;
|
|
47
|
+
case 'eq':
|
|
48
|
+
return fieldValue == value;
|
|
49
|
+
default:
|
|
50
|
+
console.error(`Unsupported operator: ${operator}`);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Handling custom JSON logic
|
|
55
|
+
else {
|
|
56
|
+
const data = {
|
|
57
|
+
data: formValues,
|
|
58
|
+
instance: instance,
|
|
59
|
+
};
|
|
60
|
+
const result = jsonLogic.apply(condition, data);
|
|
61
|
+
return result === true;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export function isAddressProperty(key) {
|
|
65
|
+
return /\.line1|\.line2|\.city|\.county|\.state|\.zipCode$/.test(key);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Determine if a form entry is visible or not.
|
|
69
|
+
*/
|
|
70
|
+
export const entryIsVisible = (entry, formValues, instance) => {
|
|
71
|
+
const display = 'display' in entry ? entry.display : undefined;
|
|
72
|
+
const { visibility } = display ?? ('visibility' in entry ? entry : {});
|
|
73
|
+
if (isObject(visibility) && 'conditions' in visibility && isArray(visibility.conditions)) {
|
|
74
|
+
// visibility is a simple condition
|
|
75
|
+
const { conditions } = visibility;
|
|
76
|
+
return evaluateCondition(conditions, formValues, instance);
|
|
77
|
+
}
|
|
78
|
+
else if (visibility) {
|
|
79
|
+
// visibility is a JSONlogic condition
|
|
80
|
+
return evaluateCondition(visibility, formValues, instance);
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Recursively retrieves all parameter IDs from a given entry of type Sections or Columns.
|
|
86
|
+
*
|
|
87
|
+
* @param {Sections | Columns} entry - The entry object, which can be of type Sections or Columns.
|
|
88
|
+
* @returns {string[]} - An array of parameter IDs found within the entry.
|
|
89
|
+
*/
|
|
90
|
+
export const getNestedParameterIds = (entry) => {
|
|
91
|
+
const parameterIds = [];
|
|
92
|
+
const entries = entry.type === 'columns'
|
|
93
|
+
? entry.columns.flatMap((column) => column.entries ?? [])
|
|
94
|
+
: entry.sections.flatMap((section) => section.entries ?? []);
|
|
95
|
+
for (const subEntry of entries) {
|
|
96
|
+
if (subEntry.type === 'columns' || subEntry.type === 'sections') {
|
|
97
|
+
parameterIds.push(...getNestedParameterIds(subEntry));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const paramId = getEntryId(subEntry);
|
|
101
|
+
if (paramId && paramId !== 'collection') {
|
|
102
|
+
parameterIds.push(paramId);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return parameterIds;
|
|
107
|
+
};
|
|
108
|
+
export const getEntryId = (entry) => {
|
|
109
|
+
return entry.type === 'input'
|
|
110
|
+
? entry.parameterId
|
|
111
|
+
: entry.type === 'readonlyField'
|
|
112
|
+
? entry.propertyId
|
|
113
|
+
: entry.type === 'inputField'
|
|
114
|
+
? entry.input.id
|
|
115
|
+
: undefined;
|
|
116
|
+
};
|
|
117
|
+
export function getPrefixedUrl(url) {
|
|
118
|
+
const wcsMatchers = ['/apps', '/pages', '/widgets'];
|
|
119
|
+
const dataMatchers = ['/objects', '/correspondenceTemplates', '/documents', '/payments', '/locations'];
|
|
120
|
+
const signalrMatchers = ['/hubs'];
|
|
121
|
+
const accessManagementMatchers = ['/users'];
|
|
122
|
+
const workflowMatchers = ['/workflows'];
|
|
123
|
+
if (wcsMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
124
|
+
return `/webContent${url}`;
|
|
125
|
+
if (dataMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
126
|
+
return `/data${url}`;
|
|
127
|
+
if (signalrMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
128
|
+
return `/signalr${url}`;
|
|
129
|
+
if (accessManagementMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
130
|
+
return `/accessManagement${url}`;
|
|
131
|
+
if (workflowMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
132
|
+
return `/workflow${url}`;
|
|
133
|
+
console.error('Invalid URL');
|
|
134
|
+
return url;
|
|
135
|
+
}
|
|
136
|
+
export const isOptionEqualToValue = (option, value) => {
|
|
137
|
+
if (typeof option === 'string') {
|
|
138
|
+
return option === value;
|
|
139
|
+
}
|
|
140
|
+
return option.value === value;
|
|
141
|
+
};
|
|
142
|
+
export function addressProperties(addressProperty) {
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
id: `${addressProperty.id}.line1`,
|
|
146
|
+
name: `${addressProperty.name} Line 1`,
|
|
147
|
+
type: 'string',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: `${addressProperty.id}.line2`,
|
|
151
|
+
name: `${addressProperty.name} Line 2`,
|
|
152
|
+
type: 'string',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: `${addressProperty.id}.city`,
|
|
156
|
+
name: `${addressProperty.name} City`,
|
|
157
|
+
type: 'string',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: `${addressProperty.id}.county`,
|
|
161
|
+
name: `${addressProperty.name} County`,
|
|
162
|
+
type: 'string',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: `${addressProperty.id}.state`,
|
|
166
|
+
name: `${addressProperty.name} State`,
|
|
167
|
+
type: 'string',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: `${addressProperty.id}.zipCode`,
|
|
171
|
+
name: `${addressProperty.name} Zip Code`,
|
|
172
|
+
type: 'string',
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
export const normalizeDates = (instance, evokeObject) => {
|
|
177
|
+
const dateProps = ['date', 'date-time', 'time'];
|
|
178
|
+
const properties = evokeObject?.properties
|
|
179
|
+
?.filter((property) => dateProps.includes(property.type))
|
|
180
|
+
.reduce((agg, property) => Object.assign(agg, { [property.id]: property.type }), {}) ?? {};
|
|
181
|
+
const propKeys = Object.keys(properties);
|
|
182
|
+
const updatedInstance = { ...instance };
|
|
183
|
+
Object.keys(instance).forEach((key) => {
|
|
184
|
+
// Ignore non-datelike and empty fields.
|
|
185
|
+
if (!propKeys.includes(key) || !instance[key]) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
switch (properties[key]) {
|
|
189
|
+
case 'date':
|
|
190
|
+
// Casting here is valid because the value has already been
|
|
191
|
+
// determined to be a datelike field that is non-empty.
|
|
192
|
+
updatedInstance[key] = DateTime.fromISO(instance[key]).toLocaleString(DateTime.DATE_SHORT);
|
|
193
|
+
break;
|
|
194
|
+
case 'date-time':
|
|
195
|
+
// Casting here is valid because the value has already been
|
|
196
|
+
// determined to be a datelike field that is non-empty.
|
|
197
|
+
updatedInstance[key] = DateTime.fromISO(instance[key]).toLocaleString(DateTime.DATETIME_SHORT);
|
|
198
|
+
break;
|
|
199
|
+
case 'time':
|
|
200
|
+
// Casting here is valid because the value has already been
|
|
201
|
+
// determined to be a datelike field that is non-empty.
|
|
202
|
+
updatedInstance[key] = DateTime.fromISO(instance[key]).toLocaleString(DateTime.TIME_SIMPLE);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return updatedInstance;
|
|
207
|
+
};
|
|
208
|
+
const OPERATOR_MAP = {
|
|
209
|
+
$and: 'and',
|
|
210
|
+
$or: 'or',
|
|
211
|
+
$eq: 'eq',
|
|
212
|
+
$ne: 'neq',
|
|
213
|
+
$lt: 'lt',
|
|
214
|
+
$lte: 'lte',
|
|
215
|
+
$gt: 'gt',
|
|
216
|
+
$gte: 'gte',
|
|
217
|
+
$in: 'inq',
|
|
218
|
+
$nin: 'nin',
|
|
219
|
+
$regex: 'regexp',
|
|
220
|
+
$exists: 'exists',
|
|
221
|
+
$not: 'not',
|
|
222
|
+
};
|
|
223
|
+
export const transformToWhere = (mongoQuery) => {
|
|
224
|
+
return transform(mongoQuery, (result, value, key) => {
|
|
225
|
+
const newKey = typeof key === 'string' && key.startsWith('$') ? OPERATOR_MAP[key] : key;
|
|
226
|
+
if (newKey === undefined) {
|
|
227
|
+
throw new Error(`Unsupported operator ${key}`);
|
|
228
|
+
}
|
|
229
|
+
result[newKey] = isObject(value) ? transformToWhere(value) : value;
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
export const getMiddleObject = (fieldDefinition, endObjectId, endObjectName, instance) => {
|
|
233
|
+
if (fieldDefinition.relatedPropertyId && fieldDefinition.manyToManyPropertyId) {
|
|
234
|
+
const middleObject = {
|
|
235
|
+
[fieldDefinition.relatedPropertyId]: {
|
|
236
|
+
id: instance?.id,
|
|
237
|
+
name: instance?.name,
|
|
238
|
+
},
|
|
239
|
+
[fieldDefinition.manyToManyPropertyId]: {
|
|
240
|
+
id: endObjectId,
|
|
241
|
+
name: endObjectName,
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
return middleObject;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
export const getMiddleObjectFilter = (fieldDefinition, instanceId) => {
|
|
248
|
+
const filterProperty = `${fieldDefinition.relatedPropertyId}.id`;
|
|
249
|
+
const filter = { where: { [filterProperty]: instanceId } };
|
|
250
|
+
return filter;
|
|
251
|
+
};
|
|
252
|
+
export const encodePageSlug = (slug) => {
|
|
253
|
+
return encodeURIComponent(encodeURIComponent(slug));
|
|
254
|
+
};
|
|
255
|
+
export async function getDefaultPages(parameters, defaultPages, findDefaultPageSlugFor) {
|
|
256
|
+
let foundDefaultPages = defaultPages;
|
|
257
|
+
const relatedObjectProperties = parameters?.filter((param) => param.type === 'object');
|
|
258
|
+
if (relatedObjectProperties) {
|
|
259
|
+
foundDefaultPages = await relatedObjectProperties.reduce(async (acc, parameter) => {
|
|
260
|
+
const result = await acc;
|
|
261
|
+
if (parameter.objectId && defaultPages && defaultPages[parameter.objectId]) {
|
|
262
|
+
const slug = await findDefaultPageSlugFor(parameter.objectId);
|
|
263
|
+
if (slug) {
|
|
264
|
+
return { ...result, [parameter.objectId]: slug };
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
}, Promise.resolve({}));
|
|
269
|
+
}
|
|
270
|
+
return { ...defaultPages, ...foundDefaultPages };
|
|
271
|
+
}
|
|
272
|
+
function compileQueryValues(query, data) {
|
|
273
|
+
if ('rules' in query && Array.isArray(query.rules)) {
|
|
274
|
+
const updatedRules = query.rules
|
|
275
|
+
.map((item) => compileQueryValues(item, data))
|
|
276
|
+
.filter((item) => item !== undefined);
|
|
277
|
+
if (updatedRules?.length) {
|
|
278
|
+
return {
|
|
279
|
+
...query,
|
|
280
|
+
rules: updatedRules,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
if ('value' in query && typeof query.value === 'string') {
|
|
289
|
+
const template = Handlebars.compileAST(query.value);
|
|
290
|
+
const result = template(data);
|
|
291
|
+
if (result !== '') {
|
|
292
|
+
return {
|
|
293
|
+
...query,
|
|
294
|
+
value: result,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return query;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
export function updateCriteriaInputs(criteria, data, user) {
|
|
305
|
+
const dataSet = {
|
|
306
|
+
input: {
|
|
307
|
+
...data,
|
|
308
|
+
},
|
|
309
|
+
user: user,
|
|
310
|
+
};
|
|
311
|
+
const compiledQuery = compileQueryValues(parseMongoDB(criteria), dataSet);
|
|
312
|
+
// The "compiledQueryValues" function filters out rules that have a value of "undefined".
|
|
313
|
+
// If "compiledQuery" is "undefined", that means that all rules and nested rules have a value of "undefined".
|
|
314
|
+
// Therefore, the resulting query is empty.
|
|
315
|
+
return !compiledQuery
|
|
316
|
+
? {}
|
|
317
|
+
: JSON.parse(formatQuery(compiledQuery, {
|
|
318
|
+
format: 'mongodb',
|
|
319
|
+
ruleProcessor: (rule, options) => {
|
|
320
|
+
let updatedRule = rule;
|
|
321
|
+
if (['contains', 'beginsWith', 'endsWith'].includes(rule.operator)) {
|
|
322
|
+
updatedRule = { ...rule, value: escape(rule.value) };
|
|
323
|
+
}
|
|
324
|
+
return defaultRuleProcessorMongoDB(updatedRule, options);
|
|
325
|
+
},
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
export async function fetchCollectionData(apiServices, fieldDefinition, setFetchedOptions, instanceId, fetchedOptions, initialMiddleObjectInstances) {
|
|
329
|
+
try {
|
|
330
|
+
if ((fetchedOptions && !fetchedOptions[`${fieldDefinition.id}MiddleObject`]) || !fetchedOptions) {
|
|
331
|
+
const fetchedMiddleObject = await apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/effective?sanitizedVersion=true`), {
|
|
332
|
+
params: {
|
|
333
|
+
filter: { fields: ['properties', 'actions', 'rootObjectId'] },
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
setFetchedOptions({ [`${fieldDefinition.id}MiddleObject`]: fetchedMiddleObject });
|
|
337
|
+
}
|
|
338
|
+
// Fetch the initial middle object instances
|
|
339
|
+
const filter = instanceId ? getMiddleObjectFilter(fieldDefinition, instanceId) : {};
|
|
340
|
+
if (!isArray(initialMiddleObjectInstances)) {
|
|
341
|
+
const fetchedInitialMiddleObjectInstances = await apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/instances`), {
|
|
342
|
+
params: { filter: JSON.stringify(filter) },
|
|
343
|
+
});
|
|
344
|
+
setFetchedOptions({
|
|
345
|
+
[`${fieldDefinition.id}InitialMiddleObjectInstances`]: fetchedInitialMiddleObjectInstances,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
console.error('Error fetching collection data:', error);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
export const getErrorCountForSection = (section, errors) => {
|
|
354
|
+
const entries = section.entries || [];
|
|
355
|
+
return isArray(section.entries)
|
|
356
|
+
? entries.reduce((count, entry) => {
|
|
357
|
+
if (get(errors, entry.type === 'input' ? entry.parameterId : entry.type === 'inputField' ? entry.input.id : '')) {
|
|
358
|
+
count += 1;
|
|
359
|
+
}
|
|
360
|
+
else if (entry.type === 'sections') {
|
|
361
|
+
count += entry.sections.reduce((subCount, subSection) => {
|
|
362
|
+
return subCount + getErrorCountForSection(subSection, errors);
|
|
363
|
+
}, 0);
|
|
364
|
+
}
|
|
365
|
+
else if (entry.type === 'columns') {
|
|
366
|
+
count += entry.columns.reduce((colCount, column) => {
|
|
367
|
+
return colCount + getErrorCountForSection(column, errors);
|
|
368
|
+
}, 0);
|
|
369
|
+
}
|
|
370
|
+
return count;
|
|
371
|
+
}, 0)
|
|
372
|
+
: 0;
|
|
373
|
+
};
|
|
374
|
+
// to convert the properties of the current instances doc into a mappable object
|
|
375
|
+
export const convertDocToParameters = (obj) => {
|
|
376
|
+
return Object.entries(obj).flatMap(([key, value]) => {
|
|
377
|
+
if (key === 'metadata') {
|
|
378
|
+
return [
|
|
379
|
+
{
|
|
380
|
+
id: 'type',
|
|
381
|
+
name: 'Type',
|
|
382
|
+
type: 'string',
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
id: 'view_permission',
|
|
386
|
+
name: 'View Permission',
|
|
387
|
+
type: 'string',
|
|
388
|
+
enum: ['Public', 'Private', 'Portal'],
|
|
389
|
+
},
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
return [
|
|
393
|
+
{
|
|
394
|
+
id: key,
|
|
395
|
+
name: startCase(key),
|
|
396
|
+
type: 'string',
|
|
397
|
+
},
|
|
398
|
+
];
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
export const propertyToParameter = (property) => {
|
|
402
|
+
return {
|
|
403
|
+
...omit(property, ['searchable', 'formula', 'formulaType', 'mask', 'textTransform']),
|
|
404
|
+
validation: property.validation ? propertyValidationToParameterValidation(property) : undefined,
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
export const propertyValidationToParameterValidation = (property) => {
|
|
408
|
+
if (property.validation) {
|
|
409
|
+
if ('from' in property.validation || 'to' in property.validation) {
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
return { ...property.validation };
|
|
413
|
+
}
|
|
414
|
+
return undefined;
|
|
415
|
+
};
|
|
416
|
+
export const convertPropertiesToParams = (object) => {
|
|
417
|
+
return object.properties
|
|
418
|
+
?.reduce((acc, property) => {
|
|
419
|
+
return property.type === 'address'
|
|
420
|
+
? [
|
|
421
|
+
...acc,
|
|
422
|
+
...['city', 'county', 'state', 'line1', 'line2', 'zipCode'].map((field) => ({
|
|
423
|
+
id: `${property.id}.${field}`,
|
|
424
|
+
name: `${property.name} ${startCase(field)}`,
|
|
425
|
+
type: 'string',
|
|
426
|
+
})),
|
|
427
|
+
]
|
|
428
|
+
: [...acc, property];
|
|
429
|
+
}, [])
|
|
430
|
+
.filter(({ id, type }) => type !== 'collection')
|
|
431
|
+
.flat()
|
|
432
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
433
|
+
.map(propertyToParameter);
|
|
434
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormRenderer } from './FormRenderer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormRenderer } from './FormRenderer';
|
|
@@ -19,8 +19,7 @@ const styles = {
|
|
|
19
19
|
color: '#637381',
|
|
20
20
|
},
|
|
21
21
|
timelineConnector: {
|
|
22
|
-
padding: '1px 0px 24px
|
|
23
|
-
borderLeft: '2px rgba(145, 158, 171, 0.24) solid',
|
|
22
|
+
padding: '1px 0px 24px 0px',
|
|
24
23
|
marginLeft: '5px',
|
|
25
24
|
},
|
|
26
25
|
historyData: {
|
|
@@ -30,15 +29,24 @@ const styles = {
|
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
31
|
const HistoricalData = (props) => {
|
|
33
|
-
const { records, documentHistory, object, referencedObjects } = props;
|
|
32
|
+
const { records, documentHistory, object, referencedObjects, hideTimeline } = props;
|
|
34
33
|
const getPastDocumentVersion = (history) => {
|
|
35
34
|
const documentVersions = documentHistory?.[history.subject?.id ?? 'unknown'] ?? [];
|
|
36
35
|
const currentVersion = documentVersions?.map((v) => v.timestamp).indexOf(history.timestamp);
|
|
37
36
|
return currentVersion ? documentVersions[currentVersion - 1] : undefined;
|
|
38
37
|
};
|
|
39
|
-
return (React.createElement(Box, { sx:
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
return (React.createElement(Box, { sx: {
|
|
39
|
+
...styles.timelineConnector,
|
|
40
|
+
borderLeft: !hideTimeline ? '2px rgba(145, 158, 171, 0.24) solid' : undefined,
|
|
41
|
+
} }, records.map((r) => (React.createElement(Box, { margin: '16px 0px', key: `${r.timestamp}-${nanoid()}` },
|
|
42
|
+
React.createElement(Box, { sx: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
justifyContent: 'space-between',
|
|
45
|
+
flexDirection: { xs: 'column', sm: 'row' },
|
|
46
|
+
alignItems: { xs: 'flex-start', sm: 'center' },
|
|
47
|
+
gap: 0,
|
|
48
|
+
} },
|
|
49
|
+
React.createElement(Box, { sx: { display: 'flex', maxWidth: { sx: '100%', sm: '60%' }, alignContent: 'flex-start' } },
|
|
42
50
|
React.createElement(Typography, { sx: { fontSize: '12px', color: '#637381' } },
|
|
43
51
|
React.createElement(Typography, { component: 'span', sx: { fontWeight: 600, fontSize: '12px' } }, r.user.name ?? 'Unknown User'),
|
|
44
52
|
"\u00A0",
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { Circle } from '@mui/icons-material';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import { Box } from '../../layout';
|
|
3
3
|
import { Skeleton } from '../../core';
|
|
4
|
-
import {
|
|
4
|
+
import { Box } from '../../layout';
|
|
5
5
|
const styles = {
|
|
6
6
|
timelineConnector: {
|
|
7
7
|
padding: '1px 0px 5px 22px',
|
|
8
|
-
borderLeft: '2px rgba(145, 158, 171, 0.24) solid',
|
|
9
8
|
marginLeft: '5px',
|
|
10
9
|
},
|
|
11
10
|
headerSkeleton: {
|
|
@@ -18,20 +17,27 @@ const styles = {
|
|
|
18
17
|
borderRadius: '7px',
|
|
19
18
|
},
|
|
20
19
|
};
|
|
21
|
-
const HistoryLoading = () => {
|
|
20
|
+
const HistoryLoading = (props) => {
|
|
21
|
+
const { hideTimeline } = props;
|
|
22
22
|
return (React.createElement(React.Fragment, { key: 'history-log-loading' },
|
|
23
23
|
React.createElement(Box, { sx: { display: 'flex', alignItems: 'center' } },
|
|
24
|
-
React.createElement(Circle, { color: "primary", sx: { fontSize: '12px', marginRight: '12px' } }),
|
|
24
|
+
!hideTimeline && React.createElement(Circle, { color: "primary", sx: { fontSize: '12px', marginRight: '12px' } }),
|
|
25
25
|
React.createElement(Skeleton, { variant: "text", sx: styles.headerSkeleton })),
|
|
26
|
-
React.createElement(Box, { sx:
|
|
26
|
+
React.createElement(Box, { sx: {
|
|
27
|
+
...styles.timelineConnector,
|
|
28
|
+
borderLeft: !hideTimeline ? '2px rgba(145, 158, 171, 0.24) solid' : undefined,
|
|
29
|
+
} },
|
|
27
30
|
React.createElement(Box, { margin: '4px 0px 24px 0px' },
|
|
28
31
|
React.createElement(Skeleton, { variant: "text", sx: { ...styles.dataSkeleton, width: '120px' } }),
|
|
29
32
|
React.createElement(Skeleton, { variant: "text", sx: { ...styles.dataSkeleton, width: '65%' } }),
|
|
30
33
|
React.createElement(Skeleton, { variant: "text", sx: { ...styles.dataSkeleton, width: '75%' } }))),
|
|
31
34
|
React.createElement(Box, { sx: { display: 'flex', alignItems: 'center' } },
|
|
32
|
-
React.createElement(Circle, { color: "primary", sx: { fontSize: '12px', marginRight: '12px' } }),
|
|
35
|
+
!hideTimeline && React.createElement(Circle, { color: "primary", sx: { fontSize: '12px', marginRight: '12px' } }),
|
|
33
36
|
React.createElement(Skeleton, { variant: "text", sx: styles.headerSkeleton })),
|
|
34
|
-
React.createElement(Box, { sx:
|
|
37
|
+
React.createElement(Box, { sx: {
|
|
38
|
+
...styles.timelineConnector,
|
|
39
|
+
borderLeft: !hideTimeline ? '2px rgba(145, 158, 171, 0.24) solid' : undefined,
|
|
40
|
+
} },
|
|
35
41
|
React.createElement(Box, { margin: '4px 0px 20px 0px' },
|
|
36
42
|
React.createElement(Skeleton, { variant: "text", sx: { ...styles.dataSkeleton, width: '120px' } }),
|
|
37
43
|
React.createElement(Skeleton, { variant: "text", sx: { ...styles.dataSkeleton, width: '55%' } })))));
|
|
@@ -10,6 +10,8 @@ export type HistoryLogProps = {
|
|
|
10
10
|
loading?: boolean;
|
|
11
11
|
/** The title displayed above the timeline */
|
|
12
12
|
title?: string;
|
|
13
|
+
/** Whether to hide the timeline in the history log */
|
|
14
|
+
hideTimeline?: boolean;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* Renders a timeline of the instance's history log.
|
|
@@ -20,7 +20,7 @@ const { format } = require('small-date');
|
|
|
20
20
|
* @returns {JSX.Element} A timeline view representing the instance's history.
|
|
21
21
|
*/
|
|
22
22
|
export const HistoryLog = (props) => {
|
|
23
|
-
const { object, history, loading, title } = props;
|
|
23
|
+
const { object, history, loading, title, hideTimeline } = props;
|
|
24
24
|
const [historyMap, setHistoryMap] = useState({});
|
|
25
25
|
const [documentHistory, setDocumentHistory] = useState({});
|
|
26
26
|
const [referencedObjects, setReferencedObjects] = useState([]);
|
|
@@ -91,7 +91,7 @@ export const HistoryLog = (props) => {
|
|
|
91
91
|
if (records.length) {
|
|
92
92
|
return (React.createElement(React.Fragment, { key: date },
|
|
93
93
|
React.createElement(Box, { sx: { display: 'flex', alignItems: 'center' } },
|
|
94
|
-
React.createElement(Circle, { color: "primary", sx: { fontSize: '12px', marginRight: '12px' } }),
|
|
94
|
+
!hideTimeline && (React.createElement(Circle, { color: "primary", sx: { fontSize: '12px', marginRight: '12px' } })),
|
|
95
95
|
React.createElement(Typography, { sx: { fontWeight: 600, fontSize: '16px' } },
|
|
96
96
|
format(new Date(), 'yyyy-MM-dd') === date
|
|
97
97
|
? 'Today'
|
|
@@ -99,14 +99,14 @@ export const HistoryLog = (props) => {
|
|
|
99
99
|
' ',
|
|
100
100
|
"\u00A0"),
|
|
101
101
|
React.createElement(Typography, { sx: { fontWeight: 600, fontSize: '16px', color: '#637381' } }, format(new Date(date + ' 00:00:000'), 'MMM dd, yyyy'))),
|
|
102
|
-
React.createElement(HistoricalData, { object: object, records: records, documentHistory: documentHistory, referencedObjects: referencedObjects })));
|
|
102
|
+
React.createElement(HistoricalData, { object: object, records: records, documentHistory: documentHistory, referencedObjects: referencedObjects, hideTimeline: hideTimeline })));
|
|
103
103
|
}
|
|
104
104
|
return null;
|
|
105
105
|
}),
|
|
106
106
|
!loading && filteredHistory && Object.values(filteredHistory).every((v) => !v.length) && (React.createElement(Box, { width: '100%', display: 'grid', justifyContent: 'center', marginTop: '60px' },
|
|
107
107
|
React.createElement(Typography, { fontSize: '20px', fontWeight: 700 }, "You Have No History"),
|
|
108
108
|
React.createElement(Typography, { fontSize: '14px', fontWeight: 400 }, "Try modifying the history type."))),
|
|
109
|
-
loading && React.createElement(HistoryLoading,
|
|
109
|
+
loading && React.createElement(HistoryLoading, { hideTimeline: hideTimeline }),
|
|
110
110
|
React.createElement(Snackbar, { open: showSnackbar, handleClose: () => setShowSnackbar(false), message: 'Error occurred when loading referenced objects', error: true })));
|
|
111
111
|
};
|
|
112
112
|
export default HistoryLog;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ResponsiveOverflowProps {
|
|
3
|
+
/**
|
|
4
|
+
* Children elements to be displayed horizontally
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode[];
|
|
7
|
+
/**
|
|
8
|
+
* Text for the overflow button. Default is "More"
|
|
9
|
+
*/
|
|
10
|
+
moreButtonText?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Custom button element to replace the default "More" button
|
|
13
|
+
*/
|
|
14
|
+
customMoreButton?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum number of children to be displayed before overflowing
|
|
17
|
+
*/
|
|
18
|
+
maxVisible?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Function to render each overflow menu item. Receives the overflowed child and its index.
|
|
21
|
+
*/
|
|
22
|
+
renderOverflowMenuItem?: (item: React.ReactNode) => React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* If true, the container will take full width
|
|
25
|
+
*/
|
|
26
|
+
fullWidth?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* ResponsiveOverflow is a container component that displays children horizontally,
|
|
30
|
+
* automatically moving overflow items into a dropdown menu when there isn't enough space.
|
|
31
|
+
*/
|
|
32
|
+
export declare const ResponsiveOverflow: (props: ResponsiveOverflowProps) => React.JSX.Element;
|
|
33
|
+
export default ResponsiveOverflow;
|