@arquimedes.co/eureka-forms 2.0.54 → 2.0.56
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 +5 -3
- 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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import ConditionTypes, { ExpressionTypes, OperatorTypes } from '../constants/ConditionTypes';
|
|
2
|
+
import EntityPropertyTypes from '../constants/EntityPropertyTypes';
|
|
2
3
|
import FormStepTypes from '../constants/FormStepTypes';
|
|
3
|
-
export type Condition = ExpressionCondition | FormStepCondition;
|
|
4
|
+
export type Condition = ExpressionCondition | FormStepCondition | EntityValueCondition;
|
|
4
5
|
export interface ExpressionCondition<Type extends Condition = Condition> {
|
|
5
6
|
type: ConditionTypes.EXPRESSION;
|
|
6
|
-
conditions: (Type | ExpressionCondition
|
|
7
|
+
conditions: (Type | ExpressionCondition)[];
|
|
7
8
|
expression: ExpressionTypes;
|
|
8
9
|
}
|
|
9
10
|
export type FormStepCondition = ExistanceFormStepCondition | CheckBoxFormStepCondition | ClassifierSelectorFormStepCondition | DatePickerFormStepCondition | EntityValuePickerFormStepCondition | RatingFormStepCondition | SelectorFormStepCondition | TextAreaFormStepCondition | TextInputFormStepCondition;
|
|
@@ -57,4 +58,55 @@ export interface TextInputFormStepCondition extends BaseFormStepCondition {
|
|
|
57
58
|
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL | OperatorTypes.INCLUDES | OperatorTypes.NOTINCLUDES;
|
|
58
59
|
value: string;
|
|
59
60
|
}
|
|
61
|
+
export type EntityValueCondition = EntityEqualsCondition | EntityPropertyCondition;
|
|
62
|
+
export type EntityPropertyCondition = EntityPropertyExistsCondition | EntitySelectorCondition | EntityTextInputCondition | EntityTextAreaCondition | EntityCheckboxCondition | EntityDateCondition | EntityRelativeDateCondition;
|
|
63
|
+
export interface EntityEqualsCondition {
|
|
64
|
+
type: ConditionTypes.ENTITYVALUE;
|
|
65
|
+
idEntity: string;
|
|
66
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
67
|
+
values: string[];
|
|
68
|
+
}
|
|
69
|
+
export interface EntityPropertyConditionBase {
|
|
70
|
+
type: ConditionTypes.ENTITYVALUE;
|
|
71
|
+
idEntity: string;
|
|
72
|
+
operator: OperatorTypes.INCLUDES | OperatorTypes.NOTINCLUDES;
|
|
73
|
+
idProperty: string;
|
|
74
|
+
}
|
|
75
|
+
export interface EntityPropertyExistsCondition extends EntityPropertyConditionBase {
|
|
76
|
+
propertyType: EntityPropertyTypes;
|
|
77
|
+
propertyOperator: OperatorTypes.EXISTS | OperatorTypes.NOTEXISTS;
|
|
78
|
+
}
|
|
79
|
+
export interface EntitySelectorCondition extends EntityPropertyConditionBase {
|
|
80
|
+
propertyType: EntityPropertyTypes.SELECTOR;
|
|
81
|
+
propertyOperator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
82
|
+
propertyValue: string;
|
|
83
|
+
}
|
|
84
|
+
export interface EntityTextInputCondition extends EntityPropertyConditionBase {
|
|
85
|
+
propertyType: EntityPropertyTypes.TEXTINPUT | EntityPropertyTypes.NAME;
|
|
86
|
+
propertyOperator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
87
|
+
propertyValue: string;
|
|
88
|
+
}
|
|
89
|
+
export interface EntityTextAreaCondition extends EntityPropertyConditionBase {
|
|
90
|
+
propertyType: EntityPropertyTypes.TEXTAREA;
|
|
91
|
+
propertyOperator: OperatorTypes.INCLUDES | OperatorTypes.NOTINCLUDES;
|
|
92
|
+
propertyValues: string[];
|
|
93
|
+
}
|
|
94
|
+
export interface EntityCheckboxCondition extends EntityPropertyConditionBase {
|
|
95
|
+
propertyType: EntityPropertyTypes.CHECKBOX;
|
|
96
|
+
propertyOperator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
97
|
+
propertyValue: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface EntityDateCondition extends EntityPropertyConditionBase {
|
|
100
|
+
propertyType: EntityPropertyTypes.DATEPICKER;
|
|
101
|
+
propertyOperator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL | OperatorTypes.LESS | OperatorTypes.MORE;
|
|
102
|
+
propertyValue: Date;
|
|
103
|
+
}
|
|
104
|
+
export interface EntityRelativeDateCondition extends EntityPropertyConditionBase {
|
|
105
|
+
propertyType: EntityPropertyTypes.DATEPICKER;
|
|
106
|
+
propertyOperator: OperatorTypes.PAST_RELATIVE_LESS | OperatorTypes.PAST_RELATIVE_MORE | OperatorTypes.FUTURE_RELATIVE_LESS | OperatorTypes.FUTURE_RELATIVE_MORE;
|
|
107
|
+
days: number;
|
|
108
|
+
hours: number;
|
|
109
|
+
minutes: number;
|
|
110
|
+
working: boolean;
|
|
111
|
+
}
|
|
60
112
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RawDraftContentState } from 'draft-js';
|
|
2
|
+
import { DraftEntityTypes } from '../../constants/Draft/DraftEntityTypes';
|
|
3
|
+
import { DraftEntityData } from './DraftEntityData';
|
|
4
|
+
export interface EurekaDraft extends Omit<RawDraftContentState, 'entityMap'> {
|
|
5
|
+
entityMap: DraftEntityMap;
|
|
6
|
+
}
|
|
7
|
+
export type DraftEntityMap = Record<string, EurekaDraftEntity>;
|
|
8
|
+
export interface EurekaDraftEntity {
|
|
9
|
+
type: DraftEntityTypes.EUREKA;
|
|
10
|
+
mutability: 'IMMUTABLE';
|
|
11
|
+
data: DraftEntityData;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { RawDraftContentBlock } from 'draft-js';
|
|
2
|
+
import { DraftEntityDataTypes, DraftEntityDataMappingTypes } from '../../constants/Draft/DraftEntityDataTypes';
|
|
3
|
+
import { DraftEntityMap } from './Draft';
|
|
4
|
+
import { Condition } from '../Condition';
|
|
5
|
+
import { TicketPropertyTypes } from '../../constants/TicketPropertyTypes';
|
|
6
|
+
export type DraftEntityData = CompanyDraftEntityData | ConditionMetDraftEntityData | DateDraftEntityData | TicketDraftEntityData | MappableDraftEntityData;
|
|
7
|
+
export interface BaseDraftEntityData {
|
|
8
|
+
type: DraftEntityDataTypes | DraftEntityDataMappingTypes;
|
|
9
|
+
prefix?: string;
|
|
10
|
+
suffix?: string;
|
|
11
|
+
fallback?: string;
|
|
12
|
+
condition?: Condition;
|
|
13
|
+
}
|
|
14
|
+
interface CompanyDraftEntityData extends BaseDraftEntityData {
|
|
15
|
+
type: DraftEntityDataTypes.COMPANY;
|
|
16
|
+
idProperty: string;
|
|
17
|
+
}
|
|
18
|
+
interface ConditionMetDraftEntityData extends BaseDraftEntityData {
|
|
19
|
+
type: DraftEntityDataTypes.CONDITION_MET;
|
|
20
|
+
condition: Condition;
|
|
21
|
+
ifTrue?: string;
|
|
22
|
+
ifFalse?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface DateDraftEntityData extends BaseDraftEntityData {
|
|
25
|
+
type: DraftEntityDataTypes.DATE;
|
|
26
|
+
days: number;
|
|
27
|
+
hours: number;
|
|
28
|
+
minutes: number;
|
|
29
|
+
working: boolean;
|
|
30
|
+
/** date-fns formats */
|
|
31
|
+
format?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface TicketDraftEntityData extends BaseDraftEntityData {
|
|
34
|
+
type: DraftEntityDataTypes.TICKET;
|
|
35
|
+
property: TicketPropertyTypes.CASENUMBER;
|
|
36
|
+
}
|
|
37
|
+
export type MappableDraftEntityData = NestedDraftEntityData | EntityValueMappingDraftEntityData;
|
|
38
|
+
export interface BaseMappableDraftEntityData extends BaseDraftEntityData {
|
|
39
|
+
block: RawDraftContentBlock;
|
|
40
|
+
entityMap: DraftEntityMap;
|
|
41
|
+
}
|
|
42
|
+
export interface NestedDraftEntityData extends BaseMappableDraftEntityData {
|
|
43
|
+
type: DraftEntityDataTypes.NESTED;
|
|
44
|
+
}
|
|
45
|
+
export interface EntityValueMappingDraftEntityData extends BaseDraftEntityData {
|
|
46
|
+
type: DraftEntityDataMappingTypes.ENTITYVALUE_MAPPING;
|
|
47
|
+
idEntity: string;
|
|
48
|
+
idProperty: string;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import EntityPropertyTypes from '../constants/EntityPropertyTypes';
|
|
2
|
+
import { FormSelector } from './FormStep';
|
|
3
|
+
import * as GSteps from './GenericFormSteps';
|
|
4
|
+
export interface Entity {
|
|
5
|
+
_id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
steps: Record<string, EntityProperty>;
|
|
8
|
+
rootSteps: string[];
|
|
9
|
+
}
|
|
10
|
+
export type EntityProperty = Name | CheckBox | TextArea | TextInput | EntitySelector | DatePicker;
|
|
11
|
+
interface BaseProperty {
|
|
12
|
+
required: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface Name extends Omit<GSteps.GTitle, 'title'>, BaseProperty {
|
|
15
|
+
type: EntityPropertyTypes.NAME;
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CheckBox extends GSteps.GCheckBox, BaseProperty {
|
|
19
|
+
type: EntityPropertyTypes.CHECKBOX;
|
|
20
|
+
}
|
|
21
|
+
export interface TextArea extends GSteps.GTextArea, BaseProperty {
|
|
22
|
+
type: EntityPropertyTypes.TEXTAREA;
|
|
23
|
+
}
|
|
24
|
+
export interface TextInput extends GSteps.GTextInput, BaseProperty {
|
|
25
|
+
type: EntityPropertyTypes.TEXTINPUT;
|
|
26
|
+
}
|
|
27
|
+
export interface DatePicker extends GSteps.GDatePicker, BaseProperty {
|
|
28
|
+
type: EntityPropertyTypes.DATEPICKER;
|
|
29
|
+
}
|
|
30
|
+
export interface EntitySelector extends Omit<FormSelector, 'type'>, BaseProperty {
|
|
31
|
+
type: EntityPropertyTypes.SELECTOR;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FormStyleTypes, FormTypes } from '../constants/FormStepTypes';
|
|
2
2
|
import { Branding } from './Branding';
|
|
3
3
|
import { FormStep } from './FormStep';
|
|
4
|
+
import { Entity } from './Entity';
|
|
5
|
+
import { EurekaDraft } from './Draft/Draft';
|
|
4
6
|
export interface Form {
|
|
5
7
|
apiKey?: string;
|
|
6
8
|
name?: string;
|
|
@@ -14,8 +16,13 @@ export interface Form {
|
|
|
14
16
|
style?: FormStyle;
|
|
15
17
|
branding?: Branding;
|
|
16
18
|
classifiers?: Record<string, Classifier>;
|
|
19
|
+
entities?: Record<string, Entity>;
|
|
17
20
|
terms?: Term[];
|
|
18
21
|
hiddenSteps?: string[];
|
|
22
|
+
confirmationMessage?: EurekaDraft;
|
|
23
|
+
showLink?: boolean;
|
|
24
|
+
nextSectionLabel?: string;
|
|
25
|
+
prevSectionLabel?: string;
|
|
19
26
|
}
|
|
20
27
|
export interface FormSize {
|
|
21
28
|
blockNum: 1 | 2 | 3 | 4;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Types, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes';
|
|
2
2
|
import { Condition } from './Condition';
|
|
3
|
+
import { EurekaDraft } from './Draft/Draft';
|
|
3
4
|
import * as GSteps from './GenericFormSteps';
|
|
4
5
|
export type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper;
|
|
5
6
|
export interface Title extends GSteps.GBaseStep {
|
|
@@ -107,8 +108,14 @@ export interface EntityValuePicker extends GSteps.GSmartSelect {
|
|
|
107
108
|
path: EntityValuePickerPath[];
|
|
108
109
|
options: Record<string, FormEntityValuePickerOption>;
|
|
109
110
|
maxSize?: number;
|
|
111
|
+
dialogs?: EntityValuePickerDialog[];
|
|
110
112
|
}
|
|
111
113
|
export type FormEntityValuePickerOption = DefaultEntityValuePickerOption | NestedEntityValuePickerOption | HideFormEntityValuePickerOption;
|
|
114
|
+
export interface EntityValuePickerDialog {
|
|
115
|
+
type: 'WARNING' | 'INFO';
|
|
116
|
+
message: EurekaDraft;
|
|
117
|
+
condition?: Condition;
|
|
118
|
+
}
|
|
112
119
|
interface DefaultEntityValuePickerOption {
|
|
113
120
|
type: EntityValueOptionTypes.DEFAULT;
|
|
114
121
|
idEntityValue: string;
|
package/dist/App/App.css
CHANGED
|
@@ -5,7 +5,7 @@ import { CustomStep } from '../FormSteps/CustomStep';
|
|
|
5
5
|
import { MapperElement } from '../@Types/MapperElement';
|
|
6
6
|
import { Condition } from '../@Types/Condition';
|
|
7
7
|
export declare const calcValuesStore: (idOrganization: string, form: Readonly<Form>, originalValues?: Record<string, any>, postview?: boolean, customSteps?: Record<string, CustomStep>) => Promise<ValuesStore>;
|
|
8
|
-
export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep
|
|
8
|
+
export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep>, path?: string) => {
|
|
9
9
|
element: MapperElement<Type>;
|
|
10
10
|
/** Record of all the new mapper values created */
|
|
11
11
|
mappers: Record<string, MapperElement<Type>[]>;
|
|
@@ -14,5 +14,5 @@ export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<str
|
|
|
14
14
|
};
|
|
15
15
|
export declare function calcRecursiveData<Type>(element: Readonly<MapperElement<Type>>, newSteps: Record<string, FormStep>, customSteps: Record<string, CustomStep>): void;
|
|
16
16
|
export declare const calcRecursiveCondition: (condition: Condition, ids: Record<string, string>) => void;
|
|
17
|
-
export declare const mapOriginalValue: (idOrganization: string, step: FormStep, value: any, values: ValuesStore, form?: Readonly<Form
|
|
17
|
+
export declare const mapOriginalValue: (idOrganization: string, step: FormStep, value: any, values: ValuesStore, form?: Readonly<Form>, path?: string) => Promise<any>;
|
|
18
18
|
export declare const calcInitialSections: (form: Form) => Pick<SiteState, 'previousSections' | 'idCurrentSection' | 'nextSections'>;
|
package/dist/App/AppFunctions.js
CHANGED
|
@@ -82,14 +82,19 @@ export var calcValuesStore = function (idOrganization, form, originalValues, pos
|
|
|
82
82
|
switch (_b.label) {
|
|
83
83
|
case 0:
|
|
84
84
|
step = form.steps[idValue];
|
|
85
|
-
if (!
|
|
85
|
+
if (!step) return [3 /*break*/, 2];
|
|
86
86
|
return [4 /*yield*/, mapOriginalValue(idOrganization, step, originalValues[step.id], values, form)];
|
|
87
87
|
case 1:
|
|
88
88
|
value = _b.sent();
|
|
89
89
|
if (value !== undefined) {
|
|
90
|
-
if (!
|
|
91
|
-
values.sections[step.idSection]
|
|
92
|
-
|
|
90
|
+
if (!((_a = form.hiddenSteps) === null || _a === void 0 ? void 0 : _a.includes(step.id))) {
|
|
91
|
+
if (!values.sections[step.idSection])
|
|
92
|
+
values.sections[step.idSection] = {};
|
|
93
|
+
values.sections[step.idSection][step.id] = value;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
values.global[idValue] = value;
|
|
97
|
+
}
|
|
93
98
|
}
|
|
94
99
|
return [3 /*break*/, 3];
|
|
95
100
|
case 2:
|
|
@@ -122,7 +127,8 @@ export var calcValuesStore = function (idOrganization, form, originalValues, pos
|
|
|
122
127
|
});
|
|
123
128
|
});
|
|
124
129
|
};
|
|
125
|
-
export var addMapperStep = function (step, customSteps) {
|
|
130
|
+
export var addMapperStep = function (step, customSteps, path) {
|
|
131
|
+
if (path === void 0) { path = ''; }
|
|
126
132
|
var idElement = nanoid();
|
|
127
133
|
var element = {
|
|
128
134
|
ids: {},
|
|
@@ -132,10 +138,11 @@ export var addMapperStep = function (step, customSteps) {
|
|
|
132
138
|
};
|
|
133
139
|
var steps = {};
|
|
134
140
|
var mappers = {};
|
|
141
|
+
var base = path ? path + '-' : '';
|
|
135
142
|
for (var _i = 0, _a = Object.keys(step.steps); _i < _a.length; _i++) {
|
|
136
143
|
var idStep = _a[_i];
|
|
137
144
|
var baseStep = JSON.parse(JSON.stringify(step.steps[idStep]));
|
|
138
|
-
var newIdStep = step.id + '-' +
|
|
145
|
+
var newIdStep = base + step.id + '-' + idElement + '-' + idStep;
|
|
139
146
|
baseStep.id = newIdStep;
|
|
140
147
|
element.ids[idStep] = newIdStep;
|
|
141
148
|
steps[newIdStep] = baseStep;
|
|
@@ -144,7 +151,7 @@ export var addMapperStep = function (step, customSteps) {
|
|
|
144
151
|
for (var _b = 0, _c = Object.values(step.steps); _b < _c.length; _b++) {
|
|
145
152
|
var nestedStep = _c[_b];
|
|
146
153
|
if (nestedStep.type === StepTypes.MAPPER) {
|
|
147
|
-
var nested = addMapperStep(nestedStep, customSteps);
|
|
154
|
+
var nested = addMapperStep(nestedStep, customSteps, base + step.id + '-' + idElement);
|
|
148
155
|
steps = __assign(__assign({}, steps), nested.steps);
|
|
149
156
|
mappers = __assign(__assign({}, mappers), nested.mappers);
|
|
150
157
|
mappers[element.ids[nestedStep.id]] = [nested.element];
|
|
@@ -196,165 +203,169 @@ export var calcRecursiveCondition = function (condition, ids) {
|
|
|
196
203
|
break;
|
|
197
204
|
}
|
|
198
205
|
};
|
|
199
|
-
export var mapOriginalValue = function (idOrganization, step, value, values, form
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
id:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
var newIdStep, value;
|
|
236
|
-
return __generator(this, function (_a) {
|
|
237
|
-
switch (_a.label) {
|
|
238
|
-
case 0:
|
|
239
|
-
newIdStep = step.id + '-' + idStep + '-' + idElement;
|
|
240
|
-
mappedElement.ids[idStep] = newIdStep;
|
|
241
|
-
return [4 /*yield*/, mapOriginalValue(idOrganization, step.steps[idStep], element[idStep], values, form)];
|
|
242
|
-
case 1:
|
|
243
|
-
value = _a.sent();
|
|
244
|
-
if (value !== undefined) {
|
|
245
|
-
if (!values.sections[step.idSection])
|
|
246
|
-
values.sections[step.idSection] = {};
|
|
247
|
-
values.sections[step.idSection][newIdStep] = value;
|
|
248
|
-
}
|
|
249
|
-
return [2 /*return*/];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}); }))];
|
|
253
|
-
case 1:
|
|
254
|
-
_r.sent();
|
|
255
|
-
for (_l = 0, _m = Object.values(step.steps); _l < _m.length; _l++) {
|
|
256
|
-
subStep = _m[_l];
|
|
257
|
-
dependencies = (_c = subStep.dependencies) !== null && _c !== void 0 ? _c : [];
|
|
258
|
-
if (subStep.condition) {
|
|
259
|
-
dependencies = __spreadArray(__spreadArray([], dependencies, true), calcNestedConditionSteps(subStep.condition), true).filter(function (item, i, ar) { return ar.indexOf(item) === i; });
|
|
206
|
+
export var mapOriginalValue = function (idOrganization, step, value, values, form, path) {
|
|
207
|
+
if (path === void 0) { path = ''; }
|
|
208
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
209
|
+
var _a, elements, mappedElements, _loop_1, _i, elements_1, element, defaultValue, option, stepClassifier, classifier, params, url, entityValues, entityValue;
|
|
210
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
211
|
+
return __generator(this, function (_k) {
|
|
212
|
+
switch (_k.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
if (!value)
|
|
215
|
+
return [2 /*return*/, value];
|
|
216
|
+
_a = step === null || step === void 0 ? void 0 : step.type;
|
|
217
|
+
switch (_a) {
|
|
218
|
+
case StepTypes.MAPPER: return [3 /*break*/, 1];
|
|
219
|
+
case StepTypes.TEXTAREA: return [3 /*break*/, 6];
|
|
220
|
+
case StepTypes.SELECTOR: return [3 /*break*/, 7];
|
|
221
|
+
case StepTypes.CLASSIFIER_SELECTOR: return [3 /*break*/, 8];
|
|
222
|
+
case StepTypes.ENTITYVALUEPICKER: return [3 /*break*/, 9];
|
|
223
|
+
}
|
|
224
|
+
return [3 /*break*/, 12];
|
|
225
|
+
case 1:
|
|
226
|
+
elements = value;
|
|
227
|
+
mappedElements = [];
|
|
228
|
+
_loop_1 = function (element) {
|
|
229
|
+
var idElement, mappedElement, base, _l, _m, subStep, dependencies, _o, dependencies_1, idDep, mappedIdDep, _p, _q, key;
|
|
230
|
+
return __generator(this, function (_r) {
|
|
231
|
+
switch (_r.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
idElement = (_b = element.id) !== null && _b !== void 0 ? _b : nanoid();
|
|
234
|
+
mappedElement = {
|
|
235
|
+
id: idElement,
|
|
236
|
+
ids: {},
|
|
237
|
+
originalValues: {},
|
|
238
|
+
isOriginal: true,
|
|
239
|
+
};
|
|
240
|
+
if (element.value) {
|
|
241
|
+
mappedElement.value = element.value;
|
|
260
242
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
243
|
+
base = path ? path + '-' : '';
|
|
244
|
+
return [4 /*yield*/, Promise.all(Object.keys(step.steps).map(function (idStep) { return __awaiter(void 0, void 0, void 0, function () {
|
|
245
|
+
var newIdStep, value;
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
switch (_a.label) {
|
|
248
|
+
case 0:
|
|
249
|
+
newIdStep = base + step.id + '-' + idElement + '-' + idStep;
|
|
250
|
+
mappedElement.ids[idStep] = newIdStep;
|
|
251
|
+
return [4 /*yield*/, mapOriginalValue(idOrganization, step.steps[idStep], element[idStep], values, form, base + step.id + '-' + idElement)];
|
|
252
|
+
case 1:
|
|
253
|
+
value = _a.sent();
|
|
254
|
+
if (value !== undefined) {
|
|
255
|
+
if (!values.sections[step.idSection])
|
|
256
|
+
values.sections[step.idSection] = {};
|
|
257
|
+
values.sections[step.idSection][newIdStep] = value;
|
|
258
|
+
}
|
|
259
|
+
return [2 /*return*/];
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}); }))];
|
|
263
|
+
case 1:
|
|
264
|
+
_r.sent();
|
|
265
|
+
for (_l = 0, _m = Object.values(step.steps); _l < _m.length; _l++) {
|
|
266
|
+
subStep = _m[_l];
|
|
267
|
+
dependencies = (_c = subStep.dependencies) !== null && _c !== void 0 ? _c : [];
|
|
268
|
+
if (subStep.condition) {
|
|
269
|
+
dependencies = __spreadArray(__spreadArray([], dependencies, true), calcNestedConditionSteps(subStep.condition), true).filter(function (item, i, ar) { return ar.indexOf(item) === i; });
|
|
270
|
+
}
|
|
271
|
+
for (_o = 0, dependencies_1 = dependencies; _o < dependencies_1.length; _o++) {
|
|
272
|
+
idDep = dependencies_1[_o];
|
|
273
|
+
mappedIdDep = base + step.id + '-' + idElement + '-' + idDep;
|
|
274
|
+
if (!values.sections[step.idSection][idDep] &&
|
|
275
|
+
!values.global[mappedIdDep] &&
|
|
276
|
+
element[idDep]) {
|
|
277
|
+
values.global[mappedIdDep] = element[idDep];
|
|
278
|
+
mappedElement.ids[idDep] = mappedIdDep;
|
|
279
|
+
}
|
|
269
280
|
}
|
|
270
281
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
282
|
+
for (_p = 0, _q = Object.keys(element); _p < _q.length; _p++) {
|
|
283
|
+
key = _q[_p];
|
|
284
|
+
if (step.steps[key] || key === 'id')
|
|
285
|
+
continue;
|
|
286
|
+
mappedElement.originalValues[key] = element[key];
|
|
287
|
+
}
|
|
288
|
+
mappedElements.push(mappedElement);
|
|
289
|
+
return [2 /*return*/];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
_i = 0, elements_1 = elements;
|
|
294
|
+
_k.label = 2;
|
|
295
|
+
case 2:
|
|
296
|
+
if (!(_i < elements_1.length)) return [3 /*break*/, 5];
|
|
297
|
+
element = elements_1[_i];
|
|
298
|
+
return [5 /*yield**/, _loop_1(element)];
|
|
299
|
+
case 3:
|
|
300
|
+
_k.sent();
|
|
301
|
+
_k.label = 4;
|
|
302
|
+
case 4:
|
|
303
|
+
_i++;
|
|
304
|
+
return [3 /*break*/, 2];
|
|
305
|
+
case 5: return [2 /*return*/, { elements: mappedElements, page: 0 }];
|
|
306
|
+
case 6:
|
|
307
|
+
{
|
|
308
|
+
if (step.hasTextEditor) {
|
|
309
|
+
if (typeof value === 'string') {
|
|
310
|
+
return [2 /*return*/, stringToDraft(value)];
|
|
311
|
+
}
|
|
312
|
+
return [2 /*return*/, getRawText(value === null || value === void 0 ? void 0 : value.draft, value === null || value === void 0 ? void 0 : value.text)];
|
|
313
|
+
}
|
|
314
|
+
defaultValue = (_d = value.value) !== null && _d !== void 0 ? _d : value;
|
|
315
|
+
if (typeof defaultValue === 'string') {
|
|
316
|
+
return [2 /*return*/, defaultValue];
|
|
280
317
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
_i = 0, elements_1 = elements;
|
|
284
|
-
_k.label = 2;
|
|
285
|
-
case 2:
|
|
286
|
-
if (!(_i < elements_1.length)) return [3 /*break*/, 5];
|
|
287
|
-
element = elements_1[_i];
|
|
288
|
-
return [5 /*yield**/, _loop_1(element)];
|
|
289
|
-
case 3:
|
|
290
|
-
_k.sent();
|
|
291
|
-
_k.label = 4;
|
|
292
|
-
case 4:
|
|
293
|
-
_i++;
|
|
294
|
-
return [3 /*break*/, 2];
|
|
295
|
-
case 5: return [2 /*return*/, mappedElements];
|
|
296
|
-
case 6:
|
|
297
|
-
{
|
|
298
|
-
if (step.hasTextEditor) {
|
|
299
|
-
if (typeof value === 'string') {
|
|
300
|
-
return [2 /*return*/, stringToDraft(value)];
|
|
318
|
+
else {
|
|
319
|
+
return [2 /*return*/, (_e = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text) !== null && _e !== void 0 ? _e : ''];
|
|
301
320
|
}
|
|
302
|
-
return [2 /*return*/, getRawText(value === null || value === void 0 ? void 0 : value.draft, value === null || value === void 0 ? void 0 : value.text)];
|
|
303
321
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
322
|
+
_k.label = 7;
|
|
323
|
+
case 7:
|
|
324
|
+
{
|
|
325
|
+
option = step.options.find(function (option) { return option.value === value; });
|
|
326
|
+
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
327
|
+
return [2 /*return*/, option];
|
|
328
|
+
return [2 /*return*/, value];
|
|
307
329
|
}
|
|
308
|
-
|
|
309
|
-
|
|
330
|
+
_k.label = 8;
|
|
331
|
+
case 8:
|
|
332
|
+
{
|
|
333
|
+
stepClassifier = (_f = form === null || form === void 0 ? void 0 : form.classifiers) === null || _f === void 0 ? void 0 : _f[(_g = step.idClassifier) !== null && _g !== void 0 ? _g : ''];
|
|
334
|
+
if (stepClassifier && !value.value) {
|
|
335
|
+
classifier = (_h = form.classifiers) === null || _h === void 0 ? void 0 : _h[value];
|
|
336
|
+
return [2 /*return*/, { value: value, label: classifier === null || classifier === void 0 ? void 0 : classifier.name }];
|
|
337
|
+
}
|
|
338
|
+
return [3 /*break*/, 13];
|
|
310
339
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
classifier = (_h = form.classifiers) === null || _h === void 0 ? void 0 : _h[value];
|
|
326
|
-
return [2 /*return*/, { value: value, label: classifier === null || classifier === void 0 ? void 0 : classifier.name }];
|
|
340
|
+
_k.label = 9;
|
|
341
|
+
case 9:
|
|
342
|
+
if (!!value._id) return [3 /*break*/, 11];
|
|
343
|
+
params = new URLSearchParams(value);
|
|
344
|
+
url = "".concat(idOrganization, "/entities/").concat(step.idEntity, "?").concat(params.toString());
|
|
345
|
+
return [4 /*yield*/, widgetInstance.get(url)];
|
|
346
|
+
case 10:
|
|
347
|
+
entityValues = (_k.sent()).data;
|
|
348
|
+
if (entityValues.length === 1) {
|
|
349
|
+
entityValue = entityValues[0];
|
|
350
|
+
if (((_j = step.options[entityValue._id]) === null || _j === void 0 ? void 0 : _j.type) ===
|
|
351
|
+
EntityValueOptionTypes.HIDE)
|
|
352
|
+
return [2 /*return*/, undefined];
|
|
353
|
+
return [2 /*return*/, entityValues[0]];
|
|
327
354
|
}
|
|
328
|
-
return [
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (((_j = step.options[entityValue._id]) === null || _j === void 0 ? void 0 : _j.type) ===
|
|
341
|
-
EntityValueOptionTypes.HIDE)
|
|
342
|
-
return [2 /*return*/, undefined];
|
|
343
|
-
return [2 /*return*/, entityValues[0]];
|
|
344
|
-
}
|
|
345
|
-
return [2 /*return*/, null];
|
|
346
|
-
case 11: return [2 /*return*/, value];
|
|
347
|
-
case 12:
|
|
348
|
-
if (step.type.startsWith('CBR_') &&
|
|
349
|
-
(value === null || value === void 0 ? void 0 : value.id) &&
|
|
350
|
-
typeof value.id === 'number') {
|
|
351
|
-
return [2 /*return*/, __assign(__assign({}, value), { id: value.id.toString() })];
|
|
352
|
-
}
|
|
353
|
-
return [2 /*return*/, value];
|
|
354
|
-
case 13: return [2 /*return*/];
|
|
355
|
-
}
|
|
355
|
+
return [2 /*return*/, null];
|
|
356
|
+
case 11: return [2 /*return*/, value];
|
|
357
|
+
case 12:
|
|
358
|
+
if (step.type.startsWith('CBR_') &&
|
|
359
|
+
(value === null || value === void 0 ? void 0 : value.id) &&
|
|
360
|
+
typeof value.id === 'number') {
|
|
361
|
+
return [2 /*return*/, __assign(__assign({}, value), { id: value.id.toString() })];
|
|
362
|
+
}
|
|
363
|
+
return [2 /*return*/, value];
|
|
364
|
+
case 13: return [2 /*return*/];
|
|
365
|
+
}
|
|
366
|
+
});
|
|
356
367
|
});
|
|
357
|
-
}
|
|
368
|
+
};
|
|
358
369
|
function calcNestedConditionSteps(condition) {
|
|
359
370
|
var steps = [];
|
|
360
371
|
if (!condition)
|