orc-shared 5.10.1-dev.3 → 5.10.1-dev.4

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.
@@ -6,7 +6,7 @@ var _immutable = _interopRequireDefault(require("immutable"));
6
6
  var _lodash = require("lodash");
7
7
  var _ListHelper;
8
8
  var _excluded = ["resetList", "scope", "filters", "sorting"],
9
- _excluded2 = ["sorting", "filters", "scope", "page", "nextPageToLoad", "index", "list", "totalCount"];
9
+ _excluded2 = ["sorting", "filters", "scope", "page", "nextPageToLoad", "index", "list", "totalCount", "searchRequested"];
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  (function () {
12
12
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
@@ -30,13 +30,16 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
30
30
  return a;
31
31
  };
32
32
  var ListInfoPropertyName = exports.ListInfoPropertyName = "listInfo";
33
- var standardInfoKeys = ["scope", "page", "filters", "sorting", "totalCount", "nextPageToLoad", "index", "list"];
33
+ var standardInfoKeys = ["scope", "page", "filters", "sorting", "totalCount", "nextPageToLoad", "index", "list", "searchRequested"];
34
34
  var ListReducerHelper = /*#__PURE__*/function () {
35
35
  function ListReducerHelper(groupPropertyName) {
36
36
  var _this = this;
37
37
  _defineProperty(this, "setNextPageToLoad", function (state, nextPageToLoad) {
38
38
  return state.setIn([_this.groupPropertyName, "nextPageToLoad"], nextPageToLoad);
39
39
  });
40
+ _defineProperty(this, "setSearchRequested", function (state, searchRequested) {
41
+ return state.setIn([_this.groupPropertyName, "searchRequested"], searchRequested);
42
+ });
40
43
  _defineProperty(this, "setResults", function (state, listInfo, forceReset) {
41
44
  if (forceReset === void 0) {
42
45
  forceReset = false;
@@ -79,6 +82,7 @@ var ListReducerHelper = /*#__PURE__*/function () {
79
82
  s.setIn([_this.groupPropertyName, "scope"], scope != null ? scope : null);
80
83
  s.setIn([_this.groupPropertyName, "filters"], _immutable.default.fromJS(filters != null ? filters : null));
81
84
  s.setIn([_this.groupPropertyName, "sorting"], _immutable.default.fromJS(sorting != null ? sorting : null));
85
+ s.setIn([_this.groupPropertyName, "searchRequested"], false);
82
86
  var otherKeys = Object.keys(others);
83
87
  s.get(_this.groupPropertyName).keySeq().forEach(function (key) {
84
88
  if (!standardInfoKeys.includes(key) && !otherKeys.includes(key)) {
@@ -109,7 +113,7 @@ var ListReducerHelper = /*#__PURE__*/function () {
109
113
  if (propertiesToKeep === void 0) {
110
114
  propertiesToKeep = {};
111
115
  }
112
- var updatedState = state.setIn([_this.groupPropertyName, "nextPageToLoad"], 1).setIn([_this.groupPropertyName, "index"], _immutable.default.fromJS({})).setIn([_this.groupPropertyName, "list"], _immutable.default.fromJS([])).setIn([_this.groupPropertyName, "totalCount"], 0);
116
+ var updatedState = state.setIn([_this.groupPropertyName, "nextPageToLoad"], 1).setIn([_this.groupPropertyName, "searchRequested"], false).setIn([_this.groupPropertyName, "index"], _immutable.default.fromJS({})).setIn([_this.groupPropertyName, "list"], _immutable.default.fromJS([])).setIn([_this.groupPropertyName, "totalCount"], 0);
113
117
  if (!propertiesToKeep.filters) {
114
118
  updatedState = updatedState.setIn([_this.groupPropertyName, "filters"], null);
115
119
  }
@@ -145,7 +149,8 @@ var ListSelectorHelper = /*#__PURE__*/function () {
145
149
  currentPage: listInfo.get("page"),
146
150
  currentFilters: (_listInfo$get = listInfo.get("filters")) == null ? void 0 : _listInfo$get.toJS(),
147
151
  currentSorting: (_listInfo$get2 = listInfo.get("sorting")) == null ? void 0 : _listInfo$get2.toJS(),
148
- totalCount: listInfo.get("totalCount")
152
+ totalCount: listInfo.get("totalCount"),
153
+ searchRequested: listInfo.get("searchRequested")
149
154
  };
150
155
  listInfo.mapKeys(function (key, value) {
151
156
  if (standardInfoKeys.includes(key)) {
@@ -165,6 +170,9 @@ var ListSelectorHelper = /*#__PURE__*/function () {
165
170
  _defineProperty(this, "getNextPageToLoad", function (state) {
166
171
  return state.getIn([_this2.groupPropertyName, "nextPageToLoad"]);
167
172
  });
173
+ _defineProperty(this, "getSearchRequested", function (state) {
174
+ return state.getIn([_this2.groupPropertyName, "searchRequested"]);
175
+ });
168
176
  this.groupPropertyName = groupPropertyName;
169
177
  }
170
178
  var _proto2 = ListSelectorHelper.prototype;
@@ -200,6 +208,7 @@ var ListHelper = /*#__PURE__*/function () {
200
208
  index = _ref4.index,
201
209
  list = _ref4.list,
202
210
  totalCount = _ref4.totalCount,
211
+ searchRequested = _ref4.searchRequested,
203
212
  additionalValues = _objectWithoutProperties(_ref4, _excluded2);
204
213
  return _defineProperty({}, _this3.groupPropertyName, _objectSpread({
205
214
  sorting: sorting != null ? sorting : null,
@@ -209,7 +218,8 @@ var ListHelper = /*#__PURE__*/function () {
209
218
  nextPageToLoad: nextPageToLoad != null ? nextPageToLoad : 1,
210
219
  index: index != null ? index : {},
211
220
  list: list != null ? list : [],
212
- totalCount: totalCount != null ? totalCount : 0
221
+ totalCount: totalCount != null ? totalCount : 0,
222
+ searchRequested: searchRequested != null ? searchRequested : false
213
223
  }, additionalValues));
214
224
  });
215
225
  this.groupPropertyName = groupPropertyName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.10.1-dev.3",
3
+ "version": "5.10.1-dev.4",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -3,7 +3,17 @@ import { isObject } from "lodash";
3
3
 
4
4
  export const ListInfoPropertyName = "listInfo";
5
5
 
6
- const standardInfoKeys = ["scope", "page", "filters", "sorting", "totalCount", "nextPageToLoad", "index", "list"];
6
+ const standardInfoKeys = [
7
+ "scope",
8
+ "page",
9
+ "filters",
10
+ "sorting",
11
+ "totalCount",
12
+ "nextPageToLoad",
13
+ "index",
14
+ "list",
15
+ "searchRequested",
16
+ ];
7
17
 
8
18
  class ListReducerHelper {
9
19
  constructor(groupPropertyName) {
@@ -14,6 +24,10 @@ class ListReducerHelper {
14
24
  return state.setIn([this.groupPropertyName, "nextPageToLoad"], nextPageToLoad);
15
25
  };
16
26
 
27
+ setSearchRequested = (state, searchRequested) => {
28
+ return state.setIn([this.groupPropertyName, "searchRequested"], searchRequested);
29
+ };
30
+
17
31
  setResults = (state, listInfo, forceReset = false) => {
18
32
  return state.withMutations(s => {
19
33
  const page = s.getIn([this.groupPropertyName, "nextPageToLoad"]);
@@ -51,6 +65,7 @@ class ListReducerHelper {
51
65
  s.setIn([this.groupPropertyName, "scope"], scope ?? null);
52
66
  s.setIn([this.groupPropertyName, "filters"], Immutable.fromJS(filters ?? null));
53
67
  s.setIn([this.groupPropertyName, "sorting"], Immutable.fromJS(sorting ?? null));
68
+ s.setIn([this.groupPropertyName, "searchRequested"], false);
54
69
 
55
70
  const otherKeys = Object.keys(others);
56
71
 
@@ -90,6 +105,7 @@ class ListReducerHelper {
90
105
  resetListInfo = (state, propertiesToKeep = {}) => {
91
106
  let updatedState = state
92
107
  .setIn([this.groupPropertyName, "nextPageToLoad"], 1)
108
+ .setIn([this.groupPropertyName, "searchRequested"], false)
93
109
  .setIn([this.groupPropertyName, "index"], Immutable.fromJS({}))
94
110
  .setIn([this.groupPropertyName, "list"], Immutable.fromJS([]))
95
111
  .setIn([this.groupPropertyName, "totalCount"], 0);
@@ -128,6 +144,7 @@ class ListSelectorHelper {
128
144
  currentFilters: listInfo.get("filters")?.toJS(),
129
145
  currentSorting: listInfo.get("sorting")?.toJS(),
130
146
  totalCount: listInfo.get("totalCount"),
147
+ searchRequested: listInfo.get("searchRequested"),
131
148
  };
132
149
 
133
150
  listInfo.mapKeys((key, value) => {
@@ -152,6 +169,10 @@ class ListSelectorHelper {
152
169
  getNextPageToLoad = state => {
153
170
  return state.getIn([this.groupPropertyName, "nextPageToLoad"]);
154
171
  };
172
+
173
+ getSearchRequested = state => {
174
+ return state.getIn([this.groupPropertyName, "searchRequested"]);
175
+ };
155
176
  }
156
177
 
157
178
  class ListHelper {
@@ -182,6 +203,7 @@ class ListHelper {
182
203
  index,
183
204
  list,
184
205
  totalCount,
206
+ searchRequested,
185
207
  ...additionalValues
186
208
  } = {}) => {
187
209
  return {
@@ -194,6 +216,7 @@ class ListHelper {
194
216
  index: index ?? {},
195
217
  list: list ?? [],
196
218
  totalCount: totalCount ?? 0,
219
+ searchRequested: searchRequested ?? false,
197
220
  ...additionalValues,
198
221
  },
199
222
  };
@@ -14,6 +14,7 @@ describe("createInitialListInfo", () => {
14
14
  index: {},
15
15
  list: [],
16
16
  totalCount: 0,
17
+ searchRequested: false,
17
18
  },
18
19
  });
19
20
  });
@@ -33,6 +34,7 @@ describe("createInitialListInfo", () => {
33
34
  index: {},
34
35
  list: [],
35
36
  totalCount: 0,
37
+ searchRequested: false,
36
38
  prop1: 123,
37
39
  prop2: { subprop: "a" },
38
40
  },
@@ -49,6 +51,7 @@ describe("createInitialListInfo", () => {
49
51
  index: { c: 1 },
50
52
  list: [1, 2, 3],
51
53
  totalCount: 10,
54
+ searchRequested: false,
52
55
  prop1: 123,
53
56
  prop2: { subprop: "a" },
54
57
  });
@@ -62,6 +65,7 @@ describe("createInitialListInfo", () => {
62
65
  index: { c: 1 },
63
66
  list: [1, 2, 3],
64
67
  totalCount: 10,
68
+ searchRequested: false,
65
69
  prop1: 123,
66
70
  prop2: { subprop: "a" },
67
71
  },
@@ -82,6 +86,7 @@ describe("createListInfoFrom", () => {
82
86
  index: {},
83
87
  list: [],
84
88
  totalCount: 0,
89
+ searchRequested: false,
85
90
  },
86
91
  });
87
92
  });
@@ -101,6 +106,7 @@ describe("createListInfoFrom", () => {
101
106
  index: {},
102
107
  list: [],
103
108
  totalCount: 0,
109
+ searchRequested: false,
104
110
  prop1: 123,
105
111
  prop2: { subprop: "a" },
106
112
  },
@@ -117,6 +123,7 @@ describe("createListInfoFrom", () => {
117
123
  index: { c: 1 },
118
124
  list: [1, 2, 3],
119
125
  totalCount: 10,
126
+ searchRequested: false,
120
127
  prop1: 123,
121
128
  prop2: { subprop: "a" },
122
129
  });
@@ -130,6 +137,7 @@ describe("createListInfoFrom", () => {
130
137
  index: { c: 1 },
131
138
  list: [1, 2, 3],
132
139
  totalCount: 10,
140
+ searchRequested: false,
133
141
  prop1: 123,
134
142
  prop2: { subprop: "a" },
135
143
  },
@@ -148,6 +156,7 @@ describe("ListSelectorHelper", () => {
148
156
  index: { c: 1 },
149
157
  list: [1, 2, 3],
150
158
  totalCount: 10,
159
+ searchRequested: true,
151
160
  prop1: 123,
152
161
  prop2: { subprop: "a" },
153
162
  }),
@@ -168,6 +177,11 @@ describe("ListSelectorHelper", () => {
168
177
  expect(value, "to equal", Immutable.fromJS({ c: 1 }));
169
178
  });
170
179
 
180
+ it("getSearchRequested", () => {
181
+ const value = ListHelper.selector.getSearchRequested(initialState);
182
+ expect(value, "to equal", true);
183
+ });
184
+
171
185
  it("getCurrentInfo", () => {
172
186
  const value = ListHelper.selector.getCurrentInfo(initialState);
173
187
  expect(value, "to equal", {
@@ -176,6 +190,7 @@ describe("ListSelectorHelper", () => {
176
190
  currentScope: "canada",
177
191
  currentPage: 1,
178
192
  totalCount: 10,
193
+ searchRequested: true,
179
194
  prop1: 123,
180
195
  prop2: { subprop: "a" },
181
196
  });
@@ -191,6 +206,7 @@ describe("ListSelectorHelper", () => {
191
206
  currentScope: "canada",
192
207
  currentPage: 1,
193
208
  totalCount: 10,
209
+ searchRequested: true,
194
210
  prop1: 123,
195
211
  prop2: { subprop: "a" },
196
212
  });
@@ -204,6 +220,7 @@ describe("ListSelectorHelper", () => {
204
220
  currentScope: undefined,
205
221
  currentPage: undefined,
206
222
  totalCount: undefined,
223
+ searchRequested: undefined,
207
224
  });
208
225
  });
209
226
  });
@@ -219,6 +236,7 @@ describe("ListReducerHelper", () => {
219
236
  index: { c: 1 },
220
237
  list: [1, 2, 3],
221
238
  totalCount: 10,
239
+ searchRequested: false,
222
240
  prop1: 123,
223
241
  prop2: { subprop: "a" },
224
242
  }),
@@ -239,6 +257,30 @@ describe("ListReducerHelper", () => {
239
257
  index: { c: 1 },
240
258
  list: [1, 2, 3],
241
259
  totalCount: 10,
260
+ searchRequested: false,
261
+ prop1: 123,
262
+ prop2: { subprop: "a" },
263
+ }),
264
+ ),
265
+ );
266
+ });
267
+
268
+ it("setSearchRequested", () => {
269
+ const newState = ListHelper.reducer.setSearchRequested(initialState, true);
270
+ expect(
271
+ newState,
272
+ "to equal",
273
+ Immutable.fromJS(
274
+ ListHelper.createListInfoFrom({
275
+ sorting: { a: 1 },
276
+ filters: { b: 1 },
277
+ scope: "canada",
278
+ page: 1,
279
+ nextPageToLoad: 2,
280
+ index: { c: 1 },
281
+ list: [1, 2, 3],
282
+ totalCount: 10,
283
+ searchRequested: true,
242
284
  prop1: 123,
243
285
  prop2: { subprop: "a" },
244
286
  }),
@@ -269,6 +311,7 @@ describe("ListReducerHelper", () => {
269
311
  index: { d: 1 },
270
312
  list: [4, 5, 6],
271
313
  totalCount: 222,
314
+ searchRequested: undefined,
272
315
  prop1: 123,
273
316
  prop2: { subprop: "a" },
274
317
  }),
@@ -300,6 +343,7 @@ describe("ListReducerHelper", () => {
300
343
  index: {},
301
344
  list: [4, 5, 6],
302
345
  totalCount: 222,
346
+ searchRequested: undefined,
303
347
  prop1: 123,
304
348
  prop2: { subprop: "a" },
305
349
  }),
@@ -327,6 +371,7 @@ describe("ListReducerHelper", () => {
327
371
  index: { c: 1, d: 1 },
328
372
  list: [1, 2, 3, 4, 5, 6],
329
373
  totalCount: 222,
374
+ searchRequested: undefined,
330
375
  prop1: 123,
331
376
  prop2: { subprop: "a" },
332
377
  }),
@@ -354,6 +399,7 @@ describe("ListReducerHelper", () => {
354
399
  index: { d: 1 },
355
400
  list: [4, 5, 6],
356
401
  totalCount: 222,
402
+ searchRequested: undefined,
357
403
  prop1: 123,
358
404
  prop2: { subprop: "a" },
359
405
  }),
@@ -384,6 +430,7 @@ describe("ListReducerHelper", () => {
384
430
  index: {},
385
431
  list: [],
386
432
  totalCount: 0,
433
+ searchRequested: false,
387
434
  prop1: 456,
388
435
  prop2: { subprop: "b" },
389
436
  }),
@@ -414,6 +461,7 @@ describe("ListReducerHelper", () => {
414
461
  index: { c: 1 },
415
462
  list: [1, 2, 3],
416
463
  totalCount: 10,
464
+ searchRequested: false,
417
465
  prop1: 456,
418
466
  prop2: { subprop: "b" },
419
467
  }),
@@ -444,6 +492,7 @@ describe("ListReducerHelper", () => {
444
492
  index: { c: 1 },
445
493
  list: [1, 2, 3],
446
494
  totalCount: 10,
495
+ searchRequested: false,
447
496
  prop1: 456,
448
497
  prop3: 789,
449
498
  }),
@@ -472,6 +521,7 @@ describe("ListReducerHelper", () => {
472
521
  index: { c: 1 },
473
522
  list: [1, 2, 3],
474
523
  totalCount: 10,
524
+ searchRequested: false,
475
525
  }),
476
526
  ),
477
527
  );
@@ -500,6 +550,7 @@ describe("ListReducerHelper", () => {
500
550
  index: { c: 1 },
501
551
  list: [1, 2, 3],
502
552
  totalCount: 10,
553
+ searchRequested: false,
503
554
  prop1: 456,
504
555
  prop2: { subprop: "b" },
505
556
  }),
@@ -522,6 +573,7 @@ describe("ListReducerHelper", () => {
522
573
  index: { c: 1 },
523
574
  list: [1, 2, 3],
524
575
  totalCount: 10,
576
+ searchRequested: false,
525
577
  }),
526
578
  ),
527
579
  );
@@ -542,6 +594,7 @@ describe("ListReducerHelper", () => {
542
594
  index: { c: 1, d: 888 },
543
595
  list: [1, 2, 3],
544
596
  totalCount: 10,
597
+ searchRequested: false,
545
598
  prop1: 123,
546
599
  prop2: { subprop: "a" },
547
600
  }),
@@ -564,6 +617,7 @@ describe("ListReducerHelper", () => {
564
617
  index: { c: 1 },
565
618
  list: [1, 2, 3, 888],
566
619
  totalCount: 10,
620
+ searchRequested: false,
567
621
  prop1: 123,
568
622
  prop2: { subprop: "a" },
569
623
  }),
@@ -586,6 +640,7 @@ describe("ListReducerHelper", () => {
586
640
  index: { c: 888 },
587
641
  list: [1, 2, 3],
588
642
  totalCount: 10,
643
+ searchRequested: false,
589
644
  prop1: 123,
590
645
  prop2: { subprop: "a" },
591
646
  }),
@@ -608,6 +663,7 @@ describe("ListReducerHelper", () => {
608
663
  index: { c: 1 },
609
664
  list: [1, 2, 3],
610
665
  totalCount: 10,
666
+ searchRequested: false,
611
667
  prop1: 123,
612
668
  prop2: { subprop: "a" },
613
669
  }),
@@ -630,6 +686,7 @@ describe("ListReducerHelper", () => {
630
686
  index: {},
631
687
  list: [1, 2, 3],
632
688
  totalCount: 10,
689
+ searchRequested: false,
633
690
  prop1: 123,
634
691
  prop2: { subprop: "a" },
635
692
  }),
@@ -652,6 +709,7 @@ describe("ListReducerHelper", () => {
652
709
  index: { c: 1 },
653
710
  list: [1, 2, 3],
654
711
  totalCount: 10,
712
+ searchRequested: false,
655
713
  prop1: 123,
656
714
  prop2: { subprop: "a" },
657
715
  }),
@@ -674,6 +732,7 @@ describe("ListReducerHelper", () => {
674
732
  index: {},
675
733
  list: [],
676
734
  totalCount: 0,
735
+ searchRequested: false,
677
736
  prop1: 123,
678
737
  prop2: { subprop: "a" },
679
738
  }),
@@ -701,6 +760,7 @@ describe("ListReducerHelper", () => {
701
760
  index: {},
702
761
  list: [],
703
762
  totalCount: 0,
763
+ searchRequested: false,
704
764
  prop1: 123,
705
765
  prop2: { subprop: "a" },
706
766
  }),