orc-shared 5.9.1-dev.0 → 5.10.0-dev.10

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 (109) hide show
  1. package/dist/actions/requestsApi.js +160 -6791
  2. package/dist/components/AppFrame/Preferences.js +46 -45
  3. package/dist/components/ColumnWrapper.js +28 -5
  4. package/dist/components/DropMenu/Menu.js +79 -45
  5. package/dist/components/DropMenu/index.js +34 -29
  6. package/dist/components/Form/Combination.js +45 -16
  7. package/dist/components/Form/Field.js +57 -38
  8. package/dist/components/Form/FieldElements.js +0 -11
  9. package/dist/components/Form/Fieldset.js +47 -19
  10. package/dist/components/Form/Form.js +22 -9
  11. package/dist/components/Form/FormElement.js +40 -7
  12. package/dist/components/Form/Inputs/Button.js +63 -18
  13. package/dist/components/Form/Inputs/ReadOnly.js +50 -27
  14. package/dist/components/Form/Inputs/Selector.js +81 -0
  15. package/dist/components/Form/Inputs/Text.js +20 -37
  16. package/dist/components/Form/Inputs/Toggles.js +39 -40
  17. package/dist/components/Form/Inputs/index.js +2 -13
  18. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
  19. package/dist/components/MaterialUI/DataDisplay/Table.js +83 -18
  20. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
  21. package/dist/components/MaterialUI/Inputs/Select.js +2 -0
  22. package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
  23. package/dist/components/MaterialUI/muiThemes.js +2 -1
  24. package/dist/constants.js +2 -1
  25. package/dist/hocs/withScrollBox.js +27 -12
  26. package/dist/hooks/useInMemoryPaging.js +139 -0
  27. package/dist/selectors/locale.js +1 -0
  28. package/dist/selectors/metadata.js +16 -1
  29. package/dist/utils/ListHelper.js +271 -0
  30. package/dist/utils/comparisonHelper.js +176 -0
  31. package/dist/utils/propertyBagHelper.js +3 -1
  32. package/package.json +3 -3
  33. package/src/actions/requestsApi.js +123 -4727
  34. package/src/components/AppFrame/AppFrame.test.js +6 -19
  35. package/src/components/AppFrame/Preferences.js +30 -29
  36. package/src/components/AppFrame/Preferences.test.js +108 -206
  37. package/src/components/AppFrame/Topbar.test.js +3 -10
  38. package/src/components/ColumnWrapper.js +18 -9
  39. package/src/components/DropMenu/DropMenu.test.js +185 -224
  40. package/src/components/DropMenu/Menu.js +73 -80
  41. package/src/components/DropMenu/Menu.test.js +35 -86
  42. package/src/components/DropMenu/index.js +19 -15
  43. package/src/components/Form/Combination.js +35 -28
  44. package/src/components/Form/Combination.test.js +6 -19
  45. package/src/components/Form/Field.js +53 -66
  46. package/src/components/Form/Field.test.js +29 -51
  47. package/src/components/Form/FieldElements.js +0 -14
  48. package/src/components/Form/FieldElements.test.js +104 -111
  49. package/src/components/Form/Fieldset.js +42 -37
  50. package/src/components/Form/Fieldset.test.js +14 -7
  51. package/src/components/Form/Form.js +11 -7
  52. package/src/components/Form/Form.test.js +75 -56
  53. package/src/components/Form/FormElement.js +24 -16
  54. package/src/components/Form/InputField.test.js +24 -30
  55. package/src/components/Form/Inputs/Button.js +58 -14
  56. package/src/components/Form/Inputs/Button.test.js +32 -7
  57. package/src/components/Form/Inputs/Inputs.test.js +0 -7
  58. package/src/components/Form/Inputs/ReadOnly.js +34 -28
  59. package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
  60. package/src/components/Form/Inputs/Selector.js +22 -0
  61. package/src/components/Form/Inputs/Selector.test.js +105 -0
  62. package/src/components/Form/Inputs/Text.js +15 -44
  63. package/src/components/Form/Inputs/Text.test.js +20 -29
  64. package/src/components/Form/Inputs/Toggles.js +27 -26
  65. package/src/components/Form/Inputs/Toggles.test.js +22 -28
  66. package/src/components/Form/Inputs/index.js +4 -15
  67. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
  68. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
  69. package/src/components/MaterialUI/DataDisplay/Table.js +165 -114
  70. package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
  71. package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
  72. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  73. package/src/components/MaterialUI/Inputs/Select.js +2 -0
  74. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  75. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  76. package/src/components/MaterialUI/muiThemes.js +1 -0
  77. package/src/components/Navigation/Bar.test.js +92 -87
  78. package/src/constants.js +1 -0
  79. package/src/hocs/withScrollBox.js +32 -19
  80. package/src/hocs/withScrollBox.test.js +15 -3
  81. package/src/hooks/useInMemoryPaging.js +85 -0
  82. package/src/hooks/useInMemoryPaging.test.js +551 -0
  83. package/src/requests +34 -0
  84. package/src/selectors/locale.js +1 -1
  85. package/src/selectors/metadata.js +18 -1
  86. package/src/selectors/metadata.test.js +104 -0
  87. package/src/utils/ListHelper.js +203 -0
  88. package/src/utils/ListHelper.test.js +710 -0
  89. package/src/utils/comparisonHelper.js +124 -0
  90. package/src/utils/comparisonHelper.test.js +324 -0
  91. package/src/utils/propertyBagHelper.js +2 -0
  92. package/src/utils/propertyBagHelper.test.js +6 -0
  93. package/dist/components/Form/FieldList.js +0 -270
  94. package/dist/components/Form/Inputs/FieldButtons.js +0 -66
  95. package/dist/components/Form/Inputs/Number.js +0 -117
  96. package/dist/components/Form/Inputs/SmallButton.js +0 -91
  97. package/dist/components/Form/Inputs/Time.js +0 -86
  98. package/dist/components/Form/Inputs/Translation.js +0 -169
  99. package/src/components/Form/FieldList.js +0 -210
  100. package/src/components/Form/FieldList.test.js +0 -558
  101. package/src/components/Form/Inputs/FieldButtons.js +0 -90
  102. package/src/components/Form/Inputs/Number.js +0 -60
  103. package/src/components/Form/Inputs/Number.test.js +0 -435
  104. package/src/components/Form/Inputs/SmallButton.js +0 -37
  105. package/src/components/Form/Inputs/SmallButton.test.js +0 -65
  106. package/src/components/Form/Inputs/Time.js +0 -32
  107. package/src/components/Form/Inputs/Time.test.js +0 -41
  108. package/src/components/Form/Inputs/Translation.js +0 -93
  109. package/src/components/Form/Inputs/Translation.test.js +0 -204
@@ -31,6 +31,7 @@ import {
31
31
  lookupByNameSelector,
32
32
  mappedLookupsListSelector,
33
33
  lookupExistAndIsActiveSelector,
34
+ namedLookupsValuesSelector,
34
35
  } from "./metadata";
35
36
 
36
37
  const lookups = {
@@ -409,6 +410,109 @@ describe("namedLookupValuesSelector", () => {
409
410
  });
410
411
  });
411
412
 
413
+ describe("namedLookupsValuesSelector", () => {
414
+ let state;
415
+ beforeEach(() => {
416
+ state = Immutable.fromJS({
417
+ locale: { locale: "it-IT" },
418
+ metadata: {
419
+ lookups: {
420
+ order: {
421
+ index: {
422
+ CanceledStatusReasons: {
423
+ lookupName: "CanceledStatusReasons",
424
+ values: {
425
+ CanceledReason1: {
426
+ id: "e16d07f847284775b77cfb985724cf58",
427
+ value: "CanceledReason1",
428
+ lookupId: "CanceledStatusReasons",
429
+ sortOrder: 0,
430
+ isActive: true,
431
+ isSystem: true,
432
+ displayName: {
433
+ "en-CA": "Cancel for reason 1",
434
+ "en-US": "Cancel for reason 1",
435
+ "fr-CA": "Annulé pour raison 1",
436
+ "it-IT": "Annulla per motivo 1",
437
+ },
438
+ },
439
+ CanceledReason2: {
440
+ id: "6bbfe77703c745d68b8eaceb9cd484b1",
441
+ value: "CanceledReason2",
442
+ lookupId: "CanceledStatusReasons",
443
+ sortOrder: 0,
444
+ isActive: true,
445
+ isSystem: true,
446
+ displayName: {
447
+ "en-CA": "Cancel for reason 2",
448
+ "en-US": "Cancel for reason 2",
449
+ "fr-CA": "Annulé pour raison 2",
450
+ "it-IT": "Annulla per motivo 2",
451
+ },
452
+ },
453
+ },
454
+ isActive: true,
455
+ isSystem: true,
456
+ },
457
+ CartStatus: {
458
+ lookupName: "CartStatus",
459
+ values: {},
460
+ isActive: true,
461
+ isSystem: true,
462
+ },
463
+ },
464
+ list: [],
465
+ },
466
+ },
467
+ },
468
+ });
469
+ });
470
+
471
+ it("gets the value list for multiple named lookups", () =>
472
+ expect(
473
+ namedLookupsValuesSelector,
474
+ "when called with",
475
+ ["order", ["CanceledStatusReasons", "CartStatus"]],
476
+ "when called with",
477
+ [state],
478
+ "to satisfy",
479
+ Immutable.fromJS({
480
+ CanceledStatusReasons: {
481
+ CanceledReason1: {
482
+ id: "e16d07f847284775b77cfb985724cf58",
483
+ value: "CanceledReason1",
484
+ lookupId: "CanceledStatusReasons",
485
+ sortOrder: 0,
486
+ isActive: true,
487
+ isSystem: true,
488
+ displayName: "Annulla per motivo 1",
489
+ },
490
+ CanceledReason2: {
491
+ id: "6bbfe77703c745d68b8eaceb9cd484b1",
492
+ value: "CanceledReason2",
493
+ lookupId: "CanceledStatusReasons",
494
+ sortOrder: 0,
495
+ isActive: true,
496
+ isSystem: true,
497
+ displayName: "Annulla per motivo 2",
498
+ },
499
+ },
500
+ CartStatus: {},
501
+ }),
502
+ ));
503
+
504
+ it("will get an empty Map if lookup does not exist", () =>
505
+ expect(
506
+ namedLookupsValuesSelector,
507
+ "when called with",
508
+ ["order", ["NotALookup"]],
509
+ "when called with",
510
+ [state],
511
+ "to equal",
512
+ Immutable.fromJS({}),
513
+ ));
514
+ });
515
+
412
516
  describe("selectCurrentLookupDetails", () => {
413
517
  let state;
414
518
  beforeEach(() => {
@@ -0,0 +1,203 @@
1
+ import Immutable from "immutable";
2
+ import { isObject } from "lodash";
3
+
4
+ export const ListInfoPropertyName = "listInfo";
5
+
6
+ const standardInfoKeys = ["scope", "page", "filters", "sorting", "totalCount", "nextPageToLoad", "index", "list"];
7
+
8
+ class ListReducerHelper {
9
+ constructor(groupPropertyName) {
10
+ this.groupPropertyName = groupPropertyName;
11
+ }
12
+
13
+ setNextPageToLoad = (state, nextPageToLoad) => {
14
+ return state.setIn([this.groupPropertyName, "nextPageToLoad"], nextPageToLoad);
15
+ };
16
+
17
+ setResults = (state, listInfo, forceReset = false) => {
18
+ return state.withMutations(s => {
19
+ const page = s.getIn([this.groupPropertyName, "nextPageToLoad"]);
20
+
21
+ const entities = Immutable.fromJS(listInfo.indexEntities || {});
22
+ if (page === 1 || forceReset) {
23
+ s.setIn([this.groupPropertyName, "index"], entities);
24
+ s.setIn([this.groupPropertyName, "list"], Immutable.fromJS(listInfo.listEntities));
25
+ } else {
26
+ s.mergeIn([this.groupPropertyName, "index"], entities);
27
+ s.setIn(
28
+ [this.groupPropertyName, "list"],
29
+ s.getIn([this.groupPropertyName, "list"]).concat(Immutable.fromJS(listInfo.listEntities)),
30
+ );
31
+ }
32
+
33
+ s.setIn([this.groupPropertyName, "totalCount"], listInfo.totalCount);
34
+ });
35
+ };
36
+
37
+ setCurrentInfo = (state, { resetList, scope, filters, sorting, ...others } = {}) => {
38
+ return state.withMutations(s => {
39
+ if (resetList) {
40
+ s.setIn([this.groupPropertyName, "nextPageToLoad"], 1);
41
+ s.setIn([this.groupPropertyName, "page"], null);
42
+ s.setIn([this.groupPropertyName, "index"], Immutable.fromJS({}));
43
+ s.setIn([this.groupPropertyName, "list"], Immutable.fromJS([]));
44
+ s.setIn([this.groupPropertyName, "totalCount"], 0);
45
+ } else {
46
+ const nextPageToLoad = state.getIn([this.groupPropertyName, "nextPageToLoad"]);
47
+ s.setIn([this.groupPropertyName, "nextPageToLoad"], nextPageToLoad);
48
+ s.setIn([this.groupPropertyName, "page"], nextPageToLoad);
49
+ }
50
+
51
+ s.setIn([this.groupPropertyName, "scope"], scope ?? null);
52
+ s.setIn([this.groupPropertyName, "filters"], Immutable.fromJS(filters ?? null));
53
+ s.setIn([this.groupPropertyName, "sorting"], Immutable.fromJS(sorting ?? null));
54
+
55
+ const otherKeys = Object.keys(others);
56
+
57
+ s.get(this.groupPropertyName)
58
+ .keySeq()
59
+ .forEach(key => {
60
+ if (!standardInfoKeys.includes(key) && !otherKeys.includes(key)) {
61
+ s.removeIn([this.groupPropertyName, key]);
62
+ }
63
+ });
64
+
65
+ otherKeys.forEach(key => {
66
+ s.setIn([this.groupPropertyName, key], isObject(others[key]) ? Immutable.fromJS(others[key]) : others[key]);
67
+ });
68
+ });
69
+ };
70
+
71
+ addIndexWithMutations = (mutator, id, value) => {
72
+ mutator.setIn([this.groupPropertyName, "index", id], Immutable.fromJS(value));
73
+ };
74
+
75
+ appendIdToListWithMutations = (mutator, id) => {
76
+ mutator.setIn([this.groupPropertyName, "list"], mutator.getIn([this.groupPropertyName, "list"]).push(id));
77
+ };
78
+
79
+ updateIndexWithMutations = (mutator, id, value) => {
80
+ const key = [this.groupPropertyName, "index", id];
81
+ if (mutator.getIn(key)) {
82
+ mutator.setIn(key, Immutable.fromJS(value));
83
+ }
84
+ };
85
+
86
+ removeFromIndexWithMutations = (mutator, id) => {
87
+ mutator.removeIn([this.groupPropertyName, "index", id]);
88
+ };
89
+
90
+ resetListInfo = (state, propertiesToKeep = {}) => {
91
+ let updatedState = state
92
+ .setIn([this.groupPropertyName, "nextPageToLoad"], 1)
93
+ .setIn([this.groupPropertyName, "index"], Immutable.fromJS({}))
94
+ .setIn([this.groupPropertyName, "list"], Immutable.fromJS([]))
95
+ .setIn([this.groupPropertyName, "totalCount"], 0);
96
+
97
+ if (!propertiesToKeep.filters) {
98
+ updatedState = updatedState.setIn([this.groupPropertyName, "filters"], null);
99
+ }
100
+
101
+ if (!propertiesToKeep.sorting) {
102
+ updatedState = updatedState.setIn([this.groupPropertyName, "sorting"], null);
103
+ }
104
+
105
+ if (!propertiesToKeep.scope) {
106
+ updatedState = updatedState.setIn([this.groupPropertyName, "scope"], null);
107
+ }
108
+
109
+ if (!propertiesToKeep.page) {
110
+ updatedState = updatedState.setIn([this.groupPropertyName, "page"], null);
111
+ }
112
+
113
+ return updatedState;
114
+ };
115
+ }
116
+
117
+ class ListSelectorHelper {
118
+ constructor(groupPropertyName) {
119
+ this.groupPropertyName = groupPropertyName;
120
+ }
121
+
122
+ getCurrentInfo = state => {
123
+ const listInfo = state.get(this.groupPropertyName) || Immutable.Map();
124
+
125
+ const info = {
126
+ currentScope: listInfo.get("scope"),
127
+ currentPage: listInfo.get("page"),
128
+ currentFilters: listInfo.get("filters")?.toJS(),
129
+ currentSorting: listInfo.get("sorting")?.toJS(),
130
+ totalCount: listInfo.get("totalCount"),
131
+ };
132
+
133
+ listInfo.mapKeys((key, value) => {
134
+ if (standardInfoKeys.includes(key)) {
135
+ // standard key, nothing to do
136
+ } else {
137
+ info[key] = value?.toJS ? value.toJS() : value;
138
+ }
139
+ });
140
+
141
+ return info;
142
+ };
143
+
144
+ getIndex = state => {
145
+ return state.getIn([this.groupPropertyName, "index"]);
146
+ };
147
+
148
+ getList = state => {
149
+ return state.getIn([this.groupPropertyName, "list"]);
150
+ };
151
+
152
+ getNextPageToLoad = state => {
153
+ return state.getIn([this.groupPropertyName, "nextPageToLoad"]);
154
+ };
155
+ }
156
+
157
+ class ListHelper {
158
+ constructor(groupPropertyName = ListInfoPropertyName) {
159
+ this.groupPropertyName = groupPropertyName;
160
+ this.reducer = new ListReducerHelper(this.groupPropertyName);
161
+ this.selector = new ListSelectorHelper(this.groupPropertyName);
162
+ }
163
+
164
+ static defaultInstance = new ListHelper();
165
+ static reducer = ListHelper.defaultInstance.reducer;
166
+ static selector = ListHelper.defaultInstance.selector;
167
+ static createInitialListInfo = ListHelper.defaultInstance.createInitialListInfo;
168
+ static createListInfoFrom = ListHelper.defaultInstance.createListInfoFrom;
169
+
170
+ createInitialListInfo = (additionalValues = null) => {
171
+ return this.createListInfoFrom({
172
+ ...additionalValues,
173
+ });
174
+ };
175
+
176
+ createListInfoFrom = ({
177
+ sorting,
178
+ filters,
179
+ scope,
180
+ page,
181
+ nextPageToLoad,
182
+ index,
183
+ list,
184
+ totalCount,
185
+ ...additionalValues
186
+ } = {}) => {
187
+ return {
188
+ [this.groupPropertyName]: {
189
+ sorting: sorting ?? null,
190
+ filters: filters ?? null,
191
+ scope: scope ?? null,
192
+ page: page ?? null,
193
+ nextPageToLoad: nextPageToLoad ?? 1,
194
+ index: index ?? {},
195
+ list: list ?? [],
196
+ totalCount: totalCount ?? 0,
197
+ ...additionalValues,
198
+ },
199
+ };
200
+ };
201
+ }
202
+
203
+ export default ListHelper;