@arquimedes.co/eureka-forms 2.0.100 → 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/Form/FormFunctions.js +2 -3
- 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 +84 -58
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +1 -1
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +20 -7
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +6 -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 */
|
|
@@ -228,7 +228,6 @@ function calcStepDependency(idStep, steps, values, customSteps) {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
function calcStepDependencyValue(depStep, originalValue, customSteps) {
|
|
231
|
-
var _a;
|
|
232
231
|
var custom = customSteps[depStep === null || depStep === void 0 ? void 0 : depStep.type];
|
|
233
232
|
if (custom === null || custom === void 0 ? void 0 : custom.calcDependencyValue) {
|
|
234
233
|
return custom.calcDependencyValue(depStep, originalValue);
|
|
@@ -246,10 +245,10 @@ function calcStepDependencyValue(depStep, originalValue, customSteps) {
|
|
|
246
245
|
}
|
|
247
246
|
case FormStepTypes.MAPPER: {
|
|
248
247
|
//TODO: Esto aun no se usa
|
|
249
|
-
return
|
|
248
|
+
return {
|
|
250
249
|
elements: originalValue === null || originalValue === void 0 ? void 0 : originalValue.map(function (mapperValue) { var _a; return (_a = mapperValue.value) !== null && _a !== void 0 ? _a : mapperValue; }),
|
|
251
250
|
page: 0,
|
|
252
|
-
}
|
|
251
|
+
};
|
|
253
252
|
}
|
|
254
253
|
default:
|
|
255
254
|
return originalValue !== null && originalValue !== void 0 ? originalValue : null;
|
|
@@ -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: {
|
|
@@ -96,7 +96,7 @@ function EntityValuePickerStep(_a) {
|
|
|
96
96
|
: undefined;
|
|
97
97
|
});
|
|
98
98
|
}, []);
|
|
99
|
-
return (_jsxs(React.Fragment, { children: [dialogs !== undefined && ((_b = form.entities) === null || _b === void 0 ? void 0 : _b[step.idEntity]) && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: (_c = form.entities) === null || _c === void 0 ? void 0 : _c[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
|
|
99
|
+
return (_jsxs(React.Fragment, { children: [dialogs !== undefined && ((_b = form.entities) === null || _b === void 0 ? void 0 : _b[step.idEntity]) && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: (_c = form.entities) === null || _c === void 0 ? void 0 : _c[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionalDependencies: getOptionalDependencies, getOptionSelected: function (option, value) {
|
|
100
100
|
return option._id === value._id;
|
|
101
101
|
}, calcDepError: function (steps) {
|
|
102
102
|
for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
|
|
@@ -171,67 +171,93 @@ 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
|
+
};
|
|
245
|
+
var getOptionalDependencies = function (step) {
|
|
246
|
+
var _a;
|
|
247
|
+
var optional = [];
|
|
248
|
+
for (var _i = 0, _b = step.filters; _i < _b.length; _i++) {
|
|
249
|
+
var filter = _b[_i];
|
|
250
|
+
switch (filter.type) {
|
|
251
|
+
case EntityValueDataTypes.STEP: {
|
|
252
|
+
if (filter.idStep &&
|
|
253
|
+
!filter.required &&
|
|
254
|
+
!((_a = step.dependencies) === null || _a === void 0 ? void 0 : _a.includes(filter.idStep)))
|
|
255
|
+
optional.push(filter.idStep);
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
default:
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return optional;
|
|
263
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SmartSelectStepProps } from '../SmartSelectStep';
|
|
3
3
|
import { GSmartSelect } from '../../../@Types/GenericFormSteps';
|
|
4
|
-
declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, filterOptions, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, getOptionsConditionsIdSteps, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
|
|
4
|
+
declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, filterOptions, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, getOptionalDependencies, getOptionsConditionsIdSteps, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
|
|
5
5
|
export default SmartSelectStep;
|
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
58
|
import { useFormContext } from 'react-hook-form';
|
|
50
59
|
import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
@@ -57,8 +66,8 @@ import { selectDependencies, selectStepDependencies, useFormStep, } from '../../
|
|
|
57
66
|
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
58
67
|
function SmartSelectStep(_a) {
|
|
59
68
|
var _this = this;
|
|
60
|
-
var _b, _c, _d, _e, _f, _g
|
|
61
|
-
var icon = _a.icon, step = _a.step, editable = _a.editable, getOptions = _a.getOptions, calcDepError = _a.calcDepError, defaultValue = _a.defaultValue, filterOptions = _a.filterOptions, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, changeListener = _a.changeListener, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, _j = _a.getOptionsConditionsIdSteps, getOptionsConditionsIdSteps = _j === void 0 ? function () { return []; } : _j, renderNestedSteps = _a.renderNestedSteps;
|
|
69
|
+
var _b, _c, _d, _e, _f, _g;
|
|
70
|
+
var icon = _a.icon, step = _a.step, editable = _a.editable, getOptions = _a.getOptions, calcDepError = _a.calcDepError, defaultValue = _a.defaultValue, filterOptions = _a.filterOptions, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, changeListener = _a.changeListener, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, _h = _a.getOptionalDependencies, getOptionalDependencies = _h === void 0 ? function () { return []; } : _h, _j = _a.getOptionsConditionsIdSteps, getOptionsConditionsIdSteps = _j === void 0 ? function () { return []; } : _j, renderNestedSteps = _a.renderNestedSteps;
|
|
62
71
|
var _k = useFormStep(step, {
|
|
63
72
|
sizeChange: true,
|
|
64
73
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : null,
|
|
@@ -69,16 +78,17 @@ function SmartSelectStep(_a) {
|
|
|
69
78
|
var onChange = useCallback(function (value) {
|
|
70
79
|
return handleChange(valueOverwrite ? valueOverwrite(value) : value);
|
|
71
80
|
}, [handleChange, valueOverwrite]);
|
|
72
|
-
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;
|
|
73
82
|
var form = useContext(FormContext);
|
|
74
83
|
var _m = useState(), options = _m[0], setOptions = _m[1];
|
|
75
84
|
var _o = useState(false), loading = _o[0], setLoading = _o[1];
|
|
76
85
|
var _p = useState(true), firstTime = _p[0], setFirstTime = _p[1];
|
|
77
86
|
var _q = useState(false), touched = _q[0], setTouched = _q[1];
|
|
78
87
|
var dispatch = useAppDispatch();
|
|
88
|
+
var allDeps = useMemo(function () { var _a; return __spreadArray(__spreadArray([], ((_a = step.dependencies) !== null && _a !== void 0 ? _a : []), true), getOptionalDependencies(step), true); }, []);
|
|
79
89
|
var idDependencies = useMemo(function () { return getOptionsConditionsIdSteps(step); }, []);
|
|
80
90
|
var dependencies = useAppSelector(function (state) {
|
|
81
|
-
return selectDependencies(state,
|
|
91
|
+
return selectDependencies(state, allDeps);
|
|
82
92
|
});
|
|
83
93
|
var deps = useAppSelector(function (state) {
|
|
84
94
|
return selectDependencies(state, idDependencies);
|
|
@@ -99,7 +109,7 @@ function SmartSelectStep(_a) {
|
|
|
99
109
|
else if (value && !step.searchable) {
|
|
100
110
|
setOptions([value]);
|
|
101
111
|
}
|
|
102
|
-
}, (
|
|
112
|
+
}, (_b = allDeps.map(function (dep) { var _a; return (_a = dependencies[dep]) === null || _a === void 0 ? void 0 : _a.value; })) !== null && _b !== void 0 ? _b : []);
|
|
103
113
|
var calcOptions = function (firstTime) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
114
|
var resp, newValue, empty, error_1;
|
|
105
115
|
return __generator(this, function (_a) {
|
|
@@ -112,7 +122,10 @@ function SmartSelectStep(_a) {
|
|
|
112
122
|
_a.label = 1;
|
|
113
123
|
case 1:
|
|
114
124
|
_a.trys.push([1, 3, , 4]);
|
|
115
|
-
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
|
+
}))];
|
|
116
129
|
case 2:
|
|
117
130
|
resp = _a.sent();
|
|
118
131
|
if (value) {
|
|
@@ -202,6 +215,6 @@ function SmartSelectStep(_a) {
|
|
|
202
215
|
}
|
|
203
216
|
return undefined;
|
|
204
217
|
}, [invalids, touched, value, filteredOptions]);
|
|
205
|
-
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, onClick: onFocus, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { inputRef: ref, value: value, handleUpdate: onChange, onFocus: onFocus, disabled: filteredOptions === null || disabled, hidden: disabled, loading: loading, options: filteredOptions !== null && filteredOptions !== void 0 ? filteredOptions : undefined, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (
|
|
218
|
+
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, onClick: onFocus, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { inputRef: ref, value: value, handleUpdate: onChange, onFocus: onFocus, disabled: filteredOptions === null || disabled, hidden: disabled, loading: loading, options: filteredOptions !== null && filteredOptions !== void 0 ? filteredOptions : undefined, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_c = formStyle.stepBackgroundColor) !== null && _c !== void 0 ? _c : 'white', label: step.label, required: step.required, height: '31px', changeListener: changeListener, searchable: step.searchable, icon: step.showIcon ? icon : undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", getOptionSelected: getOptionSelected, getValueString: getValueString, helperText: (_g = (_f = (_d = errorMsg !== null && errorMsg !== void 0 ? errorMsg : warning) !== null && _d !== void 0 ? _d : (_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : step.description) !== null && _g !== void 0 ? _g : undefined, error: !!errorMsg || !!warning || !!error })) })), renderNestedSteps === null || renderNestedSteps === void 0 ? void 0 : renderNestedSteps(value)] }));
|
|
206
219
|
}
|
|
207
220
|
export default SmartSelectStep;
|
|
@@ -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 */
|
|
@@ -18,6 +21,8 @@ export interface SmartSelectStepProps<StepType extends GSmartSelect = GSmartSele
|
|
|
18
21
|
getValueString: (value: any | undefined) => string;
|
|
19
22
|
/** Function to if currently selected option has warning */
|
|
20
23
|
getValueWarning?: (value: any | undefined) => string | null;
|
|
24
|
+
/** Function called to get the idSteps of the optional dependencies */
|
|
25
|
+
getOptionalDependencies?: (step: StepType) => string[];
|
|
21
26
|
/** Function called to get the idSteps of the step's conditions for better refreshing */
|
|
22
27
|
getOptionsConditionsIdSteps?: (step: StepType) => string[];
|
|
23
28
|
/** Function that returns the error message based on the steps of the missing Dependencies, undefined if no error msg */
|
|
@@ -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