@arquimedes.co/eureka-forms 2.0.101 → 2.0.103
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/FormStep.d.ts +7 -3
- package/dist/App/App.css +11 -0
- package/dist/App/App.d.ts +2 -0
- package/dist/App/AppHooks.js +0 -17
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +33 -30
- package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +26 -23
- package/dist/FormSteps/AYFStepMapper.js +45 -42
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +57 -54
- package/dist/FormSteps/CBRStepMapper.js +80 -65
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +64 -57
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +5 -2
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +4 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +13 -6
- package/dist/States/GlobalSlice.d.ts +2 -0
- package/dist/constants/FormStepTypes.d.ts +2 -1
- package/dist/constants/FormStepTypes.js +1 -0
- package/package.json +1 -1
|
@@ -7,8 +7,8 @@ import { Time } from './Time';
|
|
|
7
7
|
export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper;
|
|
8
8
|
export interface Title extends GSteps.GBaseStep {
|
|
9
9
|
type: FormStepTypes.TITLE;
|
|
10
|
-
title
|
|
11
|
-
description
|
|
10
|
+
title?: EurekaDraft;
|
|
11
|
+
description?: EurekaDraft;
|
|
12
12
|
size?: 1 | 2 | 3 | 4;
|
|
13
13
|
}
|
|
14
14
|
export interface TimePicker extends GSteps.GTimePicker {
|
|
@@ -146,7 +146,7 @@ export interface ValueEntityValuePickerPath {
|
|
|
146
146
|
type: EntityValueDataTypes.VALUE;
|
|
147
147
|
idEntityValue: string | null;
|
|
148
148
|
}
|
|
149
|
-
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter;
|
|
149
|
+
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter;
|
|
150
150
|
export interface StepEntityValuePickerFilter {
|
|
151
151
|
idProperty: string;
|
|
152
152
|
type: EntityValueDataTypes.STEP;
|
|
@@ -159,6 +159,10 @@ export interface ValueEntityValuePickerFilter {
|
|
|
159
159
|
type: EntityValueDataTypes.VALUE;
|
|
160
160
|
value: any;
|
|
161
161
|
}
|
|
162
|
+
export interface CurrentAgentEntityValuePickerFilter {
|
|
163
|
+
idProperty: string;
|
|
164
|
+
type: EntityValueDataTypes.CURRENT_AGENT;
|
|
165
|
+
}
|
|
162
166
|
export interface ApiSelector extends GSteps.GSmartSelect {
|
|
163
167
|
type: FormStepTypes.API_SELECTOR;
|
|
164
168
|
icon?: IconTypes;
|
package/dist/App/App.css
CHANGED
package/dist/App/App.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { CountryCode } from 'libphonenumber-js';
|
|
|
7
7
|
export interface AppProps {
|
|
8
8
|
/** If the app is currently a widget */
|
|
9
9
|
isWidget?: boolean;
|
|
10
|
+
/** The id of the current agent using the form (Internal)*/
|
|
11
|
+
idCurrentAgent?: string;
|
|
10
12
|
/** The apikey of the Form */
|
|
11
13
|
apiKey?: string;
|
|
12
14
|
/** The id of the form's organization */
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -68,8 +68,6 @@ import { calcDependencies } from '../Form/FormFunctions';
|
|
|
68
68
|
import { iterateNestedSteps } from '../FormSteps/StepFunctions';
|
|
69
69
|
import { createNextState } from '@reduxjs/toolkit';
|
|
70
70
|
import { BaseConfirmationMessage } from '../Contexts/FormContext';
|
|
71
|
-
import FormStepTypes from '../constants/FormStepTypes';
|
|
72
|
-
import { draftToString } from '../Utils/DraftFunctions';
|
|
73
71
|
export var useSetupApp = function (isEmbedded, _a) {
|
|
74
72
|
var _b;
|
|
75
73
|
var preview = _a.preview, internal = _a.internal, postview = _a.postview, partial = _a.partial, editable = _a.editable, handleConfirmed = _a.handleConfirmed, customSteps = _a.customSteps, valuesData = _a.valuesData, apiKey = _a.apiKey, formData = _a.formData, classifiers = _a.classifiers, others = __rest(_a, ["preview", "internal", "postview", "partial", "editable", "handleConfirmed", "customSteps", "valuesData", "apiKey", "formData", "classifiers"]);
|
|
@@ -158,22 +156,7 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
158
156
|
for (var _b = 0, _c = section.steps; _b < _c.length; _b++) {
|
|
159
157
|
var idStep = _c[_b];
|
|
160
158
|
iterateNestedSteps(idStep, form.steps, function (step) {
|
|
161
|
-
var _a, _b, _c;
|
|
162
159
|
step.idSection = section.id;
|
|
163
|
-
if (step.type === FormStepTypes.TITLE) {
|
|
164
|
-
if ((_a = step.title) === null || _a === void 0 ? void 0 : _a.blocks) {
|
|
165
|
-
if ((_b = step.title) === null || _b === void 0 ? void 0 : _b.blocks)
|
|
166
|
-
step.title = draftToString({
|
|
167
|
-
form: form,
|
|
168
|
-
dependencies: {},
|
|
169
|
-
}, step.title);
|
|
170
|
-
if ((_c = step.description) === null || _c === void 0 ? void 0 : _c.blocks)
|
|
171
|
-
step.description = draftToString({
|
|
172
|
-
form: form,
|
|
173
|
-
dependencies: {},
|
|
174
|
-
}, step.description);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
160
|
});
|
|
178
161
|
}
|
|
179
162
|
};
|
|
@@ -91,37 +91,40 @@ function ElementSubStepRenderer(_a) {
|
|
|
91
91
|
return option.id === value.id;
|
|
92
92
|
}, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value.id; }, renderNestedSteps: function (value) { return (_jsx(ElementSubStepRenderer, __assign({ value: value }, stepProps, { step: subStep }))); } })));
|
|
93
93
|
}
|
|
94
|
-
var getElementOptions = function (
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
94
|
+
var getElementOptions = function (step, dependencyStore, _a) {
|
|
95
|
+
var idOrganization = _a.idOrganization;
|
|
96
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
+
var idProyecto, response, father_1;
|
|
98
|
+
var _b, _c, _d;
|
|
99
|
+
return __generator(this, function (_e) {
|
|
100
|
+
switch (_e.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
|
|
103
|
+
idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
|
|
104
|
+
if (!idProyecto) {
|
|
105
|
+
return [2 /*return*/, null]; //null para indicar que falta la depedency
|
|
106
|
+
}
|
|
107
|
+
return [4 /*yield*/, axios.get("https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/Locativas?idOrganization=").concat(idOrganization))];
|
|
108
|
+
case 1:
|
|
109
|
+
response = (_e.sent()).data;
|
|
110
|
+
father_1 = (_d = dependencyStore[step.dependencies[1]]) === null || _d === void 0 ? void 0 : _d.value;
|
|
111
|
+
if (father_1 && father_1.id === undefined) {
|
|
112
|
+
return [2 /*return*/, null];
|
|
113
|
+
}
|
|
114
|
+
return [2 /*return*/, response.filter(function (locativa) {
|
|
115
|
+
if (father_1 === null || father_1 === void 0 ? void 0 : father_1.id) {
|
|
116
|
+
return (locativa.id.startsWith(father_1.id) &&
|
|
117
|
+
locativa.id !== father_1.id);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return locativa.id.length === 2;
|
|
121
|
+
}
|
|
122
|
+
})];
|
|
123
|
+
case 2: return [2 /*return*/, null];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
123
126
|
});
|
|
124
|
-
}
|
|
127
|
+
};
|
|
125
128
|
var calcDepError = function (steps) {
|
|
126
129
|
for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
|
|
127
130
|
var step = steps_1[_i];
|
|
@@ -62,30 +62,33 @@ function CBRPropertyStepComponent(props) {
|
|
|
62
62
|
var _this = this;
|
|
63
63
|
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
64
64
|
var _a = useState(undefined), showWarning = _a[0], setShowWarning = _a[1];
|
|
65
|
-
var getInmueblesOptions = function (
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
var getInmueblesOptions = function (step, dependencyStore, _a) {
|
|
66
|
+
var idOrganization = _a.idOrganization;
|
|
67
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
68
|
+
var idProyecto, idMacroProyecto;
|
|
69
|
+
var _b, _c, _d, _e;
|
|
70
|
+
return __generator(this, function (_f) {
|
|
71
|
+
switch (_f.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
|
|
74
|
+
idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
|
|
75
|
+
idMacroProyecto = (_e = (_d = dependencyStore[step.dependencies[0]]) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.idMacroProyecto;
|
|
76
|
+
if (!idProyecto) {
|
|
77
|
+
return [2 /*return*/, null]; //null para indicar que falta la depedency
|
|
78
|
+
}
|
|
79
|
+
return [4 /*yield*/, axios.get(baseUrl +
|
|
80
|
+
'Inmuebles?idMacro=' +
|
|
81
|
+
idMacroProyecto +
|
|
82
|
+
'&idProyecto=' +
|
|
83
|
+
idProyecto +
|
|
84
|
+
'&idOrganization=' +
|
|
85
|
+
idOrganization)];
|
|
86
|
+
case 1: return [2 /*return*/, (_f.sent()).data];
|
|
87
|
+
case 2: return [2 /*return*/, null];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
87
90
|
});
|
|
88
|
-
}
|
|
91
|
+
};
|
|
89
92
|
return (_jsxs(React.Fragment, { children: [_jsx(SmartSelectStep, __assign({}, props, { icon: _jsx(InputIcon, { icon: 'PROPERTY' }), getOptionSelected: function (option, value) {
|
|
90
93
|
return option.id === value.id;
|
|
91
94
|
}, calcDepError: function (steps) {
|
|
@@ -75,51 +75,54 @@ function AYFStepMapper(props) {
|
|
|
75
75
|
]];
|
|
76
76
|
});
|
|
77
77
|
}); };
|
|
78
|
-
var getCiudadesOptions = function (
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
78
|
+
var getCiudadesOptions = function (step, dependencyStore, _a) {
|
|
79
|
+
var idOrganization = _a.idOrganization;
|
|
80
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
81
|
+
var nit, params, _i, _b, dep, value, error_1;
|
|
82
|
+
var _c, _d, _e, _f;
|
|
83
|
+
return __generator(this, function (_g) {
|
|
84
|
+
switch (_g.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
if (!idOrganization)
|
|
87
|
+
return [2 /*return*/, null];
|
|
88
|
+
nit = (_c = dependencyStore[step.idNitStep]) === null || _c === void 0 ? void 0 : _c.value;
|
|
89
|
+
params = new URLSearchParams({
|
|
90
|
+
idOrganization: idOrganization,
|
|
91
|
+
idCompany: nit,
|
|
92
|
+
nit: 'true',
|
|
93
|
+
});
|
|
94
|
+
for (_i = 0, _b = (_d = step.dependencies) !== null && _d !== void 0 ? _d : []; _i < _b.length; _i++) {
|
|
95
|
+
dep = _b[_i];
|
|
96
|
+
value = (_e = dependencyStore[dep]) === null || _e === void 0 ? void 0 : _e.value;
|
|
97
|
+
if (value && dep.startsWith('AYF')) {
|
|
98
|
+
switch ((_f = dep.split('-')) === null || _f === void 0 ? void 0 : _f[0]) {
|
|
99
|
+
case AYFFormStepTypes.AYF_START_MONTH:
|
|
100
|
+
params.set('startMonth', value.id);
|
|
101
|
+
break;
|
|
102
|
+
case AYFFormStepTypes.AYF_END_MONTH:
|
|
103
|
+
params.set('endMonth', value.id);
|
|
104
|
+
break;
|
|
105
|
+
case AYFFormStepTypes.AYF_YEAR:
|
|
106
|
+
params.set('year', value);
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return [2 /*return
|
|
119
|
-
|
|
120
|
-
}
|
|
113
|
+
_g.label = 1;
|
|
114
|
+
case 1:
|
|
115
|
+
_g.trys.push([1, 3, , 4]);
|
|
116
|
+
return [4 /*yield*/, axios.get(baseUrl + 'CiudadesICA?' + params.toString())];
|
|
117
|
+
case 2: return [2 /*return*/, (_g.sent()).data];
|
|
118
|
+
case 3:
|
|
119
|
+
error_1 = _g.sent();
|
|
120
|
+
return [2 /*return*/, null];
|
|
121
|
+
case 4: return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
121
124
|
});
|
|
122
|
-
}
|
|
125
|
+
};
|
|
123
126
|
switch (props.step.type) {
|
|
124
127
|
case AYFFormStepTypes.AYF_START_MONTH:
|
|
125
128
|
case AYFFormStepTypes.AYF_END_MONTH:
|
|
@@ -90,65 +90,68 @@ function ApiSelectorComponent(_a) {
|
|
|
90
90
|
return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
|
|
91
91
|
}
|
|
92
92
|
var getApiOptions = useMemo(function () {
|
|
93
|
-
return function (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
return function (step, dependencyStore, _a) {
|
|
94
|
+
var idOrganization = _a.idOrganization;
|
|
95
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
+
function calcOptionId(option) {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
|
|
99
|
+
}
|
|
100
|
+
var params, _i, _b, filter, currentValue, filterStep, url, response;
|
|
101
|
+
var _c, _d;
|
|
102
|
+
return __generator(this, function (_e) {
|
|
103
|
+
switch (_e.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
params = new URLSearchParams({});
|
|
106
|
+
for (_i = 0, _b = step.queryParams; _i < _b.length; _i++) {
|
|
107
|
+
filter = _b[_i];
|
|
108
|
+
switch (filter.type) {
|
|
109
|
+
case ApiSelectorParamTypes.STEP: {
|
|
110
|
+
currentValue = (_c = dependencyStore[filter.idStep]) === null || _c === void 0 ? void 0 : _c.value;
|
|
111
|
+
filterStep = form.steps[filter.idStep];
|
|
112
|
+
if (currentValue) {
|
|
113
|
+
if (filterStep.type ===
|
|
114
|
+
FormStepTypes.API_SELECTOR) {
|
|
115
|
+
params.set(filter.key, currentValue[step.idAttribute]);
|
|
116
|
+
}
|
|
117
|
+
else if (typeof currentValue === 'string')
|
|
118
|
+
params.set(filter.key, currentValue);
|
|
119
|
+
else
|
|
120
|
+
params.set(filter.key, (_d = currentValue.label) !== null && _d !== void 0 ? _d : currentValue.id);
|
|
114
121
|
}
|
|
115
|
-
else if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
else if (filter.required) {
|
|
121
|
-
return [2 /*return*/, null];
|
|
122
|
+
else if (filter.required) {
|
|
123
|
+
return [2 /*return*/, null];
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
122
126
|
}
|
|
123
|
-
|
|
127
|
+
case ApiSelectorParamTypes.VALUE:
|
|
128
|
+
default:
|
|
129
|
+
params.set(filter.key, filter.value);
|
|
130
|
+
break;
|
|
124
131
|
}
|
|
125
|
-
case ApiSelectorParamTypes.VALUE:
|
|
126
|
-
default:
|
|
127
|
-
params.set(filter.key, filter.value);
|
|
128
|
-
break;
|
|
129
132
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
url +=
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
133
|
+
url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
|
|
134
|
+
if (idOrganization &&
|
|
135
|
+
url.includes(process.env.REACT_APP_DOMAIN))
|
|
136
|
+
params.set('idOrganization', idOrganization);
|
|
137
|
+
if (!step.url.includes('?'))
|
|
138
|
+
url += '?';
|
|
139
|
+
url += params.toString();
|
|
140
|
+
return [4 /*yield*/, (idOrganization
|
|
141
|
+
? widgetInstance.get(url)
|
|
142
|
+
: axiosInstance.get(url))];
|
|
143
|
+
case 1:
|
|
144
|
+
response = _e.sent();
|
|
145
|
+
return [2 /*return*/, response.data.filter(function (option) {
|
|
146
|
+
var _a;
|
|
147
|
+
return calcOptionId(option) &&
|
|
148
|
+
((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
|
|
149
|
+
ApiSelectorOptionTypes.HIDE;
|
|
150
|
+
})];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
150
153
|
});
|
|
151
|
-
}
|
|
154
|
+
};
|
|
152
155
|
}, [form]);
|
|
153
156
|
return (_jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, __assign({}, others, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
|
|
154
157
|
return calcOptionId(option) === calcOptionId(value);
|
|
@@ -59,76 +59,91 @@ import InputIcon from '../Shared/InputIcon/InputIcon';
|
|
|
59
59
|
var baseUrl = "https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/");
|
|
60
60
|
function CBRStepMapper(props) {
|
|
61
61
|
var _this = this;
|
|
62
|
-
var getTipoDocOptions = function (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
var getTipoDocOptions = function (_step, _dependencies, _a) {
|
|
63
|
+
var idOrganization = _a.idOrganization;
|
|
64
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
65
|
+
return __generator(this, function (_b) {
|
|
66
|
+
switch (_b.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
if (!idOrganization)
|
|
69
|
+
return [2 /*return*/, null];
|
|
70
|
+
return [4 /*yield*/, axios.get(baseUrl + 'TiposDoc?idOrganization=' + idOrganization)];
|
|
71
|
+
case 1: return [2 /*return*/, (_b.sent()).data];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
71
74
|
});
|
|
72
|
-
}
|
|
73
|
-
var getProyectoOptions = function (
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
proyectos =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
};
|
|
76
|
+
var getProyectoOptions = function (step, dependencyStore, _a) {
|
|
77
|
+
var idOrganization = _a.idOrganization;
|
|
78
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
79
|
+
var idMacroProyecto, proyectos;
|
|
80
|
+
var _b, _c, _d, _e;
|
|
81
|
+
return __generator(this, function (_f) {
|
|
82
|
+
switch (_f.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!idOrganization)
|
|
85
|
+
return [2 /*return*/, null];
|
|
86
|
+
idMacroProyecto = (_e = (_d = dependencyStore[(_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '']) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.id;
|
|
87
|
+
return [4 /*yield*/, axios.get(baseUrl + 'Proyectos?idOrganization=' + idOrganization)];
|
|
88
|
+
case 1:
|
|
89
|
+
proyectos = (_f.sent()).data;
|
|
90
|
+
if (idMacroProyecto) {
|
|
91
|
+
proyectos = proyectos.filter(function (proyecto) { return proyecto.idMacroProyecto === idMacroProyecto; });
|
|
92
|
+
}
|
|
93
|
+
return [2 /*return*/, proyectos];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
90
96
|
});
|
|
91
|
-
}
|
|
92
|
-
var getMacroProyectoOptions = function (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
};
|
|
98
|
+
var getMacroProyectoOptions = function (_step, _dependencies, _a) {
|
|
99
|
+
var idOrganization = _a.idOrganization;
|
|
100
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
101
|
+
return __generator(this, function (_b) {
|
|
102
|
+
switch (_b.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
if (!idOrganization)
|
|
105
|
+
return [2 /*return*/, null];
|
|
106
|
+
return [4 /*yield*/, axios.get(baseUrl + 'MacroProyectos?idOrganization=' + idOrganization)];
|
|
107
|
+
case 1: return [2 /*return*/, (_b.sent()).data];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
101
110
|
});
|
|
102
|
-
}
|
|
103
|
-
var getTipoSolicitanteOptions = function (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
};
|
|
112
|
+
var getTipoSolicitanteOptions = function (_step, _dependencies, _a) {
|
|
113
|
+
var idOrganization = _a.idOrganization;
|
|
114
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_b) {
|
|
116
|
+
switch (_b.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
if (!idOrganization)
|
|
119
|
+
return [2 /*return*/, null];
|
|
120
|
+
return [4 /*yield*/, axios.get(baseUrl + 'TiposSolicitante?idOrganization=' + idOrganization)];
|
|
121
|
+
case 1: return [2 /*return*/, (_b.sent()).data];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
112
124
|
});
|
|
113
|
-
}
|
|
114
|
-
var getTipoEspaciosOptions = function (
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
};
|
|
126
|
+
var getTipoEspaciosOptions = function (step, dependencyStore, _a) {
|
|
127
|
+
var idOrganization = _a.idOrganization;
|
|
128
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
129
|
+
var idProyecto, params;
|
|
130
|
+
var _b, _c;
|
|
131
|
+
return __generator(this, function (_d) {
|
|
132
|
+
switch (_d.label) {
|
|
133
|
+
case 0:
|
|
134
|
+
if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
|
|
135
|
+
idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
|
|
136
|
+
if (!idProyecto) {
|
|
137
|
+
return [2 /*return*/, null]; //null para indicar que falta la depedency
|
|
138
|
+
}
|
|
139
|
+
params = new URLSearchParams({ idProyecto: idProyecto, idOrganization: idOrganization });
|
|
140
|
+
return [4 /*yield*/, axios.get(baseUrl + 'TiposEspacio?' + params.toString())];
|
|
141
|
+
case 1: return [2 /*return*/, (_d.sent()).data];
|
|
142
|
+
case 2: return [2 /*return*/, null];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
130
145
|
});
|
|
131
|
-
}
|
|
146
|
+
};
|
|
132
147
|
switch (props.step.type) {
|
|
133
148
|
case CBRFormStepTypes.CBR_EMAIL:
|
|
134
149
|
return (_jsx(TextInputStep, __assign({}, props, { step: props.step, validation: {
|
|
@@ -171,70 +171,77 @@ function EntityValuePickerStep(_a) {
|
|
|
171
171
|
} }) }))] }));
|
|
172
172
|
}
|
|
173
173
|
export default EntityValuePickerStep;
|
|
174
|
-
var getEntityValueOptions = function (
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else
|
|
194
|
-
idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
case EntityValueDataTypes.VALUE:
|
|
198
|
-
default:
|
|
199
|
-
idEntityValue = (_f = path.idEntityValue) !== null && _f !== void 0 ? _f : 'null';
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
urlPath +=
|
|
203
|
-
'/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
|
|
204
|
-
}
|
|
205
|
-
params = new URLSearchParams({});
|
|
206
|
-
for (_b = 0, _c = step.filters; _b < _c.length; _b++) {
|
|
207
|
-
filter = _c[_b];
|
|
208
|
-
switch (filter.type) {
|
|
209
|
-
case EntityValueDataTypes.STEP: {
|
|
210
|
-
currentValue = (_g = dependencyStore[filter.idStep]) === null || _g === void 0 ? void 0 : _g.value;
|
|
211
|
-
if (currentValue) {
|
|
174
|
+
var getEntityValueOptions = function (step, dependencyStore, _a) {
|
|
175
|
+
var idOrganization = _a.idOrganization, idCurrentAgent = _a.idCurrentAgent;
|
|
176
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
177
|
+
var urlPath, _i, _b, path, idEntityValue, currentValue, params, _c, _d, filter, currentValue, url, response;
|
|
178
|
+
var _e, _f, _g, _h, _j;
|
|
179
|
+
return __generator(this, function (_k) {
|
|
180
|
+
switch (_k.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
if (!idOrganization)
|
|
183
|
+
return [2 /*return*/, null];
|
|
184
|
+
urlPath = '';
|
|
185
|
+
for (_i = 0, _b = step.path; _i < _b.length; _i++) {
|
|
186
|
+
path = _b[_i];
|
|
187
|
+
idEntityValue = 'null';
|
|
188
|
+
switch (path.type) {
|
|
189
|
+
case EntityValueDataTypes.STEP: {
|
|
190
|
+
currentValue = (_e = dependencyStore[path.idStep]) === null || _e === void 0 ? void 0 : _e.value;
|
|
191
|
+
if (!currentValue)
|
|
192
|
+
return [2 /*return*/, null];
|
|
212
193
|
if (typeof currentValue === 'string')
|
|
213
|
-
|
|
194
|
+
idEntityValue = currentValue;
|
|
214
195
|
else
|
|
215
|
-
|
|
196
|
+
idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
|
|
197
|
+
break;
|
|
216
198
|
}
|
|
217
|
-
|
|
218
|
-
|
|
199
|
+
case EntityValueDataTypes.VALUE:
|
|
200
|
+
default:
|
|
201
|
+
idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
urlPath +=
|
|
205
|
+
'/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
|
|
206
|
+
}
|
|
207
|
+
params = new URLSearchParams({});
|
|
208
|
+
for (_c = 0, _d = step.filters; _c < _d.length; _c++) {
|
|
209
|
+
filter = _d[_c];
|
|
210
|
+
switch (filter.type) {
|
|
211
|
+
case EntityValueDataTypes.STEP: {
|
|
212
|
+
currentValue = (_h = dependencyStore[filter.idStep]) === null || _h === void 0 ? void 0 : _h.value;
|
|
213
|
+
if (currentValue) {
|
|
214
|
+
if (typeof currentValue === 'string')
|
|
215
|
+
params.set(filter.idProperty, currentValue);
|
|
216
|
+
else
|
|
217
|
+
params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
|
|
218
|
+
}
|
|
219
|
+
else if (filter.required) {
|
|
220
|
+
return [2 /*return*/, null];
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
219
223
|
}
|
|
220
|
-
|
|
224
|
+
case EntityValueDataTypes.CURRENT_AGENT:
|
|
225
|
+
if (idCurrentAgent)
|
|
226
|
+
params.set(filter.idProperty, idCurrentAgent);
|
|
227
|
+
break;
|
|
228
|
+
case EntityValueDataTypes.VALUE:
|
|
229
|
+
default:
|
|
230
|
+
params.set(filter.idProperty, filter.value);
|
|
231
|
+
break;
|
|
221
232
|
}
|
|
222
|
-
case EntityValueDataTypes.VALUE:
|
|
223
|
-
default:
|
|
224
|
-
params.set(filter.idProperty, filter.value);
|
|
225
|
-
break;
|
|
226
233
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
234
|
+
url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
|
|
235
|
+
return [4 /*yield*/, widgetInstance.get(url, {
|
|
236
|
+
timeout: 120000,
|
|
237
|
+
})];
|
|
238
|
+
case 1:
|
|
239
|
+
response = _k.sent();
|
|
240
|
+
return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
236
243
|
});
|
|
237
|
-
}
|
|
244
|
+
};
|
|
238
245
|
var getOptionalDependencies = function (step) {
|
|
239
246
|
var _a;
|
|
240
247
|
var optional = [];
|
|
@@ -78,7 +78,7 @@ function SmartSelectStep(_a) {
|
|
|
78
78
|
var onChange = useCallback(function (value) {
|
|
79
79
|
return handleChange(valueOverwrite ? valueOverwrite(value) : value);
|
|
80
80
|
}, [handleChange, valueOverwrite]);
|
|
81
|
-
var _l = useAppSelector(function (state) { return state.global; }), postview = _l.postview, formStyle = _l.formStyle, idOrganization = _l.idOrganization;
|
|
81
|
+
var _l = useAppSelector(function (state) { return state.global; }), postview = _l.postview, formStyle = _l.formStyle, idOrganization = _l.idOrganization, idCurrentAgent = _l.idCurrentAgent;
|
|
82
82
|
var form = useContext(FormContext);
|
|
83
83
|
var _m = useState(), options = _m[0], setOptions = _m[1];
|
|
84
84
|
var _o = useState(false), loading = _o[0], setLoading = _o[1];
|
|
@@ -122,7 +122,10 @@ function SmartSelectStep(_a) {
|
|
|
122
122
|
_a.label = 1;
|
|
123
123
|
case 1:
|
|
124
124
|
_a.trys.push([1, 3, , 4]);
|
|
125
|
-
return [4 /*yield*/, (getOptions === null || getOptions === void 0 ? void 0 : getOptions(
|
|
125
|
+
return [4 /*yield*/, (getOptions === null || getOptions === void 0 ? void 0 : getOptions(step, dependencies, {
|
|
126
|
+
idOrganization: idOrganization,
|
|
127
|
+
idCurrentAgent: postview ? undefined : idCurrentAgent,
|
|
128
|
+
}))];
|
|
126
129
|
case 2:
|
|
127
130
|
resp = _a.sent();
|
|
128
131
|
if (value) {
|
|
@@ -9,7 +9,10 @@ export interface SmartSelectStepProps<StepType extends GSmartSelect = GSmartSele
|
|
|
9
9
|
/** The icon to display */
|
|
10
10
|
icon?: React.ReactNode;
|
|
11
11
|
/** Function to call to get the options of the selector, return null if dependency is not met */
|
|
12
|
-
getOptions: (
|
|
12
|
+
getOptions: (step: StepType, dependencyStore: DependencyStore, options: {
|
|
13
|
+
idOrganization?: string;
|
|
14
|
+
idCurrentAgent?: string;
|
|
15
|
+
}) => Promise<any[] | null>;
|
|
13
16
|
/** Function to call to filter the options of the selector */
|
|
14
17
|
filterOptions?: (options: any[], dependencyStore: DependencyStore) => any[];
|
|
15
18
|
/** Function to determine the currently selected option */
|
|
@@ -16,30 +16,37 @@ import { useAppSelector } from '../../../hooks';
|
|
|
16
16
|
import FormContext from '../../../Contexts/FormContext';
|
|
17
17
|
import { useContext } from 'react';
|
|
18
18
|
import { useFormStep } from '../../StepHooks';
|
|
19
|
+
import { convertFromRaw, EditorState } from 'draft-js';
|
|
20
|
+
import { stringToDraft } from '../../../Utils/DraftFunctions';
|
|
21
|
+
import { Editor } from 'react-draft-wysiwyg';
|
|
19
22
|
function TitleStep(_a) {
|
|
20
23
|
var _b, _c, _d;
|
|
21
24
|
var step = _a.step;
|
|
22
25
|
var value = useFormStep(step, {
|
|
23
26
|
defaultValue: undefined,
|
|
24
27
|
}).value;
|
|
25
|
-
var title = (_b = value === null || value === void 0 ? void 0 : value.title) !== null && _b !== void 0 ? _b : step.title;
|
|
26
|
-
var description = (_c = value === null || value === void 0 ? void 0 : value.description) !== null && _c !== void 0 ? _c : step.description;
|
|
27
28
|
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
28
29
|
var form = useContext(FormContext);
|
|
29
30
|
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
30
|
-
var size = (
|
|
31
|
+
var size = (_b = step.size) !== null && _b !== void 0 ? _b : form.size.blockNum;
|
|
32
|
+
var title = convertFromRaw((value === null || value === void 0 ? void 0 : value.title)
|
|
33
|
+
? stringToDraft(value.title)
|
|
34
|
+
: (_c = step.title) !== null && _c !== void 0 ? _c : stringToDraft(''));
|
|
35
|
+
var description = convertFromRaw((value === null || value === void 0 ? void 0 : value.description)
|
|
36
|
+
? stringToDraft(value.description)
|
|
37
|
+
: (_d = step.description) !== null && _d !== void 0 ? _d : stringToDraft(''));
|
|
31
38
|
return (_jsxs("div", __assign({ className: styles.container, style: {
|
|
32
39
|
color: formStyle.textColor,
|
|
33
40
|
width: widthStats.currentBreakPoint <= size
|
|
34
41
|
? '100%'
|
|
35
42
|
: calcStepWidth(size, form.size),
|
|
36
|
-
} }, { children: [title && (_jsx("div", __assign({ className: styles.titleLbl, style: {
|
|
43
|
+
} }, { children: [title.getPlainText().length > 0 && (_jsx("div", __assign({ className: styles.titleLbl, style: {
|
|
37
44
|
textAlign: widthStats.isMobile &&
|
|
38
45
|
widthStats.currentBreakPoint <= size
|
|
39
46
|
? 'center'
|
|
40
47
|
: 'start',
|
|
41
|
-
} }, { children: title }))), description && (_jsx("
|
|
48
|
+
} }, { children: _jsx(Editor, { editorClassName: 'Erk-Forms-Draft', editorState: EditorState.createWithContent(title), readOnly: true, toolbarHidden: true }) }))), description.getPlainText().length > 0 && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
|
|
42
49
|
margin: title ? '10px 0px' : '0px 0px 5px 0px',
|
|
43
|
-
} }, { children: description })))] })));
|
|
50
|
+
} }, { children: _jsx(Editor, { editorClassName: 'Erk-Forms-Draft', editorState: EditorState.createWithContent(description), readOnly: true, toolbarHidden: true }) })))] })));
|
|
44
51
|
}
|
|
45
52
|
export default TitleStep;
|
|
@@ -5,6 +5,7 @@ import { EurekaDraft } from '../@Types/Draft/Draft';
|
|
|
5
5
|
import { CountryCode } from 'libphonenumber-js';
|
|
6
6
|
export interface GlobalState {
|
|
7
7
|
idOrganization: string;
|
|
8
|
+
idCurrentAgent?: string;
|
|
8
9
|
countryCode: CountryCode;
|
|
9
10
|
formStyle: FormStyle;
|
|
10
11
|
confirmation: {
|
|
@@ -28,6 +29,7 @@ export declare const GlobalSlice: import("@reduxjs/toolkit").Slice<GlobalState,
|
|
|
28
29
|
formStyle: FormStyle;
|
|
29
30
|
preview: boolean;
|
|
30
31
|
idOrganization: string;
|
|
32
|
+
idCurrentAgent?: string | undefined;
|
|
31
33
|
countryCode: CountryCode;
|
|
32
34
|
confirmation: {
|
|
33
35
|
confirmationMessage: EurekaDraft;
|
|
@@ -67,6 +67,7 @@ export var EntityValueDataTypes;
|
|
|
67
67
|
(function (EntityValueDataTypes) {
|
|
68
68
|
EntityValueDataTypes["STEP"] = "STEP";
|
|
69
69
|
EntityValueDataTypes["VALUE"] = "VALUE";
|
|
70
|
+
EntityValueDataTypes["CURRENT_AGENT"] = "CURRENT_AGENT";
|
|
70
71
|
})(EntityValueDataTypes || (EntityValueDataTypes = {}));
|
|
71
72
|
export var ApiSelectorParamTypes;
|
|
72
73
|
(function (ApiSelectorParamTypes) {
|
package/package.json
CHANGED