@legalplace/wizardx-core 2.4.0 → 2.5.1

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/CHANGELOG.md CHANGED
@@ -3,12 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.5.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.5.0...@legalplace/wizardx-core@2.5.1) (2021-12-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * review api[#4354](https://git.legalplace.eu/legalplace/monorepo/issues/4354) ([2a109bc](https://git.legalplace.eu/legalplace/monorepo/commits/2a109bca57aa1f63b30eb4b207ebb581af8ca376))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.5.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.4.0...@legalplace/wizardx-core@2.5.0) (2021-12-06)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * fix push api[#3338](https://git.legalplace.eu/legalplace/monorepo/issues/3338) ([1c961d5](https://git.legalplace.eu/legalplace/monorepo/commits/1c961d5a459513f791c2afb363881aa3d9214add))
23
+ * fixing issue with smartscript not getting executed after init_inputs api[#3338](https://git.legalplace.eu/legalplace/monorepo/issues/3338) ([2c96fd6](https://git.legalplace.eu/legalplace/monorepo/commits/2c96fd63a6d2e7685e75ee9125a4759831548139))
24
+
25
+
26
+ ### Features
27
+
28
+ * Adding possibility to clone instance and improving UX on kanoon softSocial modal api[#3338](https://git.legalplace.eu/legalplace/monorepo/issues/3338) ([cec91b7](https://git.legalplace.eu/legalplace/monorepo/commits/cec91b79a512de1699e75fbb0e1bf95359f43376))
29
+
30
+
31
+
32
+
33
+
6
34
  # [2.4.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.3.0...@legalplace/wizardx-core@2.4.0) (2021-12-03)
7
35
 
8
36
 
9
37
  ### Bug Fixes
10
38
 
11
39
  * disabling tests tmp api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([79c3050](https://git.legalplace.eu/legalplace/monorepo/commits/79c30506ba070b50a0f9a7ab48b84a4822200437))
40
+ * fix merge ([ce4fb47](https://git.legalplace.eu/legalplace/monorepo/commits/ce4fb47dd42c56e27ee427725893d0c2acb826f7))
12
41
  * fixing test api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([53ff5be](https://git.legalplace.eu/legalplace/monorepo/commits/53ff5be76e31c5cc5476b0c5a1ce43cab5e36656))
13
42
  * loading third parties api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([fb69116](https://git.legalplace.eu/legalplace/monorepo/commits/fb69116f896cf4055eed75ecba1e1fa19f9a01ed))
14
43
  * setting eval to sync to avoid potential bugs until further refactoring api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([99c7e7c](https://git.legalplace.eu/legalplace/monorepo/commits/99c7e7c0fb3f06e2ead8c4d418991292fd692dc1))
@@ -23,7 +52,58 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
23
52
 
24
53
 
25
54
 
26
- # [2.3.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.2.0...@legalplace/wizardx-core@2.3.0) (2021-11-10)
55
+ # [2.1.0-alpha.9](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.8...@legalplace/wizardx-core@2.1.0-alpha.9) (2021-11-28)
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * fix linting api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([e8d76f5](https://git.legalplace.eu/legalplace/monorepo/commits/e8d76f5333b2940dbb170099a77d19a37c503cba))
61
+
62
+
63
+ ### Features
64
+
65
+ * load speed optimizations api[#4480](https://git.legalplace.eu/legalplace/monorepo/issues/4480) ([5227752](https://git.legalplace.eu/legalplace/monorepo/commits/522775255c71f98d4a4052fbcd05c5ae956925a2))
66
+
67
+
68
+
69
+
70
+
71
+ # [2.1.0-alpha.8](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.7...@legalplace/wizardx-core@2.1.0-alpha.8) (2021-11-24)
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * fixing issue with smartscript not getting executed after init_inputs api[#3338](https://git.legalplace.eu/legalplace/monorepo/issues/3338) ([2c96fd6](https://git.legalplace.eu/legalplace/monorepo/commits/2c96fd63a6d2e7685e75ee9125a4759831548139))
77
+
78
+
79
+
80
+
81
+
82
+ # [2.1.0-alpha.7](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.6...@legalplace/wizardx-core@2.1.0-alpha.7) (2021-11-24)
83
+
84
+ **Note:** Version bump only for package @legalplace/wizardx-core
85
+
86
+
87
+
88
+
89
+
90
+ # [2.1.0-alpha.6](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.5...@legalplace/wizardx-core@2.1.0-alpha.6) (2021-11-23)
91
+
92
+
93
+ ### Bug Fixes
94
+
95
+ * fix push api[#3338](https://git.legalplace.eu/legalplace/monorepo/issues/3338) ([1c961d5](https://git.legalplace.eu/legalplace/monorepo/commits/1c961d5a459513f791c2afb363881aa3d9214add))
96
+
97
+
98
+ ### Features
99
+
100
+ * Adding possibility to clone instance and improving UX on kanoon softSocial modal api[#3338](https://git.legalplace.eu/legalplace/monorepo/issues/3338) ([cec91b7](https://git.legalplace.eu/legalplace/monorepo/commits/cec91b79a512de1699e75fbb0e1bf95359f43376))
101
+
102
+
103
+
104
+
105
+
106
+ # [2.1.0-alpha.5](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.4...@legalplace/wizardx-core@2.1.0-alpha.5) (2021-11-15)
27
107
 
28
108
 
29
109
  ### Features
@@ -34,7 +114,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
34
114
 
35
115
 
36
116
 
37
- # [2.2.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0...@legalplace/wizardx-core@2.2.0) (2021-11-10)
117
+ # [2.1.0-alpha.4](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.3...@legalplace/wizardx-core@2.1.0-alpha.4) (2021-11-08)
118
+
119
+ **Note:** Version bump only for package @legalplace/wizardx-core
120
+
121
+
122
+
123
+
124
+
125
+ # [2.1.0-alpha.3](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.2...@legalplace/wizardx-core@2.1.0-alpha.3) (2021-11-04)
38
126
 
39
127
 
40
128
  ### Bug Fixes
@@ -44,6 +132,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
44
132
  * fix type errors api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([c14a871](https://git.legalplace.eu/legalplace/monorepo/commits/c14a8717b53d023f89d09b329d2dff062b4890f0))
45
133
 
46
134
 
135
+
136
+
137
+
138
+ # [2.1.0-alpha.2](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0...@legalplace/wizardx-core@2.1.0-alpha.2) (2021-11-04)
139
+
140
+
47
141
  ### Features
48
142
 
49
143
  * upgrading wizardx-app to support wizard-params throught props and fixing notFoundUrl api[#4377](https://git.legalplace.eu/legalplace/monorepo/issues/4377) ([72709a3](https://git.legalplace.eu/legalplace/monorepo/commits/72709a374e5037ed5eb743679159459e3b7d5483))
@@ -52,7 +146,18 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
52
146
 
53
147
 
54
148
 
55
- # [2.1.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.0.0...@legalplace/wizardx-core@2.1.0) (2021-11-04)
149
+ # [2.1.0-alpha.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.0...@legalplace/wizardx-core@2.1.0-alpha.1) (2021-11-03)
150
+
151
+
152
+ ### Features
153
+
154
+ * supporting theme preloading for wizardx-core & preloading theme on kanoon-app api[#4363](https://git.legalplace.eu/legalplace/monorepo/issues/4363) ([01f258e](https://git.legalplace.eu/legalplace/monorepo/commits/01f258e4e2266ae6a8978fa4035289b50e0366bc))
155
+
156
+
157
+
158
+
159
+
160
+ # [2.1.0-alpha.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.0.0...@legalplace/wizardx-core@2.1.0-alpha.0) (2021-11-03)
56
161
 
57
162
 
58
163
  ### Bug Fixes
@@ -65,14 +170,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
65
170
  ### Features
66
171
 
67
172
  * poc intégration wizardx kanoon-app api[#4363](https://git.legalplace.eu/legalplace/monorepo/issues/4363) ([13f5637](https://git.legalplace.eu/legalplace/monorepo/commits/13f563752d48a94575a77fcf9924cb6569547bd6))
68
- * supporting theme preloading for wizardx-core & preloading theme on kanoon-app api[#4363](https://git.legalplace.eu/legalplace/monorepo/issues/4363) ([01f258e](https://git.legalplace.eu/legalplace/monorepo/commits/01f258e4e2266ae6a8978fa4035289b50e0366bc))
69
173
  * testing merge prepare script api[#4375](https://git.legalplace.eu/legalplace/monorepo/issues/4375) ([936f4e9](https://git.legalplace.eu/legalplace/monorepo/commits/936f4e9cfaaa6c346c87f4f4de5f5b651f02cd41))
70
174
 
71
175
 
72
176
 
73
177
 
74
178
 
75
- ## [1.1.2](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@1.1.1...@legalplace/wizardx-core@1.1.2) (2021-10-29)
179
+ # [1.1.0-alpha.2](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@1.1.0-alpha.1...@legalplace/wizardx-core@1.1.0-alpha.2) (2021-10-29)
76
180
 
77
181
 
78
182
  ### Bug Fixes
@@ -83,7 +187,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
83
187
 
84
188
 
85
189
 
86
- ## [1.1.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@1.1.0...@legalplace/wizardx-core@1.1.1) (2021-10-29)
190
+ # [1.1.0-alpha.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@1.1.0...@legalplace/wizardx-core@1.1.0-alpha.1) (2021-10-29)
87
191
 
88
192
 
89
193
  ### Bug Fixes
@@ -94,7 +198,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
94
198
 
95
199
 
96
200
 
97
- # [1.1.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@1.0.1...@legalplace/wizardx-core@1.1.0) (2021-10-28)
201
+ # [1.1.0-alpha.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@1.0.1-alpha.0...@legalplace/wizardx-core@1.1.0-alpha.0) (2021-10-27)
98
202
 
99
203
 
100
204
  ### Bug Fixes
@@ -111,7 +215,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
111
215
 
112
216
 
113
217
 
114
- ## [1.0.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@0.0.1...@legalplace/wizardx-core@1.0.1) (2021-10-27)
218
+ ## [1.0.1-alpha.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@0.0.1...@legalplace/wizardx-core@1.0.1-alpha.0) (2021-10-27)
115
219
 
116
220
 
117
221
  ### Bug Fixes
@@ -1,4 +1,6 @@
1
+ import { StateType } from "../../types/State.type";
1
2
  import { ActionsType } from "../../types/Actions.type";
3
+ export declare const initInputsAction: (inputs: StateType.Inputs, references?: StateType.References | undefined) => ActionsType.Inputs.initInputs;
2
4
  export declare const initOptionAction: (id: number, values: boolean[]) => ActionsType.Inputs.initOption;
3
5
  export declare const updateOptionAction: (id: number, value: boolean, index: number) => ActionsType.Inputs.updateOptionInput;
4
6
  export declare const initVariableAction: (id: number, values: (string | number)[]) => ActionsType.Inputs.initVariable;
@@ -1,4 +1,9 @@
1
- import { INIT_OPTION, INIT_VARIABLE, UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, } from "../constants/inputs";
1
+ import { INIT_INPUTS, INIT_OPTION, INIT_VARIABLE, UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, } from "../constants/inputs";
2
+ export const initInputsAction = (inputs, references) => ({
3
+ type: INIT_INPUTS,
4
+ inputs,
5
+ references,
6
+ });
2
7
  export const initOptionAction = (id, values) => ({
3
8
  type: INIT_OPTION,
4
9
  id,
@@ -31,6 +31,7 @@ export declare const actionsLibrary: {
31
31
  setMandatorySectionAction: (id: number, value: boolean) => import("../../types/Actions.type").ActionsType.Mandatories.setMandatorySection;
32
32
  setMandatoryOptionAction: (id: number, index: number, value: boolean) => import("../../types/Actions.type").ActionsType.Mandatories.setMandatoryOption;
33
33
  setMandatoryVariableAction: (id: number, index: number, value: boolean) => import("../../types/Actions.type").ActionsType.Mandatories.setMandatoryVariable;
34
+ initInputsAction: (inputs: import("../../types/State.type").StateType.Inputs, references?: import("../../types/State.type").StateType.References | undefined) => import("../../types/Actions.type").ActionsType.Inputs.initInputs;
34
35
  initOptionAction: (id: number, values: boolean[]) => import("../../types/Actions.type").ActionsType.Inputs.initOption;
35
36
  updateOptionAction: (id: number, value: boolean, index: number) => import("../../types/Actions.type").ActionsType.Inputs.updateOptionInput;
36
37
  initVariableAction: (id: number, values: (string | number)[]) => import("../../types/Actions.type").ActionsType.Inputs.initVariable;
@@ -4,3 +4,4 @@ export declare const INIT_OPTION = "INIT_OPTION";
4
4
  export declare const UPDATE_OPTION_INPUT = "UPDATE_OPTION_INPUT";
5
5
  export declare const INIT_VARIABLE = "INIT_VARIABLE";
6
6
  export declare const UPDATE_VARIABLE_INPUT = "UPDATE_VARIABLE_INPUT";
7
+ export declare const INIT_INPUTS = "INIT_INPUTS";
@@ -4,3 +4,4 @@ export const INIT_OPTION = "INIT_OPTION";
4
4
  export const UPDATE_OPTION_INPUT = "UPDATE_OPTION_INPUT";
5
5
  export const INIT_VARIABLE = "INIT_VARIABLE";
6
6
  export const UPDATE_VARIABLE_INPUT = "UPDATE_VARIABLE_INPUT";
7
+ export const INIT_INPUTS = "INIT_INPUTS";
@@ -1,10 +1,11 @@
1
1
  import cloneDeep from "lodash/cloneDeep";
2
2
  import { generatePath } from "react-router-dom";
3
3
  import { getConfig } from "../../config";
4
- import { ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, } from "../constants/inputs";
4
+ import { INIT_INPUTS, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, } from "../constants/inputs";
5
5
  import { ENABLE_SMARTSCRIPT } from "../constants/smartscript";
6
6
  import { PathReader } from "../../libs/PathReader";
7
7
  import { initSmartscriptTriggersAction } from "../actions/smartscript";
8
+ import { updateOptionAction, updateVariableAction } from "../actions/inputs";
8
9
  let iframe = null;
9
10
  const watchEnableSmartScript = (mpi, next, action) => {
10
11
  next(action);
@@ -77,12 +78,29 @@ const watchUpdateVariableInput = (mpi, next, action) => {
77
78
  }
78
79
  }
79
80
  };
81
+ const watchInitInputs = (mpi, next, action) => {
82
+ next(action);
83
+ if (!iframe)
84
+ return;
85
+ const { inputs } = action;
86
+ Object.keys(inputs.options).forEach((id) => {
87
+ inputs.options[id].forEach((value, index) => {
88
+ watchUpdateOptionInput(mpi, next, updateOptionAction(parseInt(id, 10), value, index));
89
+ });
90
+ });
91
+ Object.keys(inputs.variables).forEach((id) => {
92
+ inputs.variables[id].forEach((value, index) => {
93
+ watchUpdateVariableInput(mpi, next, updateVariableAction(parseInt(id, 10), value, index));
94
+ });
95
+ });
96
+ };
80
97
  const watchersEnum = {
81
98
  [ENABLE_SMARTSCRIPT]: watchEnableSmartScript,
82
99
  [UPDATE_OPTION_INPUT]: watchUpdateOptionInput,
83
100
  [UPDATE_VARIABLE_INPUT]: watchUpdateVariableInput,
84
101
  [ADD_MULTIPLE_OCCURENCY]: watchUpdateOptionInput,
85
102
  [DELETE_MULTIPLE_OCCURENCY]: watchUpdateOptionInput,
103
+ [INIT_INPUTS]: watchInitInputs,
86
104
  };
87
105
  const smartscriptMiddleware = (mpi) => (next) => (action) => {
88
106
  if (Object.prototype.hasOwnProperty.call(watchersEnum, action.type)) {
@@ -1,12 +1,10 @@
1
1
  import { call, put, takeLatest, select, fork, join } from "redux-saga/effects";
2
2
  import Cookies from "universal-cookie";
3
+ import { initInputsAction } from "../actions/inputs";
3
4
  import { initMetaAction, initPaginationAction, initInstanceAction, fetchModelSucceededAction, fetchModelFailedAction, initCustomizationMetaAction, fetchModelUnhealthyAction, initCustomizationAutoDefaultAction, fetchModelUserLockedAction, updateAvailableAppStatesAction, goPageAction, fetchModelNonBlockingAction, setModelUuidAction, } from "../actions/app";
4
- import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
5
5
  import { initReferencesAction } from "../actions/references";
6
- import { initOptionAction, initVariableAction } from "../actions/inputs";
7
- import { initConditionsAction } from "../actions/conditions";
8
6
  import { selectSectionConditionValue } from "../selectors/conditions";
9
- import { selectAllSectionsReferences, selectOptionRelations, } from "../selectors/references";
7
+ import { selectAllSectionsReferences } from "../selectors/references";
10
8
  import { selectInstanceUniqid, isStepAvailable } from "../selectors/app";
11
9
  import { getConfig, updateConfig } from "../../config";
12
10
  import { isLevelAccessibleForUser } from "../selectors/user";
@@ -18,13 +16,11 @@ import Globals from "../../Globals";
18
16
  import { getFetchModelArguments, getCreateInstanceArguments, getClientConfigArguments, getWizardConfigArguments, getModelInformationArguments, } from "../../service/api.manager";
19
17
  import { loadTheme, setWizardTheme } from "../../ThemeLoader";
20
18
  import { loadPlugins } from "../../PluginLoader";
21
- import { selectMandatoryOptionItem, selectMandatoryOption, } from "../selectors/mandatories";
22
- import { initMandatoryOptionAction, initMandatoryVariableAction, } from "../actions/mandatories";
23
19
  import { enableSmartscriptAction } from "../actions/smartscript";
24
20
  import { FETCH_MODEL, FETCH_MODEL_PREREQUISITES, } from "../constants/sagas/model";
25
21
  import { fetchModelAction } from "../actions/sagas/model";
22
+ import { initInputsDecorator } from "./initInputs";
26
23
  const cookies = new Cookies();
27
- const getValues = (arr1, arr2) => arr1.map((v, index) => arr2[index] || v);
28
24
  function* setFetchModelToNonBlocking(firstCurrentAppState) {
29
25
  yield put(initPaginationAction({
30
26
  currentPage: 1,
@@ -273,51 +269,7 @@ function* fetchModelDecorator(action) {
273
269
  if (OvcConverter.isOvc(ovc))
274
270
  ovc = OvcConverter.convertToOptionsVariables(ovc, references);
275
271
  const inputs = new IntputsInitiator(references, ovc).getInputs();
276
- const conditions = new ConditionsInitiator(references, inputs).getConditions();
277
- yield put(initConditionsAction(conditions));
278
- const optionsIds = Object.keys(inputs.options);
279
- for (let i = 0; i < optionsIds.length; i += 1) {
280
- let optionId = parseInt(optionsIds[i], 10);
281
- let values = inputs.options[optionId];
282
- yield put(initOptionAction(optionId, values));
283
- const { meta: meta2 } = references.options[optionId];
284
- const { type } = meta2;
285
- let { mandatory } = meta2;
286
- let sendOptionAction = true;
287
- if (["checkbox", "radio"].includes(type)) {
288
- if (type === "radio") {
289
- const { parents } = selectOptionRelations(optionId);
290
- const parentId = parents[0];
291
- const isMandatoryOption = selectMandatoryOptionItem(parentId);
292
- if (typeof isMandatoryOption !== "undefined") {
293
- const mandatoryOption = selectMandatoryOption(parentId);
294
- sendOptionAction = !mandatoryOption.every((v) => v === true);
295
- if (sendOptionAction === true && mandatoryOption) {
296
- if (values.length >= mandatoryOption.length) {
297
- values = getValues(values, [...mandatoryOption]);
298
- }
299
- else {
300
- values = getValues([...mandatoryOption], values);
301
- }
302
- }
303
- }
304
- mandatory = references.options[parentId].meta.mandatory;
305
- optionId = parentId;
306
- }
307
- if (mandatory === true && sendOptionAction === true) {
308
- yield put(initMandatoryOptionAction(optionId, values));
309
- }
310
- }
311
- }
312
- const variablesIds = Object.keys(inputs.variables);
313
- for (let i = 0; i < variablesIds.length; i += 1) {
314
- const variableId = variablesIds[i];
315
- const values = inputs.variables[variableId];
316
- yield put(initVariableAction(parseInt(variableId, 10), values));
317
- if (references.variables[variableId].mandatory === true)
318
- yield put(initMandatoryVariableAction(parseInt(variableId, 10), values.map((value) => `${value}`.trim().length > 0)));
319
- }
320
- yield put(initConditionsAction(conditions));
272
+ yield call(initInputsDecorator, initInputsAction(inputs, references));
321
273
  const sectionsReferences = selectAllSectionsReferences();
322
274
  if (sectionsReferences === undefined)
323
275
  throw new Error("Sections references not found");
@@ -0,0 +1,5 @@
1
+ import { StateType } from "../../types/State.type";
2
+ import { ActionsType } from "../../types/Actions.type";
3
+ export declare function initInputsDecorator(action: ActionsType.Inputs.initInputs): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<ActionsType.Conditions.initConditions> | import("redux-saga/effects").PutEffect<ActionsType.Inputs.initOption> | import("redux-saga/effects").PutEffect<ActionsType.Mandatories.initMandatoryOption> | import("redux-saga/effects").PutEffect<ActionsType.Inputs.initVariable> | import("redux-saga/effects").PutEffect<ActionsType.Mandatories.initMandatoryVariable>, void, StateType>;
4
+ declare function initInputsSaga(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
5
+ export default initInputsSaga;
@@ -0,0 +1,63 @@
1
+ import { select, takeLatest, put } from "redux-saga/effects";
2
+ import { INIT_INPUTS } from "../constants/inputs";
3
+ import { selectMandatoryOptionItem, selectMandatoryOption, } from "../selectors/mandatories";
4
+ import { initMandatoryOptionAction, initMandatoryVariableAction, } from "../actions/mandatories";
5
+ import { initOptionAction, initVariableAction } from "../actions/inputs";
6
+ import { initConditionsAction } from "../actions/conditions";
7
+ import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
8
+ import { selectOptionRelations } from "../selectors/references";
9
+ const getValues = (arr1, arr2) => arr1.map((v, index) => arr2[index] || v);
10
+ export function* initInputsDecorator(action) {
11
+ const state = yield select((s) => s);
12
+ const references = action.references ? action.references : state.references;
13
+ const { inputs } = action;
14
+ const conditions = new ConditionsInitiator(references, inputs).getConditions();
15
+ yield put(initConditionsAction(conditions));
16
+ const optionsIds = Object.keys(inputs.options);
17
+ for (let i = 0; i < optionsIds.length; i += 1) {
18
+ let optionId = parseInt(optionsIds[i], 10);
19
+ let values = inputs.options[optionId];
20
+ yield put(initOptionAction(optionId, values));
21
+ const { meta: meta2 } = references.options[optionId];
22
+ const { type } = meta2;
23
+ let { mandatory } = meta2;
24
+ let sendOptionAction = true;
25
+ if (["checkbox", "radio"].includes(type)) {
26
+ if (type === "radio") {
27
+ const { parents } = selectOptionRelations(optionId);
28
+ const parentId = parents[0];
29
+ const isMandatoryOption = selectMandatoryOptionItem(parentId);
30
+ if (typeof isMandatoryOption !== "undefined") {
31
+ const mandatoryOption = selectMandatoryOption(parentId);
32
+ sendOptionAction = !mandatoryOption.every((v) => v === true);
33
+ if (sendOptionAction === true && mandatoryOption) {
34
+ if (values.length >= mandatoryOption.length) {
35
+ values = getValues(values, [...mandatoryOption]);
36
+ }
37
+ else {
38
+ values = getValues([...mandatoryOption], values);
39
+ }
40
+ }
41
+ }
42
+ mandatory = references.options[parentId].meta.mandatory;
43
+ optionId = parentId;
44
+ }
45
+ if (mandatory === true && sendOptionAction === true) {
46
+ yield put(initMandatoryOptionAction(optionId, values));
47
+ }
48
+ }
49
+ }
50
+ const variablesIds = Object.keys(inputs.variables);
51
+ for (let i = 0; i < variablesIds.length; i += 1) {
52
+ const variableId = variablesIds[i];
53
+ const values = inputs.variables[variableId];
54
+ yield put(initVariableAction(parseInt(variableId, 10), values));
55
+ if (references.variables[variableId].mandatory === true)
56
+ yield put(initMandatoryVariableAction(parseInt(variableId, 10), values.map((value) => `${value}`.trim().length > 0)));
57
+ }
58
+ yield put(initConditionsAction(conditions));
59
+ }
60
+ function* initInputsSaga() {
61
+ yield takeLatest(INIT_INPUTS, initInputsDecorator);
62
+ }
63
+ export default initInputsSaga;
@@ -3,12 +3,14 @@ import setDefaultsSaga from "./setDefaults";
3
3
  import saveDataSaga from "./saveData";
4
4
  import homogeneousRadioInputsSaga from "./homogeneousRadioInputsSaga";
5
5
  import setUserEmailSaga from "./setUserEmail";
6
+ import initInputsSaga from "./initInputs";
6
7
  const sagas = [
7
8
  fetchModelSaga,
8
9
  setDefaultsSaga,
9
10
  saveDataSaga,
10
11
  setUserEmailSaga,
11
12
  homogeneousRadioInputsSaga,
13
+ initInputsSaga,
12
14
  ];
13
15
  export const sagasRunner = (sagaMiddleware) => {
14
16
  sagas.forEach((saga) => sagaMiddleware.run(saga));
@@ -7,6 +7,7 @@ export declare const selectorsLibrary: {
7
7
  isLevelAccessibleForUser: (level: "ADMIN" | "MANAGER" | "USER" | "GUEST" | "SUPER") => Readonly<boolean>;
8
8
  selectIsSmartscriptOptionIndexHidden: (id: number, index: number) => Readonly<boolean>;
9
9
  selectIsSmartscriptVariableIndexHidden: (id: number, index: number) => Readonly<boolean>;
10
+ selectReferences: () => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesType>;
10
11
  selectOutputReference: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesSingleOutputType | undefined>;
11
12
  selectBoxReference: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesSingleBoxType>;
12
13
  isOptionMultiple: (id: number) => Readonly<boolean | undefined>;
@@ -1,3 +1,4 @@
1
+ export declare const selectReferences: () => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesType>;
1
2
  export declare const selectOutputReference: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesSingleOutputType | undefined>;
2
3
  export declare const selectBoxReference: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesSingleBoxType>;
3
4
  export declare const isOptionMultiple: (id: number) => Readonly<boolean | undefined>;
@@ -1,4 +1,5 @@
1
1
  import { createSelector } from "./selectors";
2
+ export const selectReferences = createSelector((state) => state.references);
2
3
  export const selectOutputReference = createSelector((state, id) => {
3
4
  if (typeof state.references === "undefined")
4
5
  return undefined;
@@ -3,7 +3,7 @@ import { StateType } from "./State.type";
3
3
  import { UPDATE_AVAILABLE_SECTIONS, UPDATE_AVAILABLE_APPSTATES, GO_PREVIOUS_PAGE, GO_NEXT_PAGE, GO_PAGE, INIT_PAGINATION, UPDATE_INSTANCE_PAID, INIT_INSTANCE, UPDATE_INSTANCE, INIT_META, UPDATE_CURRENT_APPSTATE, UPDATE_CURRENT_SECTION_ID, FETCH_MODEL_SUCCEEDED, FETCH_MODEL_FAILED, SET_DATA_STATUS, SET_FETCH_STATUS, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID } from "../redux/constants/app";
4
4
  import { INIT_USER, SET_USER_STATUS, SET_USER_VALID_TOKEN } from "../redux/constants/user";
5
5
  import { INIT_REFERENCES, UPDATE_VARIABLE_META, UPDATE_OPTION_META } from "../redux/constants/references";
6
- import { INIT_OPTION, UPDATE_OPTION_INPUT, INIT_VARIABLE, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY } from "../redux/constants/inputs";
6
+ import { INIT_INPUTS, INIT_OPTION, UPDATE_OPTION_INPUT, INIT_VARIABLE, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY } from "../redux/constants/inputs";
7
7
  import { INIT_CONDITIONS, UPDATE_OPTION_CONDITION, UPDATE_VARIABLE_CONDITION, UPDATE_SECTION_CONDITION, UPDATE_PREFILLER_CONDITION, UPDATE_OPTION_VALIDATOR_CONDITION, UPDATE_VARIABLE_VALIDATOR_CONDITION, UPDATE_DOCUMENT_CONDITION } from "../redux/constants/conditions";
8
8
  import { FETCH_MODEL, FETCH_MODEL_PREREQUISITES } from "../redux/constants/sagas/model";
9
9
  import { SAVE_DATA } from "../redux/constants/sagas/data";
@@ -154,6 +154,11 @@ export declare namespace ActionsType {
154
154
  }
155
155
  }
156
156
  namespace Inputs {
157
+ interface initInputs {
158
+ type: typeof INIT_INPUTS;
159
+ references?: StateType.References;
160
+ inputs: StateType.Inputs;
161
+ }
157
162
  interface initOption {
158
163
  type: typeof INIT_OPTION;
159
164
  id: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "exports": {
@@ -24,7 +24,7 @@
24
24
  "@legalplace/lplogic": "^2.1.6",
25
25
  "@legalplace/model-healthcheck": "^1.1.5",
26
26
  "@legalplace/referencesparser": "^1.7.0",
27
- "@legalplace/sb-experiment": "^0.1.0-alpha.2",
27
+ "@legalplace/sb-experiment": "^0.1.0-alpha.3",
28
28
  "@loadable/component": "^5.15.0",
29
29
  "@redux-saga/core": "^1.1.3",
30
30
  "awesome-phonenumber": "^2.62.1",
@@ -51,9 +51,9 @@
51
51
  "xss": "^1.0.9"
52
52
  },
53
53
  "devDependencies": {
54
- "@legalplace/eslint-config": "^2.1.0",
54
+ "@legalplace/eslint-config": "^2.1.2",
55
55
  "@legalplace/models-v3-types": "^3.6.0",
56
- "@legalplace/prettier-config": "^2.1.0",
56
+ "@legalplace/prettier-config": "^2.1.2",
57
57
  "@swc-node/jest": "^1.3.2",
58
58
  "@swc/core": "^1.2.93",
59
59
  "@swc/jest": "^0.2.4",
@@ -92,5 +92,5 @@
92
92
  "*.test.ts",
93
93
  "*.test.tsx"
94
94
  ],
95
- "gitHead": "9273e6b6c177b2ded27acfab75da4b29d7fb474d"
95
+ "gitHead": "c5a3c6493619bb09f3341f167ebc177aae8f022c"
96
96
  }
@@ -1,5 +1,7 @@
1
+ import { StateType } from "../../types/State.type";
1
2
  import { ActionsType } from "../../types/Actions.type";
2
3
  import {
4
+ INIT_INPUTS,
3
5
  INIT_OPTION,
4
6
  INIT_VARIABLE,
5
7
  UPDATE_OPTION_INPUT,
@@ -8,6 +10,20 @@ import {
8
10
  DELETE_MULTIPLE_OCCURENCY,
9
11
  } from "../constants/inputs";
10
12
 
13
+ /**
14
+ * Initiates inputs
15
+ * @param inputs inputs object
16
+ * @param references (optional) references object
17
+ */
18
+ export const initInputsAction = (
19
+ inputs: StateType.Inputs,
20
+ references?: StateType.References
21
+ ): ActionsType.Inputs.initInputs => ({
22
+ type: INIT_INPUTS,
23
+ inputs,
24
+ references,
25
+ });
26
+
11
27
  /**
12
28
  * Initiates option's input
13
29
  * @param id Option's id
@@ -11,3 +11,5 @@ export const UPDATE_OPTION_INPUT = "UPDATE_OPTION_INPUT";
11
11
  // State.inputs.variables
12
12
  export const INIT_VARIABLE = "INIT_VARIABLE";
13
13
  export const UPDATE_VARIABLE_INPUT = "UPDATE_VARIABLE_INPUT";
14
+
15
+ export const INIT_INPUTS = "INIT_INPUTS";
@@ -5,6 +5,7 @@ import { getConfig } from "../../config";
5
5
  import { ActionsType } from "../../types/Actions.type";
6
6
  import { StateType } from "../../types/State.type";
7
7
  import {
8
+ INIT_INPUTS,
8
9
  ADD_MULTIPLE_OCCURENCY,
9
10
  DELETE_MULTIPLE_OCCURENCY,
10
11
  UPDATE_OPTION_INPUT,
@@ -13,6 +14,7 @@ import {
13
14
  import { ENABLE_SMARTSCRIPT } from "../constants/smartscript";
14
15
  import { PathReader } from "../../libs/PathReader";
15
16
  import { initSmartscriptTriggersAction } from "../actions/smartscript";
17
+ import { updateOptionAction, updateVariableAction } from "../actions/inputs";
16
18
 
17
19
  let iframe: HTMLIFrameElement | null = null;
18
20
 
@@ -153,6 +155,44 @@ const watchUpdateVariableInput = (
153
155
  }
154
156
  };
155
157
 
158
+ /**
159
+ * Watches inputs init
160
+ * @param mpi MiddlewareAPI
161
+ * @param next Dispatch function
162
+ * @param action INIT_INPUT action
163
+ */
164
+ const watchInitInputs = (
165
+ mpi: MiddlewareAPI<Dispatch, StateType>,
166
+ next: Dispatch,
167
+ action: ActionsType.Inputs.initInputs
168
+ ) => {
169
+ next(action);
170
+
171
+ if (!iframe) return;
172
+
173
+ const { inputs } = action;
174
+
175
+ Object.keys(inputs.options).forEach((id) => {
176
+ inputs.options[id].forEach((value, index) => {
177
+ watchUpdateOptionInput(
178
+ mpi,
179
+ next,
180
+ updateOptionAction(parseInt(id, 10), value, index)
181
+ );
182
+ });
183
+ });
184
+
185
+ Object.keys(inputs.variables).forEach((id) => {
186
+ inputs.variables[id].forEach((value, index) => {
187
+ watchUpdateVariableInput(
188
+ mpi,
189
+ next,
190
+ updateVariableAction(parseInt(id, 10), value, index)
191
+ );
192
+ });
193
+ });
194
+ };
195
+
156
196
  export type WatcherActions =
157
197
  | ActionsType.SmartScript.enableSmartScript
158
198
  | ActionsType.Inputs.updateOptionInput
@@ -168,6 +208,7 @@ const watchersEnum: Record<
168
208
  [UPDATE_VARIABLE_INPUT]: watchUpdateVariableInput,
169
209
  [ADD_MULTIPLE_OCCURENCY]: watchUpdateOptionInput,
170
210
  [DELETE_MULTIPLE_OCCURENCY]: watchUpdateOptionInput,
211
+ [INIT_INPUTS]: watchInitInputs,
171
212
  };
172
213
 
173
214
  /**
@@ -2,6 +2,7 @@ import { call, put, takeLatest, select, fork, join } from "redux-saga/effects";
2
2
  import Cookies from "universal-cookie";
3
3
  import type { CustomizationMetaDefault } from "@legalplace/models-v3-types";
4
4
  import type { HealthCheckReport } from "@legalplace/model-healthcheck/dist/libs/HealthCheck.type";
5
+ import { initInputsAction } from "../actions/inputs";
5
6
  import {
6
7
  initMetaAction,
7
8
  initPaginationAction,
@@ -17,15 +18,9 @@ import {
17
18
  fetchModelNonBlockingAction,
18
19
  setModelUuidAction,
19
20
  } from "../actions/app";
20
- import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
21
21
  import { initReferencesAction } from "../actions/references";
22
- import { initOptionAction, initVariableAction } from "../actions/inputs";
23
- import { initConditionsAction } from "../actions/conditions";
24
22
  import { selectSectionConditionValue } from "../selectors/conditions";
25
- import {
26
- selectAllSectionsReferences,
27
- selectOptionRelations,
28
- } from "../selectors/references";
23
+ import { selectAllSectionsReferences } from "../selectors/references";
29
24
  import { ActionsType } from "../../types/Actions.type";
30
25
  import { selectInstanceUniqid, isStepAvailable } from "../selectors/app";
31
26
  import { getConfig, updateConfig } from "../../config";
@@ -45,14 +40,6 @@ import {
45
40
  } from "../../service/api.manager";
46
41
  import { loadTheme, setWizardTheme } from "../../ThemeLoader";
47
42
  import { loadPlugins } from "../../PluginLoader";
48
- import {
49
- selectMandatoryOptionItem,
50
- selectMandatoryOption,
51
- } from "../selectors/mandatories";
52
- import {
53
- initMandatoryOptionAction,
54
- initMandatoryVariableAction,
55
- } from "../actions/mandatories";
56
43
  import { enableSmartscriptAction } from "../actions/smartscript";
57
44
  import {
58
45
  FETCH_MODEL,
@@ -64,12 +51,10 @@ import {
64
51
  WizardConfigResponse,
65
52
  CreateInstanceResponse,
66
53
  } from "../../types/api.type";
54
+ import { initInputsDecorator } from "./initInputs";
67
55
 
68
56
  const cookies = new Cookies();
69
57
 
70
- const getValues = (arr1: boolean[], arr2: boolean[]) =>
71
- arr1.map((v, index) => arr2[index] || v);
72
-
73
58
  function* setFetchModelToNonBlocking(firstCurrentAppState?: string) {
74
59
  yield put(
75
60
  initPaginationAction({
@@ -630,84 +615,7 @@ function* fetchModelDecorator(action: ActionsType.Sagas.Model.fetchModel): any {
630
615
  // Data
631
616
  const inputs = new IntputsInitiator(references, ovc).getInputs();
632
617
 
633
- // Initiating Conditions
634
- const conditions = new ConditionsInitiator(
635
- references,
636
- inputs
637
- ).getConditions();
638
-
639
- /**
640
- * Initiating conditions first before initiating inputs
641
- */
642
- yield put(initConditionsAction(conditions));
643
-
644
- /**
645
- * Initiating inputs
646
- */
647
-
648
- // Options
649
- const optionsIds = Object.keys(inputs.options);
650
- for (let i = 0; i < optionsIds.length; i += 1) {
651
- let optionId = parseInt(optionsIds[i], 10);
652
- let values = inputs.options[optionId];
653
- yield put(initOptionAction(optionId, values));
654
- // If option is mandatory we initiate it
655
- const { meta: meta2 } = references.options[optionId];
656
- const { type } = meta2;
657
- let { mandatory } = meta2;
658
- let sendOptionAction = true;
659
- if (["checkbox", "radio"].includes(type)) {
660
- if (type === "radio") {
661
- const { parents } = selectOptionRelations(optionId);
662
- // Get parentId
663
- const parentId = parents[0];
664
- // check if optin exist on mandatory
665
- const isMandatoryOption = selectMandatoryOptionItem(parentId);
666
- // If parentId value = true don't send an action
667
- if (typeof isMandatoryOption !== "undefined") {
668
- const mandatoryOption = selectMandatoryOption(parentId);
669
- sendOptionAction = !mandatoryOption.every((v) => v === true);
670
- // handle multiple
671
- if (sendOptionAction === true && mandatoryOption) {
672
- if (values.length >= mandatoryOption.length) {
673
- values = getValues(values, [...mandatoryOption]);
674
- } else {
675
- values = getValues([...mandatoryOption], values);
676
- }
677
- }
678
- }
679
-
680
- mandatory = references.options[parentId].meta.mandatory;
681
- optionId = parentId;
682
- }
683
-
684
- if (mandatory === true && sendOptionAction === true) {
685
- yield put(initMandatoryOptionAction(optionId, values));
686
- }
687
- }
688
- }
689
-
690
- // Variables
691
- const variablesIds = Object.keys(inputs.variables);
692
- for (let i = 0; i < variablesIds.length; i += 1) {
693
- const variableId = variablesIds[i];
694
- const values = inputs.variables[variableId];
695
- yield put(initVariableAction(parseInt(variableId, 10), values));
696
-
697
- // If variable is mandatory we initiate it
698
- if (references.variables[variableId].mandatory === true)
699
- yield put(
700
- initMandatoryVariableAction(
701
- parseInt(variableId, 10),
702
- values.map((value) => `${value}`.trim().length > 0)
703
- )
704
- );
705
- }
706
-
707
- /**
708
- * Initiating conditions a second time after initiating inputs
709
- */
710
- yield put(initConditionsAction(conditions));
618
+ yield call(initInputsDecorator, initInputsAction(inputs, references));
711
619
 
712
620
  /**
713
621
  * Initiating pagination
@@ -0,0 +1,110 @@
1
+ import { select, takeLatest, put } from "redux-saga/effects";
2
+ import { StateType } from "../../types/State.type";
3
+ import { ActionsType } from "../../types/Actions.type";
4
+ import { INIT_INPUTS } from "../constants/inputs";
5
+ import {
6
+ selectMandatoryOptionItem,
7
+ selectMandatoryOption,
8
+ } from "../selectors/mandatories";
9
+ import {
10
+ initMandatoryOptionAction,
11
+ initMandatoryVariableAction,
12
+ } from "../actions/mandatories";
13
+ import { initOptionAction, initVariableAction } from "../actions/inputs";
14
+ import { initConditionsAction } from "../actions/conditions";
15
+ import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
16
+ import { selectOptionRelations } from "../selectors/references";
17
+
18
+ const getValues = (arr1: boolean[], arr2: boolean[]) =>
19
+ arr1.map((v, index) => arr2[index] || v);
20
+
21
+ export function* initInputsDecorator(action: ActionsType.Inputs.initInputs) {
22
+ const state: StateType = yield select((s) => s);
23
+ const references = action.references ? action.references : state.references;
24
+ const { inputs } = action;
25
+
26
+ // Initiating Conditions
27
+ const conditions = new ConditionsInitiator(
28
+ references,
29
+ inputs
30
+ ).getConditions();
31
+
32
+ /**
33
+ * Initiating conditions first before initiating inputs
34
+ */
35
+ yield put(initConditionsAction(conditions));
36
+
37
+ /**
38
+ * Initiating inputs
39
+ */
40
+
41
+ // Options
42
+ const optionsIds = Object.keys(inputs.options);
43
+ for (let i = 0; i < optionsIds.length; i += 1) {
44
+ let optionId = parseInt(optionsIds[i], 10);
45
+ let values = inputs.options[optionId];
46
+ yield put(initOptionAction(optionId, values));
47
+ // If option is mandatory we initiate it
48
+ const { meta: meta2 } = references.options[optionId];
49
+ const { type } = meta2;
50
+ let { mandatory } = meta2;
51
+ let sendOptionAction = true;
52
+ if (["checkbox", "radio"].includes(type)) {
53
+ if (type === "radio") {
54
+ const { parents } = selectOptionRelations(optionId);
55
+ // Get parentId
56
+ const parentId = parents[0];
57
+ // check if optin exist on mandatory
58
+ const isMandatoryOption = selectMandatoryOptionItem(parentId);
59
+ // If parentId value = true don't send an action
60
+ if (typeof isMandatoryOption !== "undefined") {
61
+ const mandatoryOption = selectMandatoryOption(parentId);
62
+ sendOptionAction = !mandatoryOption.every((v) => v === true);
63
+ // handle multiple
64
+ if (sendOptionAction === true && mandatoryOption) {
65
+ if (values.length >= mandatoryOption.length) {
66
+ values = getValues(values, [...mandatoryOption]);
67
+ } else {
68
+ values = getValues([...mandatoryOption], values);
69
+ }
70
+ }
71
+ }
72
+
73
+ mandatory = references.options[parentId].meta.mandatory;
74
+ optionId = parentId;
75
+ }
76
+
77
+ if (mandatory === true && sendOptionAction === true) {
78
+ yield put(initMandatoryOptionAction(optionId, values));
79
+ }
80
+ }
81
+ }
82
+
83
+ // Variables
84
+ const variablesIds = Object.keys(inputs.variables);
85
+ for (let i = 0; i < variablesIds.length; i += 1) {
86
+ const variableId = variablesIds[i];
87
+ const values = inputs.variables[variableId];
88
+ yield put(initVariableAction(parseInt(variableId, 10), values));
89
+
90
+ // If variable is mandatory we initiate it
91
+ if (references.variables[variableId].mandatory === true)
92
+ yield put(
93
+ initMandatoryVariableAction(
94
+ parseInt(variableId, 10),
95
+ values.map((value) => `${value}`.trim().length > 0)
96
+ )
97
+ );
98
+ }
99
+
100
+ /**
101
+ * Initiating conditions a second time after initiating inputs
102
+ */
103
+ yield put(initConditionsAction(conditions));
104
+ }
105
+
106
+ function* initInputsSaga() {
107
+ yield takeLatest(INIT_INPUTS, initInputsDecorator);
108
+ }
109
+
110
+ export default initInputsSaga;
@@ -4,6 +4,7 @@ import setDefaultsSaga from "./setDefaults";
4
4
  import saveDataSaga from "./saveData";
5
5
  import homogeneousRadioInputsSaga from "./homogeneousRadioInputsSaga";
6
6
  import setUserEmailSaga from "./setUserEmail";
7
+ import initInputsSaga from "./initInputs";
7
8
 
8
9
  const sagas: { (): any }[] = [
9
10
  fetchModelSaga,
@@ -11,6 +12,7 @@ const sagas: { (): any }[] = [
11
12
  saveDataSaga,
12
13
  setUserEmailSaga,
13
14
  homogeneousRadioInputsSaga,
15
+ initInputsSaga,
14
16
  ];
15
17
 
16
18
  /**
@@ -8,6 +8,10 @@ import { createSelector } from "./selectors";
8
8
  * memoization for them
9
9
  */
10
10
 
11
+ export const selectReferences = createSelector(
12
+ (state: StateType) => state.references
13
+ );
14
+
11
15
  /**
12
16
  * Returns output's reference
13
17
  * @param id Option's id
@@ -39,6 +39,7 @@ import {
39
39
  UPDATE_OPTION_META,
40
40
  } from "../redux/constants/references";
41
41
  import {
42
+ INIT_INPUTS,
42
43
  INIT_OPTION,
43
44
  UPDATE_OPTION_INPUT,
44
45
  INIT_VARIABLE,
@@ -329,6 +330,13 @@ export namespace ActionsType {
329
330
 
330
331
  // Inputs
331
332
  export namespace Inputs {
333
+ // INIT_INPUTS
334
+ export interface initInputs {
335
+ type: typeof INIT_INPUTS;
336
+ references?: StateType.References;
337
+ inputs: StateType.Inputs;
338
+ }
339
+
332
340
  // INIT_OPTION
333
341
  export interface initOption {
334
342
  type: typeof INIT_OPTION;