@inseefr/lunatic 0.3.2-experimental → 0.3.6-experimental
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/lib/index.js +38 -82
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/breadcrumb/component.js +29 -29
- package/src/components/button/component.js +53 -53
- package/src/components/button/index.js +1 -1
- package/src/components/checkbox/index.js +3 -3
- package/src/components/datepicker/index.js +1 -1
- package/src/components/declarations/index.js +1 -1
- package/src/components/declarations/wrappers/input-declarations-wrapper.js +28 -7
- package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
- package/src/components/dropdown/commons/components/dropdown.js +21 -0
- package/src/components/dropdown/dropdown-edit/dropdown-edit.js +4 -1
- package/src/components/dropdown/dropdown-simple/dropdown.js +3 -1
- package/src/components/filter-description/component.js +42 -42
- package/src/components/icon/component.js +33 -33
- package/src/components/input/index.js +2 -2
- package/src/components/input/input-number.js +2 -1
- package/src/components/loop/index.js +1 -1
- package/src/components/loop-constructor/wrapper/body-component.js +13 -1
- package/src/components/radio/index.js +1 -1
- package/src/components/sequence/index.js +1 -1
- package/src/components/subsequence/index.js +1 -1
- package/src/components/suggester/check-store.js +70 -70
- package/src/components/suggester/components/suggester-content.js +42 -42
- package/src/components/suggester/components/suggester.js +43 -3
- package/src/components/suggester/idb-suggester.js +7 -1
- package/src/components/suggester/lunatic-suggester.js +1 -0
- package/src/components/suggester/suggester-wrapper.js +6 -0
- package/src/components/tooltip/response.js +52 -52
- package/src/stories/checkbox-boolean/data-forced.json +48 -48
- package/src/stories/icons/icons.stories.js +16 -16
- package/src/stories/questionnaire/kish.json +275 -0
- package/src/stories/questionnaire/logement-queen.json +23390 -23390
- package/src/stories/questionnaire/logement-s2.json +46027 -44536
- package/src/stories/questionnaire/questionnaire.stories.js +14 -2
- package/src/stories/utils/custom-lunatic.scss +23 -23
- package/src/stories/utils/orchestrator-split.js +4 -2
- package/src/stories/utils/orchestrator.js +4 -2
- package/src/tests/components/breadcrumb.spec.js +13 -13
- package/src/tests/components/button.spec.js +11 -11
- package/src/tests/components/checkbox-boolean.spec.js +45 -45
- package/src/tests/components/checkbox-group.spec.js +53 -53
- package/src/tests/components/checkbox-one.spec.js +32 -32
- package/src/tests/components/datepicker.spec.js +22 -22
- package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
- package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
- package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
- package/src/tests/components/declarations.spec.js +46 -46
- package/src/tests/components/input.spec.js +18 -18
- package/src/tests/components/loops/loop-static.json +66 -66
- package/src/tests/components/loops/loop.json +258 -258
- package/src/tests/components/loops/loop.spec.js +30 -30
- package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
- package/src/tests/components/progress-bar.spec.js +15 -15
- package/src/tests/components/radio.spec.js +27 -27
- package/src/tests/components/sequence.spec.js +9 -9
- package/src/tests/components/subsequence.spec.js +9 -9
- package/src/tests/components/table.spec.js +11 -11
- package/src/tests/components/textarea.spec.js +18 -18
- package/src/tests/components/tooltip.spec.js +25 -25
- package/src/tests/setup/setupTests.js +4 -4
- package/src/tests/utils/lib/alphabet.spec.js +36 -36
- package/src/tests/utils/lib/array.spec.js +22 -22
- package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
- package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
- package/src/tests/utils/lib/input-number.spec.js +18 -18
- package/src/tests/utils/lib/items-positioning.spec.js +17 -17
- package/src/tests/utils/lib/label-position.spec.js +22 -22
- package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
- package/src/tests/utils/lib/loops/shared.spec.js +82 -82
- package/src/tests/utils/lib/missing/missing.spec.js +74 -74
- package/src/tests/utils/lib/missing/mock.js +137 -137
- package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
- package/src/tests/utils/lib/responses.spec.js +64 -64
- package/src/tests/utils/lib/style.spec.js +26 -26
- package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
- package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
- package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
- package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
- package/src/tests/utils/to-expose/handler/results/index.js +6 -6
- package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
- package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
- package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
- package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
- package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
- package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
- package/src/tests/utils/to-expose/state/results.js +78 -78
- package/src/utils/lib/splitting.js +55 -23
- package/src/utils/lib/tooltip/build-response.js +41 -41
- package/src/utils/store-tools/create/index.js +1 -1
- package/src/utils/store-tools/create/update-store-info.js +26 -26
- package/src/utils/store-tools/index.js +5 -5
- package/src/utils/to-expose/handler.js +12 -14
- package/src/utils/to-expose/hooks/lunatic-split.js +44 -27
- package/src/utils/to-expose/hooks/lunatic.js +12 -5
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"components": [],
|
|
3
|
-
"variables": {
|
|
4
|
-
"EXTERNAL": { "VAR_EXTERNAL": "Value VAR_EXTERNAL" },
|
|
5
|
-
"CALCULATED": {
|
|
6
|
-
"VAR_CALCULATED": { "expression": "VTL expression", "value": null }
|
|
7
|
-
},
|
|
8
|
-
"COLLECTED": {
|
|
9
|
-
"input": {
|
|
10
|
-
"componentRef": "2",
|
|
11
|
-
"values": {
|
|
12
|
-
"PREVIOUS": null,
|
|
13
|
-
"COLLECTED": "My input",
|
|
14
|
-
"FORCED": null,
|
|
15
|
-
"EDITED": null,
|
|
16
|
-
"INPUTED": null
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"check1": {
|
|
20
|
-
"componentRef": "3",
|
|
21
|
-
"values": {
|
|
22
|
-
"PREVIOUS": null,
|
|
23
|
-
"COLLECTED": true,
|
|
24
|
-
"FORCED": null,
|
|
25
|
-
"EDITED": null,
|
|
26
|
-
"INPUTED": null
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"check2": {
|
|
30
|
-
"componentRef": "3",
|
|
31
|
-
"values": {
|
|
32
|
-
"PREVIOUS": null,
|
|
33
|
-
"COLLECTED": false,
|
|
34
|
-
"FORCED": true,
|
|
35
|
-
"EDITED": null,
|
|
36
|
-
"INPUTED": null
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"table11": {
|
|
40
|
-
"componentRef": "4",
|
|
41
|
-
"values": {
|
|
42
|
-
"PREVIOUS": null,
|
|
43
|
-
"COLLECTED": "1",
|
|
44
|
-
"FORCED": null,
|
|
45
|
-
"EDITED": null,
|
|
46
|
-
"INPUTED": null
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"table12": {
|
|
50
|
-
"componentRef": "4",
|
|
51
|
-
"values": {
|
|
52
|
-
"PREVIOUS": null,
|
|
53
|
-
"COLLECTED": null,
|
|
54
|
-
"FORCED": null,
|
|
55
|
-
"EDITED": null,
|
|
56
|
-
"INPUTED": null
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"components": [],
|
|
3
|
+
"variables": {
|
|
4
|
+
"EXTERNAL": { "VAR_EXTERNAL": "Value VAR_EXTERNAL" },
|
|
5
|
+
"CALCULATED": {
|
|
6
|
+
"VAR_CALCULATED": { "expression": "VTL expression", "value": null }
|
|
7
|
+
},
|
|
8
|
+
"COLLECTED": {
|
|
9
|
+
"input": {
|
|
10
|
+
"componentRef": "2",
|
|
11
|
+
"values": {
|
|
12
|
+
"PREVIOUS": null,
|
|
13
|
+
"COLLECTED": "My input",
|
|
14
|
+
"FORCED": null,
|
|
15
|
+
"EDITED": null,
|
|
16
|
+
"INPUTED": null
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"check1": {
|
|
20
|
+
"componentRef": "3",
|
|
21
|
+
"values": {
|
|
22
|
+
"PREVIOUS": null,
|
|
23
|
+
"COLLECTED": true,
|
|
24
|
+
"FORCED": null,
|
|
25
|
+
"EDITED": null,
|
|
26
|
+
"INPUTED": null
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"check2": {
|
|
30
|
+
"componentRef": "3",
|
|
31
|
+
"values": {
|
|
32
|
+
"PREVIOUS": null,
|
|
33
|
+
"COLLECTED": false,
|
|
34
|
+
"FORCED": true,
|
|
35
|
+
"EDITED": null,
|
|
36
|
+
"INPUTED": null
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"table11": {
|
|
40
|
+
"componentRef": "4",
|
|
41
|
+
"values": {
|
|
42
|
+
"PREVIOUS": null,
|
|
43
|
+
"COLLECTED": "1",
|
|
44
|
+
"FORCED": null,
|
|
45
|
+
"EDITED": null,
|
|
46
|
+
"INPUTED": null
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"table12": {
|
|
50
|
+
"componentRef": "4",
|
|
51
|
+
"values": {
|
|
52
|
+
"PREVIOUS": null,
|
|
53
|
+
"COLLECTED": null,
|
|
54
|
+
"FORCED": null,
|
|
55
|
+
"EDITED": null,
|
|
56
|
+
"INPUTED": null
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
export const calculatedState = {
|
|
2
|
-
VAR_CALCULATED: null,
|
|
3
|
-
};
|
|
4
|
-
export const collectedState = {
|
|
5
|
-
input: {
|
|
6
|
-
PREVIOUS: null,
|
|
7
|
-
COLLECTED: 'My input',
|
|
8
|
-
FORCED: null,
|
|
9
|
-
EDITED: null,
|
|
10
|
-
INPUTED: null,
|
|
11
|
-
},
|
|
12
|
-
check1: {
|
|
13
|
-
PREVIOUS: null,
|
|
14
|
-
COLLECTED: true,
|
|
15
|
-
FORCED: null,
|
|
16
|
-
EDITED: null,
|
|
17
|
-
INPUTED: null,
|
|
18
|
-
},
|
|
19
|
-
check2: {
|
|
20
|
-
PREVIOUS: null,
|
|
21
|
-
COLLECTED: false,
|
|
22
|
-
FORCED: true,
|
|
23
|
-
EDITED: null,
|
|
24
|
-
INPUTED: null,
|
|
25
|
-
},
|
|
26
|
-
table11: {
|
|
27
|
-
PREVIOUS: null,
|
|
28
|
-
COLLECTED: '1',
|
|
29
|
-
FORCED: null,
|
|
30
|
-
EDITED: null,
|
|
31
|
-
INPUTED: null,
|
|
32
|
-
},
|
|
33
|
-
table12: {
|
|
34
|
-
PREVIOUS: null,
|
|
35
|
-
COLLECTED: null,
|
|
36
|
-
FORCED: null,
|
|
37
|
-
EDITED: null,
|
|
38
|
-
INPUTED: null,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const externalState = { VAR_EXTERNAL: 'Value VAR_EXTERNAL' };
|
|
43
|
-
|
|
44
|
-
export const state = {
|
|
45
|
-
EXTERNAL: externalState,
|
|
46
|
-
CALCULATED: calculatedState,
|
|
47
|
-
COLLECTED: collectedState,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const collectedStateCollected = {
|
|
51
|
-
input: 'My input',
|
|
52
|
-
check1: true,
|
|
53
|
-
check2: false,
|
|
54
|
-
table11: '1',
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const collectedStateCollectedWithNull = {
|
|
58
|
-
...collectedStateCollected,
|
|
59
|
-
table12: null,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const collectedStateForced = {
|
|
63
|
-
check2: true,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const collectedStateForcedWithNull = {
|
|
67
|
-
input: null,
|
|
68
|
-
check1: null,
|
|
69
|
-
check2: true,
|
|
70
|
-
table11: null,
|
|
71
|
-
table12: null,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const bindingsResults = {
|
|
75
|
-
...collectedStateCollectedWithNull,
|
|
76
|
-
VAR_CALCULATED: null,
|
|
77
|
-
...externalState,
|
|
78
|
-
};
|
|
1
|
+
export const calculatedState = {
|
|
2
|
+
VAR_CALCULATED: null,
|
|
3
|
+
};
|
|
4
|
+
export const collectedState = {
|
|
5
|
+
input: {
|
|
6
|
+
PREVIOUS: null,
|
|
7
|
+
COLLECTED: 'My input',
|
|
8
|
+
FORCED: null,
|
|
9
|
+
EDITED: null,
|
|
10
|
+
INPUTED: null,
|
|
11
|
+
},
|
|
12
|
+
check1: {
|
|
13
|
+
PREVIOUS: null,
|
|
14
|
+
COLLECTED: true,
|
|
15
|
+
FORCED: null,
|
|
16
|
+
EDITED: null,
|
|
17
|
+
INPUTED: null,
|
|
18
|
+
},
|
|
19
|
+
check2: {
|
|
20
|
+
PREVIOUS: null,
|
|
21
|
+
COLLECTED: false,
|
|
22
|
+
FORCED: true,
|
|
23
|
+
EDITED: null,
|
|
24
|
+
INPUTED: null,
|
|
25
|
+
},
|
|
26
|
+
table11: {
|
|
27
|
+
PREVIOUS: null,
|
|
28
|
+
COLLECTED: '1',
|
|
29
|
+
FORCED: null,
|
|
30
|
+
EDITED: null,
|
|
31
|
+
INPUTED: null,
|
|
32
|
+
},
|
|
33
|
+
table12: {
|
|
34
|
+
PREVIOUS: null,
|
|
35
|
+
COLLECTED: null,
|
|
36
|
+
FORCED: null,
|
|
37
|
+
EDITED: null,
|
|
38
|
+
INPUTED: null,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const externalState = { VAR_EXTERNAL: 'Value VAR_EXTERNAL' };
|
|
43
|
+
|
|
44
|
+
export const state = {
|
|
45
|
+
EXTERNAL: externalState,
|
|
46
|
+
CALCULATED: calculatedState,
|
|
47
|
+
COLLECTED: collectedState,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const collectedStateCollected = {
|
|
51
|
+
input: 'My input',
|
|
52
|
+
check1: true,
|
|
53
|
+
check2: false,
|
|
54
|
+
table11: '1',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const collectedStateCollectedWithNull = {
|
|
58
|
+
...collectedStateCollected,
|
|
59
|
+
table12: null,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const collectedStateForced = {
|
|
63
|
+
check2: true,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const collectedStateForcedWithNull = {
|
|
67
|
+
input: null,
|
|
68
|
+
check1: null,
|
|
69
|
+
check2: true,
|
|
70
|
+
table11: null,
|
|
71
|
+
table12: null,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const bindingsResults = {
|
|
75
|
+
...collectedStateCollectedWithNull,
|
|
76
|
+
VAR_CALCULATED: null,
|
|
77
|
+
...externalState,
|
|
78
|
+
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
const getBindingsDependenciesCalculated = (variables) => {
|
|
2
2
|
if (!variables) return {};
|
|
3
|
-
return variables.reduce(
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return acc;
|
|
11
|
-
},
|
|
12
|
-
{}
|
|
13
|
-
);
|
|
3
|
+
return variables.reduce((acc, { name, bindingDependencies, shapeFrom }) => {
|
|
4
|
+
if (shapeFrom && bindingDependencies)
|
|
5
|
+
return { ...acc, [name]: [...bindingDependencies, shapeFrom] };
|
|
6
|
+
if (bindingDependencies) return { ...acc, [name]: bindingDependencies };
|
|
7
|
+
if (shapeFrom) return { ...acc, [name]: [shapeFrom] };
|
|
8
|
+
return acc;
|
|
9
|
+
}, {});
|
|
14
10
|
};
|
|
15
11
|
|
|
16
12
|
const getAllDeps = (deps) => (variablesCalcDeps) => {
|
|
@@ -24,20 +20,51 @@ const getAllDeps = (deps) => (variablesCalcDeps) => {
|
|
|
24
20
|
}, []);
|
|
25
21
|
};
|
|
26
22
|
|
|
23
|
+
const getNestedVarsInFilterOrControl = (element) => {
|
|
24
|
+
if (element && Array.isArray(element?.bindingDependencies))
|
|
25
|
+
return element?.bindingDependencies;
|
|
26
|
+
return [];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getNestedVarsInComponent = (component) => {
|
|
30
|
+
const {
|
|
31
|
+
componentType,
|
|
32
|
+
bindingDependencies = [],
|
|
33
|
+
conditionFilter,
|
|
34
|
+
controls = [],
|
|
35
|
+
} = component;
|
|
36
|
+
var bindings = [
|
|
37
|
+
...bindingDependencies, // bindingDependencies of Component
|
|
38
|
+
...getNestedVarsInFilterOrControl(conditionFilter), // bindingDependencies of its conditionFilter
|
|
39
|
+
...controls.reduce(
|
|
40
|
+
(acc, c) => [...acc, ...getNestedVarsInFilterOrControl(c)],
|
|
41
|
+
[]
|
|
42
|
+
), // bindingDependencies of its controls
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
if (componentType === 'Loop') {
|
|
46
|
+
const { components, loopDependencies } = component;
|
|
47
|
+
if (Array.isArray(loopDependencies))
|
|
48
|
+
bindings = [...bindings, ...loopDependencies];
|
|
49
|
+
if (Array.isArray(components)) {
|
|
50
|
+
bindings = components.reduce(
|
|
51
|
+
(acc, c) => [...acc, ...getNestedVarsInComponent(c)],
|
|
52
|
+
[...bindings]
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return bindings;
|
|
58
|
+
};
|
|
59
|
+
|
|
27
60
|
const getNestedVars =
|
|
28
61
|
(components = []) =>
|
|
29
62
|
(variables) => {
|
|
30
63
|
const variableCalculatedDependencies =
|
|
31
64
|
getBindingsDependenciesCalculated(variables);
|
|
32
65
|
const depsVarsTemp = components
|
|
33
|
-
.reduce((acc,
|
|
34
|
-
|
|
35
|
-
var superBind = [];
|
|
36
|
-
if (Array.isArray(bindingDependencies))
|
|
37
|
-
superBind = [...superBind, ...bindingDependencies];
|
|
38
|
-
if (Array.isArray(conditionFilter?.bindingDependencies))
|
|
39
|
-
superBind = [...superBind, ...conditionFilter.bindingDependencies];
|
|
40
|
-
return [...acc, ...superBind];
|
|
66
|
+
.reduce((acc, c) => {
|
|
67
|
+
return [...acc, ...getNestedVarsInComponent(c)];
|
|
41
68
|
}, [])
|
|
42
69
|
.filter((v, i, a) => a.indexOf(v) === i);
|
|
43
70
|
return getAllDeps(depsVarsTemp)(variableCalculatedDependencies).filter(
|
|
@@ -46,7 +73,6 @@ const getNestedVars =
|
|
|
46
73
|
};
|
|
47
74
|
|
|
48
75
|
const getUsefullVariablesFromSource = (variables) => (nestedVars) => {
|
|
49
|
-
if (!variables) return true;
|
|
50
76
|
return variables.filter(({ variableType, name }) => {
|
|
51
77
|
if (variableType === 'CALCULATED' && !nestedVars.includes(name))
|
|
52
78
|
return false;
|
|
@@ -60,18 +86,24 @@ export const getSplitQuestionnaireSource = (source) => {
|
|
|
60
86
|
const { components, variables, ...rest } = source;
|
|
61
87
|
var split = [];
|
|
62
88
|
var currentComponents = [];
|
|
63
|
-
|
|
64
|
-
|
|
89
|
+
var previousPage = null;
|
|
90
|
+
components.map((c) => {
|
|
91
|
+
const { componentType, page } = c;
|
|
65
92
|
// splitting by Sequence or Loop
|
|
66
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
(componentType === 'Sequence' || componentType === 'Loop') &&
|
|
95
|
+
previousPage !== page
|
|
96
|
+
) {
|
|
67
97
|
if (currentComponents.length > 0) split.push(currentComponents);
|
|
68
98
|
currentComponents = [c];
|
|
69
99
|
} else {
|
|
70
100
|
currentComponents.push(c);
|
|
71
101
|
}
|
|
102
|
+
previousPage = page;
|
|
72
103
|
return null;
|
|
73
104
|
});
|
|
74
105
|
if (currentComponents.length > 0) split.push(currentComponents);
|
|
106
|
+
|
|
75
107
|
return split.reduce((prev, currentSource) => {
|
|
76
108
|
const firstPage = currentSource[0].page;
|
|
77
109
|
const maxPage = currentSource[currentSource.length - 1].page;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { buildNewValue } from '../../to-expose/handler';
|
|
2
|
-
import * as C from '../../../constants/value-types';
|
|
3
|
-
|
|
4
|
-
export const buildMultiTooltipResponse = (options) => (response) => {
|
|
5
|
-
if (!response || Object.keys(response).length === 0 || !options) return {};
|
|
6
|
-
const { name, values } = response;
|
|
7
|
-
const newValues = Object.entries(values).reduce(
|
|
8
|
-
(acc, [k, v]) =>
|
|
9
|
-
v === null
|
|
10
|
-
? { ...acc, [k]: v }
|
|
11
|
-
: { ...acc, [k]: options.find((o) => o.value === v).label },
|
|
12
|
-
{}
|
|
13
|
-
);
|
|
14
|
-
return { name, values: newValues };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const buildBooleanTooltipResponse = (response) => {
|
|
18
|
-
if (!response || Object.keys(response).length === 0) return {};
|
|
19
|
-
const { name, values } = response;
|
|
20
|
-
const newValues = Object.entries(values).reduce(
|
|
21
|
-
(acc, [k, v]) =>
|
|
22
|
-
v === null ? { ...acc, [k]: v } : { ...acc, [k]: v ? 'Vrai' : 'Faux' },
|
|
23
|
-
{}
|
|
24
|
-
);
|
|
25
|
-
return { name, values: newValues };
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Assume we use this tool in management mode only
|
|
30
|
-
*/
|
|
31
|
-
export const buildLocalResponse = (response, value) => {
|
|
32
|
-
if (!response || Object.keys(response).length === 0) return {};
|
|
33
|
-
const { name, values } = response;
|
|
34
|
-
const newValue = buildNewValue([C.COLLECTED, C.FORCED, C.EDITED])(C.EDITED)(
|
|
35
|
-
values
|
|
36
|
-
)(value);
|
|
37
|
-
return {
|
|
38
|
-
name,
|
|
39
|
-
values: { ...values, EDITED: newValue },
|
|
40
|
-
};
|
|
41
|
-
};
|
|
1
|
+
import { buildNewValue } from '../../to-expose/handler';
|
|
2
|
+
import * as C from '../../../constants/value-types';
|
|
3
|
+
|
|
4
|
+
export const buildMultiTooltipResponse = (options) => (response) => {
|
|
5
|
+
if (!response || Object.keys(response).length === 0 || !options) return {};
|
|
6
|
+
const { name, values } = response;
|
|
7
|
+
const newValues = Object.entries(values).reduce(
|
|
8
|
+
(acc, [k, v]) =>
|
|
9
|
+
v === null
|
|
10
|
+
? { ...acc, [k]: v }
|
|
11
|
+
: { ...acc, [k]: options.find((o) => o.value === v).label },
|
|
12
|
+
{}
|
|
13
|
+
);
|
|
14
|
+
return { name, values: newValues };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const buildBooleanTooltipResponse = (response) => {
|
|
18
|
+
if (!response || Object.keys(response).length === 0) return {};
|
|
19
|
+
const { name, values } = response;
|
|
20
|
+
const newValues = Object.entries(values).reduce(
|
|
21
|
+
(acc, [k, v]) =>
|
|
22
|
+
v === null ? { ...acc, [k]: v } : { ...acc, [k]: v ? 'Vrai' : 'Faux' },
|
|
23
|
+
{}
|
|
24
|
+
);
|
|
25
|
+
return { name, values: newValues };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Assume we use this tool in management mode only
|
|
30
|
+
*/
|
|
31
|
+
export const buildLocalResponse = (response, value) => {
|
|
32
|
+
if (!response || Object.keys(response).length === 0) return {};
|
|
33
|
+
const { name, values } = response;
|
|
34
|
+
const newValue = buildNewValue([C.COLLECTED, C.FORCED, C.EDITED])(C.EDITED)(
|
|
35
|
+
values
|
|
36
|
+
)(value);
|
|
37
|
+
return {
|
|
38
|
+
name,
|
|
39
|
+
values: { ...values, EDITED: newValue },
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './create';
|
|
1
|
+
export { default } from './create';
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import CONSTANTES from '../constantes';
|
|
2
|
-
|
|
3
|
-
function update(db, storeInfo) {
|
|
4
|
-
return new Promise(function (resolve, reject) {
|
|
5
|
-
try {
|
|
6
|
-
const transaction = db.transaction(
|
|
7
|
-
CONSTANTES.STORE_INFO_NAME,
|
|
8
|
-
'readwrite'
|
|
9
|
-
);
|
|
10
|
-
const store = transaction.objectStore(CONSTANTES.STORE_INFO_NAME);
|
|
11
|
-
const request = store.add(storeInfo);
|
|
12
|
-
|
|
13
|
-
request.onsuccess = function () {
|
|
14
|
-
resolve('success');
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
request.onerror = function (e) {
|
|
18
|
-
reject(e);
|
|
19
|
-
};
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default update;
|
|
1
|
+
import CONSTANTES from '../constantes';
|
|
2
|
+
|
|
3
|
+
function update(db, storeInfo) {
|
|
4
|
+
return new Promise(function (resolve, reject) {
|
|
5
|
+
try {
|
|
6
|
+
const transaction = db.transaction(
|
|
7
|
+
CONSTANTES.STORE_INFO_NAME,
|
|
8
|
+
'readwrite'
|
|
9
|
+
);
|
|
10
|
+
const store = transaction.objectStore(CONSTANTES.STORE_INFO_NAME);
|
|
11
|
+
const request = store.add(storeInfo);
|
|
12
|
+
|
|
13
|
+
request.onsuccess = function () {
|
|
14
|
+
resolve('success');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
request.onerror = function (e) {
|
|
18
|
+
reject(e);
|
|
19
|
+
};
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default update;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * as CONSTANTES from './constantes';
|
|
2
|
-
export { default as openOrCreateStore } from './open-or-create-store';
|
|
3
|
-
export { default as clearStoreData } from './clear-store-data';
|
|
4
|
-
export { default as useStoreIndex } from './use-store-index';
|
|
5
|
-
export { default as getStoreCount } from './get-store-count';
|
|
1
|
+
export * as CONSTANTES from './constantes';
|
|
2
|
+
export { default as openOrCreateStore } from './open-or-create-store';
|
|
3
|
+
export { default as clearStoreData } from './clear-store-data';
|
|
4
|
+
export { default as useStoreIndex } from './use-store-index';
|
|
5
|
+
export { default as getStoreCount } from './get-store-count';
|
|
@@ -60,7 +60,7 @@ export const updateQuestionnaire =
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const updateExternals =
|
|
63
|
-
(questionnaire) => (logFunction) => (updatedValues) => {
|
|
63
|
+
(questionnaire) => (logFunction, preferences) => (updatedValues) => {
|
|
64
64
|
const { variables, ...other } = questionnaire;
|
|
65
65
|
const { EXTERNAL } = variables;
|
|
66
66
|
const newVariables = {
|
|
@@ -71,8 +71,7 @@ export const updateExternals =
|
|
|
71
71
|
const newVariablesWithCalculated = addCalculatedVars(
|
|
72
72
|
newVariables,
|
|
73
73
|
updatedValues
|
|
74
|
-
)(logFunction);
|
|
75
|
-
|
|
74
|
+
)(logFunction, preferences);
|
|
76
75
|
return {
|
|
77
76
|
...other,
|
|
78
77
|
variables: newVariablesWithCalculated,
|
|
@@ -94,30 +93,29 @@ export const buildNewValue =
|
|
|
94
93
|
|
|
95
94
|
// Separate methods to avoid perf issue on collect simplest use case
|
|
96
95
|
const getCollectedAndExternal = (preferences) => (variables) => {
|
|
97
|
-
const { COLLECTED } = variables;
|
|
96
|
+
const { COLLECTED, EXTERNAL } = variables;
|
|
98
97
|
if (preferences.length === 1 && preferences[0] === 'COLLECTED')
|
|
99
|
-
return getCollectedAndExternalSimple(COLLECTED);
|
|
100
|
-
return
|
|
98
|
+
return { ...getCollectedAndExternalSimple(COLLECTED), ...EXTERNAL };
|
|
99
|
+
return {
|
|
100
|
+
...getCollectedAndExternalByPreferences(preferences)(COLLECTED),
|
|
101
|
+
...EXTERNAL,
|
|
102
|
+
};
|
|
101
103
|
};
|
|
102
104
|
|
|
103
|
-
const getCollectedAndExternalSimple = (variables) =>
|
|
104
|
-
|
|
105
|
+
const getCollectedAndExternalSimple = (variables) =>
|
|
106
|
+
Object.entries(variables).reduce(
|
|
105
107
|
(acc, [k, { values }]) => ({ ...acc, [k]: values.COLLECTED }),
|
|
106
108
|
{}
|
|
107
109
|
);
|
|
108
|
-
return { ...collected, ...variables.EXTERNAL };
|
|
109
|
-
};
|
|
110
110
|
|
|
111
|
-
const getCollectedAndExternalByPreferences = (preferences) => (variables) =>
|
|
112
|
-
|
|
111
|
+
const getCollectedAndExternalByPreferences = (preferences) => (variables) =>
|
|
112
|
+
Object.entries(variables).reduce((acc, [k, { values }]) => {
|
|
113
113
|
const v = preferences.reduce((acc, p) => {
|
|
114
114
|
const value = values[p];
|
|
115
115
|
return [null, ''].includes(value) ? acc : value;
|
|
116
116
|
}, null);
|
|
117
117
|
return { ...acc, [k]: v };
|
|
118
118
|
}, {});
|
|
119
|
-
return { ...collected, ...variables.EXTERNAL };
|
|
120
|
-
};
|
|
121
119
|
|
|
122
120
|
const addCalculatedVars =
|
|
123
121
|
(variables, updatedValues) => (logFunction, preferences) => {
|