@inseefr/lunatic 0.3.4-experimental → 0.3.7-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.
Files changed (85) hide show
  1. package/lib/index.js +2 -2
  2. package/lib/index.js.map +1 -1
  3. package/package.json +2 -1
  4. package/src/components/breadcrumb/component.js +29 -29
  5. package/src/components/button/component.js +53 -53
  6. package/src/components/button/index.js +1 -1
  7. package/src/components/checkbox/index.js +3 -3
  8. package/src/components/datepicker/index.js +1 -1
  9. package/src/components/declarations/index.js +1 -1
  10. package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
  11. package/src/components/filter-description/component.js +42 -42
  12. package/src/components/icon/component.js +33 -33
  13. package/src/components/index.js +2 -0
  14. package/src/components/input/index.js +2 -2
  15. package/src/components/loop/index.js +1 -1
  16. package/src/components/loop-constructor/wrapper/body-component.js +13 -1
  17. package/src/components/radio/index.js +1 -1
  18. package/src/components/sequence/index.js +1 -1
  19. package/src/components/subsequence/index.js +1 -1
  20. package/src/components/suggester/check-store.js +70 -70
  21. package/src/components/suggester/components/create-on-keydown-callback.js +28 -28
  22. package/src/components/tooltip/response.js +52 -52
  23. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  24. package/src/stories/checkbox-group/data-vtl.json +102 -102
  25. package/src/stories/icons/icons.stories.js +16 -16
  26. package/src/stories/questionnaire/kish.json +275 -0
  27. package/src/stories/questionnaire/questionnaire.stories.js +12 -0
  28. package/src/stories/utils/custom-lunatic.scss +23 -23
  29. package/src/tests/components/breadcrumb.spec.js +13 -13
  30. package/src/tests/components/button.spec.js +11 -11
  31. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  32. package/src/tests/components/checkbox-group.spec.js +53 -53
  33. package/src/tests/components/checkbox-one.spec.js +32 -32
  34. package/src/tests/components/datepicker.spec.js +22 -22
  35. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  36. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  37. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  38. package/src/tests/components/declarations.spec.js +46 -46
  39. package/src/tests/components/input.spec.js +18 -18
  40. package/src/tests/components/loops/loop-static.json +66 -66
  41. package/src/tests/components/loops/loop.json +258 -258
  42. package/src/tests/components/loops/loop.spec.js +30 -30
  43. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  44. package/src/tests/components/progress-bar.spec.js +15 -15
  45. package/src/tests/components/radio.spec.js +27 -27
  46. package/src/tests/components/sequence.spec.js +9 -9
  47. package/src/tests/components/subsequence.spec.js +9 -9
  48. package/src/tests/components/table.spec.js +11 -11
  49. package/src/tests/components/textarea.spec.js +18 -18
  50. package/src/tests/components/tooltip.spec.js +25 -25
  51. package/src/tests/setup/setupTests.js +4 -4
  52. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  53. package/src/tests/utils/lib/array.spec.js +22 -22
  54. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  55. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  56. package/src/tests/utils/lib/input-number.spec.js +18 -18
  57. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  58. package/src/tests/utils/lib/label-position.spec.js +22 -22
  59. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  60. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  61. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  62. package/src/tests/utils/lib/missing/mock.js +137 -137
  63. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  64. package/src/tests/utils/lib/responses.spec.js +64 -64
  65. package/src/tests/utils/lib/style.spec.js +26 -26
  66. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  67. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  68. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  69. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  70. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  71. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  72. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  73. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  74. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  75. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  76. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  77. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  78. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  79. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  80. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  81. package/src/tests/utils/to-expose/state/results.js +78 -78
  82. package/src/utils/lib/tooltip/build-response.js +41 -41
  83. package/src/utils/store-tools/create/index.js +1 -1
  84. package/src/utils/store-tools/create/update-store-info.js +26 -26
  85. package/src/utils/store-tools/index.js +5 -5
@@ -1,46 +1,46 @@
1
- import { renderHook, act } from '@testing-library/react-hooks';
2
- import useLunatic from 'utils/to-expose/hooks/lunatic';
3
- import source from '../init-questionnaire/questionnaire';
4
-
5
- describe('useLunatic', () => {
6
- it('with pagination', () => {
7
- const { result } = renderHook(() =>
8
- useLunatic(source, {}, { features: ['VTL', 'MD'], pagination: true })
9
- );
10
- const {
11
- current: {
12
- components,
13
- pagination: { page, goNext, goPrevious },
14
- },
15
- } = result;
16
- expect(components.length).toEqual(2);
17
- expect(page).toEqual('1');
18
-
19
- act(() => {
20
- goNext();
21
- });
22
-
23
- expect(components.length).toEqual(2);
24
- expect(page).toEqual('1');
25
-
26
- act(() => {
27
- goPrevious();
28
- });
29
-
30
- expect(components.length).toEqual(2);
31
- expect(page).toEqual('1');
32
- });
33
- it('with custom props', () => {
34
- renderHook(() =>
35
- useLunatic(
36
- source,
37
- {},
38
- {
39
- management: true,
40
- savingType: 'EDITED',
41
- preferences: ['COLLECTED', 'EDITED'],
42
- }
43
- )
44
- );
45
- });
46
- });
1
+ import { renderHook, act } from '@testing-library/react-hooks';
2
+ import useLunatic from 'utils/to-expose/hooks/lunatic';
3
+ import source from '../init-questionnaire/questionnaire';
4
+
5
+ describe('useLunatic', () => {
6
+ it('with pagination', () => {
7
+ const { result } = renderHook(() =>
8
+ useLunatic(source, {}, { features: ['VTL', 'MD'], pagination: true })
9
+ );
10
+ const {
11
+ current: {
12
+ components,
13
+ pagination: { page, goNext, goPrevious },
14
+ },
15
+ } = result;
16
+ expect(components.length).toEqual(2);
17
+ expect(page).toEqual('1');
18
+
19
+ act(() => {
20
+ goNext();
21
+ });
22
+
23
+ expect(components.length).toEqual(2);
24
+ expect(page).toEqual('1');
25
+
26
+ act(() => {
27
+ goPrevious();
28
+ });
29
+
30
+ expect(components.length).toEqual(2);
31
+ expect(page).toEqual('1');
32
+ });
33
+ it('with custom props', () => {
34
+ renderHook(() =>
35
+ useLunatic(
36
+ source,
37
+ {},
38
+ {
39
+ management: true,
40
+ savingType: 'EDITED',
41
+ preferences: ['COLLECTED', 'EDITED'],
42
+ }
43
+ )
44
+ );
45
+ });
46
+ });
@@ -1,12 +1,12 @@
1
- {
2
- "COLLECTED": {
3
- "inputOk": { "COLLECTED": "Hello" },
4
- "check1": { "COLLECTED": true },
5
- "check2": { "COLLECTED": false, "FORCED": true },
6
- "table11": { "COLLECTED": "1" },
7
- "Roster": { "COLLECTED": ["ok"] }
8
- },
9
- "EXTERNAL": {
10
- "VAR_EXTERNAL": "Value VAR_EXTERNAL"
11
- }
12
- }
1
+ {
2
+ "COLLECTED": {
3
+ "inputOk": { "COLLECTED": "Hello" },
4
+ "check1": { "COLLECTED": true },
5
+ "check2": { "COLLECTED": false, "FORCED": true },
6
+ "table11": { "COLLECTED": "1" },
7
+ "Roster": { "COLLECTED": ["ok"] }
8
+ },
9
+ "EXTERNAL": {
10
+ "VAR_EXTERNAL": "Value VAR_EXTERNAL"
11
+ }
12
+ }
@@ -1,19 +1,19 @@
1
- import * as I from 'utils/to-expose/init-questionnaire';
2
- import questionnaire from './questionnaire';
3
- import data from './data';
4
- import result from './result';
5
-
6
- describe('init-questionnaire', () => {
7
- describe('mergeQuestionnaireAndData', () => {
8
- it('should return default', () => {
9
- expect(I.mergeQuestionnaireAndData()()).toEqual({});
10
- expect(I.mergeQuestionnaireAndData({})({})).toEqual({});
11
- expect(I.mergeQuestionnaireAndData({ components: [] })({})).toEqual({
12
- components: [],
13
- });
14
- });
15
- it('should return filled questionnaire', () => {
16
- expect(I.mergeQuestionnaireAndData(questionnaire)(data)).toEqual(result);
17
- });
18
- });
19
- });
1
+ import * as I from 'utils/to-expose/init-questionnaire';
2
+ import questionnaire from './questionnaire';
3
+ import data from './data';
4
+ import result from './result';
5
+
6
+ describe('init-questionnaire', () => {
7
+ describe('mergeQuestionnaireAndData', () => {
8
+ it('should return default', () => {
9
+ expect(I.mergeQuestionnaireAndData()()).toEqual({});
10
+ expect(I.mergeQuestionnaireAndData({})({})).toEqual({});
11
+ expect(I.mergeQuestionnaireAndData({ components: [] })({})).toEqual({
12
+ components: [],
13
+ });
14
+ });
15
+ it('should return filled questionnaire', () => {
16
+ expect(I.mergeQuestionnaireAndData(questionnaire)(data)).toEqual(result);
17
+ });
18
+ });
19
+ });
@@ -1,48 +1,48 @@
1
- import { interpret } from 'utils/to-expose/interpret';
2
-
3
- describe('interpret', () => {
4
- describe('interpretVTL', () => {
5
- it('should return empty label', () => {
6
- expect(interpret()()()).toEqual('');
7
- });
8
- it('should return empty label', () => {
9
- expect(interpret({})()()).toEqual('');
10
- });
11
- it('should return the same label', () => {
12
- expect(interpret([])({})('label')).toEqual('label');
13
- });
14
- it('should return VTL interpreted label', () => {
15
- expect(interpret(['VTL'])({ NAME: 'Mauro' })('"Hello " || NAME')).toEqual(
16
- 'Hello Mauro'
17
- );
18
- });
19
- it('should return VTL interpreted label with default value', () => {
20
- expect(interpret(['VTL'])({ NAME: null })('"Hello " || NAME')).toEqual(
21
- 'Hello null'
22
- );
23
- });
24
- });
25
- describe('interpretVTLMD', () => {
26
- it('should return empty label', () => {
27
- expect(interpret()()()).toEqual('');
28
- });
29
- it('should return empty label', () => {
30
- expect(interpret({})()()).toEqual('');
31
- });
32
- it('should return the same label', () => {
33
- expect(interpret([])({})('label')).toEqual('label');
34
- });
35
- it('should return VTL interpreted label', () => {
36
- expect(
37
- interpret(['VTL', 'MD'])({ NAME: 'Mauro' })('"Hello " || NAME').props
38
- .source
39
- ).toEqual('Hello Mauro');
40
- });
41
- it('should return VTL interpreted label with default value', () => {
42
- expect(
43
- interpret(['VTL', 'MD'])({ NAME: null })('"Hello " || NAME').props
44
- .source
45
- ).toEqual('Hello null');
46
- });
47
- });
48
- });
1
+ import { interpret } from 'utils/to-expose/interpret';
2
+
3
+ describe('interpret', () => {
4
+ describe('interpretVTL', () => {
5
+ it('should return empty label', () => {
6
+ expect(interpret()()()).toEqual('');
7
+ });
8
+ it('should return empty label', () => {
9
+ expect(interpret({})()()).toEqual('');
10
+ });
11
+ it('should return the same label', () => {
12
+ expect(interpret([])({})('label')).toEqual('label');
13
+ });
14
+ it('should return VTL interpreted label', () => {
15
+ expect(interpret(['VTL'])({ NAME: 'Mauro' })('"Hello " || NAME')).toEqual(
16
+ 'Hello Mauro'
17
+ );
18
+ });
19
+ it('should return VTL interpreted label with default value', () => {
20
+ expect(interpret(['VTL'])({ NAME: null })('"Hello " || NAME')).toEqual(
21
+ 'Hello null'
22
+ );
23
+ });
24
+ });
25
+ describe('interpretVTLMD', () => {
26
+ it('should return empty label', () => {
27
+ expect(interpret()()()).toEqual('');
28
+ });
29
+ it('should return empty label', () => {
30
+ expect(interpret({})()()).toEqual('');
31
+ });
32
+ it('should return the same label', () => {
33
+ expect(interpret([])({})('label')).toEqual('label');
34
+ });
35
+ it('should return VTL interpreted label', () => {
36
+ expect(
37
+ interpret(['VTL', 'MD'])({ NAME: 'Mauro' })('"Hello " || NAME').props
38
+ .source
39
+ ).toEqual('Hello Mauro');
40
+ });
41
+ it('should return VTL interpreted label with default value', () => {
42
+ expect(
43
+ interpret(['VTL', 'MD'])({ NAME: null })('"Hello " || NAME').props
44
+ .source
45
+ ).toEqual('Hello null');
46
+ });
47
+ });
48
+ });
@@ -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,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;