@legalplace/wizardx-core 4.13.0 → 4.13.2

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.
@@ -185,18 +185,22 @@ const watchFetchModelSucceeded = (mpi, next, action) => {
185
185
  const variableId = parseInt(variableStrId, 10);
186
186
  const { prefillings, prioritizePrefillings } = selectVariableReference(variableId);
187
187
  if (Array.isArray(prefillings)) {
188
- const firstUnconditionnedIndex = prefillings
189
- .map((c) => c.conditions === undefined ||
190
- ConditionsMapper.countConditions(c.conditions) === 0)
191
- .indexOf(true);
192
- if (firstUnconditionnedIndex > -1) {
193
- variables[variableId].forEach((value, variableIndex) => {
194
- const prefillerValue = parsePrefillerValue(variableId, variableIndex, firstUnconditionnedIndex);
195
- if (value.toString().trim().length === 0 || prioritizePrefillings) {
196
- mpi.dispatch(updateVariableAction(variableId, prefillerValue, variableIndex));
197
- }
198
- });
199
- }
188
+ variables[variableId].forEach((value, variableIndex) => {
189
+ var _a;
190
+ const firstUnconditionnedIndex = prefillings
191
+ .map((c) => c.conditions === undefined ||
192
+ ConditionsMapper.countConditions(c.conditions) === 0)
193
+ .indexOf(true);
194
+ const prefillingConditions = (_a = selectPrefillerConditionValue(variableId)) === null || _a === void 0 ? void 0 : _a[variableIndex];
195
+ const firstTruthfulPrefill = prefillingConditions === null || prefillingConditions === void 0 ? void 0 : prefillingConditions.indexOf(true);
196
+ const prefillIndex = typeof firstTruthfulPrefill === "number" && firstTruthfulPrefill > -1
197
+ ? firstTruthfulPrefill
198
+ : firstUnconditionnedIndex;
199
+ const prefillerValue = parsePrefillerValue(variableId, variableIndex, prefillIndex);
200
+ if (value.toString().trim().length === 0 || prioritizePrefillings) {
201
+ mpi.dispatch(updateVariableAction(variableId, prefillerValue, variableIndex));
202
+ }
203
+ });
200
204
  }
201
205
  });
202
206
  };
@@ -7,7 +7,6 @@ import { selectInputs } from "../selectors/inputs";
7
7
  import { OvcConverter } from "../../libs/OvcConverter";
8
8
  import { updateInstanceArguments } from "../../service/api.manager";
9
9
  import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
10
- import { trimInputs } from "../../helpers/trimInputs";
11
10
  function* saveDataDecorator(action) {
12
11
  try {
13
12
  yield put(setDataStatus("saving"));
@@ -15,7 +14,7 @@ function* saveDataDecorator(action) {
15
14
  const uniqid = selectInstanceUniqid();
16
15
  if (uniqid === undefined)
17
16
  throw new Error("Cannot save data, uniqid is not defined");
18
- const response = yield call(fetch, ...updateInstanceArguments(permalink, uniqid, OvcConverter.convertToOvc(trimInputs(selectInputs())), action.confirmAnswer ? 0 : 1, action.additionalProperties));
17
+ const response = yield call(fetch, ...updateInstanceArguments(permalink, uniqid, OvcConverter.convertToOvc(selectInputs()), action.confirmAnswer ? 0 : 1, action.additionalProperties));
19
18
  const responseData = yield call([response, "json"]);
20
19
  if (action.redirect === true) {
21
20
  const searchParams = new URLSearchParams(window.location.search);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "4.13.0",
3
+ "version": "4.13.2",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -96,5 +96,5 @@
96
96
  "*.test.ts",
97
97
  "*.test.tsx"
98
98
  ],
99
- "gitHead": "331e8226c0c2a9f66024621240f8485cabe874de"
99
+ "gitHead": "3240a0186197e2448190353665f556d64d945bf5"
100
100
  }
@@ -1,2 +0,0 @@
1
- import type { StateType } from "../types/State.type";
2
- export declare const trimInputs: (inputs: StateType.Inputs) => StateType.Inputs;
@@ -1,7 +0,0 @@
1
- export const trimInputs = (inputs) => {
2
- const trimmedVariables = Object.keys(inputs.variables).reduce((acc, key) => {
3
- acc[key] = inputs.variables[key].map((value) => typeof value === "string" ? value.trim() : value);
4
- return acc;
5
- }, {});
6
- return Object.assign(Object.assign({}, inputs), { variables: trimmedVariables });
7
- };