@evoke-platform/ui-components 1.8.0-testing.6 → 1.8.0-testing.8
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/custom/Form/utils.js +74 -44
- package/dist/published/components/custom/FormV2/FormRendererContainer.js +3 -3
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +2 -2
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.js +2 -2
- package/dist/published/components/custom/FormV2/components/utils.js +1 -1
- package/package.json +1 -1
|
@@ -489,49 +489,76 @@ export function flattenFormComponents(components) {
|
|
|
489
489
|
export async function addObjectPropertiesToComponentProps(properties,
|
|
490
490
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
491
491
|
formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associatedObject, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight, richTextEditor) {
|
|
492
|
+
function removeEmptySections(component) {
|
|
493
|
+
// if a component is an entry to a property that the user doesn't have permission to view, remove it
|
|
494
|
+
if (component?.property?.id) {
|
|
495
|
+
const hasPermission = allProperties.some((p) => p.id === component.property.id);
|
|
496
|
+
if (!hasPermission)
|
|
497
|
+
return undefined;
|
|
498
|
+
}
|
|
499
|
+
// remove sections or tabs with no components
|
|
500
|
+
if (component.components) {
|
|
501
|
+
component.components = component.components
|
|
502
|
+
.map(removeEmptySections)
|
|
503
|
+
.filter((c) => c !== undefined);
|
|
504
|
+
if (component.components.length === 0)
|
|
505
|
+
return undefined;
|
|
506
|
+
}
|
|
507
|
+
// check columns for empty components or sections with no components
|
|
508
|
+
const actionInput = component;
|
|
509
|
+
if (actionInput.columns) {
|
|
510
|
+
const processedColumns = actionInput.columns.map((col) => ({
|
|
511
|
+
...col,
|
|
512
|
+
components: (col.components || [])
|
|
513
|
+
.map(removeEmptySections)
|
|
514
|
+
.filter((c) => c !== undefined),
|
|
515
|
+
}));
|
|
516
|
+
actionInput.columns = processedColumns;
|
|
517
|
+
if (processedColumns.every((col) => col.components.length === 0)) {
|
|
518
|
+
return undefined;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return component;
|
|
522
|
+
}
|
|
523
|
+
const allProperties = properties.flatMap((property) => property.type === 'address'
|
|
524
|
+
? [
|
|
525
|
+
{
|
|
526
|
+
id: `${property.id}.line1`,
|
|
527
|
+
name: `${property.name} Line 1`,
|
|
528
|
+
type: 'string',
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
id: `${property.id}.line2`,
|
|
532
|
+
name: `${property.name} Line 2`,
|
|
533
|
+
type: 'string',
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
id: `${property.id}.city`,
|
|
537
|
+
name: `${property.name} City`,
|
|
538
|
+
type: 'string',
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
id: `${property.id}.county`,
|
|
542
|
+
name: `${property.name} County`,
|
|
543
|
+
type: 'string',
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
id: `${property.id}.state`,
|
|
547
|
+
name: `${property.name} State`,
|
|
548
|
+
type: 'string',
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
id: `${property.id}.zipCode`,
|
|
552
|
+
name: `${property.name} Zip Code`,
|
|
553
|
+
type: 'string',
|
|
554
|
+
},
|
|
555
|
+
]
|
|
556
|
+
: [property]);
|
|
492
557
|
return [
|
|
493
558
|
...(await Promise.all(formComponents
|
|
494
559
|
?.filter((component) => !isUndefined(component) && !isNil(component))
|
|
495
560
|
?.map(async (component) => {
|
|
496
|
-
const property =
|
|
497
|
-
.flatMap((property) => {
|
|
498
|
-
if (property.type === 'address') {
|
|
499
|
-
return [
|
|
500
|
-
{
|
|
501
|
-
id: `${property.id}.line1`,
|
|
502
|
-
name: `${property.name} Line 1`,
|
|
503
|
-
type: 'string',
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
id: `${property.id}.line2`,
|
|
507
|
-
name: `${property.name} Line 2`,
|
|
508
|
-
type: 'string',
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
id: `${property.id}.city`,
|
|
512
|
-
name: `${property.name} City`,
|
|
513
|
-
type: 'string',
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
id: `${property.id}.county`,
|
|
517
|
-
name: `${property.name} County`,
|
|
518
|
-
type: 'string',
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
id: `${property.id}.state`,
|
|
522
|
-
name: `${property.name} State`,
|
|
523
|
-
type: 'string',
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
id: `${property.id}.zipCode`,
|
|
527
|
-
name: `${property.name} Zip Code`,
|
|
528
|
-
type: 'string',
|
|
529
|
-
},
|
|
530
|
-
];
|
|
531
|
-
}
|
|
532
|
-
return property;
|
|
533
|
-
})
|
|
534
|
-
.find((property) => property.id === component.key);
|
|
561
|
+
const property = allProperties.find((prop) => prop.id === component.key);
|
|
535
562
|
const id = property?.id ?? component.key;
|
|
536
563
|
if (component.type === 'Content') {
|
|
537
564
|
return component;
|
|
@@ -543,7 +570,7 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
|
|
|
543
570
|
? DateTime.now().toISODate()
|
|
544
571
|
: DateTime.fromISO(component.initialValue).toISODate();
|
|
545
572
|
}
|
|
546
|
-
// @
|
|
573
|
+
// @Deprecated
|
|
547
574
|
// This will overwrite the default value
|
|
548
575
|
if (component.defaultToCurrentDate) {
|
|
549
576
|
component.initialValue = DateTime.now().toISODate();
|
|
@@ -556,7 +583,7 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
|
|
|
556
583
|
? DateTime.now().toISO()
|
|
557
584
|
: DateTime.fromISO(component.initialValue).toISO();
|
|
558
585
|
}
|
|
559
|
-
// @
|
|
586
|
+
// @Deprecated
|
|
560
587
|
// This will overwrite the default value
|
|
561
588
|
if (component.defaultToCurrentDate) {
|
|
562
589
|
component.initialValue = DateTime.now().toISO();
|
|
@@ -575,7 +602,7 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
|
|
|
575
602
|
suppressMilliseconds: true,
|
|
576
603
|
});
|
|
577
604
|
}
|
|
578
|
-
// @
|
|
605
|
+
// @Deprecated
|
|
579
606
|
// This will overwrite the default value
|
|
580
607
|
if (component.defaultToCurrentTime) {
|
|
581
608
|
component.initialValue = DateTime.now().toISOTime({
|
|
@@ -709,13 +736,16 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
|
|
|
709
736
|
: undefined,
|
|
710
737
|
};
|
|
711
738
|
}
|
|
712
|
-
|
|
739
|
+
else {
|
|
740
|
+
component = removeEmptySections(component);
|
|
741
|
+
}
|
|
742
|
+
if (component?.columns) {
|
|
713
743
|
for (const column of component.columns) {
|
|
714
744
|
column.components = await addObjectPropertiesToComponentProps(properties, column.components, allCriteriaInputs, instance, objectPropertyInputProps, associatedObject, autoSave, readOnly, undefined, undefined, queryAddresses, apiServices, isModal, fieldHeight, richTextEditor);
|
|
715
745
|
}
|
|
716
746
|
return component;
|
|
717
747
|
}
|
|
718
|
-
if (component
|
|
748
|
+
if (component?.components) {
|
|
719
749
|
for (const item of component.components) {
|
|
720
750
|
const nestedFieldProperty = properties.find((property) => property.id === item.key);
|
|
721
751
|
if (item.type) {
|
|
@@ -97,7 +97,7 @@ function FormRendererContainer(props) {
|
|
|
97
97
|
return;
|
|
98
98
|
if (formId || action?.defaultFormId) {
|
|
99
99
|
apiServices
|
|
100
|
-
.get(getPrefixedUrl(
|
|
100
|
+
.get(getPrefixedUrl(`/forms/${formId || action?.defaultFormId}`))
|
|
101
101
|
.then((evokeForm) => {
|
|
102
102
|
if (evokeForm?.actionId === actionId) {
|
|
103
103
|
const form = onClose ? { ...evokeForm, name: '' } : evokeForm;
|
|
@@ -113,7 +113,7 @@ function FormRendererContainer(props) {
|
|
|
113
113
|
}
|
|
114
114
|
else if (action) {
|
|
115
115
|
apiServices
|
|
116
|
-
.get(getPrefixedUrl('
|
|
116
|
+
.get(getPrefixedUrl('/forms'), {
|
|
117
117
|
params: {
|
|
118
118
|
filter: {
|
|
119
119
|
where: {
|
|
@@ -146,7 +146,7 @@ function FormRendererContainer(props) {
|
|
|
146
146
|
},
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
else if (instance) {
|
|
149
|
+
else if (instance || action.type === 'create') {
|
|
150
150
|
setError(true);
|
|
151
151
|
}
|
|
152
152
|
})
|
|
@@ -66,7 +66,7 @@ const RepeatableField = (props) => {
|
|
|
66
66
|
function getForm(setForm, action, formId) {
|
|
67
67
|
if (formId || action?.defaultFormId) {
|
|
68
68
|
apiServices
|
|
69
|
-
.get(getPrefixedUrl(
|
|
69
|
+
.get(getPrefixedUrl(`/forms/${formId || action?.defaultFormId}`))
|
|
70
70
|
.then((evokeForm) => {
|
|
71
71
|
setForm(evokeForm);
|
|
72
72
|
})
|
|
@@ -76,7 +76,7 @@ const RepeatableField = (props) => {
|
|
|
76
76
|
}
|
|
77
77
|
else if (action) {
|
|
78
78
|
apiServices
|
|
79
|
-
.get(getPrefixedUrl('
|
|
79
|
+
.get(getPrefixedUrl('/forms'), {
|
|
80
80
|
params: {
|
|
81
81
|
filter: {
|
|
82
82
|
where: {
|
|
@@ -147,7 +147,7 @@ const ObjectPropertyInput = (props) => {
|
|
|
147
147
|
useEffect(() => {
|
|
148
148
|
if (formId || action?.defaultFormId) {
|
|
149
149
|
apiServices
|
|
150
|
-
.get(getPrefixedUrl(
|
|
150
|
+
.get(getPrefixedUrl(`/forms/${formId || action?.defaultFormId}`))
|
|
151
151
|
.then((evokeForm) => {
|
|
152
152
|
setForm(evokeForm);
|
|
153
153
|
})
|
|
@@ -157,7 +157,7 @@ const ObjectPropertyInput = (props) => {
|
|
|
157
157
|
}
|
|
158
158
|
else if (action) {
|
|
159
159
|
apiServices
|
|
160
|
-
.get(getPrefixedUrl('
|
|
160
|
+
.get(getPrefixedUrl('/forms'), {
|
|
161
161
|
params: {
|
|
162
162
|
filter: {
|
|
163
163
|
where: {
|
|
@@ -116,7 +116,7 @@ export const getEntryId = (entry) => {
|
|
|
116
116
|
};
|
|
117
117
|
export function getPrefixedUrl(url) {
|
|
118
118
|
const wcsMatchers = ['/apps', '/pages', '/widgets'];
|
|
119
|
-
const dataMatchers = ['/objects', '/correspondenceTemplates', '/documents', '/payments', '/locations'];
|
|
119
|
+
const dataMatchers = ['/objects', '/correspondenceTemplates', '/documents', '/payments', '/forms', '/locations'];
|
|
120
120
|
const signalrMatchers = ['/hubs'];
|
|
121
121
|
const accessManagementMatchers = ['/users'];
|
|
122
122
|
const workflowMatchers = ['/workflows'];
|