@legalplace/wizardx-core 2.13.0 → 2.14.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,6 +3,35 @@
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.14.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.14.0...@legalplace/wizardx-core@2.14.1) (2023-01-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix updateInputs api[#7333](https://git.legalplace.eu/legalplace/monorepo/issues/7333) ([d5958dd](https://git.legalplace.eu/legalplace/monorepo/commits/d5958dde32b6b5a42bfd60e7197cba933672e10b))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.14.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.13.0...@legalplace/wizardx-core@2.14.0) (2023-01-04)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * fixed chech string ([fd9a21d](https://git.legalplace.eu/legalplace/monorepo/commits/fd9a21de30173e54b69a48cf9f4476a4a85c3eaf)), closes [api#7133](https://git.legalplace.eu/legalplace/monorepo/issues/7133)
23
+ * fixed naming function ([9bb2d83](https://git.legalplace.eu/legalplace/monorepo/commits/9bb2d83e761c6849ce326603cbfb26e0fa3fd630)), closes [api#7133](https://git.legalplace.eu/legalplace/monorepo/issues/7133)
24
+ * fixed review ([d5a0220](https://git.legalplace.eu/legalplace/monorepo/commits/d5a02206b123768ce97a20a8ba77e23bc8610dd6)), closes [api#7133](https://git.legalplace.eu/legalplace/monorepo/issues/7133)
25
+
26
+
27
+ ### Features
28
+
29
+ * added validator date ([d8f482c](https://git.legalplace.eu/legalplace/monorepo/commits/d8f482c259b052e018a3d6fe067141c2f5bdf469)), closes [api#7133](https://git.legalplace.eu/legalplace/monorepo/issues/7133)
30
+
31
+
32
+
33
+
34
+
6
35
  # [2.13.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.12.1...@legalplace/wizardx-core@2.13.0) (2022-12-27)
7
36
 
8
37
 
@@ -0,0 +1 @@
1
+ export declare const checkDateValidity: (date: string) => boolean;
@@ -0,0 +1,5 @@
1
+ export const checkDateValidity = (date) => {
2
+ const [day, month, year] = (date === null || date === void 0 ? void 0 : date.toString().split("/")) || [];
3
+ const dateObject = new Date(`${year}-${month}-${day}`);
4
+ return new Date(dateObject).toString() !== "Invalid Date";
5
+ };
@@ -2,3 +2,4 @@ export * from "./OvcConverter";
2
2
  export * from "./InputsInitiator";
3
3
  export * from "./PathReader";
4
4
  export * from "./SectionValidity";
5
+ export * from "./ConditionsInitiator";
@@ -2,3 +2,4 @@ export * from "./OvcConverter";
2
2
  export * from "./InputsInitiator";
3
3
  export * from "./PathReader";
4
4
  export * from "./SectionValidity";
5
+ export * from "./ConditionsInitiator";
@@ -1,12 +1,13 @@
1
1
  import { UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, } from "../constants/inputs";
2
2
  import { selectVariableInputByIndex, selectOptionInputByIndex, selectOptionInput, } from "../selectors/inputs";
3
3
  import { SET_MANDATORY_OPTION, SET_MANDATORY_VARIABLE, } from "../constants/mandatories";
4
- import { selectOptionRelations, selectOptionReference, selectSectionReference, selectVariableRelations, selectAllSectionsReferences, selectRadioSiblings, } from "../selectors/references";
4
+ import { selectOptionRelations, selectOptionReference, selectSectionReference, selectVariableRelations, selectAllSectionsReferences, selectRadioSiblings, selectVariableReference, } from "../selectors/references";
5
5
  import { selectMandatoryOption, selectMandatoryVariable, } from "../selectors/mandatories";
6
6
  import { setMandatoryOptionAction, setMandatorySectionAction, setMandatoryVariableAction, } from "../actions/mandatories";
7
7
  import { UPDATE_OPTION_CONDITION, UPDATE_VARIABLE_CONDITION, UPDATE_SECTION_CONDITION, } from "../constants/conditions";
8
8
  import { selectOptionConditionValue, selectVariableConditionValue, selectIsOptionDisplayed, selectIsVariableDisplayed, } from "../selectors/conditions";
9
9
  import { FETCH_MODEL_SUCCEEDED } from "../constants/app";
10
+ import { checkDateValidity } from "../../helpers/date.helper";
10
11
  const validateSectionMandatory = (mpi, sectionId) => {
11
12
  const parentSection = selectSectionReference(sectionId);
12
13
  let childOptions = [...parentSection.options];
@@ -126,10 +127,16 @@ const watchUpdateVariableInputCondition = (mpi, next, action, ignoreNext) => {
126
127
  const inputValue = type === UPDATE_VARIABLE_INPUT
127
128
  ? `${value}`.trim().length > 0
128
129
  : `${selectVariableInputByIndex(id, index)}`.trim().length > 0;
130
+ const { type: variableType } = selectVariableReference(id);
129
131
  const conditionValue = action.type === UPDATE_VARIABLE_CONDITION
130
132
  ? action.value
131
133
  : selectVariableConditionValue(id, index) !== false;
132
- const mandatoryValue = !conditionValue || (conditionValue && inputValue);
134
+ let mandatoryValue = !conditionValue || (conditionValue && inputValue);
135
+ if (variableType === "date" &&
136
+ typeof value === "string" &&
137
+ !checkDateValidity(value)) {
138
+ mandatoryValue = false;
139
+ }
133
140
  mpi.dispatch(setMandatoryVariableAction(id, index, mandatoryValue));
134
141
  };
135
142
  const watchUpdateOptionInputCondition = (mpi, next, action, ignoreNext) => {
@@ -5,7 +5,8 @@ import { initMandatoryOptionAction, initMandatoryVariableAction, } from "../acti
5
5
  import { initOptionAction, initVariableAction } from "../actions/inputs";
6
6
  import { initConditionsAction } from "../actions/conditions";
7
7
  import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
8
- import { selectOptionRelations } from "../selectors/references";
8
+ import { selectOptionRelations, selectVariableReference, } from "../selectors/references";
9
+ import { checkDateValidity } from "../../helpers/date.helper";
9
10
  const getValues = (arr1, arr2) => arr1.map((v, index) => arr2[index] || v);
10
11
  export function* initInputsDecorator(action) {
11
12
  const state = yield select((s) => s);
@@ -52,7 +53,15 @@ export function* initInputsDecorator(action) {
52
53
  const values = inputs.variables[variableId];
53
54
  yield put(initVariableAction(parseInt(variableId, 10), values));
54
55
  if (references.variables[variableId].mandatory === true)
55
- yield put(initMandatoryVariableAction(parseInt(variableId, 10), values.map((value) => `${value}`.trim().length > 0)));
56
+ yield put(initMandatoryVariableAction(parseInt(variableId, 10), values.map((value) => {
57
+ const { type: variableType } = selectVariableReference(parseInt(variableId, 10));
58
+ if (variableType === "date" &&
59
+ typeof value === "string" &&
60
+ !checkDateValidity(value)) {
61
+ return false;
62
+ }
63
+ return `${value}`.trim().length > 0;
64
+ })));
56
65
  }
57
66
  yield put(initConditionsAction(conditions));
58
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "2.13.0",
3
+ "version": "2.14.1",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -93,5 +93,5 @@
93
93
  "*.test.ts",
94
94
  "*.test.tsx"
95
95
  ],
96
- "gitHead": "9c632b92011012db9b5a466b608fcbcbd5401890"
96
+ "gitHead": "7905939c0106a35b983aaf2b57a19a5746a01fc0"
97
97
  }