@arquimedes.co/eureka-forms 2.0.54 → 2.0.55
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/@Types/Condition.d.ts +54 -2
- package/dist/@Types/Draft/Draft.d.ts +12 -0
- package/dist/@Types/Draft/Draft.js +1 -0
- package/dist/@Types/Draft/DraftEntityData.d.ts +50 -0
- package/dist/@Types/Draft/DraftEntityData.js +1 -0
- package/dist/@Types/Entity.d.ts +33 -0
- package/dist/@Types/Entity.js +1 -0
- package/dist/@Types/Form.d.ts +7 -0
- package/dist/@Types/FormStep.d.ts +7 -0
- package/dist/App/App.css +14 -0
- package/dist/App/AppFunctions.d.ts +2 -2
- package/dist/App/AppFunctions.js +167 -156
- package/dist/App/AppHooks.js +12 -8
- package/dist/Contexts/FormContext.d.ts +2 -0
- package/dist/Contexts/FormContext.js +49 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +30 -5
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.module.css +2 -0
- package/dist/Form/Form.js +1 -1
- package/dist/Form/FormFunctions.js +15 -12
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +10 -7
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.d.ts +12 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.js +49 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.module.css +60 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +103 -49
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.d.ts +3 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +3 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.d.ts +5 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.js +204 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.module.css +75 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +6 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +44 -14
- package/dist/FormSteps/StepFunctions.d.ts +11 -1
- package/dist/FormSteps/StepFunctions.js +146 -1
- package/dist/FormSteps/StepHooks.js +12 -4
- package/dist/Shared/CustomBtn/CustomBtn.d.ts +7 -2
- package/dist/Shared/CustomBtn/CustomBtn.js +14 -5
- package/dist/Shared/CustomBtn/CustomBtn.module.css +0 -2
- package/dist/States/GlobalSlice.d.ts +9 -0
- package/dist/States/GlobalSlice.js +5 -0
- package/dist/States/SiteSlice.d.ts +32 -3
- package/dist/States/SiteSlice.js +50 -5
- package/dist/Utils/DraftFunctions.d.ts +21 -0
- package/dist/Utils/DraftFunctions.js +239 -0
- package/dist/constants/ConditionTypes.d.ts +6 -1
- package/dist/constants/ConditionTypes.js +5 -0
- package/dist/constants/Draft/DraftEntityDataTypes.d.ts +10 -0
- package/dist/constants/Draft/DraftEntityDataTypes.js +12 -0
- package/dist/constants/Draft/DraftEntityTypes.d.ts +3 -0
- package/dist/constants/Draft/DraftEntityTypes.js +4 -0
- package/dist/constants/Draft/DraftStyleTypes.d.ts +7 -0
- package/dist/constants/Draft/DraftStyleTypes.js +8 -0
- package/dist/constants/EntityPropertyTypes.d.ts +9 -0
- package/dist/constants/EntityPropertyTypes.js +10 -0
- package/dist/constants/FormStepTypes.d.ts +1 -0
- package/dist/constants/FormStepTypes.js +1 -0
- package/dist/constants/TicketPropertyTypes.d.ts +3 -0
- package/dist/constants/TicketPropertyTypes.js +4 -0
- package/package.json +2 -2
|
@@ -12,6 +12,7 @@ import CBRFormStepTypes from '../constants/CBRFormStepTypes';
|
|
|
12
12
|
import AYFFormStepTypes from '../constants/AYFFormStepTypes';
|
|
13
13
|
import { getRawText } from '../Utils/DraftFunctions';
|
|
14
14
|
import ConditionTypes, { ExpressionTypes, OperatorTypes, } from '../constants/ConditionTypes';
|
|
15
|
+
import EntityPropertyTypes from '../constants/EntityPropertyTypes';
|
|
15
16
|
export function calcFillerSize(step, steps, values, size) {
|
|
16
17
|
var _a;
|
|
17
18
|
var maxSize = (_a = step.maxSize) !== null && _a !== void 0 ? _a : size.blockNum;
|
|
@@ -136,6 +137,7 @@ export var calcDefaultValue = function (step) {
|
|
|
136
137
|
case StepTypes.ENTITYVALUEPICKER:
|
|
137
138
|
return null;
|
|
138
139
|
case StepTypes.MAPPER:
|
|
140
|
+
return { elements: [], page: 0 };
|
|
139
141
|
case StepTypes.FILEUPLOAD:
|
|
140
142
|
case CBRFormStepTypes.CBR_INCIDENCIAS:
|
|
141
143
|
return [];
|
|
@@ -271,7 +273,7 @@ export var calcSubSteps = function (idStep, allSteps, idModifier) {
|
|
|
271
273
|
}
|
|
272
274
|
return subSteps;
|
|
273
275
|
};
|
|
274
|
-
export var evaluateCondition = function (condition, dependencies) {
|
|
276
|
+
export var evaluateCondition = function (condition, dependencies, entityValue) {
|
|
275
277
|
var _a, _b, _c;
|
|
276
278
|
switch (condition.type) {
|
|
277
279
|
case ConditionTypes.EXPRESSION: {
|
|
@@ -423,6 +425,11 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
423
425
|
}
|
|
424
426
|
break;
|
|
425
427
|
}
|
|
428
|
+
case ConditionTypes.ENTITYVALUE: {
|
|
429
|
+
if (!entityValue || !entityValue.entity)
|
|
430
|
+
return false;
|
|
431
|
+
return evaluateEntityValueCondition(condition, entityValue.entity, entityValue.entityValue);
|
|
432
|
+
}
|
|
426
433
|
default:
|
|
427
434
|
return false;
|
|
428
435
|
}
|
|
@@ -432,3 +439,141 @@ function isFormStepExistance(condition) {
|
|
|
432
439
|
return (condition.operator === OperatorTypes.EXISTS ||
|
|
433
440
|
condition.operator === OperatorTypes.NOTEXISTS);
|
|
434
441
|
}
|
|
442
|
+
var evaluateEntityValueCondition = function (condition, entity, entityValue) {
|
|
443
|
+
switch (condition.operator) {
|
|
444
|
+
case OperatorTypes.EQUAL:
|
|
445
|
+
case OperatorTypes.NOTEQUAL: {
|
|
446
|
+
var boolFactor = condition.operator === OperatorTypes.EQUAL;
|
|
447
|
+
for (var _i = 0, _a = condition.values; _i < _a.length; _i++) {
|
|
448
|
+
var value = _a[_i];
|
|
449
|
+
if (value === entityValue._id) {
|
|
450
|
+
return boolFactor;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return !boolFactor;
|
|
454
|
+
}
|
|
455
|
+
case OperatorTypes.INCLUDES: {
|
|
456
|
+
return evaluateEntityPropertyCondition(condition, entity, entityValue);
|
|
457
|
+
}
|
|
458
|
+
case OperatorTypes.NOTINCLUDES: {
|
|
459
|
+
return !evaluateEntityPropertyCondition(condition, entity, entityValue);
|
|
460
|
+
}
|
|
461
|
+
default:
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
return false;
|
|
465
|
+
};
|
|
466
|
+
var evaluateEntityPropertyCondition = function (condition, entity, entityValue) {
|
|
467
|
+
if (isEntityPropertyExistance(condition)) {
|
|
468
|
+
var boolFactor = condition.propertyOperator === OperatorTypes.EXISTS;
|
|
469
|
+
var value_2 = entityValue[condition.idProperty];
|
|
470
|
+
if (value_2 !== undefined) {
|
|
471
|
+
return boolFactor;
|
|
472
|
+
}
|
|
473
|
+
return !boolFactor;
|
|
474
|
+
}
|
|
475
|
+
var property = entity.steps[condition.idProperty];
|
|
476
|
+
if (!property || property.type !== condition.propertyType) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
var value = entityValue[condition.idProperty];
|
|
480
|
+
if (value === undefined)
|
|
481
|
+
return false;
|
|
482
|
+
switch (condition.propertyType) {
|
|
483
|
+
case EntityPropertyTypes.CHECKBOX: {
|
|
484
|
+
var boolFactor = condition.propertyOperator === OperatorTypes.EQUAL;
|
|
485
|
+
if (value === condition.propertyValue) {
|
|
486
|
+
return boolFactor;
|
|
487
|
+
}
|
|
488
|
+
return !boolFactor;
|
|
489
|
+
}
|
|
490
|
+
case EntityPropertyTypes.DATEPICKER: {
|
|
491
|
+
var date = new Date(value);
|
|
492
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) {
|
|
493
|
+
return condition.propertyOperator === OperatorTypes.NOTEQUAL;
|
|
494
|
+
}
|
|
495
|
+
switch (condition.propertyOperator) {
|
|
496
|
+
case OperatorTypes.EQUAL: {
|
|
497
|
+
var propertyDate = new Date(condition.propertyValue);
|
|
498
|
+
return date.getTime() === propertyDate.getTime();
|
|
499
|
+
}
|
|
500
|
+
case OperatorTypes.NOTEQUAL: {
|
|
501
|
+
var propertyDate = new Date(condition.propertyValue);
|
|
502
|
+
return date.getTime() !== propertyDate.getTime();
|
|
503
|
+
}
|
|
504
|
+
case OperatorTypes.LESS: {
|
|
505
|
+
var propertyDate = new Date(condition.propertyValue);
|
|
506
|
+
return date.getTime() < propertyDate.getTime();
|
|
507
|
+
}
|
|
508
|
+
case OperatorTypes.MORE: {
|
|
509
|
+
var propertyDate = new Date(condition.propertyValue);
|
|
510
|
+
return date.getTime() > propertyDate.getTime();
|
|
511
|
+
}
|
|
512
|
+
case OperatorTypes.PAST_RELATIVE_LESS:
|
|
513
|
+
case OperatorTypes.PAST_RELATIVE_MORE:
|
|
514
|
+
case OperatorTypes.FUTURE_RELATIVE_LESS:
|
|
515
|
+
case OperatorTypes.FUTURE_RELATIVE_MORE: {
|
|
516
|
+
var date_1 = getRelativeDate(condition.days, condition.hours, condition.minutes, condition.propertyOperator ===
|
|
517
|
+
OperatorTypes.PAST_RELATIVE_LESS ||
|
|
518
|
+
condition.propertyOperator ===
|
|
519
|
+
OperatorTypes.PAST_RELATIVE_MORE);
|
|
520
|
+
if (condition.propertyOperator ===
|
|
521
|
+
OperatorTypes.PAST_RELATIVE_LESS ||
|
|
522
|
+
condition.propertyOperator ===
|
|
523
|
+
OperatorTypes.FUTURE_RELATIVE_LESS)
|
|
524
|
+
return new Date().getTime() > date_1.getTime();
|
|
525
|
+
else
|
|
526
|
+
return new Date().getTime() < date_1.getTime();
|
|
527
|
+
}
|
|
528
|
+
default:
|
|
529
|
+
false;
|
|
530
|
+
}
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
case EntityPropertyTypes.SELECTOR:
|
|
534
|
+
case EntityPropertyTypes.TEXTAREA:
|
|
535
|
+
case EntityPropertyTypes.TEXTINPUT: {
|
|
536
|
+
if (condition.propertyOperator === OperatorTypes.INCLUDES ||
|
|
537
|
+
condition.propertyOperator === OperatorTypes.NOTINCLUDES) {
|
|
538
|
+
var words = condition.propertyValues;
|
|
539
|
+
var regx = "\\b(".concat(words[0].toLowerCase());
|
|
540
|
+
for (var i = 1; i < words.length; i++) {
|
|
541
|
+
regx += "|".concat(words[i].toLowerCase());
|
|
542
|
+
}
|
|
543
|
+
regx += ')\\b';
|
|
544
|
+
if (condition.propertyOperator === OperatorTypes.INCLUDES) {
|
|
545
|
+
return new RegExp(regx).test(value.toLowerCase());
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
return !new RegExp(regx).test(value.toLowerCase());
|
|
549
|
+
}
|
|
550
|
+
/** For Inputs and Selectors */
|
|
551
|
+
}
|
|
552
|
+
else if (condition.propertyOperator === OperatorTypes.EQUAL) {
|
|
553
|
+
return (condition.propertyValue.toLowerCase() ===
|
|
554
|
+
value.toLowerCase());
|
|
555
|
+
}
|
|
556
|
+
else if (condition.propertyOperator === OperatorTypes.NOTEQUAL) {
|
|
557
|
+
return !(condition.propertyValue.toLowerCase() ===
|
|
558
|
+
value.toLowerCase());
|
|
559
|
+
}
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
default:
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
return false;
|
|
566
|
+
};
|
|
567
|
+
function isEntityPropertyExistance(condition) {
|
|
568
|
+
return (condition.propertyOperator === OperatorTypes.EXISTS ||
|
|
569
|
+
condition.propertyOperator === OperatorTypes.NOTEXISTS);
|
|
570
|
+
}
|
|
571
|
+
export function getRelativeDate(nDays, nHours, nMinutes, subtract, date) {
|
|
572
|
+
if (nDays === void 0) { nDays = 0; }
|
|
573
|
+
if (nHours === void 0) { nHours = 0; }
|
|
574
|
+
if (nMinutes === void 0) { nMinutes = 0; }
|
|
575
|
+
if (subtract === void 0) { subtract = false; }
|
|
576
|
+
if (date === void 0) { date = new Date(); }
|
|
577
|
+
var millis = nDays * 86400000 + nHours * 3600000 + nMinutes * 60000;
|
|
578
|
+
return new Date(date.getTime() + (subtract ? -millis : millis));
|
|
579
|
+
}
|
|
@@ -202,12 +202,17 @@ export var calcStepDeps = function (step) {
|
|
|
202
202
|
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
+
if (step.dialogs)
|
|
206
|
+
for (var _e = 0, _f = Object.values(step.dialogs); _e < _f.length; _e++) {
|
|
207
|
+
var dialog = _f[_e];
|
|
208
|
+
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(dialog.condition));
|
|
209
|
+
}
|
|
205
210
|
}
|
|
206
211
|
break;
|
|
207
212
|
case FormStepTypes.API_SELECTOR:
|
|
208
213
|
{
|
|
209
|
-
for (var
|
|
210
|
-
var option =
|
|
214
|
+
for (var _g = 0, _h = Object.values(step.options); _g < _h.length; _g++) {
|
|
215
|
+
var option = _h[_g];
|
|
211
216
|
if (option.type !== ApiSelectorOptionTypes.HIDE &&
|
|
212
217
|
option.condition) {
|
|
213
218
|
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
@@ -217,8 +222,8 @@ export var calcStepDeps = function (step) {
|
|
|
217
222
|
break;
|
|
218
223
|
case FormStepTypes.SELECTOR:
|
|
219
224
|
{
|
|
220
|
-
for (var
|
|
221
|
-
var option =
|
|
225
|
+
for (var _j = 0, _k = Object.values(step.options); _j < _k.length; _j++) {
|
|
226
|
+
var option = _k[_j];
|
|
222
227
|
if (option.condition) {
|
|
223
228
|
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
224
229
|
}
|
|
@@ -242,5 +247,8 @@ export var recursivelyCalcConditionSteps = function (condition) {
|
|
|
242
247
|
case ConditionTypes.FORM_STEP: {
|
|
243
248
|
return [condition.idStep];
|
|
244
249
|
}
|
|
250
|
+
case ConditionTypes.ENTITYVALUE: {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
245
253
|
}
|
|
246
254
|
};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
interface CustomBtnProps {
|
|
3
|
-
label
|
|
3
|
+
label?: string;
|
|
4
4
|
'data-testid'?: string;
|
|
5
5
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
6
6
|
backgroundColor?: string;
|
|
7
7
|
color?: string;
|
|
8
|
+
height?: string;
|
|
8
9
|
width?: string;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
loading?: boolean;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
padding?: string;
|
|
14
|
+
borderRadius?: string;
|
|
15
|
+
contentMargin?: string;
|
|
11
16
|
}
|
|
12
|
-
declare function CustomBtn({ label, onClick, backgroundColor, color, loading, disabled, width, ...others }: CustomBtnProps): JSX.Element;
|
|
17
|
+
declare function CustomBtn({ label, onClick, backgroundColor, color, loading, disabled, height, width, padding, borderRadius, contentMargin, children, ...others }: CustomBtnProps): JSX.Element;
|
|
13
18
|
export default CustomBtn;
|
|
@@ -62,15 +62,20 @@ import styles from './CustomBtn.module.css';
|
|
|
62
62
|
import Loader from '../Loader/Loader';
|
|
63
63
|
function CustomBtn(_a) {
|
|
64
64
|
var _this = this;
|
|
65
|
-
var label = _a.label, onClick = _a.onClick, backgroundColor = _a.backgroundColor, color = _a.color, _b = _a.loading, loading = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.
|
|
66
|
-
var
|
|
65
|
+
var label = _a.label, onClick = _a.onClick, backgroundColor = _a.backgroundColor, color = _a.color, _b = _a.loading, loading = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.height, height = _d === void 0 ? 'fit-content' : _d, _e = _a.width, width = _e === void 0 ? 'fit-content' : _e, _f = _a.padding, padding = _f === void 0 ? '15px 30px' : _f, _g = _a.borderRadius, borderRadius = _g === void 0 ? '20px' : _g, _h = _a.contentMargin, contentMargin = _h === void 0 ? '0px 10px' : _h, children = _a.children, others = __rest(_a, ["label", "onClick", "backgroundColor", "color", "loading", "disabled", "height", "width", "padding", "borderRadius", "contentMargin", "children"]);
|
|
66
|
+
var _j = useState(undefined), coords = _j[0], setCoords = _j[1];
|
|
67
|
+
var _k = useState(true), mounted = _k[0], setMounted = _k[1];
|
|
67
68
|
useEffect(function () {
|
|
68
69
|
if (coords)
|
|
69
70
|
setCoords(undefined);
|
|
71
|
+
return function () { return setMounted(false); };
|
|
70
72
|
}, [label]);
|
|
71
73
|
return (_jsxs("button", __assign({ className: styles.customBtn, style: {
|
|
72
74
|
width: width,
|
|
75
|
+
height: height,
|
|
76
|
+
borderRadius: borderRadius,
|
|
73
77
|
background: backgroundColor,
|
|
78
|
+
padding: padding,
|
|
74
79
|
color: color,
|
|
75
80
|
}, "data-testid": others['data-testid'], disabled: disabled || loading, onClick: function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
81
|
var rect;
|
|
@@ -80,7 +85,10 @@ function CustomBtn(_a) {
|
|
|
80
85
|
x: e.clientX - rect.left,
|
|
81
86
|
y: e.clientY - rect.top,
|
|
82
87
|
});
|
|
83
|
-
setTimeout(function () {
|
|
88
|
+
setTimeout(function () {
|
|
89
|
+
if (mounted)
|
|
90
|
+
setCoords(undefined);
|
|
91
|
+
}, 600);
|
|
84
92
|
onClick && onClick(e);
|
|
85
93
|
return [2 /*return*/];
|
|
86
94
|
});
|
|
@@ -90,7 +98,8 @@ function CustomBtn(_a) {
|
|
|
90
98
|
top: coords.y,
|
|
91
99
|
} })) : (_jsx(_Fragment, {})), _jsx("div", __assign({ style: {
|
|
92
100
|
visibility: loading ? 'hidden' : 'visible',
|
|
93
|
-
margin:
|
|
94
|
-
|
|
101
|
+
margin: contentMargin,
|
|
102
|
+
display: 'flex',
|
|
103
|
+
} }, { children: children !== null && children !== void 0 ? children : label })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: color, position: "unset" }) })))] })));
|
|
95
104
|
}
|
|
96
105
|
export default CustomBtn;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { FormStyle } from '../@Types/Form';
|
|
2
2
|
import type { PayloadAction } from '@reduxjs/toolkit';
|
|
3
3
|
import { SiteState } from './SiteSlice';
|
|
4
|
+
import { EurekaDraft } from '../@Types/Draft/Draft';
|
|
4
5
|
export interface GlobalState {
|
|
5
6
|
idOrganization: string;
|
|
6
7
|
formStyle: FormStyle;
|
|
8
|
+
confirmation: {
|
|
9
|
+
confirmationMessage: EurekaDraft;
|
|
10
|
+
showLink: boolean;
|
|
11
|
+
};
|
|
7
12
|
/** If the formsteps can be edited (For internal) */
|
|
8
13
|
editable: boolean;
|
|
9
14
|
preview: boolean;
|
|
@@ -21,6 +26,10 @@ export declare const GlobalSlice: import("@reduxjs/toolkit").Slice<GlobalState,
|
|
|
21
26
|
formStyle: FormStyle;
|
|
22
27
|
preview: boolean;
|
|
23
28
|
idOrganization: string;
|
|
29
|
+
confirmation: {
|
|
30
|
+
confirmationMessage: EurekaDraft;
|
|
31
|
+
showLink: boolean;
|
|
32
|
+
};
|
|
24
33
|
internal: boolean;
|
|
25
34
|
dependencies: import("../Form/Form").DependencyStore;
|
|
26
35
|
values: import("./SiteSlice").ValuesStore;
|
|
@@ -11,9 +11,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import InternalFormStyle from '../constants/InternalFormStyle';
|
|
13
13
|
import { createSlice } from '@reduxjs/toolkit';
|
|
14
|
+
import { BaseConfirmationMessage } from '../Contexts/FormContext';
|
|
14
15
|
var initialState = {
|
|
15
16
|
idOrganization: '',
|
|
16
17
|
formStyle: InternalFormStyle,
|
|
18
|
+
confirmation: {
|
|
19
|
+
confirmationMessage: BaseConfirmationMessage,
|
|
20
|
+
showLink: true,
|
|
21
|
+
},
|
|
17
22
|
editable: false,
|
|
18
23
|
preview: false,
|
|
19
24
|
postview: false,
|
|
@@ -5,6 +5,7 @@ import { CustomStep } from '../FormSteps/CustomStep';
|
|
|
5
5
|
import { CBRFormStep } from '../@Types/CBRFormStep';
|
|
6
6
|
import type { PayloadAction } from '@reduxjs/toolkit';
|
|
7
7
|
import { FieldValues } from 'react-hook-form';
|
|
8
|
+
import { Form } from '../@Types';
|
|
8
9
|
export interface SiteState {
|
|
9
10
|
dependencies: DependencyStore;
|
|
10
11
|
values: ValuesStore;
|
|
@@ -41,8 +42,27 @@ export declare const SiteSlice: import("@reduxjs/toolkit").Slice<SiteState, {
|
|
|
41
42
|
};
|
|
42
43
|
type: string;
|
|
43
44
|
}) => void;
|
|
44
|
-
handlePrevious: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload
|
|
45
|
-
|
|
45
|
+
handlePrevious: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload: { values, form }, }: {
|
|
46
|
+
payload: {
|
|
47
|
+
values: Record<string, any>;
|
|
48
|
+
form: Form;
|
|
49
|
+
};
|
|
50
|
+
type: string;
|
|
51
|
+
}) => void;
|
|
52
|
+
handleNext: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload: { values, form }, }: {
|
|
53
|
+
payload: {
|
|
54
|
+
values: Record<string, any>;
|
|
55
|
+
form: Form;
|
|
56
|
+
};
|
|
57
|
+
type: string;
|
|
58
|
+
}) => void;
|
|
59
|
+
updateNestedValues: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload: { key, values }, }: {
|
|
60
|
+
payload: {
|
|
61
|
+
key: string;
|
|
62
|
+
values: Record<string, any>;
|
|
63
|
+
};
|
|
64
|
+
type: string;
|
|
65
|
+
}) => void;
|
|
46
66
|
focusStep: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload, }: PayloadAction<{
|
|
47
67
|
step: FormStep;
|
|
48
68
|
values: FieldValues;
|
|
@@ -61,5 +81,14 @@ export declare const focusStep: import("@reduxjs/toolkit").ActionCreatorWithOpti
|
|
|
61
81
|
}, "site/addStepsDependencies">, setEmptyDependency: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
62
82
|
step: GBaseStep;
|
|
63
83
|
empty: StepDependency['empty'];
|
|
64
|
-
}, "site/setEmptyDependency">, handlePrevious: import("@reduxjs/toolkit").ActionCreatorWithPayload<
|
|
84
|
+
}, "site/setEmptyDependency">, handlePrevious: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
85
|
+
values: Record<string, any>;
|
|
86
|
+
form: Form;
|
|
87
|
+
}, "site/handlePrevious">, handleNext: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
88
|
+
values: Record<string, any>;
|
|
89
|
+
form: Form;
|
|
90
|
+
}, "site/handleNext">, updateNestedValues: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
91
|
+
key: string;
|
|
92
|
+
values: Record<string, any>;
|
|
93
|
+
}, "site/updateNestedValues">;
|
|
65
94
|
export default SiteSlice;
|
package/dist/States/SiteSlice.js
CHANGED
|
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
var _a;
|
|
13
|
+
import StepTypes from '../constants/FormStepTypes';
|
|
13
14
|
import { createSlice } from '@reduxjs/toolkit';
|
|
14
15
|
import { reset } from './GlobalSlice';
|
|
15
16
|
import { calcDependencies } from '../Form/FormFunctions';
|
|
@@ -72,25 +73,41 @@ export var SiteSlice = createSlice({
|
|
|
72
73
|
calcDependencies(steps, customSteps, allSteps, state.dependencies);
|
|
73
74
|
},
|
|
74
75
|
handlePrevious: function (state, _a) {
|
|
75
|
-
var
|
|
76
|
+
var _b = _a.payload, values = _b.values, form = _b.form;
|
|
76
77
|
var previousSections = state.previousSections, nextSections = state.nextSections, idCurrentSection = state.idCurrentSection;
|
|
77
78
|
var idPreviousSection = previousSections.pop();
|
|
78
79
|
if (!idPreviousSection || !idCurrentSection)
|
|
79
80
|
return;
|
|
80
81
|
nextSections.unshift(idCurrentSection);
|
|
81
|
-
state.values.sections[idCurrentSection]
|
|
82
|
+
addPagedValues(form.steps, values, state.values.sections[idCurrentSection]);
|
|
83
|
+
state.values.sections[idCurrentSection] = values;
|
|
82
84
|
state.idCurrentSection = idPreviousSection;
|
|
83
85
|
},
|
|
84
86
|
handleNext: function (state, _a) {
|
|
85
|
-
var
|
|
87
|
+
var _b = _a.payload, values = _b.values, form = _b.form;
|
|
86
88
|
var previousSections = state.previousSections, nextSections = state.nextSections, idCurrentSection = state.idCurrentSection;
|
|
87
89
|
var idNextSection = nextSections.shift();
|
|
88
90
|
if (!idNextSection || !idCurrentSection)
|
|
89
91
|
return;
|
|
90
92
|
previousSections.push(idCurrentSection);
|
|
91
|
-
state.values.sections[idCurrentSection]
|
|
93
|
+
addPagedValues(form.steps, values, state.values.sections[idCurrentSection]);
|
|
94
|
+
state.values.sections[idCurrentSection] = values;
|
|
92
95
|
state.idCurrentSection = idNextSection;
|
|
93
96
|
},
|
|
97
|
+
updateNestedValues: function (state, _a) {
|
|
98
|
+
var _b = _a.payload, key = _b.key, values = _b.values;
|
|
99
|
+
var idCurrentSection = state.idCurrentSection;
|
|
100
|
+
if (!idCurrentSection)
|
|
101
|
+
return;
|
|
102
|
+
var sectionValues = state.values.sections[idCurrentSection];
|
|
103
|
+
for (var _i = 0, _c = Object.keys(sectionValues); _i < _c.length; _i++) {
|
|
104
|
+
var idStep = _c[_i];
|
|
105
|
+
if (idStep.startsWith(key)) {
|
|
106
|
+
delete sectionValues[idStep];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
state.values.sections[idCurrentSection] = __assign(__assign({}, sectionValues), values);
|
|
110
|
+
},
|
|
94
111
|
focusStep: function (state, _a) {
|
|
95
112
|
var payload = _a.payload;
|
|
96
113
|
var idSection = payload === null || payload === void 0 ? void 0 : payload.step.idSection;
|
|
@@ -125,5 +142,33 @@ export var SiteSlice = createSlice({
|
|
|
125
142
|
});
|
|
126
143
|
},
|
|
127
144
|
});
|
|
128
|
-
export var focusStep = (_a = SiteSlice.actions, _a.focusStep), clearDependency = _a.clearDependency, setStepDependency = _a.setStepDependency, addStepsDependencies = _a.addStepsDependencies, setEmptyDependency = _a.setEmptyDependency, handlePrevious = _a.handlePrevious, handleNext = _a.handleNext;
|
|
145
|
+
export var focusStep = (_a = SiteSlice.actions, _a.focusStep), clearDependency = _a.clearDependency, setStepDependency = _a.setStepDependency, addStepsDependencies = _a.addStepsDependencies, setEmptyDependency = _a.setEmptyDependency, handlePrevious = _a.handlePrevious, handleNext = _a.handleNext, updateNestedValues = _a.updateNestedValues;
|
|
129
146
|
export default SiteSlice;
|
|
147
|
+
function addPagedValues(steps, values, original, path) {
|
|
148
|
+
if (path === void 0) { path = ''; }
|
|
149
|
+
for (var _i = 0, _a = Object.values(steps); _i < _a.length; _i++) {
|
|
150
|
+
var step = _a[_i];
|
|
151
|
+
var idStep = (path ? path + '-' : '') + step.id;
|
|
152
|
+
if (step.type === StepTypes.MAPPER) {
|
|
153
|
+
var value = values[idStep];
|
|
154
|
+
if (value) {
|
|
155
|
+
var elements = value.elements, page = value.page;
|
|
156
|
+
for (var _b = 0, elements_1 = elements; _b < elements_1.length; _b++) {
|
|
157
|
+
var element = elements_1[_b];
|
|
158
|
+
addPagedValues(step.steps, values, original, idStep + '-' + element.id);
|
|
159
|
+
}
|
|
160
|
+
if (step.style.type === 'PAGED') {
|
|
161
|
+
var currentPageElement = elements[page];
|
|
162
|
+
for (var _c = 0, _d = Object.keys(original); _c < _d.length; _c++) {
|
|
163
|
+
var key = _d[_c];
|
|
164
|
+
if (key.startsWith(idStep + '-') &&
|
|
165
|
+
!key.startsWith(idStep + '-' + currentPageElement.id + '-') &&
|
|
166
|
+
!values[key]) {
|
|
167
|
+
values[key] = original[key];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
import { RawDraftContentState } from 'draft-js';
|
|
2
|
+
import { EurekaDraft } from '../@Types/Draft/Draft';
|
|
3
|
+
import { DependencyStore } from '../Form/Form';
|
|
4
|
+
interface FormCache {
|
|
5
|
+
dependencies: DependencyStore;
|
|
6
|
+
ticket?: {
|
|
7
|
+
caseNumber: string;
|
|
8
|
+
};
|
|
9
|
+
entityValue?: {
|
|
10
|
+
_id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
company?: {
|
|
15
|
+
_id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
entity?: Record<string, any>;
|
|
20
|
+
}
|
|
2
21
|
export declare function stringToDraft(text: string): RawDraftContentState;
|
|
3
22
|
export declare const getRawText: (draft?: RawDraftContentState, text?: string) => RawDraftContentState;
|
|
23
|
+
export declare function mapDraftEntities(cache: FormCache, draft: EurekaDraft): RawDraftContentState;
|
|
24
|
+
export {};
|