@cxbox-ui/core 1.37.2-alpha.0 → 1.37.2-alpha.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.
@@ -115,6 +115,8 @@ __export(actions_exports, {
115
115
  processPreInvoke: function () { return processPreInvoke; },
116
116
  refreshMeta: function () { return refreshMeta; },
117
117
  refreshMetaAndReloadPage: function () { return refreshMetaAndReloadPage; },
118
+ refreshMetaDone: function () { return refreshMetaDone; },
119
+ refreshMetaFail: function () { return refreshMetaFail; },
118
120
  removeMultivalueTag: function () { return removeMultivalueTag; },
119
121
  removeNotifications: function () { return removeNotifications; },
120
122
  removePendingRequest: function () { return removePendingRequest; },
@@ -165,7 +167,7 @@ var bcFetchRowMetaSuccess = createAction("bcFetchRowMetaSuccess");
165
167
  var bcFetchRowMetaFail = createAction("bcFetchRowMetaFail");
166
168
  var bcNewData = createAction("bcNewData");
167
169
  var bcNewDataSuccess = createAction("bcNewDataSuccess");
168
- var bcNewDataFail = createAction("bcNewDataSuccess");
170
+ var bcNewDataFail = createAction("bcNewDataFail");
169
171
  var bcDeleteDataFail = createAction("bcDeleteDataFail");
170
172
  var forceActiveChangeFail = createAction("forceActiveChangeFail");
171
173
  var sendOperation = createAction("sendOperation");
@@ -180,7 +182,7 @@ var drillDown = createAction("drillDown");
180
182
  var bcChangeCursors = createAction("bcChangeCursors");
181
183
  var bcChangeDepthCursor = createAction("bcChangeDepthCursor");
182
184
  var changeDataItem = createAction("changeDataItem");
183
- var changeDataItems = createAction("changeDataItem");
185
+ var changeDataItems = createAction("changeDataItems");
184
186
  var forceActiveRmUpdate = createAction("forceActiveRmUpdate");
185
187
  var showViewPopup = createAction("showViewPopup");
186
188
  var showFileUploadPopup = createAction("showFileUploadPopup");
@@ -234,6 +236,8 @@ var switchDebugMode = createAction("switchDebugMode");
234
236
  var exportState = createAction("exportState");
235
237
  var emptyAction = createAction("emptyAction");
236
238
  var refreshMeta = createAction("refreshMeta");
239
+ var refreshMetaDone = createAction("refreshMetaDone");
240
+ var refreshMetaFail = createAction("refreshMetaFail");
237
241
  var refreshMetaAndReloadPage = createAction("refreshMetaAndReloadPage");
238
242
  var switchRole = createAction("switchRole");
239
243
  var addPendingRequest = createAction("addPendingRequest");
@@ -265,7 +269,7 @@ var ReducerBuilderManager = /** @class */ (function () {
265
269
  };
266
270
  class_1.prototype.addDefaultCase = function (reducer) {
267
271
  this.defaultCaseReducer = reducer;
268
- return {};
272
+ return this;
269
273
  };
270
274
  Object.defineProperty(class_1.prototype, "builder", {
271
275
  get: function () {
@@ -343,8 +347,10 @@ __export(interfaces_exports, {
343
347
  PaginationMode: function () { return PaginationMode; },
344
348
  PendingValidationFailsFormat: function () { return PendingValidationFailsFormat; },
345
349
  PopupWidgetTypes: function () { return PopupWidgetTypes; },
350
+ PositionTypes: function () { return PositionTypes; },
346
351
  RouteType: function () { return RouteType; },
347
352
  TableLikeWidgetTypes: function () { return TableLikeWidgetTypes; },
353
+ WidgetTypes: function () { return WidgetTypes2; },
348
354
  coreOperations: function () { return coreOperations; },
349
355
  isCustomWidget: function () { return isCustomWidget; },
350
356
  isCustomWidgetConfiguration: function () { return isCustomWidgetConfiguration; },
@@ -387,6 +393,7 @@ var ApplicationErrorType = /* @__PURE__ */ (function (ApplicationErrorType2) {
387
393
  })(ApplicationErrorType || {});
388
394
  // src/interfaces/widget.ts
389
395
  import { WidgetTypes } from "@cxbox-ui/schema";
396
+ import { WidgetTypes as WidgetTypes2, PositionTypes } from "@cxbox-ui/schema";
390
397
  var TableLikeWidgetTypes = [
391
398
  WidgetTypes.List,
392
399
  WidgetTypes.DataGrid,
@@ -469,6 +476,15 @@ function isViewNavigationCategory(item) {
469
476
  function isViewNavigationGroup(item) {
470
477
  return !!item && "child" in item && !("categoryName" in item);
471
478
  }
479
+ // src/reducers/router.ts
480
+ var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
481
+ var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
482
+ state = __assign(__assign({}, state), action.payload);
483
+ }).addCase(changeLocation, function (state, action) {
484
+ state = __assign(__assign({}, state), action.payload.location);
485
+ }); };
486
+ // src/reducers/screen.ts
487
+ import { OperationTypeCrud as OperationTypeCrud3 } from "@cxbox-ui/schema";
472
488
  // src/utils/index.ts
473
489
  var utils_exports = {};
474
490
  __export(utils_exports, {
@@ -489,7 +505,6 @@ __export(utils_exports, {
489
505
  getBcChildren: function () { return getBcChildren; },
490
506
  getDescendants: function () { return getDescendants; },
491
507
  getFieldTitle: function () { return getFieldTitle; },
492
- getFileUploadEndpoint: function () { return getFileUploadEndpoint; },
493
508
  getFilterType: function () { return getFilterType; },
494
509
  getFilters: function () { return getFilters; },
495
510
  getSorters: function () { return getSorters; },
@@ -529,12 +544,6 @@ function applyRawParams(url, qso) {
529
544
  var result = new URLSearchParams(qso).toString();
530
545
  return "".concat(addTailControlSequences(url)).concat(result && "".concat(result));
531
546
  }
532
- function getFileUploadEndpoint(instance) {
533
- if (!instance.defaults.baseURL) {
534
- return "/file";
535
- }
536
- return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
537
- }
538
547
  // src/utils/strings.ts
539
548
  function getTemplate(literals) {
540
549
  var placeholders = [];
@@ -549,10 +558,9 @@ function getTemplate(literals) {
549
558
  result += literals[literals.length - 1];
550
559
  return result;
551
560
  }
552
- function buildBcUrl(bcName, includeSelf, store) {
561
+ function buildBcUrl(bcName, includeSelf, state) {
553
562
  if (includeSelf === void 0) { includeSelf = false; }
554
- var storeInstance = store;
555
- var bcMap = storeInstance.screen.bo.bc;
563
+ var bcMap = state.screen.bo.bc;
556
564
  var bc = bcMap[bcName];
557
565
  if (!bc) {
558
566
  return null;
@@ -685,7 +693,7 @@ function defaultParseURL(url) {
685
693
  }
686
694
  return {
687
695
  type: type,
688
- path: path,
696
+ path: path.length !== 0 && !path.startsWith("/") ? "/".concat(path) : path,
689
697
  params: params,
690
698
  screenName: screenName,
691
699
  viewName: viewName,
@@ -733,8 +741,9 @@ function getSorters(sorters) {
733
741
  return result;
734
742
  }
735
743
  function parseFilters(defaultFilters) {
744
+ if (defaultFilters === void 0) { defaultFilters = ""; }
736
745
  var result = [];
737
- var urlParams = new URL(defaultFilters).searchParams;
746
+ var urlParams = new URL(defaultFilters, window.location.origin).searchParams;
738
747
  urlParams.forEach(function (param) {
739
748
  var _a = param.split("."), fieldName = _a[0], type = _a[1];
740
749
  if (fieldName && type && urlParams.get(param)) {
@@ -764,7 +773,7 @@ function parseSorters(sorters) {
764
773
  return null;
765
774
  }
766
775
  var result = [];
767
- var dictionary = new URL(sorters).searchParams;
776
+ var dictionary = new URL(sorters, window.location.origin).searchParams;
768
777
  Object.entries(dictionary).map(function (_a) {
769
778
  var sort = _a[0], fieldKey = _a[1];
770
779
  var _b = sort.split(".").slice(1), order = _b[0], direction = _b[1];
@@ -843,12 +852,13 @@ function getBcChildren(originBcName, widgets, bcMap) {
843
852
  return childrenBcMap;
844
853
  }
845
854
  function getHierarchyChildBc(originBcName, hierarchyWidget) {
846
- var nestedBcNames = hierarchyWidget.options.hierarchy.map(function (nestedItem) { return nestedItem.bcName; });
847
- if (originBcName !== hierarchyWidget.bcName && !nestedBcNames.includes(originBcName)) {
855
+ var _a, _b;
856
+ var nestedBcNames = (_b = (_a = hierarchyWidget === null || hierarchyWidget === void 0 ? void 0 : hierarchyWidget.options) === null || _a === void 0 ? void 0 : _a.hierarchy) === null || _b === void 0 ? void 0 : _b.map(function (nestedItem) { return nestedItem.bcName; });
857
+ if (originBcName !== hierarchyWidget.bcName && !(nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.includes(originBcName))) {
848
858
  return [];
849
859
  }
850
- var childHierarchyBcIndex = nestedBcNames.findIndex(function (item) { return item === originBcName; });
851
- var childHierarchyBcName = nestedBcNames[childHierarchyBcIndex + 1];
860
+ var childHierarchyBcIndex = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.findIndex(function (item) { return item === originBcName; });
861
+ var childHierarchyBcName = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames[childHierarchyBcIndex + 1];
852
862
  return [childHierarchyBcName, hierarchyWidget.name];
853
863
  }
854
864
  function checkShowCondition(condition, cursor, data, pendingDataChanges) {
@@ -862,9 +872,9 @@ function checkShowCondition(condition, cursor, data, pendingDataChanges) {
862
872
  if (!record) {
863
873
  return false;
864
874
  }
865
- var actualValue = record === null || record === void 0 ? void 0 : record[params.fieldKey];
866
- var pendingValue = (_b = (_a = pendingDataChanges === null || pendingDataChanges === void 0 ? void 0 : pendingDataChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor]) === null || _b === void 0 ? void 0 : _b[params.fieldKey];
867
- return pendingValue !== void 0 ? pendingValue === params.value : actualValue === params.value;
875
+ var actualValue = record === null || record === void 0 ? void 0 : record[params === null || params === void 0 ? void 0 : params.fieldKey];
876
+ var pendingValue = (_b = (_a = pendingDataChanges === null || pendingDataChanges === void 0 ? void 0 : pendingDataChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor]) === null || _b === void 0 ? void 0 : _b[params === null || params === void 0 ? void 0 : params.fieldKey];
877
+ return pendingValue !== void 0 ? pendingValue === (params === null || params === void 0 ? void 0 : params.value) : actualValue === (params === null || params === void 0 ? void 0 : params.value);
868
878
  }
869
879
  // src/utils/tree.ts
870
880
  function assignTreeLinks(flat) {
@@ -872,6 +882,7 @@ function assignTreeLinks(flat) {
872
882
  var map12 = {};
873
883
  var orphans = [];
874
884
  result.forEach(function (item) {
885
+ var _a, _b;
875
886
  if (!item.parentId || item.parentId === "0") {
876
887
  return;
877
888
  }
@@ -890,7 +901,7 @@ function assignTreeLinks(flat) {
890
901
  result[parentIndex].children = [item];
891
902
  }
892
903
  else {
893
- result[parentIndex].children.push(item);
904
+ (_b = (_a = result[parentIndex]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.push(item);
894
905
  }
895
906
  });
896
907
  if (orphans.length) {
@@ -968,22 +979,7 @@ function deleteUndefinedFromObject(obj) {
968
979
  }
969
980
  });
970
981
  }
971
- // src/reducers/router.ts
972
- var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
973
- var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
974
- state = __assign(__assign({}, state), action.payload);
975
- }).addCase(changeLocation, function (state, action) {
976
- var _a = action.payload, url = _a.url, route = _a.route;
977
- if (url) {
978
- var path = new URL(url);
979
- state = __assign(__assign({}, state), defaultParseURL(path));
980
- }
981
- if (route !== null) {
982
- state = __assign(__assign({}, state), route);
983
- }
984
- }); };
985
982
  // src/reducers/screen.ts
986
- import { OperationTypeCrud as OperationTypeCrud3 } from "@cxbox-ui/schema";
987
983
  var initialScreenState = {
988
984
  screenName: "",
989
985
  bo: { activeBcName: "", bc: {} },
@@ -995,10 +991,11 @@ var initialScreenState = {
995
991
  };
996
992
  var operationsHandledLocally = [OperationTypeCrud3.associate, OperationTypeCrud3.fileUpload];
997
993
  var createScreenReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(selectScreen, function (state, action) {
994
+ var _a, _b, _c, _d, _e;
998
995
  var bcDictionary = {};
999
996
  var bcSorters = {};
1000
997
  var bcFilters = {};
1001
- action.payload.screen.meta.bo.bc.forEach(function (item) {
998
+ (_a = action.payload.screen.meta) === null || _a === void 0 ? void 0 : _a.bo.bc.forEach(function (item) {
1002
999
  bcDictionary[item.name] = item;
1003
1000
  var sorter = parseSorters(item.defaultSort);
1004
1001
  var filter56 = parseFilters(item.defaultFilter);
@@ -1010,8 +1007,8 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1010
1007
  }
1011
1008
  });
1012
1009
  state.screenName = action.payload.screen.name;
1013
- state.primaryView = action.payload.screen.meta.primary;
1014
- state.views = action.payload.screen.meta.views;
1010
+ state.primaryView = (_c = (_b = action.payload.screen.meta) === null || _b === void 0 ? void 0 : _b.primary) !== null && _c !== void 0 ? _c : state.primaryView;
1011
+ state.views = (_e = (_d = action.payload.screen.meta) === null || _d === void 0 ? void 0 : _d.views) !== null && _e !== void 0 ? _e : state.views;
1015
1012
  state.bo = { activeBcName: null, bc: bcDictionary };
1016
1013
  state.sorters = __assign(__assign({}, state.sorters), bcSorters);
1017
1014
  state.filters = __assign(__assign({}, state.filters), bcFilters);
@@ -1021,12 +1018,14 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1021
1018
  }).addCase(bcFetchDataRequest, function (state, action) {
1022
1019
  state.bo.bc[action.payload.bcName].loading = true;
1023
1020
  }).addCase(bcLoadMore, function (state, action) {
1021
+ var _a;
1024
1022
  var currentBc = state.bo.bc[action.payload.bcName];
1025
- currentBc.page += 1;
1023
+ currentBc.page = ((_a = currentBc.page) !== null && _a !== void 0 ? _a : 1) + 1;
1026
1024
  currentBc.loading = true;
1027
1025
  }).addCase(selectView, function (state, action) {
1026
+ var _a;
1028
1027
  var newBcs = {};
1029
- Array.from(new Set(action.payload.widgets.map(function (widget) { return widget.bcName; }))
1028
+ Array.from(new Set((_a = action.payload.widgets) === null || _a === void 0 ? void 0 : _a.map(function (widget) { return widget.bcName; }))
1030
1029
  // БК которые есть на вьюхе
1031
1030
  ).filter(function (bcName) { return state.bo.bc[bcName]; }).forEach(function (bcName) {
1032
1031
  newBcs[bcName] = __assign(__assign({}, state.bo.bc[bcName]), { page: 1 });
@@ -1038,9 +1037,10 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1038
1037
  currentBc.loading = false;
1039
1038
  state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
1040
1039
  }).addCase(bcFetchDataFail, function (state, action) {
1041
- if (Object.values(state.bo.bc).some(function (bc) { return bc.name === action.payload.bcName; })) {
1042
- state.bo.bc[action.payload.bcName].loading = false;
1043
- state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
1040
+ var bcName = action.payload.bcName;
1041
+ if (Object.values(state.bo.bc).some(function (bc) { return bc.name === bcName; })) {
1042
+ state.bo.bc[bcName].loading = false;
1043
+ state.cachedBc[bcName] = action.payload.bcUrl;
1044
1044
  }
1045
1045
  }).addCase(sendOperation, function (state, action) {
1046
1046
  if (!operationsHandledLocally.includes(action.payload.operationType)) {
@@ -1068,10 +1068,12 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1068
1068
  Object.assign(state.bo.bc, newCursors);
1069
1069
  Object.assign(state.cachedBc, newCache);
1070
1070
  }).addCase(bcChangeDepthCursor, function (state, action) {
1071
+ var _a;
1071
1072
  if (action.payload.depth === 1) {
1072
1073
  state.bo.bc[action.payload.bcName].cursor = action.payload.cursor;
1073
1074
  }
1074
1075
  else {
1076
+ state.bo.bc[action.payload.bcName].depthBc = (_a = state.bo.bc[action.payload.bcName].depthBc) !== null && _a !== void 0 ? _a : {};
1075
1077
  state.bo.bc[action.payload.bcName].depthBc[action.payload.depth].cursor = action.payload.cursor;
1076
1078
  }
1077
1079
  }).addCase(bcSelectRecord, function (state, action) {
@@ -1156,9 +1158,11 @@ var createSessionReducerBuilderManager = function (initialState) { return new Re
1156
1158
  }).addCase(switchDebugMode, function (state, action) {
1157
1159
  state.debugMode = action.payload;
1158
1160
  }).addCase(addPendingRequest, function (state, action) {
1159
- state.pendingRequests.push(action.payload.request);
1161
+ var _a;
1162
+ (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.push(action.payload.request);
1160
1163
  }).addCase(removePendingRequest, function (state, action) {
1161
- state.pendingRequests = state.pendingRequests.filter(function (item) { return item.requestId !== action.payload.requestId; });
1164
+ var _a;
1165
+ state.pendingRequests = (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return item.requestId !== action.payload.requestId; });
1162
1166
  }).addCase(addNotification, function (state, action) {
1163
1167
  state.notifications.push(action.payload);
1164
1168
  }).addCase(removeNotifications, function (state, action) {
@@ -1205,12 +1209,15 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1205
1209
  state.metaInProgress[action.payload.bcName] = true;
1206
1210
  }
1207
1211
  }).addCase(bcFetchRowMetaSuccess, function (state, action) {
1212
+ var _a;
1213
+ state.rowMeta[action.payload.bcName] = (_a = state.rowMeta[action.payload.bcName]) !== null && _a !== void 0 ? _a : {};
1208
1214
  state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1209
1215
  state.metaInProgress[action.payload.bcName] = false;
1210
1216
  }).addCase(bcNewDataSuccess, function (state, action) {
1211
1217
  state.selectedCell = initialViewState.selectedCell;
1212
1218
  }).addCase(forceActiveRmUpdate, function (state, action) {
1213
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, currentRecordData = _a.currentRecordData, rowMeta = _a.rowMeta, cursor = _a.cursor;
1219
+ var _a, _b, _c, _d;
1220
+ var _e = action.payload, bcName = _e.bcName, bcUrl = _e.bcUrl, currentRecordData = _e.currentRecordData, rowMeta = _e.rowMeta, cursor = _e.cursor;
1214
1221
  var handledForceActive = {};
1215
1222
  var rowMetaForcedValues = {};
1216
1223
  var newPendingChangesDiff = {};
@@ -1233,17 +1240,21 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1233
1240
  handledForceActive[key] = newPendingDataChanges[key];
1234
1241
  }
1235
1242
  });
1243
+ state.handledForceActive[bcName] = (_a = state.handledForceActive[bcName]) !== null && _a !== void 0 ? _a : {};
1244
+ state.handledForceActive[bcName][cursor] = (_b = state.handledForceActive[bcName][cursor]) !== null && _b !== void 0 ? _b : {};
1236
1245
  Object.assign(state.handledForceActive[bcName][cursor], handledForceActive);
1246
+ state.pendingDataChanges[bcName] = (_c = state.pendingDataChanges[bcName]) !== null && _c !== void 0 ? _c : {};
1237
1247
  state.pendingDataChanges[bcName][cursor] = newPendingDataChanges;
1248
+ state.rowMeta[bcName] = (_d = state.rowMeta[bcName]) !== null && _d !== void 0 ? _d : {};
1238
1249
  state.rowMeta[bcName][bcUrl] = rowMeta;
1239
1250
  }).addCase(changeDataItem, function (state, action) {
1240
- var _a;
1251
+ var _a, _b, _c;
1241
1252
  var actionBcName = action.payload.bcName;
1242
1253
  var prevBc = state.pendingDataChanges[action.payload.bcName] || {};
1243
1254
  var prevCursor = prevBc[action.payload.cursor] || {};
1244
1255
  var prevPending = prevCursor || {};
1245
1256
  var nextPending = __assign(__assign({}, prevPending), action.payload.dataItem);
1246
- var bcUrl = buildBcUrl(actionBcName, true);
1257
+ var bcUrl = action.payload.bcUrl;
1247
1258
  var rowMeta = (_a = state.rowMeta[actionBcName]) === null || _a === void 0 ? void 0 : _a[bcUrl];
1248
1259
  var nextValidationFails = {};
1249
1260
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
@@ -1254,10 +1265,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1254
1265
  nextValidationFails[fieldKey] = "This field is mandatory";
1255
1266
  }
1256
1267
  });
1268
+ state.pendingDataChanges[action.payload.bcName] = (_b = state.pendingDataChanges[action.payload.bcName]) !== null && _b !== void 0 ? _b : {};
1257
1269
  state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending;
1258
1270
  if (isTargetFormatPVF) {
1259
1271
  ;
1260
- state.pendingValidationFails[actionBcName][action.payload.cursor] = nextValidationFails;
1272
+ ((_c = state.pendingValidationFails) === null || _c === void 0 ? void 0 : _c[actionBcName])[action.payload.cursor] = nextValidationFails;
1261
1273
  }
1262
1274
  else {
1263
1275
  state.pendingValidationFails = nextValidationFails;
@@ -1278,7 +1290,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1278
1290
  pendingDataChanges[bcName] = pendingBcChanges;
1279
1291
  });
1280
1292
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1281
- var pendingValidationFails = __assign({}, state.pendingValidationFails);
1293
+ var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
1282
1294
  if (isTargetFormatPVF) {
1283
1295
  action.payload.bcNames.forEach(function (i) {
1284
1296
  pendingValidationFails[i] = {};
@@ -1293,7 +1305,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1293
1305
  }).addCase(bcFetchRowMetaFail, function (state, action) {
1294
1306
  state.metaInProgress[action.payload.bcName] = false;
1295
1307
  }).addCase(forceActiveChangeFail, function (state, action) {
1296
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1308
+ var _a;
1309
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1297
1310
  var errors = {};
1298
1311
  if (entityError) {
1299
1312
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1301,9 +1314,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1301
1314
  errors[fieldName] = violation;
1302
1315
  });
1303
1316
  }
1317
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1304
1318
  state.rowMeta[bcName][bcUrl].errors = errors;
1305
1319
  }).addCase(bcSaveDataFail, function (state, action) {
1306
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1320
+ var _a;
1321
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1307
1322
  var errors = {};
1308
1323
  if (entityError) {
1309
1324
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1311,9 +1326,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1311
1326
  errors[fieldName] = violation;
1312
1327
  });
1313
1328
  }
1329
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1314
1330
  state.rowMeta[bcName][bcUrl].errors = errors;
1315
1331
  }).addCase(sendOperationFail, function (state, action) {
1316
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1332
+ var _a;
1333
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1317
1334
  var errors = {};
1318
1335
  if (entityError) {
1319
1336
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1321,30 +1338,38 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1321
1338
  errors[fieldName] = violation;
1322
1339
  });
1323
1340
  }
1341
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1324
1342
  state.rowMeta[bcName][bcUrl].errors = errors;
1325
1343
  }).addCase(sendOperationSuccess, function (state, action) {
1326
- var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor;
1344
+ var _a, _b, _c;
1345
+ var bcName = action.payload.bcName;
1346
+ var cursor = action.payload.cursor;
1327
1347
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1348
+ state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
1328
1349
  state.pendingDataChanges[bcName][cursor] = {};
1329
1350
  if (isTargetFormatPVF) {
1330
1351
  ;
1331
- state.pendingValidationFails[bcName][cursor] = {};
1352
+ ((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
1332
1353
  }
1333
1354
  else {
1334
1355
  state.pendingValidationFails = initialViewState.pendingValidationFails;
1335
1356
  }
1357
+ state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
1336
1358
  state.handledForceActive[bcName][cursor] = {};
1337
1359
  }).addCase(bcSaveDataSuccess, function (state, action) {
1338
- var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor;
1360
+ var _a, _b, _c;
1361
+ var _d = action.payload, bcName = _d.bcName, cursor = _d.cursor;
1339
1362
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1363
+ state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
1340
1364
  state.pendingDataChanges[bcName][cursor] = {};
1341
1365
  if (isTargetFormatPVF) {
1342
1366
  ;
1343
- state.pendingValidationFails[bcName][cursor] = {};
1367
+ ((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
1344
1368
  }
1345
1369
  else {
1346
1370
  state.pendingValidationFails = initialViewState.pendingValidationFails;
1347
1371
  }
1372
+ state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
1348
1373
  state.handledForceActive[bcName][cursor] = {};
1349
1374
  }).addCase(bcCancelPendingChanges, function (state, action) {
1350
1375
  var _a, _b;
@@ -1355,7 +1380,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1355
1380
  }
1356
1381
  }
1357
1382
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1358
- var pendingValidationFails = __assign({}, state.pendingValidationFails);
1383
+ var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
1359
1384
  if (isTargetFormatPVF) {
1360
1385
  if (((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.bcNames) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1361
1386
  action.payload.bcNames.forEach(function (i) {
@@ -1384,8 +1409,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1384
1409
  isFilter: isFilter
1385
1410
  };
1386
1411
  }).addCase(showFileUploadPopup, function (state, action) {
1387
- var _a;
1388
- var bcName = (_a = state.widgets.find(function (item) { return item.name === action.payload.widgetName; })) === null || _a === void 0 ? void 0 : _a.bcName;
1412
+ var _a, _b;
1413
+ var bcName = (_b = (_a = state.widgets) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.name === action.payload.widgetName; })) === null || _b === void 0 ? void 0 : _b.bcName;
1389
1414
  state.popupData = {
1390
1415
  type: "file-upload",
1391
1416
  bcName: bcName,
@@ -1397,6 +1422,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1397
1422
  }).addCase(viewClearPickMap, function (state) {
1398
1423
  state.pickMap = null;
1399
1424
  }).addCase(closeViewPopup, function (state) {
1425
+ state.popupData = {};
1400
1426
  state.popupData.bcName = null;
1401
1427
  }).addCase(selectTableCell, function (state, action) {
1402
1428
  state.selectedCell = { widgetName: action.payload.widgetName, rowId: action.payload.rowId, fieldKey: action.payload.fieldKey };
@@ -1404,12 +1430,16 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1404
1430
  state.pendingDataChanges = initialViewState.pendingDataChanges;
1405
1431
  state.selectedCell = initialViewState.selectedCell;
1406
1432
  }).addCase(showNotification, function (state, action) {
1433
+ var _a, _b;
1434
+ state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
1407
1435
  state.systemNotifications.push({
1408
1436
  type: action.payload.type,
1409
1437
  message: action.payload.message,
1410
- id: state.systemNotifications.length
1438
+ id: (_b = state.systemNotifications) === null || _b === void 0 ? void 0 : _b.length
1411
1439
  });
1412
1440
  }).addCase(closeNotification, function (state, action) {
1441
+ var _a;
1442
+ state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
1413
1443
  state.systemNotifications = state.systemNotifications.filter(function (item) { return item.id !== action.payload.id; });
1414
1444
  }).addCase(showViewError, function (state, action) {
1415
1445
  state.error = action.payload.error;
@@ -1457,7 +1487,6 @@ __export(epics_exports, {
1457
1487
  httpError500Epic: function () { return httpError500Epic; },
1458
1488
  httpErrorDefaultEpic: function () { return httpErrorDefaultEpic; },
1459
1489
  inlinePickListFetchDataEpic: function () { return inlinePickListFetchDataEpic; },
1460
- knownHttpErrors: function () { return knownHttpErrors; },
1461
1490
  loginByAnotherRoleEpic: function () { return loginByAnotherRoleEpic; },
1462
1491
  loginDoneEpic: function () { return loginDoneEpic; },
1463
1492
  loginDoneSessionEpic: function () { return loginDoneSessionEpic; },
@@ -1518,7 +1547,7 @@ var sendOperationEpic = function (action$, state$, _a) {
1518
1547
  var screenName = state.screen.screenName;
1519
1548
  var _l = action.payload, bcName = _l.bcName, operationType = _l.operationType, widgetName = _l.widgetName;
1520
1549
  var confirm = ((_a = action.payload.confirmOperation) === null || _a === void 0 ? void 0 : _a.type) || action.payload.confirm;
1521
- var bcUrl = buildBcUrl(bcName, true);
1550
+ var bcUrl = buildBcUrl(bcName, true, state);
1522
1551
  var bc = state.screen.bo.bc[bcName];
1523
1552
  var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
1524
1553
  var fields = rowMeta === null || rowMeta === void 0 ? void 0 : rowMeta.fields;
@@ -1526,7 +1555,7 @@ var sendOperationEpic = function (action$, state$, _a) {
1526
1555
  var record = (_c = state.data[bcName]) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.id === bc.cursor; });
1527
1556
  var filters = state.screen.filters[bcName];
1528
1557
  var sorters = state.screen.sorters[bcName];
1529
- var pendingRecordChange = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor];
1558
+ var pendingRecordChange = __assign({}, (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor]);
1530
1559
  var _loop_1 = function (key) {
1531
1560
  if (fields.find(function (item) { return item.key === key && item.disabled; })) {
1532
1561
  delete pendingRecordChange[key];
@@ -1543,10 +1572,10 @@ var sendOperationEpic = function (action$, state$, _a) {
1543
1572
  }
1544
1573
  var context = { widgetName: action.payload.widgetName };
1545
1574
  return api.customAction(screenName, bcUrl, data, context, params).pipe(mergeMap(function (response) {
1546
- var _a;
1547
- var postInvoke = response.postActions[0];
1575
+ var _a, _b;
1576
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
1548
1577
  var preInvoke = response.preInvoke;
1549
- return defaultSaveOperation ? ((_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.onSuccessAction) ? concat(of2(bcCancelPendingChanges({ bcNames: [bcName] })), of2(action.payload.onSuccessAction)) : EMPTY : concat.apply(void 0, __spreadArray([of2(sendOperationSuccess({ bcName: bcName, cursor: cursor })),
1578
+ return defaultSaveOperation ? ((_b = action === null || action === void 0 ? void 0 : action.payload) === null || _b === void 0 ? void 0 : _b.onSuccessAction) ? concat(of2(bcCancelPendingChanges({ bcNames: [bcName] })), of2(action.payload.onSuccessAction)) : EMPTY : concat.apply(void 0, __spreadArray([of2(sendOperationSuccess({ bcName: bcName, cursor: cursor })),
1550
1579
  of2(bcForceUpdate({ bcName: bcName }))], postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName), false));
1551
1580
  }), catchError(function (e) {
1552
1581
  var _a, _b, _c, _d, _e, _f;
@@ -1564,12 +1593,12 @@ var sendOperationEpic = function (action$, state$, _a) {
1564
1593
  };
1565
1594
  // src/epics/view/showAssocPopupEpic.ts
1566
1595
  import { EMPTY as EMPTY2, filter as filter2, mergeMap as mergeMap2, of as of3 } from "rxjs";
1567
- import { WidgetTypes as WidgetTypes2 } from "@cxbox-ui/schema";
1596
+ import { WidgetTypes as WidgetTypes3 } from "@cxbox-ui/schema";
1568
1597
  var showAssocPopupEpic = function (action$, state$) { return action$.pipe(filter2(showViewPopup.match), filter2(function (action) { return !!(action.payload.calleeBCName && action.payload.associateFieldKey); }), mergeMap2(function (action) {
1569
1598
  var _a, _b, _c, _d;
1570
1599
  var _e = action.payload, bcName = _e.bcName, calleeBCName = _e.calleeBCName;
1571
1600
  var state = state$.value;
1572
- var assocWidget = state.view.widgets.find(function (widget) { return widget.bcName === bcName && widget.type === WidgetTypes2.AssocListPopup; });
1601
+ var assocWidget = state.view.widgets.find(function (widget) { return widget.bcName === bcName && widget.type === WidgetTypes3.AssocListPopup; });
1573
1602
  var calleeCursor = (_a = state.screen.bo.bc[calleeBCName]) === null || _a === void 0 ? void 0 : _a.cursor;
1574
1603
  var calleePendingChanges = (_b = state.view.pendingDataChanges[calleeBCName]) === null || _b === void 0 ? void 0 : _b[calleeCursor];
1575
1604
  var assocFieldKey = action.payload.associateFieldKey;
@@ -1611,16 +1640,17 @@ import { OperationTypeCrud as OperationTypeCrud5 } from "@cxbox-ui/schema";
1611
1640
  var fileUploadConfirmEpic = function (action$, state$, _a) {
1612
1641
  var api = _a.api;
1613
1642
  return action$.pipe(filter3(bulkUploadFiles.match), mergeMap3(function (action) {
1614
- var _a;
1643
+ var _a, _b;
1615
1644
  var state = state$.value;
1616
- var bcName = state.view.popupData.bcName;
1617
- var bcUrl = buildBcUrl(bcName, true);
1618
- var widgetName = (_a = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _a === void 0 ? void 0 : _a.name;
1645
+ var bcName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.bcName;
1646
+ var bcUrl = buildBcUrl(bcName, true, state);
1647
+ var widgetName = (_b = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.name;
1619
1648
  var data = {
1620
1649
  bulkIds: action.payload.fileIds
1621
1650
  };
1622
1651
  return api.customAction(state.screen.screenName, bcUrl, data, null, { _action: "file-upload-save" }).pipe(mergeMap3(function (response) {
1623
- var postInvoke = response.postActions[0];
1652
+ var _a;
1653
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
1624
1654
  var preInvoke = response.preInvoke;
1625
1655
  return concat2.apply(void 0, __spreadArray([of4(sendOperationSuccess({ bcName: bcName, cursor: null })),
1626
1656
  of4(bcForceUpdate({ bcName: bcName })),
@@ -1636,14 +1666,14 @@ var selectTableCellInitEpic = function (action$, state$) { return action$.pipe(f
1636
1666
  var state = state$.value;
1637
1667
  var _b = action.payload, nextRowId = _b.rowId, fieldKey = _b.fieldKey;
1638
1668
  var nextWidget = state.view.widgets.find(function (widget) { return widget.name === action.payload.widgetName; });
1639
- var nextBcName = nextWidget.bcName;
1669
+ var nextBcName = nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.bcName;
1640
1670
  var nextBcCursor = (_a = state.screen.bo.bc[nextBcName]) === null || _a === void 0 ? void 0 : _a.cursor;
1641
1671
  var selectedCell = state.view.selectedCell;
1642
1672
  if (nextRowId !== nextBcCursor) {
1643
1673
  resultObservables.push(of5(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })));
1644
1674
  }
1645
- if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || nextWidget.name !== selectedCell.widgetName) {
1646
- resultObservables.push(of5(selectTableCell({ widgetName: nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
1675
+ if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || (nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name) !== selectedCell.widgetName) {
1676
+ resultObservables.push(of5(selectTableCell({ widgetName: nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
1647
1677
  }
1648
1678
  return concat3.apply(void 0, resultObservables);
1649
1679
  })); };
@@ -1668,7 +1698,7 @@ var sendOperationAssociateEpic = function (action$, state$) { return action$.pip
1668
1698
  })); };
1669
1699
  // src/epics/view/getRowMetaByForceActiveEpic.ts
1670
1700
  import { EMPTY as EMPTY3, concat as concat5, filter as filter7, mergeMap as mergeMap6, of as of7, catchError as catchError2 } from "rxjs";
1671
- import { WidgetTypes as WidgetTypes3 } from "@cxbox-ui/schema";
1701
+ import { WidgetTypes as WidgetTypes4 } from "@cxbox-ui/schema";
1672
1702
  import { nanoid } from "@reduxjs/toolkit";
1673
1703
  var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1674
1704
  var api = _a.api;
@@ -1679,19 +1709,19 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1679
1709
  var _e = action.payload, bcName = _e.bcName, cursor = _e.cursor, disableRetry = _e.disableRetry;
1680
1710
  var isBcHierarchy = state.view.widgets.some(function (widget) {
1681
1711
  var _a, _b;
1682
- return widget.bcName === bcName && widget.type === WidgetTypes3.AssocListPopup && (((_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchySameBc) || ((_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchyFull));
1712
+ return widget.bcName === bcName && widget.type === WidgetTypes4.AssocListPopup && (((_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchySameBc) || ((_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchyFull));
1683
1713
  });
1684
1714
  if (isBcHierarchy) {
1685
1715
  return EMPTY3;
1686
1716
  }
1687
- var isPickListPopup = state.view.widgets.find(function (item) { var _a; return item.name === ((_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.widgetName) && [WidgetTypes3.PickListPopup, WidgetTypes3.FlatTreePopup].includes(item.type); });
1688
- var bcUrl = buildBcUrl(bcName, true);
1717
+ var isPickListPopup = state.view.widgets.find(function (item) { var _a; return item.name === ((_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.widgetName) && [WidgetTypes4.PickListPopup, WidgetTypes4.FlatTreePopup].includes(item.type); });
1718
+ var bcUrl = buildBcUrl(bcName, true, state);
1689
1719
  var pendingChanges = state.view.pendingDataChanges[bcName][cursor];
1690
1720
  var handledForceActive = ((_a = state.view.handledForceActive[bcName]) === null || _a === void 0 ? void 0 : _a[cursor]) || {};
1691
1721
  var currentRecordData = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (record) { return record.id === cursor; });
1692
1722
  var fieldsRowMeta = (_d = (_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]) === null || _d === void 0 ? void 0 : _d.fields;
1693
1723
  var changedFiledKey = null;
1694
- var closePopup = concat5(of7(viewClearPickMap(null)), of7(closeViewPopup(null)), of7(bcRemoveAllFilters({ bcName: bcName })));
1724
+ var closePopup = concat5(of7(closeViewPopup(null)), of7(viewClearPickMap(null)), of7(bcRemoveAllFilters({ bcName: bcName })));
1695
1725
  var someForceActiveChanged = fieldsRowMeta === null || fieldsRowMeta === void 0 ? void 0 : fieldsRowMeta.filter(function (field) { return field.forceActive && pendingChanges[field.key] !== void 0; }).some(function (field) {
1696
1726
  var result = pendingChanges[field.key] !== handledForceActive[field.key];
1697
1727
  if (result) {
@@ -1701,7 +1731,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1701
1731
  });
1702
1732
  var requestId = nanoid();
1703
1733
  if (someForceActiveChanged && !disableRetry) {
1704
- return concat5(of7(addPendingRequest({ request: { requestId: requestId, type: "force-active" } })), api.getRmByForceActive(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: currentRecordData.vstamp })).pipe(mergeMap6(function (data) {
1734
+ return concat5(of7(addPendingRequest({ request: { requestId: requestId, type: "force-active" } })), api.getRmByForceActive(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: currentRecordData === null || currentRecordData === void 0 ? void 0 : currentRecordData.vstamp })).pipe(mergeMap6(function (data) {
1705
1735
  var result = [of7(removePendingRequest({ requestId: requestId }))];
1706
1736
  if (state.view.url === initUrl) {
1707
1737
  result.push(of7(forceActiveRmUpdate({
@@ -1729,8 +1759,9 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1729
1759
  }
1730
1760
  return concat5(of7(removePendingRequest({ requestId: requestId })), state.view.url === initUrl ? concat5(of7(changeDataItem({
1731
1761
  bcName: bcName,
1762
+ bcUrl: buildBcUrl(bcName, true, state),
1732
1763
  cursor: cursor,
1733
- dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData[changedFiledKey], _a),
1764
+ dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData === null || currentRecordData === void 0 ? void 0 : currentRecordData[changedFiledKey], _a),
1734
1765
  disableRetry: true
1735
1766
  })), of7(forceActiveChangeFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError }))) : EMPTY3);
1736
1767
  })));
@@ -1743,9 +1774,14 @@ import { concat as concat6, filter as filter8, mergeMap as mergeMap7, of as of8
1743
1774
  var showAllTableRecordsInitEpic = function (action$, state$) { return action$.pipe(filter8(showAllTableRecordsInit.match), mergeMap7(function (action) {
1744
1775
  var _a;
1745
1776
  var resultObservables = [];
1746
- var bcName = action.payload.bcName;
1777
+ var _b = action.payload, bcName = _b.bcName, cursor = _b.cursor;
1778
+ var state = state$.value;
1779
+ var route = state.router;
1747
1780
  resultObservables.push(of8(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = null, _a) })));
1781
+ var bcPath = route.bcPath.slice(0, route.bcPath.indexOf("".concat(bcName, "/").concat(cursor)));
1782
+ var url = defaultBuildURL(__assign(__assign({}, route), { bcPath: bcPath }));
1748
1783
  resultObservables.push(of8(bcForceUpdate({ bcName: bcName })));
1784
+ resultObservables.push(of8(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })));
1749
1785
  return concat6.apply(void 0, resultObservables);
1750
1786
  })); };
1751
1787
  // src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts
@@ -1767,10 +1803,110 @@ var clearPendingDataChangesAfterCursorChangeEpic = function (action$, state$) {
1767
1803
  return EMPTY4;
1768
1804
  })); };
1769
1805
  // src/epics/router/drilldownEpic.ts
1770
- import { EMPTY as EMPTY5, filter as filter10, switchMap } from "rxjs";
1806
+ import { concat as concat7, EMPTY as EMPTY5, filter as filter10, switchMap } from "rxjs";
1771
1807
  var drillDownEpic = function (action$, state$) { return action$.pipe(filter10(drillDown.match), switchMap(function (action) {
1772
- return EMPTY5;
1808
+ var _a, _b;
1809
+ var state = state$.value;
1810
+ var url = action.payload.url;
1811
+ var result = [];
1812
+ switch (action.payload.drillDownType) {
1813
+ case DrillDownType.external:
1814
+ window.location.href = url;
1815
+ break;
1816
+ case DrillDownType.externalNew:
1817
+ if (/^[a-z0-9]+:\/\//i.test(url)) {
1818
+ window.open(url);
1819
+ }
1820
+ break;
1821
+ case DrillDownType.relative:
1822
+ window.location.href = "".concat(window.location.origin, "/").concat(url);
1823
+ break;
1824
+ case DrillDownType.relativeNew:
1825
+ window.open("".concat(window.location.origin, "/").concat(url), "_blank");
1826
+ break;
1827
+ case DrillDownType.inner:
1828
+ default:
1829
+ var urlBase = url.split("?")[0];
1830
+ var urlObject = new URL(url, window.location.origin);
1831
+ var urlFilters = urlObject.searchParams.get("filters");
1832
+ var urlSorters = urlObject.searchParams.get("sorters");
1833
+ var newFilters_1 = {};
1834
+ var newSorters = {};
1835
+ try {
1836
+ newFilters_1 = (_a = JSON.parse(urlFilters)) !== null && _a !== void 0 ? _a : newFilters_1;
1837
+ }
1838
+ catch (_c) {
1839
+ urlFilters && console.warn("Failed to parse filters on drilldown");
1840
+ newFilters_1 = {};
1841
+ }
1842
+ try {
1843
+ newSorters = (_b = JSON.parse(urlSorters)) !== null && _b !== void 0 ? _b : newSorters;
1844
+ }
1845
+ catch (_d) {
1846
+ urlSorters && console.warn("Failed to parse sorters on drilldown");
1847
+ newSorters = {};
1848
+ }
1849
+ var bcToUpdate_1 = {};
1850
+ Object.keys(state.screen.filters).forEach(function (bcName) {
1851
+ if (newFilters_1[bcName] === "" || newFilters_1[bcName]) {
1852
+ bcToUpdate_1[bcName] = true;
1853
+ result.push(bcRemoveAllFilters({ bcName: bcName }));
1854
+ }
1855
+ });
1856
+ var nextState = defaultParseURL(urlObject);
1857
+ var viewName_1 = nextState.viewName;
1858
+ Object.entries(newFilters_1).forEach(function (_a) {
1859
+ var _b;
1860
+ var bcName = _a[0], filterExpression = _a[1];
1861
+ var parsedFilters = (_b = parseFilters(filterExpression)) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), { viewName: viewName_1 })); });
1862
+ parsedFilters === null || parsedFilters === void 0 ? void 0 : parsedFilters.forEach(function (parsedFilter) {
1863
+ bcToUpdate_1[bcName] = true;
1864
+ result.push(bcAddFilter({ bcName: bcName, filter: parsedFilter }));
1865
+ });
1866
+ });
1867
+ Object.entries(newSorters).forEach(function (_a) {
1868
+ var bcName = _a[0], sortExpression = _a[1];
1869
+ var sorter = parseSorters(sortExpression);
1870
+ result.push(bcAddSorter({ bcName: bcName, sorter: sorter }));
1871
+ bcToUpdate_1[bcName] = true;
1872
+ });
1873
+ var prevState = state.router;
1874
+ var willUpdateAnyway = shallowCompare(prevState, nextState, ["params"]).length > 0;
1875
+ if (!willUpdateAnyway) {
1876
+ Object.keys(bcToUpdate_1).forEach(function (bcName) {
1877
+ result.push(bcForceUpdate({ bcName: bcName }));
1878
+ });
1879
+ }
1880
+ result.push(changeLocation({ location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)) }));
1881
+ break;
1882
+ }
1883
+ return result.length ? concat7(result) : EMPTY5;
1773
1884
  })); };
1885
+ function shallowCompare(prevProps, nextProps, ignore) {
1886
+ if (ignore === void 0) { ignore = []; }
1887
+ var diffProps = [];
1888
+ if (!prevProps && !nextProps) {
1889
+ return null;
1890
+ }
1891
+ if (!prevProps) {
1892
+ return Object.keys(nextProps);
1893
+ }
1894
+ if (!nextProps) {
1895
+ return Object.keys(prevProps);
1896
+ }
1897
+ var newKeys = Object.keys(nextProps);
1898
+ newKeys.forEach(function (key) {
1899
+ if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {
1900
+ diffProps.push(key);
1901
+ }
1902
+ });
1903
+ Object.keys(prevProps).forEach(function (key) {
1904
+ if (!newKeys.includes(key)) {
1905
+ diffProps.push(key);
1906
+ }
1907
+ });
1908
+ return diffProps;
1909
+ }
1774
1910
  // src/epics/router/loginDoneEpic.ts
1775
1911
  import { filter as filter11, of as of10, switchMap as switchMap2 } from "rxjs";
1776
1912
  var loginDoneEpic = function (action$, state$) { return action$.pipe(filter11(loginDone.match), switchMap2(function (action) {
@@ -1826,20 +1962,20 @@ var changeScreen = function (action$, state$) { return action$.pipe(filter14(sel
1826
1962
  return nextView ? of12(selectView(nextView)) : of12(selectViewFail({ viewName: nextViewName }));
1827
1963
  })); };
1828
1964
  // src/epics/router/userDrillDownEpic.ts
1829
- import { catchError as catchError4, concat as concat7, EMPTY as EMPTY8, filter as filter15, mergeMap as mergeMap10, of as of13, switchMap as switchMap6 } from "rxjs";
1965
+ import { catchError as catchError4, concat as concat8, EMPTY as EMPTY8, filter as filter15, mergeMap as mergeMap10, of as of13, switchMap as switchMap6 } from "rxjs";
1830
1966
  var userDrillDownEpic = function (action$, state$, _a) {
1831
1967
  var api = _a.api;
1832
1968
  return action$.pipe(filter15(userDrillDown.match), switchMap6(function (action) {
1833
1969
  var state = state$.value;
1834
1970
  var _a = action.payload, bcName = _a.bcName, fieldKey = _a.fieldKey, cursor = _a.cursor;
1835
- var bcUrl = buildBcUrl(bcName, true);
1971
+ var bcUrl = buildBcUrl(bcName, true, state);
1836
1972
  return api.fetchRowMeta(state.screen.screenName, bcUrl).pipe(mergeMap10(function (rowMeta) {
1837
1973
  var _a, _b, _c, _d;
1838
1974
  var drillDownField = rowMeta.fields.find(function (field) { return field.key === fieldKey; });
1839
1975
  var route = state.router;
1840
1976
  var drillDownKey = (_b = (_a = state.view.widgets.find(function (widget) { return widget.bcName === bcName; })) === null || _a === void 0 ? void 0 : _a.fields.find(function (field) { return field.key === fieldKey; })) === null || _b === void 0 ? void 0 : _b.drillDownKey;
1841
1977
  var customDrillDownUrl = (_d = (_c = state.data[bcName]) === null || _c === void 0 ? void 0 : _c.find(function (record) { return record.id === cursor; })) === null || _d === void 0 ? void 0 : _d[drillDownKey];
1842
- return customDrillDownUrl || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) !== route.path ? concat7(drillDownField.drillDownType !== DrillDownType.inner ? of13(bcFetchRowMetaSuccess({ bcName: bcName, rowMeta: rowMeta, bcUrl: bcUrl, cursor: cursor })) : EMPTY8, of13(userDrillDownSuccess({ bcName: bcName, bcUrl: bcUrl, cursor: cursor })), of13(drillDown({
1978
+ return customDrillDownUrl || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) !== route.path ? concat8((drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDownType) !== DrillDownType.inner ? of13(bcFetchRowMetaSuccess({ bcName: bcName, rowMeta: rowMeta, bcUrl: bcUrl, cursor: cursor })) : EMPTY8, of13(userDrillDownSuccess({ bcName: bcName, bcUrl: bcUrl, cursor: cursor })), of13(drillDown({
1843
1979
  url: customDrillDownUrl || drillDownField.drillDown,
1844
1980
  drillDownType: drillDownField.drillDownType,
1845
1981
  route: route
@@ -1851,7 +1987,7 @@ var userDrillDownEpic = function (action$, state$, _a) {
1851
1987
  }));
1852
1988
  };
1853
1989
  // src/epics/router/changeLocationEpic.ts
1854
- import { concat as concat8, EMPTY as EMPTY9, filter as filter16, mergeMap as mergeMap11, of as of14 } from "rxjs";
1990
+ import { concat as concat9, EMPTY as EMPTY9, filter as filter16, mergeMap as mergeMap11, of as of14 } from "rxjs";
1855
1991
  var changeLocationEpic = function (action$, state$) { return action$.pipe(filter16(changeLocation.match), mergeMap11(function (action) {
1856
1992
  var _a, _b;
1857
1993
  var state = state$.value;
@@ -1897,7 +2033,7 @@ var changeLocationEpic = function (action$, state$) { return action$.pipe(filter
1897
2033
  }
1898
2034
  });
1899
2035
  }
1900
- return concat8.apply(void 0, resultObservables);
2036
+ return concat9.apply(void 0, resultObservables);
1901
2037
  })); };
1902
2038
  // src/epics/router/selectViewFailEpic.ts
1903
2039
  import { filter as filter17, map as map2 } from "rxjs";
@@ -1930,12 +2066,11 @@ var userDrillDownChangeCursorsEpic = function (action$, state$) { return action$
1930
2066
  if (cursor !== action.payload.cursor) {
1931
2067
  return bcChangeCursors({ cursorsMap: (_a = {}, _a[action.payload.bcName] = action.payload.cursor, _a) });
1932
2068
  }
1933
- return void 0;
2069
+ return emptyAction;
1934
2070
  })); };
1935
2071
  // src/epics/screen/apiErrorEpic.ts
1936
2072
  import axios from "axios";
1937
2073
  import { EMPTY as EMPTY10, filter as filter20, mergeMap as mergeMap12, of as of15 } from "rxjs";
1938
- var knownHttpErrors = [401, 409, 418, 500];
1939
2074
  var apiErrorEpic = function (action$) { return action$.pipe(filter20(apiError.match), mergeMap12(function (action) {
1940
2075
  var _a = action.payload, error = _a.error, callContext = _a.callContext;
1941
2076
  if (error.response) {
@@ -1959,7 +2094,9 @@ import { EMPTY as EMPTY11, filter as filter21, mergeMap as mergeMap13, tap } fro
1959
2094
  var downloadFileEpic = function (action$, state$, _a) {
1960
2095
  var api = _a.api;
1961
2096
  return action$.pipe(filter21(downloadFile.match), tap(function (action) {
2097
+ var fileId = action.payload.fileId;
1962
2098
  var anchor = document.createElement("a");
2099
+ anchor.href = "".concat(api.fileUploadEndpoint, "?id=").concat(encodeURIComponent(fileId));
1963
2100
  anchor.style.display = "none";
1964
2101
  document.body.appendChild(anchor);
1965
2102
  setTimeout(function () {
@@ -1976,8 +2113,8 @@ var httpError401Epic = function (action$) { return action$.pipe(filter22(httpErr
1976
2113
  // src/epics/screen/httpError409Epic.ts
1977
2114
  import { filter as filter23, map as map6 } from "rxjs";
1978
2115
  var httpError409Epic = function (action$, state$) { return action$.pipe(filter23(httpError.match), filter23(function (action) { return action.payload.statusCode === 409; }), map6(function (action) {
1979
- var _a, _b;
1980
- var notificationMessage = ((_b = (_a = action.payload.error.response.data.error) === null || _a === void 0 ? void 0 : _a.popup) === null || _b === void 0 ? void 0 : _b[0]) || "";
2116
+ var _a, _b, _c;
2117
+ var notificationMessage = ((_c = (_b = ((_a = action.payload.error.response) === null || _a === void 0 ? void 0 : _a.data).error) === null || _b === void 0 ? void 0 : _b.popup) === null || _c === void 0 ? void 0 : _c[0]) || "";
1981
2118
  return addNotification({
1982
2119
  key: "action_edit_error",
1983
2120
  message: notificationMessage,
@@ -1991,12 +2128,12 @@ var httpError409Epic = function (action$, state$) { return action$.pipe(filter23
1991
2128
  });
1992
2129
  })); };
1993
2130
  // src/epics/screen/httpError418Epic.ts
1994
- import { concat as concat9, EMPTY as EMPTY12, filter as filter24, mergeMap as mergeMap14, of as of16 } from "rxjs";
2131
+ import { concat as concat10, EMPTY as EMPTY12, filter as filter24, mergeMap as mergeMap14, of as of16 } from "rxjs";
1995
2132
  var httpError418Epic = function (action$, state$) { return action$.pipe(filter24(httpError.match), filter24(function (action) { return action.payload.statusCode === 418; }), mergeMap14(function (action) {
1996
- var _a;
1997
- var _b = action.payload, error = _b.error, callContext = _b.callContext;
2133
+ var _a, _b;
2134
+ var _c = action.payload, error = _c.error, callContext = _c.callContext;
1998
2135
  var result = [];
1999
- var typedError = error.response.data;
2136
+ var typedError = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
2000
2137
  if (!typedError.error.popup) {
2001
2138
  return EMPTY12;
2002
2139
  }
@@ -2005,16 +2142,16 @@ var httpError418Epic = function (action$, state$) { return action$.pipe(filter24
2005
2142
  message: typedError.error.popup[0]
2006
2143
  };
2007
2144
  result.push(of16(showViewError({ error: businessError })));
2008
- if ((_a = typedError.error.postActions) === null || _a === void 0 ? void 0 : _a[0]) {
2145
+ if ((_b = typedError.error.postActions) === null || _b === void 0 ? void 0 : _b[0]) {
2009
2146
  var widget = state$.value.view.widgets.find(function (item) { return item.name === callContext.widgetName; });
2010
- var bcName = widget.bcName;
2147
+ var bcName = widget === null || widget === void 0 ? void 0 : widget.bcName;
2011
2148
  result.push(of16(processPostInvoke({
2012
2149
  bcName: bcName,
2013
2150
  postInvoke: typedError.error.postActions[0],
2014
- widgetName: widget.name
2151
+ widgetName: widget === null || widget === void 0 ? void 0 : widget.name
2015
2152
  })));
2016
2153
  }
2017
- return concat9.apply(void 0, result);
2154
+ return concat10.apply(void 0, result);
2018
2155
  })); };
2019
2156
  // src/epics/screen/httpError500Epic.ts
2020
2157
  import { filter as filter25, map as map7 } from "rxjs";
@@ -2029,11 +2166,13 @@ var httpError500Epic = function (action$, state$) { return action$.pipe(filter25
2029
2166
  })); };
2030
2167
  // src/epics/screen/httpErrorDefaultEpic.ts
2031
2168
  import { filter as filter26, map as map8 } from "rxjs";
2032
- var httpErrorDefaultEpic = function (action$, store) { return action$.pipe(filter26(httpError.match), filter26(function (action) { return !knownHttpErrors.includes(action.payload.statusCode); }), map8(function (action) {
2169
+ var knownHttpErrors = [401, 409, 418, 500];
2170
+ var httpErrorDefaultEpic = function (action$, state$) { return action$.pipe(filter26(httpError.match), filter26(function (action) { return !knownHttpErrors.includes(action.payload.statusCode); }), map8(function (action) {
2171
+ var _a, _b;
2033
2172
  var businessError = {
2034
2173
  type: 0 /* BusinessError */,
2035
- code: action.payload.error.response.status,
2036
- details: action.payload.error.response.data
2174
+ code: (_a = action.payload.error.response) === null || _a === void 0 ? void 0 : _a.status,
2175
+ details: (_b = action.payload.error.response) === null || _b === void 0 ? void 0 : _b.data
2037
2176
  };
2038
2177
  return showViewError({ error: businessError });
2039
2178
  })); };
@@ -2054,6 +2193,7 @@ var downloadFileByUrlEpic = function (action$, state$) { return action$.pipe(fil
2054
2193
  import { EMPTY as EMPTY14, filter as filter28, mergeMap as mergeMap16, of as of17 } from "rxjs";
2055
2194
  var processPostInvokeEpic = function (action$, state$) { return action$.pipe(filter28(processPostInvoke.match), mergeMap16(function (action) {
2056
2195
  var _a;
2196
+ var _b;
2057
2197
  var state = state$.value;
2058
2198
  switch (action.payload.postInvoke.type) {
2059
2199
  case "drillDown" /* drillDown */:
@@ -2061,7 +2201,10 @@ var processPostInvokeEpic = function (action$, state$) { return action$.pipe(fil
2061
2201
  case "postDelete" /* postDelete */: {
2062
2202
  var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
2063
2203
  var result = [bcChangeCursors({ cursorsMap: cursorsMap })];
2064
- if (state.router.bcPath.includes("".concat(action.payload.bcName, "/"))) {
2204
+ if ((_b = state.router.bcPath) === null || _b === void 0 ? void 0 : _b.includes("".concat(action.payload.bcName, "/"))) {
2205
+ var newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || "";
2206
+ var newUrl = "/screen/".concat(state.router.screenName, "/view/").concat(state.router.viewName, "/").concat(newBcUrl);
2207
+ result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }));
2065
2208
  }
2066
2209
  else {
2067
2210
  result.push(bcFetchDataRequest({
@@ -2130,33 +2273,33 @@ var processPostInvokeConfirmEpic = function (action$, state$) { return action$.p
2130
2273
  }
2131
2274
  })); };
2132
2275
  // src/epics/session/switchRoleEpic.ts
2133
- import { concat as concat10, filter as filter30, switchMap as switchMap7 } from "rxjs";
2276
+ import { concat as concat11, filter as filter30, switchMap as switchMap7 } from "rxjs";
2134
2277
  var switchRoleEpic = function (action$, state$) { return action$.pipe(filter30(switchRole.match), switchMap7(function (action) {
2135
- return concat10([logoutDone(null), login({ login: "", password: "", role: action.payload.role })]);
2278
+ return concat11([logoutDone(null), login({ login: "", password: "", role: action.payload.role })]);
2136
2279
  })); };
2137
2280
  // src/epics/session/refreshMetaEpic.ts
2138
- import { catchError as catchError5, concat as concat11, filter as filter31, mergeMap as mergeMap18, of as of19, switchMap as switchMap8 } from "rxjs";
2281
+ import { catchError as catchError5, concat as concat12, filter as filter31, mergeMap as mergeMap18, switchMap as switchMap8 } from "rxjs";
2139
2282
  var refreshMetaEpic = function (action$, state$, _a) {
2140
2283
  var api = _a.api;
2141
2284
  return action$.pipe(filter31(refreshMeta.match), mergeMap18(function () {
2142
2285
  var state = state$.value;
2143
2286
  var router = state.router;
2144
2287
  var activeRole = state.session.activeRole;
2145
- return api.refreshMeta().pipe(switchMap8(function () { return concat11([
2288
+ return api.refreshMeta().pipe(switchMap8(function () { return concat12([
2289
+ refreshMetaDone(),
2146
2290
  logoutDone(null),
2147
2291
  login({ login: "", password: "", role: activeRole }),
2148
2292
  changeLocation({
2149
- route: router,
2150
- action: "PUSH"
2293
+ location: router
2151
2294
  })
2152
- ]); }), catchError5(function (error) { return of19(loginFail(error)); }));
2295
+ ]); }), catchError5(function (error) { return concat12([loginFail(error), refreshMetaFail()]); }));
2153
2296
  }));
2154
2297
  };
2155
2298
  // src/epics/session/loginDoneEpic.ts
2156
2299
  import { EMPTY as EMPTY16, filter as filter32, switchMap as switchMap9 } from "rxjs";
2157
2300
  var loginDoneSessionEpic = function (action$, store) { return action$.pipe(filter32(login.match), switchMap9(function (action) { return EMPTY16; })); };
2158
2301
  // src/epics/session/loginByAnotherRoleEpic.ts
2159
- import { catchError as catchError6, EMPTY as EMPTY17, filter as filter33, mergeMap as mergeMap19, of as of20, switchMap as switchMap10 } from "rxjs";
2302
+ import { catchError as catchError6, concat as concat13, filter as filter33, mergeMap as mergeMap19, of as of19, switchMap as switchMap10 } from "rxjs";
2160
2303
  var responseStatusMessages = {
2161
2304
  401: "Invalid credentials",
2162
2305
  403: "Access denied"
@@ -2168,55 +2311,75 @@ var loginByAnotherRoleEpic = function (action$, state$, _a) {
2168
2311
  var role = (_a = action.payload.role) !== null && _a !== void 0 ? _a : "";
2169
2312
  var isSwitchRole = role && role !== state$.value.session.activeRole;
2170
2313
  return api.loginByRoleRequest(role).pipe(mergeMap19(function (data) {
2314
+ var _a;
2315
+ var result = [];
2171
2316
  if (isSwitchRole) {
2317
+ var defaultScreen = data.screens.find(function (screen) { return screen.defaultScreen; }) || data.screens[0];
2318
+ var defaultViewName_1 = (_a = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.primary) !== null && _a !== void 0 ? _a : defaultScreen.meta.views[0].name;
2319
+ var defaultView = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.meta.views.find(function (view) { return defaultViewName_1 === view.name; });
2320
+ if (defaultView)
2321
+ result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }));
2172
2322
  }
2173
- return EMPTY17;
2323
+ return concat13(__spreadArray(__spreadArray([], result, true), [
2324
+ loginDone({
2325
+ devPanelEnabled: data.devPanelEnabled,
2326
+ activeRole: data.activeRole,
2327
+ roles: data.roles,
2328
+ screens: data.screens,
2329
+ firstName: data.firstName,
2330
+ lastName: data.lastName,
2331
+ login: data.login
2332
+ })
2333
+ ], false));
2174
2334
  }), catchError6(function (error) {
2175
2335
  console.error(error);
2176
2336
  var errorMsg = error.response ? responseStatusMessages[error.response.status] || "Server application unavailable" : "Empty server response";
2177
- return of20(loginFail({ errorMsg: errorMsg }));
2337
+ return of19(loginFail({ errorMsg: errorMsg }));
2178
2338
  }));
2179
2339
  }));
2180
2340
  };
2181
2341
  // src/epics/session/refreshMetaAndReloadPageEpic.ts
2182
- import { concat as concat12, EMPTY as EMPTY18, filter as filter34, of as of21, switchMap as switchMap11, take, tap as tap3 } from "rxjs";
2183
- var refreshMetaAndReloadPageEpic = function (action$, state$) { return action$.pipe(filter34(refreshMetaAndReloadPage.match), switchMap11(function () { return concat12(of21(refreshMeta(null)), action$.pipe(filter34(loginDone.match), take(1), tap3(function () { return location.reload(); }), switchMap11(function () { return EMPTY18; }))); })); };
2342
+ import { concat as concat14, EMPTY as EMPTY17, filter as filter34, of as of20, switchMap as switchMap11, take, tap as tap3 } from "rxjs";
2343
+ var refreshMetaAndReloadPageEpic = function (action$, state$) { return action$.pipe(filter34(refreshMetaAndReloadPage.match), switchMap11(function () { return concat14(of20(refreshMeta(null)), action$.pipe(filter34(loginDone.match), take(1), tap3(function () { return location.reload(); }), switchMap11(function () { return EMPTY17; }))); })); };
2184
2344
  // src/epics/data/bcNewDataEpic.ts
2185
- import { catchError as catchError7, concat as concat13, EMPTY as EMPTY19, filter as filter35, mergeMap as mergeMap20, of as of22 } from "rxjs";
2345
+ import { catchError as catchError7, concat as concat15, EMPTY as EMPTY18, filter as filter35, mergeMap as mergeMap20, of as of21 } from "rxjs";
2186
2346
  import { OperationTypeCrud as OperationTypeCrud8 } from "@cxbox-ui/schema";
2187
2347
  var bcNewDataEpic = function (action$, state$, _a) {
2188
2348
  var api = _a.api;
2189
2349
  return action$.pipe(filter35(sendOperation.match), filter35(function (action) { return matchOperationRole(OperationTypeCrud8.create, action.payload, state$.value); }), mergeMap20(function (action) {
2350
+ var _a;
2190
2351
  var state = state$.value;
2191
2352
  var bcName = action.payload.bcName;
2192
- var bcUrl = buildBcUrl(bcName);
2353
+ var bcUrl = (_a = buildBcUrl(bcName, false, state)) !== null && _a !== void 0 ? _a : "";
2193
2354
  var context = { widgetName: action.payload.widgetName };
2194
2355
  var params = { _action: action.payload.operationType };
2195
2356
  return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe(mergeMap20(function (data) {
2357
+ var _a, _b;
2196
2358
  var rowMeta = data.row;
2197
2359
  var dataItem = { id: null, vstamp: -1 };
2198
2360
  data.row.fields.forEach(function (field) {
2199
2361
  dataItem[field.key] = field.currentValue;
2200
2362
  });
2201
- var postInvoke = data.postActions[0];
2363
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2202
2364
  var cursor = dataItem.id;
2203
- return concat13(of22(bcNewDataSuccess({ bcName: bcName, dataItem: dataItem, bcUrl: bcUrl })), of22(bcFetchRowMetaSuccess({ bcName: bcName, bcUrl: "".concat(bcUrl, "/").concat(cursor), rowMeta: rowMeta, cursor: cursor })), of22(changeDataItem({
2204
- bcName: action.payload.bcName,
2365
+ return concat15(of21(bcNewDataSuccess({ bcName: bcName, dataItem: dataItem, bcUrl: bcUrl })), of21(bcFetchRowMetaSuccess({ bcName: bcName, bcUrl: "".concat(bcUrl, "/").concat(cursor), rowMeta: rowMeta, cursor: cursor })), of21(changeDataItem({
2366
+ bcName: bcName,
2367
+ bcUrl: (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "",
2205
2368
  cursor: cursor,
2206
2369
  dataItem: {
2207
2370
  id: cursor
2208
2371
  }
2209
- })), postInvoke ? of22(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: action.payload.widgetName })) : EMPTY19);
2372
+ })), postInvoke ? of21(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: action.payload.widgetName })) : EMPTY18);
2210
2373
  }), catchError7(function (error) {
2211
2374
  console.error(error);
2212
- return of22(bcNewDataFail({ bcName: bcName }));
2375
+ return of21(bcNewDataFail({ bcName: bcName }));
2213
2376
  }));
2214
2377
  }));
2215
2378
  };
2216
2379
  // src/epics/data/bcLoadMoreEpic.ts
2217
- import { catchError as catchError8, filter as filter37, mergeMap as mergeMap22, of as of24, race } from "rxjs";
2380
+ import { catchError as catchError8, filter as filter37, mergeMap as mergeMap22, of as of23, race } from "rxjs";
2218
2381
  // src/utils/cancelRequestEpic.ts
2219
- import { filter as filter36, mergeMap as mergeMap21, of as of23, take as take2 } from "rxjs";
2382
+ import { filter as filter36, mergeMap as mergeMap21, of as of22, take as take2 } from "rxjs";
2220
2383
  import { isAnyOf as isAnyOf2 } from "@reduxjs/toolkit";
2221
2384
  var cancelRequestActionTypes = [selectView, logout];
2222
2385
  function cancelRequestEpic(action$, actionTypes, cancelFn, cancelActionCreator, filterFn) {
@@ -2224,8 +2387,8 @@ function cancelRequestEpic(action$, actionTypes, cancelFn, cancelActionCreator,
2224
2387
  return true;
2225
2388
  }; }
2226
2389
  return action$.pipe(filter36(isAnyOf2.apply(void 0, actionTypes)), filter36(filterFn), mergeMap21(function () {
2227
- cancelFn();
2228
- return of23(cancelActionCreator);
2390
+ cancelFn === null || cancelFn === void 0 ? void 0 : cancelFn();
2391
+ return of22(cancelActionCreator);
2229
2392
  }), take2(1));
2230
2393
  }
2231
2394
  // src/epics/data/bcLoadMoreEpic.ts
@@ -2239,7 +2402,7 @@ var bcLoadMoreEpic = function (action$, state$, _a) {
2239
2402
  var cursor = bc.cursor, page = bc.page;
2240
2403
  var limit = ((_a = state.view.widgets.find(function (i) { return i.bcName === bcName; })) === null || _a === void 0 ? void 0 : _a.limit) || bc.limit;
2241
2404
  var limitBySelfCursor = (_b = state.router.bcPath) === null || _b === void 0 ? void 0 : _b.includes("".concat(bcName, "/").concat(cursor));
2242
- var bcUrl = buildBcUrl(bcName, limitBySelfCursor);
2405
+ var bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
2243
2406
  var filters = state.screen.filters[bcName] || [];
2244
2407
  var sorters = state.screen.sorters[bcName];
2245
2408
  var fetchParams = __assign(__assign({ _page: page, _limit: limit }, getFilters(filters)), getSorters(sorters));
@@ -2249,7 +2412,7 @@ var bcLoadMoreEpic = function (action$, state$, _a) {
2249
2412
  var _a;
2250
2413
  var oldBcDataIds = (_a = state.data[bcName]) === null || _a === void 0 ? void 0 : _a.map(function (i) { return i.id; });
2251
2414
  var newData = __spreadArray(__spreadArray([], state.data[bcName], true), data.data.filter(function (i) { return !oldBcDataIds.includes(i.id); }), true);
2252
- return of24(bcFetchDataSuccess({
2415
+ return of23(bcFetchDataSuccess({
2253
2416
  bcName: bcName,
2254
2417
  data: newData,
2255
2418
  bcUrl: bcUrl,
@@ -2257,26 +2420,26 @@ var bcLoadMoreEpic = function (action$, state$, _a) {
2257
2420
  }));
2258
2421
  }), catchError8(function (error) {
2259
2422
  console.error(error);
2260
- return of24(bcFetchDataFail({ bcName: bcName, bcUrl: bcUrl }));
2423
+ return of23(bcFetchDataFail({ bcName: bcName, bcUrl: bcUrl }));
2261
2424
  }));
2262
2425
  return race(cancelFlow, normalFlow);
2263
2426
  }));
2264
2427
  };
2265
2428
  // src/epics/data/bcSaveDataEpic.ts
2266
- import { catchError as catchError9, concat as concat14, EMPTY as EMPTY20, filter as filter38, mergeMap as mergeMap23, of as of25 } from "rxjs";
2429
+ import { catchError as catchError9, concat as concat16, EMPTY as EMPTY19, filter as filter38, mergeMap as mergeMap23, of as of24 } from "rxjs";
2267
2430
  var bcSaveDataEpic = function (action$, state$, _a) {
2268
2431
  var api = _a.api;
2269
2432
  return action$.pipe(filter38(sendOperation.match), filter38(function (action) { return matchOperationRole(OperationTypeCrud.save, action.payload, state$.value); }), mergeMap23(function (action) {
2270
- var _a, _b, _c;
2433
+ var _a, _b, _c, _d;
2271
2434
  var state = state$.value;
2272
2435
  var bcName = action.payload.bcName;
2273
- var bcUrl = buildBcUrl(bcName, true);
2436
+ var bcUrl = (_a = buildBcUrl(bcName, true, state)) !== null && _a !== void 0 ? _a : "";
2274
2437
  var widgetName = action.payload.widgetName;
2275
2438
  var cursor = state.screen.bo.bc[bcName].cursor;
2276
2439
  var dataItem = state.data[bcName].find(function (item) { return item.id === cursor; });
2277
- var pendingChanges = (_a = state.view.pendingDataChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
2278
- var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
2279
- var options = (_c = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _c === void 0 ? void 0 : _c.options;
2440
+ var pendingChanges = __assign({}, (_b = state.view.pendingDataChanges[bcName]) === null || _b === void 0 ? void 0 : _b[cursor]);
2441
+ var rowMeta = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
2442
+ var options = (_d = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _d === void 0 ? void 0 : _d.options;
2280
2443
  if (rowMeta) {
2281
2444
  var fields = rowMeta.fields;
2282
2445
  var _loop_2 = function (key) {
@@ -2293,21 +2456,22 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2293
2456
  return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] });
2294
2457
  });
2295
2458
  var context = { widgetName: action.payload.widgetName };
2296
- return api.saveBcData(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: dataItem.vstamp }), context).pipe(mergeMap23(function (data) {
2297
- var postInvoke = data.postActions[0];
2459
+ return api.saveBcData(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: dataItem === null || dataItem === void 0 ? void 0 : dataItem.vstamp }), context).pipe(mergeMap23(function (data) {
2460
+ var _a;
2461
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2298
2462
  var responseDataItem = data.record;
2299
- return concat14(of25(bcSaveDataSuccess({ bcName: bcName, cursor: cursor, dataItem: responseDataItem })), of25(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName })), of25.apply(void 0, fetchChildrenBcData), postInvoke ? of25(processPostInvoke({
2463
+ return concat16(of24(bcSaveDataSuccess({ bcName: bcName, cursor: cursor, dataItem: responseDataItem })), of24(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName })), of24.apply(void 0, fetchChildrenBcData), postInvoke ? of24(processPostInvoke({
2300
2464
  bcName: bcName,
2301
2465
  widgetName: widgetName,
2302
2466
  postInvoke: postInvoke,
2303
2467
  cursor: responseDataItem.id
2304
- })) : EMPTY20, action.payload.onSuccessAction ? of25(action.payload.onSuccessAction) : EMPTY20);
2468
+ })) : EMPTY19, action.payload.onSuccessAction ? of24(action.payload.onSuccessAction) : EMPTY19);
2305
2469
  }), catchError9(function (e) {
2306
- var _a, _b, _c, _d, _e, _f;
2470
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2307
2471
  console.error(e);
2308
- var notification$ = EMPTY20;
2472
+ var notification$ = EMPTY19;
2309
2473
  if (action.payload.onSuccessAction && !(options === null || options === void 0 ? void 0 : options.disableNotification)) {
2310
- notification$ = of25(addNotification({
2474
+ notification$ = of24(addNotification({
2311
2475
  key: "data_autosave_undo",
2312
2476
  type: "buttonWarningNotification",
2313
2477
  message: "There are pending changes. Please save them or cancel.",
@@ -2324,15 +2488,15 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2324
2488
  var entityError = null;
2325
2489
  var operationError = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data;
2326
2490
  if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.data) === Object((_c = e.response) === null || _c === void 0 ? void 0 : _c.data)) {
2327
- entityError = (_d = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _d === void 0 ? void 0 : _d.entity;
2328
- viewError = (_f = (_e = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _e === void 0 ? void 0 : _e.popup) === null || _f === void 0 ? void 0 : _f[0];
2491
+ entityError = (_e = (_d = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _d === void 0 ? void 0 : _d.entity) !== null && _e !== void 0 ? _e : entityError;
2492
+ viewError = (_h = (_g = (_f = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _f === void 0 ? void 0 : _f.popup) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : viewError;
2329
2493
  }
2330
- return concat14(of25(bcSaveDataFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError })), notification$);
2494
+ return concat16(of24(bcSaveDataFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError })), notification$);
2331
2495
  }));
2332
2496
  }));
2333
2497
  };
2334
2498
  // src/epics/data/selectViewEpic.ts
2335
- import { EMPTY as EMPTY21, filter as filter39, mergeMap as mergeMap24 } from "rxjs";
2499
+ import { EMPTY as EMPTY20, filter as filter39, mergeMap as mergeMap24 } from "rxjs";
2336
2500
  var selectViewEpic = function (action$, state$) { return action$.pipe(filter39(selectView.match), mergeMap24(function (action) {
2337
2501
  try {
2338
2502
  var state_1 = state$.value;
@@ -2358,12 +2522,12 @@ var selectViewEpic = function (action$, state$) { return action$.pipe(filter39(s
2358
2522
  }
2359
2523
  catch (e) {
2360
2524
  console.error("selectView Epic:: ".concat(e));
2361
- return EMPTY21;
2525
+ return EMPTY20;
2362
2526
  }
2363
2527
  })); };
2364
2528
  // src/epics/data/bcFetchDataEpic.ts
2365
- import { catchError as catchError10, concat as concat15, EMPTY as EMPTY22, filter as filter40, mergeMap as mergeMap25, of as of26, race as race2 } from "rxjs";
2366
- import { WidgetTypes as WidgetTypes4 } from "@cxbox-ui/schema";
2529
+ import { catchError as catchError10, concat as concat17, EMPTY as EMPTY21, filter as filter40, mergeMap as mergeMap25, of as of25, race as race2 } from "rxjs";
2530
+ import { WidgetTypes as WidgetTypes5 } from "@cxbox-ui/schema";
2367
2531
  import { isAnyOf as isAnyOf3 } from "@reduxjs/toolkit";
2368
2532
  var bcFetchDataEpic = function (action$, state$, _a) {
2369
2533
  var api = _a.api;
@@ -2374,7 +2538,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2374
2538
  var bcName = action.payload.bcName;
2375
2539
  var keepDelta = bcFetchDataRequest.match(action) ? action.payload.keepDelta : void 0;
2376
2540
  var newCursor = (_b = data[0]) === null || _b === void 0 ? void 0 : _b.id;
2377
- return of26(bcChangeCursors({
2541
+ return of25(bcChangeCursors({
2378
2542
  cursorsMap: (_a = {},
2379
2543
  _a[bcName] = data.some(function (i) { return i.id === prevCursor; }) ? prevCursor : newCursor,
2380
2544
  _a),
@@ -2384,7 +2548,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2384
2548
  var getChildrenData = function (widgets, bcDictionary, isHierarchy, showConditionCheck) {
2385
2549
  var bcName = action.payload.bcName;
2386
2550
  var _a = bcFetchDataRequest.match(action) ? action.payload : { ignorePageLimit: void 0, keepDelta: void 0 }, ignorePageLimit = _a.ignorePageLimit, keepDelta = _a.keepDelta;
2387
- return concat15.apply(void 0, Object.entries(getBcChildren(bcName, widgets, bcDictionary)).filter(function (_a) {
2551
+ return concat17.apply(void 0, Object.entries(getBcChildren(bcName, widgets, bcDictionary)).filter(function (_a) {
2388
2552
  var childBcName = _a[0], widgetNames = _a[1];
2389
2553
  var nonLazyWidget = widgets.find(function (item) {
2390
2554
  return widgetNames.includes(item.name) && !PopupWidgetTypes.includes(item.type) && showConditionCheck(item);
@@ -2399,43 +2563,43 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2399
2563
  var nonLazyWidget = widgets.find(function (item) {
2400
2564
  return widgetNames.includes(item.name) && !PopupWidgetTypes.includes(item.type) && showConditionCheck(item);
2401
2565
  });
2402
- return of26(bcFetchDataRequest({
2566
+ return of25(bcFetchDataRequest({
2403
2567
  bcName: childBcName,
2404
- widgetName: nonLazyWidget.name,
2568
+ widgetName: nonLazyWidget === null || nonLazyWidget === void 0 ? void 0 : nonLazyWidget.name,
2405
2569
  ignorePageLimit: ignorePageLimit || showViewPopup.match(action),
2406
2570
  keepDelta: isHierarchy || keepDelta
2407
2571
  }));
2408
2572
  }));
2409
2573
  };
2410
2574
  var bcFetchDataImpl = function () {
2411
- var _a, _b, _c, _d, _e, _f;
2575
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2412
2576
  var state = state$.value;
2413
- var widgetName = action.payload.widgetName;
2414
- var _g = state.view, widgets = _g.widgets, infiniteWidgets = _g.infiniteWidgets;
2415
- var widget = (_a = widgets.find(function (item) { return item.name === widgetName; })) !== null && _a !== void 0 ? _a : widgets.find(function (item) { return item.bcName === action.payload.bcName; });
2577
+ var _j = action.payload.widgetName, widgetName = _j === void 0 ? "" : _j;
2578
+ var _k = state.view, widgets = _k.widgets, infiniteWidgets = _k.infiniteWidgets;
2579
+ var widget = (_a = widgets === null || widgets === void 0 ? void 0 : widgets.find(function (item) { return item.name === widgetName; })) !== null && _a !== void 0 ? _a : widgets === null || widgets === void 0 ? void 0 : widgets.find(function (item) { return item.bcName === action.payload.bcName; });
2416
2580
  if (!widget) {
2417
- return [EMPTY22];
2581
+ return [EMPTY21];
2418
2582
  }
2419
2583
  var bcName = action.payload.bcName;
2420
2584
  var bc = state.screen.bo.bc[bcName];
2421
- var cursor = bc.cursor, page = bc.page;
2422
- var limit = ((_b = widgets.find(function (i) { return i.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.limit) || bc.limit;
2585
+ var cursor = bc.cursor, _l = bc.page, page = _l === void 0 ? 1 : _l;
2586
+ var limit = (_c = (((_b = widgets === null || widgets === void 0 ? void 0 : widgets.find(function (i) { return i.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.limit) || bc.limit)) !== null && _c !== void 0 ? _c : 5;
2423
2587
  var sorters = state.screen.sorters[bcName];
2424
2588
  if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {
2425
- return [EMPTY22];
2589
+ return [EMPTY21];
2426
2590
  }
2427
- var anyHierarchyWidget = widgets.find(function (item) {
2428
- return item.bcName === widget.bcName && item.type === WidgetTypes4.AssocListPopup && isHierarchyWidget(item);
2591
+ var anyHierarchyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.find(function (item) {
2592
+ return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && isHierarchyWidget(item);
2429
2593
  });
2430
- var fullHierarchyWidget = state.view.widgets.find(function (item) {
2594
+ var fullHierarchyWidget = (_d = state.view.widgets) === null || _d === void 0 ? void 0 : _d.find(function (item) {
2431
2595
  var _a;
2432
- return item.bcName === widget.bcName && item.type === WidgetTypes4.AssocListPopup && ((_a = item.options) === null || _a === void 0 ? void 0 : _a.hierarchyFull);
2596
+ return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && ((_a = item.options) === null || _a === void 0 ? void 0 : _a.hierarchyFull);
2433
2597
  });
2434
- var limitBySelfCursor = (_c = state.router.bcPath) === null || _c === void 0 ? void 0 : _c.includes("".concat(bcName, "/").concat(cursor));
2435
- var bcUrl = buildBcUrl(bcName, limitBySelfCursor);
2598
+ var limitBySelfCursor = (_e = state.router.bcPath) === null || _e === void 0 ? void 0 : _e.includes("".concat(bcName, "/").concat(cursor));
2599
+ var bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
2436
2600
  var fetchParams = __assign(__assign({ _page: page, _limit: limit }, getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || [])), getSorters(sorters));
2437
2601
  if (bcForceUpdate.match(action)) {
2438
- var infinityPaginationWidget = widgetName && infiniteWidgets.includes(widgetName) || ((_e = (_d = widgets === null || widgets === void 0 ? void 0 : widgets.filter(function (item) { return item.bcName === bcName; })) === null || _d === void 0 ? void 0 : _d.find(function (item) { return infiniteWidgets.includes(item.name); })) === null || _e === void 0 ? void 0 : _e.name);
2602
+ var infinityPaginationWidget = widgetName && (infiniteWidgets === null || infiniteWidgets === void 0 ? void 0 : infiniteWidgets.includes(widgetName)) || ((_g = (_f = widgets === null || widgets === void 0 ? void 0 : widgets.filter(function (item) { return item.bcName === bcName; })) === null || _f === void 0 ? void 0 : _f.find(function (item) { return infiniteWidgets === null || infiniteWidgets === void 0 ? void 0 : infiniteWidgets.includes(item.name); })) === null || _g === void 0 ? void 0 : _g.name);
2439
2603
  if (infinityPaginationWidget) {
2440
2604
  fetchParams._page = 1;
2441
2605
  fetchParams._limit = limit * page;
@@ -2445,7 +2609,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2445
2609
  fetchParams._page = action.payload.from || 1;
2446
2610
  fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit;
2447
2611
  }
2448
- if (bcFetchDataRequest.match(action) && action.payload.ignorePageLimit || ((_f = anyHierarchyWidget === null || anyHierarchyWidget === void 0 ? void 0 : anyHierarchyWidget.options) === null || _f === void 0 ? void 0 : _f.hierarchyFull)) {
2612
+ if (bcFetchDataRequest.match(action) && action.payload.ignorePageLimit || ((_h = anyHierarchyWidget === null || anyHierarchyWidget === void 0 ? void 0 : anyHierarchyWidget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull)) {
2449
2613
  fetchParams._limit = 0;
2450
2614
  }
2451
2615
  var canceler = api.createCanceler();
@@ -2457,7 +2621,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2457
2621
  var normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(mergeMap25(function (response) {
2458
2622
  var _a, _b;
2459
2623
  var cursorChange = getCursorChange(response.data, cursor, !!anyHierarchyWidget);
2460
- var parentOfNotLazyWidget = widgets.some(function (item) {
2624
+ var parentOfNotLazyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.some(function (item) {
2461
2625
  var _a;
2462
2626
  return ((_a = state.screen.bo.bc[item.bcName]) === null || _a === void 0 ? void 0 : _a.parentName) === bcName && !PopupWidgetTypes.includes(item.type);
2463
2627
  });
@@ -2480,11 +2644,11 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2480
2644
  var lazyWidget = (!isWidgetVisible(widget) || PopupWidgetTypes.includes(widget.type)) && !parentOfNotLazyWidget;
2481
2645
  var skipLazy = ((_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.bcName) !== widget.bcName;
2482
2646
  if (lazyWidget && skipLazy) {
2483
- return EMPTY22;
2647
+ return EMPTY21;
2484
2648
  }
2485
- var fetchChildren = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) ? getChildrenData(widgets, state.screen.bo.bc, !!anyHierarchyWidget, isWidgetVisible) : EMPTY22;
2486
- var fetchRowMeta = of26(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName }));
2487
- return concat15(cursorChange, of26(bcFetchDataSuccess({
2649
+ var fetchChildren = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) ? getChildrenData(widgets, state.screen.bo.bc, !!anyHierarchyWidget, isWidgetVisible) : EMPTY21;
2650
+ var fetchRowMeta = of25(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName }));
2651
+ return concat17(cursorChange, of25(bcFetchDataSuccess({
2488
2652
  bcName: bcName,
2489
2653
  data: response.data,
2490
2654
  bcUrl: bcUrl,
@@ -2492,7 +2656,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2492
2656
  })), fetchRowMeta, fetchChildren);
2493
2657
  }), catchError10(function (error) {
2494
2658
  console.error(error);
2495
- return of26(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl: bcUrl }));
2659
+ return of25(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl: bcUrl }));
2496
2660
  }));
2497
2661
  return [cancelFlow, cancelByParentBc, normalFlow];
2498
2662
  };
@@ -2504,7 +2668,7 @@ function isHierarchyWidget(widget) {
2504
2668
  return ((_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchy) || ((_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchyFull);
2505
2669
  }
2506
2670
  // src/epics/data/bcDeleteDataEpic.ts
2507
- import { catchError as catchError11, concat as concat16, EMPTY as EMPTY23, filter as filter41, mergeMap as mergeMap26, of as of27 } from "rxjs";
2671
+ import { catchError as catchError11, concat as concat18, EMPTY as EMPTY22, filter as filter41, mergeMap as mergeMap26, of as of26 } from "rxjs";
2508
2672
  import { OperationTypeCrud as OperationTypeCrud9 } from "@cxbox-ui/schema";
2509
2673
  var bcDeleteDataEpic = function (action$, store$, _a) {
2510
2674
  var api = _a.api;
@@ -2513,20 +2677,21 @@ var bcDeleteDataEpic = function (action$, store$, _a) {
2513
2677
  var state = store$.value;
2514
2678
  var bcName = action.payload.bcName;
2515
2679
  var cursor = state.screen.bo.bc[bcName].cursor;
2516
- var bcUrl = buildBcUrl(bcName, true);
2680
+ var bcUrl = buildBcUrl(bcName, true, state);
2517
2681
  var context = { widgetName: action.payload.widgetName };
2518
2682
  var isTargetFormatPVF = state.view.pendingValidationFailsFormat === "target" /* target */;
2519
2683
  return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe(mergeMap26(function (data) {
2520
- var postInvoke = data.postActions[0];
2521
- return concat16(isTargetFormatPVF ? of27(bcCancelPendingChanges({ bcNames: [bcName] })) : EMPTY23, of27(bcFetchDataRequest({ bcName: bcName, widgetName: widgetName })), postInvoke ? of27(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: widgetName })) : EMPTY23);
2684
+ var _a;
2685
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2686
+ return concat18(isTargetFormatPVF ? of26(bcCancelPendingChanges({ bcNames: [bcName] })) : EMPTY22, of26(bcFetchDataRequest({ bcName: bcName, widgetName: widgetName })), postInvoke ? of26(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: widgetName })) : EMPTY22);
2522
2687
  }), catchError11(function (error) {
2523
2688
  console.error(error);
2524
- return of27(bcDeleteDataFail({ bcName: bcName }));
2689
+ return of26(bcDeleteDataFail({ bcName: bcName }));
2525
2690
  }));
2526
2691
  }));
2527
2692
  };
2528
2693
  // src/epics/data/bcSelectRecordEpic.ts
2529
- import { concat as concat17, filter as filter42, mergeMap as mergeMap27, of as of28 } from "rxjs";
2694
+ import { concat as concat19, filter as filter42, mergeMap as mergeMap27, of as of27 } from "rxjs";
2530
2695
  var bcSelectRecordEpic = function (action$, store$) { return action$.pipe(filter42(bcSelectRecord.match), mergeMap27(function (action) {
2531
2696
  var _a;
2532
2697
  var _b = action.payload, bcName = _b.bcName, cursor = _b.cursor;
@@ -2541,17 +2706,19 @@ var bcSelectRecordEpic = function (action$, store$) { return action$.pipe(filter
2541
2706
  keepDelta: action.payload.keepDelta
2542
2707
  });
2543
2708
  });
2544
- return concat17(of28(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = cursor, _a), keepDelta: action.payload.keepDelta })), of28(bcFetchRowMeta({ widgetName: "", bcName: bcName })), fetchChildrenBcData);
2709
+ return concat19(of27(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = cursor, _a), keepDelta: action.payload.keepDelta })), of27(bcFetchRowMeta({ widgetName: "", bcName: bcName })), fetchChildrenBcData);
2545
2710
  })); };
2546
2711
  // src/epics/data/changeAssociationEpic.ts
2547
- import { concat as concat18, filter as filter43, mergeMap as mergeMap28, of as of29 } from "rxjs";
2712
+ import { concat as concat20, filter as filter43, mergeMap as mergeMap28, of as of28 } from "rxjs";
2548
2713
  var changeAssociationEpic = function (action$, state$) { return action$.pipe(filter43(changeAssociation.match), mergeMap28(function (action) {
2549
2714
  var _a, _b, _c, _d, _e;
2550
2715
  var state = state$.value;
2551
2716
  var selected = action.payload.dataItem._associate;
2717
+ var bcName = action.payload.bcName;
2552
2718
  var result = [
2553
- of29(changeDataItem({
2554
- bcName: action.payload.bcName,
2719
+ of28(changeDataItem({
2720
+ bcName: bcName,
2721
+ bcUrl: buildBcUrl(bcName, true, state),
2555
2722
  cursor: action.payload.dataItem.id,
2556
2723
  dataItem: action.payload.dataItem
2557
2724
  }))
@@ -2564,30 +2731,30 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe(fil
2564
2731
  fields: widget.fields
2565
2732
  };
2566
2733
  var hierarchy = (_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchy;
2567
- var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
2734
+ var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
2568
2735
  var hierarchyGroupSelection = (_c = widget.options) === null || _c === void 0 ? void 0 : _c.hierarchyGroupSelection;
2569
2736
  var hierarchyTraverse = (_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyTraverse;
2570
- var childrenBc = hierarchy.slice(hierarchy.findIndex(function (item) { return item.bcName === action.payload.bcName; }) + 1).map(function (item) { return item.bcName; });
2737
+ var childrenBc = hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.slice(hierarchy.findIndex(function (item) { return item.bcName === action.payload.bcName; }) + 1).map(function (item) { return item.bcName; });
2571
2738
  if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {
2572
- result.push(of29(dropAllAssociations({
2739
+ result.push(of28(dropAllAssociations({
2573
2740
  bcNames: childrenBc
2574
2741
  })));
2575
2742
  }
2576
- var parent = isRoot ? null : hierarchy.find(function (item, index) {
2743
+ var parent = isRoot ? null : (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item, index) {
2577
2744
  var _a;
2578
2745
  return ((_a = hierarchy[index + 1]) === null || _a === void 0 ? void 0 : _a.bcName) === action.payload.bcName;
2579
- }) || rootHierarchyDescriptor;
2746
+ })) || rootHierarchyDescriptor;
2580
2747
  var parentItem = (_e = state.data[parent === null || parent === void 0 ? void 0 : parent.bcName]) === null || _e === void 0 ? void 0 : _e.find(function (item) { return item.id === state.screen.bo.bc[parent === null || parent === void 0 ? void 0 : parent.bcName].cursor; });
2581
2748
  if (parent && hierarchyTraverse && selected) {
2582
2749
  if (hierarchyDescriptor.radio) {
2583
- result.push(of29(dropAllAssociations({
2750
+ result.push(of28(dropAllAssociations({
2584
2751
  bcNames: [parent.bcName]
2585
2752
  })));
2586
2753
  }
2587
- result.push(of29(changeAssociation({
2754
+ result.push(of28(changeAssociation({
2588
2755
  bcName: parent.bcName,
2589
2756
  widgetName: action.payload.widgetName,
2590
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
2757
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
2591
2758
  assocValueKey: action.payload.assocValueKey
2592
2759
  })));
2593
2760
  }
@@ -2601,7 +2768,7 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe(fil
2601
2768
  data_1.find(function (dataValue) { return dataValue.id === deltaValue.id; });
2602
2769
  });
2603
2770
  if (wasLastInData && wasLastInDelta) {
2604
- result.push(of29(changeAssociation({
2771
+ result.push(of28(changeAssociation({
2605
2772
  bcName: parent.bcName,
2606
2773
  widgetName: action.payload.widgetName,
2607
2774
  dataItem: __assign(__assign({}, parentItem), { _associate: false }),
@@ -2609,10 +2776,10 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe(fil
2609
2776
  })));
2610
2777
  }
2611
2778
  }
2612
- return concat18.apply(void 0, result);
2779
+ return concat20.apply(void 0, result);
2613
2780
  })); };
2614
2781
  // src/epics/data/bcCancelCreateDataEpic.ts
2615
- import { catchError as catchError12, concat as concat19, EMPTY as EMPTY24, filter as filter44, mergeMap as mergeMap29, of as of30 } from "rxjs";
2782
+ import { catchError as catchError12, concat as concat21, EMPTY as EMPTY23, filter as filter44, mergeMap as mergeMap29, of as of29 } from "rxjs";
2616
2783
  import { OperationTypeCrud as OperationTypeCrud10 } from "@cxbox-ui/schema";
2617
2784
  import { isAnyOf as isAnyOf4 } from "@reduxjs/toolkit";
2618
2785
  var actionTypesMatcher = isAnyOf4(sendOperation);
@@ -2624,7 +2791,7 @@ var bcCancelCreateDataEpic = function (action$, state$, _a) {
2624
2791
  var state = state$.value;
2625
2792
  var screenName = state.screen.screenName;
2626
2793
  var bcName = action.payload.bcName;
2627
- var bcUrl = buildBcUrl(bcName, true);
2794
+ var bcUrl = buildBcUrl(bcName, true, state);
2628
2795
  var bc = state.screen.bo.bc[bcName];
2629
2796
  var cursor = bc === null || bc === void 0 ? void 0 : bc.cursor;
2630
2797
  var context = { widgetName: action.payload.widgetName };
@@ -2634,19 +2801,20 @@ var bcCancelCreateDataEpic = function (action$, state$, _a) {
2634
2801
  var params = { _action: action.payload.operationType };
2635
2802
  var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
2636
2803
  return api.customAction(screenName, bcUrl, data, context, params).pipe(mergeMap29(function (response) {
2637
- var postInvoke = response.postActions[0];
2638
- return concat19(of30(sendOperationSuccess({ bcName: bcName, cursor: cursor })), of30(bcChangeCursors({ cursorsMap: cursorsMap })), postInvoke ? of30(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: context.widgetName })) : EMPTY24);
2804
+ var _a;
2805
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
2806
+ return concat21(of29(sendOperationSuccess({ bcName: bcName, cursor: cursor })), of29(bcChangeCursors({ cursorsMap: cursorsMap })), postInvoke ? of29(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: context.widgetName })) : EMPTY23);
2639
2807
  }), catchError12(function (error) {
2640
2808
  console.error(error);
2641
- return of30(bcDeleteDataFail({ bcName: bcName }));
2809
+ return of29(bcDeleteDataFail({ bcName: bcName }));
2642
2810
  }));
2643
2811
  }));
2644
2812
  };
2645
2813
  // src/epics/data/bcSelectDepthRecordEpic.ts
2646
- import { concat as concat20, filter as filter45, mergeMap as mergeMap30, of as of31 } from "rxjs";
2814
+ import { concat as concat22, filter as filter45, mergeMap as mergeMap30, of as of30 } from "rxjs";
2647
2815
  var bcSelectDepthRecordEpic = function (action$) { return action$.pipe(filter45(bcSelectDepthRecord.match), mergeMap30(function (action) {
2648
2816
  var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor, depth = _a.depth;
2649
- return concat20(of31(bcChangeDepthCursor({ bcName: bcName, depth: depth, cursor: cursor })), of31(bcFetchDataRequest({
2817
+ return concat22(of30(bcChangeDepthCursor({ bcName: bcName, depth: depth, cursor: cursor })), of30(bcFetchDataRequest({
2650
2818
  bcName: bcName,
2651
2819
  depth: depth + 1,
2652
2820
  widgetName: "",
@@ -2654,7 +2822,7 @@ var bcSelectDepthRecordEpic = function (action$) { return action$.pipe(filter45(
2654
2822
  })));
2655
2823
  })); };
2656
2824
  // src/epics/data/removeMultivalueTagEpic.ts
2657
- import { concat as concat21, filter as filter46, mergeMap as mergeMap31, of as of32 } from "rxjs";
2825
+ import { concat as concat23, filter as filter46, mergeMap as mergeMap31, of as of31 } from "rxjs";
2658
2826
  var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(filter46(removeMultivalueTag.match), mergeMap31(function (action) {
2659
2827
  var _a, _b, _c;
2660
2828
  var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
@@ -2670,28 +2838,28 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(f
2670
2838
  var removedItem = data.find(function (item) { return item.id === action.payload.removedItem.id; });
2671
2839
  var associated = action.payload.dataItem.map(function (item) { return item.id; });
2672
2840
  var removedNodes = [];
2673
- if ((_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
2674
- if ((_e = widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
2841
+ if ((_d = widget === null || widget === void 0 ? void 0 : widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
2842
+ if ((_e = widget === null || widget === void 0 ? void 0 : widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
2675
2843
  data = assignTreeLinks(data);
2676
2844
  }
2677
- var removedItemChildren = data.filter(function (item) { return item.parentId === removedItem.id; });
2678
- removedNodes = __spreadArray([removedItem.id], removedItemChildren.filter(function (item) { return associated.includes(item.id); }).map(function (item) { return item.id; }), true);
2679
- if ((_f = widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
2845
+ var removedItemChildren = data.filter(function (item) { return item.parentId === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.id); });
2846
+ removedNodes = __spreadArray([removedItem === null || removedItem === void 0 ? void 0 : removedItem.id], removedItemChildren.filter(function (item) { return associated.includes(item.id); }).map(function (item) { return item.id; }), true);
2847
+ if ((_f = widget === null || widget === void 0 ? void 0 : widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
2680
2848
  getDescendants(removedItemChildren, removedNodes);
2681
2849
  removedNodes = data.filter(function (item) { return removedNodes.includes(item.id) && associated.includes(item.id); }).map(function (item) { return item.id; });
2682
2850
  }
2683
- var parent_1 = data.find(function (item) { return item.id === removedItem.parentId; });
2851
+ var parent_1 = data.find(function (item) { return item.id === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.parentId); });
2684
2852
  var siblings = data.filter(function (item) { return item.parentId === (parent_1 === null || parent_1 === void 0 ? void 0 : parent_1.id); });
2685
2853
  var parentEmpty = siblings.every(function (child) { return removedNodes.includes(child.id) || !associated.includes(child.id); });
2686
2854
  if (parent_1 && parentEmpty) {
2687
- if ((_g = widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
2855
+ if ((_g = widget === null || widget === void 0 ? void 0 : widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
2688
2856
  var parentDescendants = [];
2689
2857
  getDescendants(siblings, parentDescendants);
2690
2858
  var parentDeepEmpty = parentDescendants.every(function (descendant) {
2691
2859
  return removedNodes.includes(descendant) || !associated.includes(descendant);
2692
2860
  });
2693
2861
  if (parentDeepEmpty) {
2694
- return concat21(of32(removeMultivalueTag(__assign(__assign({}, action.payload), { removedItem: { id: parent_1.id, value: null } }))));
2862
+ return concat23(of31(removeMultivalueTag(__assign(__assign({}, action.payload), { removedItem: { id: parent_1.id, value: null } }))));
2695
2863
  }
2696
2864
  }
2697
2865
  else {
@@ -2699,53 +2867,60 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(f
2699
2867
  }
2700
2868
  }
2701
2869
  }
2702
- if ((_h = widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
2703
- return of32(changeDataItem({
2870
+ if ((_h = widget === null || widget === void 0 ? void 0 : widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
2871
+ return of31(changeDataItem({
2704
2872
  bcName: bcName,
2873
+ bcUrl: buildBcUrl(bcName, true, state),
2705
2874
  cursor: cursor,
2706
2875
  dataItem: (_a = {}, _a[associateFieldKey] = action.payload.dataItem.filter(function (item) { return !removedNodes.includes(item.id); }), _a)
2707
2876
  }));
2708
2877
  }
2709
- if ((_j = widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
2710
- return concat21(of32(changeDataItem({
2878
+ if ((_j = widget === null || widget === void 0 ? void 0 : widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
2879
+ var hierarchyBcName = (_o = (_m = (_l = (_k = widget === null || widget === void 0 ? void 0 : widget.options) === null || _k === void 0 ? void 0 : _k.hierarchy) === null || _l === void 0 ? void 0 : _l.find(function (hierarchyData) {
2880
+ var _a;
2881
+ return (_a = state.view.pendingDataChanges[hierarchyData.bcName]) === null || _a === void 0 ? void 0 : _a[action.payload.removedItem.id];
2882
+ })) === null || _m === void 0 ? void 0 : _m.bcName) !== null && _o !== void 0 ? _o : bcName;
2883
+ return concat23(of31(changeDataItem({
2711
2884
  /**
2712
2885
  * This is incorrect and will break if different BC has records with
2713
2886
  * identical ids.
2714
2887
  *
2715
2888
  * TODO: Record `level` should be mapped to hierarchyData index instead
2716
2889
  */
2717
- bcName: (_o = (_m = (_l = (_k = widget.options) === null || _k === void 0 ? void 0 : _k.hierarchy) === null || _l === void 0 ? void 0 : _l.find(function (hierarchyData) {
2718
- var _a;
2719
- return (_a = state.view.pendingDataChanges[hierarchyData.bcName]) === null || _a === void 0 ? void 0 : _a[action.payload.removedItem.id];
2720
- })) === null || _m === void 0 ? void 0 : _m.bcName) !== null && _o !== void 0 ? _o : bcName,
2890
+ bcName: hierarchyBcName,
2891
+ bcUrl: buildBcUrl(hierarchyBcName, true, state),
2721
2892
  cursor: action.payload.removedItem.id,
2722
2893
  dataItem: __assign(__assign({}, action.payload.removedItem), { _associate: false })
2723
- })), of32(changeDataItem({
2894
+ })), of31(changeDataItem({
2724
2895
  bcName: bcName,
2896
+ bcUrl: buildBcUrl(bcName, true, state),
2725
2897
  cursor: cursor,
2726
2898
  dataItem: (_b = {}, _b[associateFieldKey] = action.payload.dataItem, _b)
2727
2899
  })));
2728
2900
  }
2729
- return concat21(of32(changeDataItem({
2901
+ return concat23(of31(changeDataItem({
2730
2902
  bcName: popupBcName,
2903
+ bcUrl: buildBcUrl(popupBcName, true, state),
2731
2904
  cursor: action.payload.removedItem.id,
2732
2905
  dataItem: __assign(__assign({}, action.payload.removedItem), { _associate: false })
2733
- })), of32(changeDataItem({
2906
+ })), of31(changeDataItem({
2734
2907
  bcName: bcName,
2908
+ bcUrl: buildBcUrl(bcName, true, state),
2735
2909
  cursor: cursor,
2736
2910
  dataItem: (_c = {}, _c[associateFieldKey] = action.payload.dataItem, _c)
2737
2911
  })));
2738
2912
  })); };
2739
2913
  // src/epics/data/bcFetchRowMetaRequestEpic.ts
2740
- import { catchError as catchError13, filter as filter47, map as map9, mergeMap as mergeMap32, of as of33, race as race3 } from "rxjs";
2914
+ import { catchError as catchError13, filter as filter47, map as map9, mergeMap as mergeMap32, of as of32, race as race3 } from "rxjs";
2741
2915
  var bcFetchRowMetaRequestEpic = function (action$, state$, _a) {
2742
2916
  var api = _a.api;
2743
2917
  return action$.pipe(filter47(bcFetchRowMeta.match), mergeMap32(function (action) {
2918
+ var _a, _b;
2744
2919
  var state = state$.value;
2745
2920
  var screenName = state.screen.screenName;
2746
2921
  var bcName = action.payload.bcName;
2747
- var cursor = state.screen.bo.bc[bcName].cursor;
2748
- var bcUrl = buildBcUrl(bcName, true);
2922
+ var cursor = (_a = state.screen.bo.bc[bcName].cursor) !== null && _a !== void 0 ? _a : "";
2923
+ var bcUrl = (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "";
2749
2924
  var canceler = api.createCanceler();
2750
2925
  var cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }));
2751
2926
  var cancelByParentBc = cancelRequestEpic(action$, [bcSelectRecord], canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }), function (filteredAction) {
@@ -2756,13 +2931,13 @@ var bcFetchRowMetaRequestEpic = function (action$, state$, _a) {
2756
2931
  return bcFetchRowMetaSuccess({ bcName: bcName, rowMeta: rowMeta, bcUrl: bcUrl, cursor: cursor });
2757
2932
  }), catchError13(function (error) {
2758
2933
  console.error(error);
2759
- return of33(bcFetchRowMetaFail({ bcName: bcName }));
2934
+ return of32(bcFetchRowMetaFail({ bcName: bcName }));
2760
2935
  }));
2761
2936
  return race3(cancelFlow, cancelByParentBc, normalFlow);
2762
2937
  }));
2763
2938
  };
2764
2939
  // src/epics/data/changeAssociationFullEpic.ts
2765
- import { concat as concat22, filter as filter48, mergeMap as mergeMap33, of as of34 } from "rxjs";
2940
+ import { concat as concat24, filter as filter48, mergeMap as mergeMap33, of as of33 } from "rxjs";
2766
2941
  var changeAssociationFullEpic = function (action$, state$) { return action$.pipe(filter48(changeAssociationFull.match), mergeMap33(function (action) {
2767
2942
  var _a, _b, _c, _d, _e;
2768
2943
  var state = state$.value;
@@ -2792,7 +2967,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2792
2967
  return false;
2793
2968
  });
2794
2969
  if (prevSelected) {
2795
- result.push(of34(changeAssociationFull({
2970
+ result.push(of33(changeAssociationFull({
2796
2971
  bcName: bcName,
2797
2972
  depth: depth,
2798
2973
  widgetName: action.payload.widgetName,
@@ -2802,7 +2977,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2802
2977
  }
2803
2978
  }
2804
2979
  else {
2805
- result.push(of34(changeDescendantsAssociationsFull({
2980
+ result.push(of33(changeDescendantsAssociationsFull({
2806
2981
  bcName: bcName,
2807
2982
  parentId: action.payload.dataItem.id,
2808
2983
  depth: depth + 1,
@@ -2811,17 +2986,18 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2811
2986
  })));
2812
2987
  }
2813
2988
  }
2814
- result.push(of34(changeDataItem({
2989
+ result.push(of33(changeDataItem({
2815
2990
  bcName: action.payload.bcName,
2991
+ bcUrl: buildBcUrl(action.payload.bcName, true, state),
2816
2992
  cursor: action.payload.dataItem.id,
2817
2993
  dataItem: action.payload.dataItem
2818
2994
  })));
2819
2995
  if (parentDepth && hierarchyTraverse && selected) {
2820
- result.push(of34(changeAssociationFull({
2996
+ result.push(of33(changeAssociationFull({
2821
2997
  bcName: bcName,
2822
2998
  depth: parentDepth,
2823
2999
  widgetName: action.payload.widgetName,
2824
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[assocValueKey] }),
3000
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[assocValueKey] }),
2825
3001
  assocValueKey: assocValueKey
2826
3002
  })));
2827
3003
  }
@@ -2833,7 +3009,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2833
3009
  var deltaFalseId_1 = delta && ((_e = Object.values(delta)) === null || _e === void 0 ? void 0 : _e.filter(function (item) { return item._associate === false; }).map(function (item) { return item.id; }));
2834
3010
  var wasLastInData = currentLevelData.filter(function (item) { return item.id !== action.payload.dataItem.id && !(deltaFalseId_1 === null || deltaFalseId_1 === void 0 ? void 0 : deltaFalseId_1.includes(item.id)); }).every(function (item) { return !item._associate; });
2835
3011
  if (wasLastInData && wasLastInDelta) {
2836
- result.push(of34(changeAssociationFull({
3012
+ result.push(of33(changeAssociationFull({
2837
3013
  bcName: bcName,
2838
3014
  depth: parentDepth,
2839
3015
  widgetName: action.payload.widgetName,
@@ -2842,66 +3018,69 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2842
3018
  })));
2843
3019
  }
2844
3020
  }
2845
- return concat22.apply(void 0, result);
3021
+ return concat24.apply(void 0, result);
2846
3022
  })); };
2847
3023
  // src/epics/data/saveAssociationsActiveEpic.ts
2848
- import { catchError as catchError14, concat as concat23, EMPTY as EMPTY25, filter as filter49, mergeMap as mergeMap34, of as of35, switchMap as switchMap12 } from "rxjs";
3024
+ import { catchError as catchError14, concat as concat25, EMPTY as EMPTY24, filter as filter49, mergeMap as mergeMap34, of as of34, switchMap as switchMap12 } from "rxjs";
2849
3025
  var saveAssociationsActiveEpic = function (action$, state$, _a) {
2850
3026
  var api = _a.api;
2851
3027
  return action$.pipe(filter49(saveAssociations.match), filter49(function (action) {
2852
- return state$.value.view.popupData.active;
3028
+ var _a;
3029
+ return (_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active;
2853
3030
  }), switchMap12(function (action) {
3031
+ var _a, _b;
2854
3032
  var state = state$.value;
2855
- var calleeBCName = state.view.popupData.calleeBCName;
2856
- var calleeWidgetName = state.view.popupData.calleeWidgetName;
3033
+ var calleeBCName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.calleeBCName;
3034
+ var calleeWidgetName = (_b = state.view.popupData) === null || _b === void 0 ? void 0 : _b.calleeWidgetName;
2857
3035
  var bcNames = action.payload.bcNames;
2858
- var bcUrl = buildBcUrl(calleeBCName, true);
3036
+ var bcUrl = buildBcUrl(calleeBCName, true, state);
2859
3037
  var pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {};
2860
3038
  var params = bcNames.length ? { _bcName: bcNames[bcNames.length - 1] } : {};
2861
3039
  return api.associate(state.screen.screenName, bcUrl, Object.values(pendingChanges).filter(function (i) { return i._associate; }), params).pipe(mergeMap34(function (response) {
2862
3040
  var postInvoke = response.postActions[0];
2863
3041
  var calleeWidget = state.view.widgets.find(function (widgetItem) { return widgetItem.bcName === calleeBCName; });
2864
- return concat23(postInvoke ? of35(processPostInvoke({ bcName: calleeBCName, postInvoke: postInvoke, widgetName: calleeWidget.name })) : EMPTY25, of35(bcCancelPendingChanges({ bcNames: bcNames })), of35(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
3042
+ return concat25(postInvoke ? of34(processPostInvoke({ bcName: calleeBCName, postInvoke: postInvoke, widgetName: calleeWidget === null || calleeWidget === void 0 ? void 0 : calleeWidget.name })) : EMPTY24, of34(bcCancelPendingChanges({ bcNames: bcNames })), of34(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
2865
3043
  }), catchError14(function (err) {
2866
3044
  console.error(err);
2867
- return EMPTY25;
3045
+ return EMPTY24;
2868
3046
  }));
2869
3047
  }));
2870
3048
  };
2871
3049
  // src/epics/data/changeAssociationSameBcEpic.ts
2872
- import { concat as concat24, filter as filter50, mergeMap as mergeMap35, of as of36 } from "rxjs";
3050
+ import { concat as concat26, filter as filter50, mergeMap as mergeMap35, of as of35 } from "rxjs";
2873
3051
  var changeAssociationSameBcEpic = function (action$, state$) { return action$.pipe(filter50(changeAssociationSameBc.match), mergeMap35(function (action) {
2874
- var _a, _b, _c, _d, _e;
3052
+ var _a, _b, _c, _d, _e, _f;
3053
+ var state = state$.value;
2875
3054
  var bcName = action.payload.bcName;
2876
3055
  var result = [
2877
- of36(changeDataItem({
3056
+ of35(changeDataItem({
2878
3057
  bcName: bcName,
3058
+ bcUrl: buildBcUrl(bcName, true, state),
2879
3059
  cursor: action.payload.dataItem.id,
2880
3060
  dataItem: action.payload.dataItem
2881
3061
  }))
2882
3062
  ];
2883
- var state = state$.value;
2884
3063
  var selected = action.payload.dataItem._associate;
2885
3064
  var depth = action.payload.depth || 1;
2886
3065
  var parentDepth = depth - 1;
2887
3066
  var widget = state.view.widgets.find(function (item) { return item.name === action.payload.widgetName; });
2888
3067
  var hierarchyTraverse = (_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchyTraverse;
2889
3068
  var currentData = depth > 1 ? (_b = state.depthData[depth]) === null || _b === void 0 ? void 0 : _b[bcName] : state.data[bcName];
2890
- var parentCursor = parentDepth ? parentDepth > 1 ? (_c = state.screen.bo.bc[bcName].depthBc[parentDepth]) === null || _c === void 0 ? void 0 : _c.cursor : state.screen.bo.bc[bcName].cursor : null;
2891
- var parentItem = parentCursor ? parentDepth > 1 ? (_e = (_d = state.depthData[parentDepth]) === null || _d === void 0 ? void 0 : _d[bcName]) === null || _e === void 0 ? void 0 : _e.find(function (item) { return item.id === parentCursor; }) : state.data[bcName].find(function (item) { return item.id === parentCursor; }) : null;
3069
+ var parentCursor = parentDepth ? parentDepth > 1 ? (_d = (_c = state.screen.bo.bc[bcName].depthBc) === null || _c === void 0 ? void 0 : _c[parentDepth]) === null || _d === void 0 ? void 0 : _d.cursor : state.screen.bo.bc[bcName].cursor : null;
3070
+ var parentItem = parentCursor ? parentDepth > 1 ? (_f = (_e = state.depthData[parentDepth]) === null || _e === void 0 ? void 0 : _e[bcName]) === null || _f === void 0 ? void 0 : _f.find(function (item) { return item.id === parentCursor; }) : state.data[bcName].find(function (item) { return item.id === parentCursor; }) : null;
2892
3071
  if (parentDepth && hierarchyTraverse && selected) {
2893
- result.push(of36(changeAssociationSameBc({
3072
+ result.push(of35(changeAssociationSameBc({
2894
3073
  bcName: bcName,
2895
3074
  depth: parentDepth,
2896
3075
  widgetName: action.payload.widgetName,
2897
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[action.payload.assocValueKey] }),
3076
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[action.payload.assocValueKey] }),
2898
3077
  assocValueKey: action.payload.assocValueKey
2899
3078
  })));
2900
3079
  }
2901
3080
  if (parentDepth && hierarchyTraverse && !selected) {
2902
3081
  var wasLastInData = currentData.filter(function (item) { return item.id !== action.payload.dataItem.id; }).every(function (item) { return !item._associate; });
2903
3082
  if (wasLastInData) {
2904
- result.push(of36(changeAssociationSameBc({
3083
+ result.push(of35(changeAssociationSameBc({
2905
3084
  bcName: bcName,
2906
3085
  depth: parentDepth,
2907
3086
  widgetName: action.payload.widgetName,
@@ -2910,38 +3089,40 @@ var changeAssociationSameBcEpic = function (action$, state$) { return action$.pi
2910
3089
  })));
2911
3090
  }
2912
3091
  }
2913
- return concat24.apply(void 0, result);
3092
+ return concat26.apply(void 0, result);
2914
3093
  })); };
2915
3094
  // src/epics/data/inlinePickListFetchDataEpic.ts
2916
- import { catchError as catchError15, filter as filter51, mergeMap as mergeMap36, of as of37, race as race4 } from "rxjs";
3095
+ import { catchError as catchError15, filter as filter51, mergeMap as mergeMap36, of as of36, race as race4 } from "rxjs";
2917
3096
  var inlinePickListFetchDataEpic = function (action$, state$, _a) {
2918
3097
  var api = _a.api;
2919
3098
  return action$.pipe(filter51(inlinePickListFetchDataRequest.match), mergeMap36(function (action) {
2920
3099
  var _a;
2921
3100
  var _b = action.payload, bcName = _b.bcName, searchSpec = _b.searchSpec, searchString = _b.searchString;
2922
- var bcUrl = buildBcUrl(bcName, false);
3101
+ var state = state$.value;
3102
+ var bcUrl = buildBcUrl(bcName, false, state);
2923
3103
  var canceler = api.createCanceler();
2924
3104
  var cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName: bcName, bcUrl: bcUrl }));
2925
3105
  var normalFlow = api.fetchBcData(state$.value.screen.screenName, bcUrl, (_a = {}, _a[searchSpec + ".contains"] = searchString, _a), canceler.cancelToken).pipe(mergeMap36(function (data) {
2926
- return of37(bcFetchDataSuccess({ bcName: bcName, data: data.data, bcUrl: bcUrl }));
3106
+ return of36(bcFetchDataSuccess({ bcName: bcName, data: data.data, bcUrl: bcUrl }));
2927
3107
  }), catchError15(function (error) {
2928
3108
  console.error(error);
2929
- return of37(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl: bcUrl }));
3109
+ return of36(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl: bcUrl }));
2930
3110
  }));
2931
3111
  return race4(cancelFlow, normalFlow);
2932
3112
  }));
2933
3113
  };
2934
3114
  // src/epics/data/saveAssociationsPassiveEpic.ts
2935
- import { filter as filter52, of as of38, switchMap as switchMap13 } from "rxjs";
3115
+ import { filter as filter52, of as of37, switchMap as switchMap13 } from "rxjs";
2936
3116
  var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pipe(filter52(saveAssociations.match), filter52(function () {
2937
- return !state$.value.view.popupData.active;
3117
+ var _a;
3118
+ return !((_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active);
2938
3119
  }), switchMap13(function (action) {
2939
3120
  var _a, _b;
2940
- var _c;
3121
+ var _c, _d;
2941
3122
  var state = state$.value;
2942
- var _d = state.view.popupData, _e = _d.calleeBCName, calleeBCName = _e === void 0 ? action.payload.calleeBcName : _e, _f = _d.associateFieldKey, associateFieldKey = _f === void 0 ? action.payload.associateFieldKey : _f;
3123
+ var _e = (_c = state.view.popupData) !== null && _c !== void 0 ? _c : {}, _f = _e.calleeBCName, calleeBCName = _f === void 0 ? action.payload.calleeBcName : _f, _g = _e.associateFieldKey, associateFieldKey = _g === void 0 ? action.payload.associateFieldKey : _g;
2943
3124
  var cursor = state.screen.bo.bc[calleeBCName].cursor;
2944
- var recordPrevData = (_c = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _c !== void 0 ? _c : [];
3125
+ var recordPrevData = (_d = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _d !== void 0 ? _d : [];
2945
3126
  var newValues = [];
2946
3127
  action.payload.bcNames.forEach(function (pendingBc) {
2947
3128
  var pendingChanges = state.view.pendingDataChanges[pendingBc] || {};
@@ -2965,8 +3146,9 @@ var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pi
2965
3146
  }
2966
3147
  return true;
2967
3148
  })).concat.apply(_a, addedItems);
2968
- return of38(changeDataItem({
3149
+ return of37(changeDataItem({
2969
3150
  bcName: calleeBCName,
3151
+ bcUrl: buildBcUrl(calleeBCName, true, state),
2970
3152
  cursor: cursor,
2971
3153
  dataItem: (_b = {},
2972
3154
  _b[associateFieldKey] = result,
@@ -2974,13 +3156,13 @@ var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pi
2974
3156
  }));
2975
3157
  })); };
2976
3158
  // src/epics/data/changeChildrenAssociationsEpic.ts
2977
- import { filter as filter53, mergeMap as mergeMap37, of as of39 } from "rxjs";
3159
+ import { filter as filter53, mergeMap as mergeMap37, of as of38 } from "rxjs";
2978
3160
  var changeChildrenAssociationsEpic = function (action$, state$, _a) {
2979
3161
  var api = _a.api;
2980
3162
  return action$.pipe(filter53(changeChildrenAssociations.match), mergeMap37(function (action) {
2981
3163
  var state = state$.value;
2982
3164
  var data = state.data[action.payload.bcName];
2983
- return of39(changeDataItems({
3165
+ return of38(changeDataItems({
2984
3166
  bcName: action.payload.bcName,
2985
3167
  cursors: data.map(function (item) { return item.id; }),
2986
3168
  dataItems: data.map(function (item) { return (__assign(__assign({}, item), { _value: item[action.payload.assocValueKey], _associate: action.payload.selected })); })
@@ -2988,26 +3170,26 @@ var changeChildrenAssociationsEpic = function (action$, state$, _a) {
2988
3170
  }));
2989
3171
  };
2990
3172
  // src/epics/data/changeChildrenAssociationsSameBcEpic.ts
2991
- import { filter as filter54, mergeMap as mergeMap38, of as of40 } from "rxjs";
3173
+ import { filter as filter54, mergeMap as mergeMap38, of as of39 } from "rxjs";
2992
3174
  var changeChildrenAssociationsSameBcEpic = function (action$, state$) { return action$.pipe(filter54(changeChildrenAssociationsSameBc.match), mergeMap38(function (action) {
2993
3175
  var _a;
2994
3176
  var state = state$.value;
2995
3177
  var data = ((_a = state.depthData[action.payload.depth]) === null || _a === void 0 ? void 0 : _a[action.payload.bcName]) || [];
2996
- return of40(changeDataItems({
3178
+ return of39(changeDataItems({
2997
3179
  bcName: action.payload.bcName,
2998
3180
  cursors: data.map(function (item) { return item.id; }),
2999
3181
  dataItems: data.map(function (item) { return (__assign(__assign({}, item), { _value: item[action.payload.assocValueKey], _associate: action.payload.selected })); })
3000
3182
  }));
3001
3183
  })); };
3002
3184
  // src/epics/data/changeDescendantsAssociationsFullEpic.ts
3003
- import { concat as concat25, filter as filter55, mergeMap as mergeMap39, of as of41 } from "rxjs";
3185
+ import { concat as concat27, filter as filter55, mergeMap as mergeMap39, of as of40 } from "rxjs";
3004
3186
  var changeDescendantsAssociationsFullEpic = function (action$, state$) { return action$.pipe(filter55(changeDescendantsAssociationsFull.match), mergeMap39(function (action) {
3005
3187
  var state = state$.value;
3006
3188
  var depth = action.payload.depth;
3007
3189
  var data = state.data[action.payload.bcName];
3008
3190
  var targetData = (data || []).filter(function (item) { return item.level === depth && item.parentId === action.payload.parentId; });
3009
3191
  var result = [
3010
- of41(changeDataItems({
3192
+ of40(changeDataItems({
3011
3193
  bcName: action.payload.bcName,
3012
3194
  cursors: targetData.map(function (item) { return item.id; }),
3013
3195
  dataItems: targetData.map(function (item) { return (__assign(__assign({}, item), { _value: item[action.payload.assocValueKey], _associate: action.payload.selected })); })
@@ -3015,10 +3197,10 @@ var changeDescendantsAssociationsFullEpic = function (action$, state$) { return
3015
3197
  ];
3016
3198
  targetData.forEach(function (targetDataItem) {
3017
3199
  if (data.find(function (dataItem) { return dataItem.parentId === targetDataItem.id; })) {
3018
- result.push(of41(changeDescendantsAssociationsFull(__assign(__assign({}, action.payload), { parentId: targetDataItem.id, depth: depth + 1 }))));
3200
+ result.push(of40(changeDescendantsAssociationsFull(__assign(__assign({}, action.payload), { parentId: targetDataItem.id, depth: depth + 1 }))));
3019
3201
  }
3020
3202
  });
3021
- return concat25.apply(void 0, result);
3203
+ return concat27.apply(void 0, result);
3022
3204
  })); };
3023
3205
  // src/api/ObservableApiWrapper.ts
3024
3206
  import axios2 from "axios";
@@ -3047,7 +3229,6 @@ var ObservableApiWrapper = /** @class */ (function () {
3047
3229
  this.instance = instance;
3048
3230
  }
3049
3231
  class_2.prototype.get = function (path, config, callContext) {
3050
- if (config === void 0) { config = {}; }
3051
3232
  return from(this.instance.get(path, config)).pipe(takeWhile(redirectOccurred), map10(function (response) { return response.data; }));
3052
3233
  };
3053
3234
  class_2.prototype.put = function (path, data, callContext) {
@@ -3063,10 +3244,9 @@ var ObservableApiWrapper = /** @class */ (function () {
3063
3244
  }());
3064
3245
  // src/api/ObservableApi.ts
3065
3246
  import axios3 from "axios";
3066
- import { EMPTY as EMPTY26, expand, map as map11, reduce } from "rxjs";
3247
+ import { EMPTY as EMPTY25, expand, map as map11, reduce } from "rxjs";
3067
3248
  var Api = /** @class */ (function () {
3068
3249
  function class_3(instance) {
3069
- this.api$ = new ObservableApiWrapper();
3070
3250
  this.api$ = new ObservableApiWrapper(instance);
3071
3251
  }
3072
3252
  class_3.prototype.routerRequest = function (path, params) {
@@ -3084,30 +3264,31 @@ var Api = /** @class */ (function () {
3084
3264
  if (params === void 0) { params = {}; }
3085
3265
  var currentPage = 1;
3086
3266
  return this.fetchBcData(screenName, bcUrl, __assign(__assign({}, params), { _page: currentPage })).pipe(expand(function (response) {
3087
- return response.hasNext ? _this.fetchBcData(screenName, bcUrl, __assign(__assign({}, params), { _page: ++currentPage })) : EMPTY26;
3267
+ return response.hasNext ? _this.fetchBcData(screenName, bcUrl, __assign(__assign({}, params), { _page: ++currentPage })) : EMPTY25;
3088
3268
  }), reduce(function (items, nextResponse) {
3089
3269
  return __spreadArray(__spreadArray([], items, true), nextResponse.data, true);
3090
3270
  }, []));
3091
3271
  };
3092
3272
  class_3.prototype.fetchRowMeta = function (screenName, bcUrl, params, cancelToken) {
3093
3273
  var url = applyParams(buildUrl(templateObject_2 || (templateObject_2 = __makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"])), screenName) + bcUrl, params);
3094
- return this.api$.get(url, { cancelToken: cancelToken }).pipe(map11(function (response) { return response.data.row; }));
3274
+ return this.api$.get(url, { cancelToken: cancelToken }).pipe(map11(function (response) { var _a; return (_a = response.data) === null || _a === void 0 ? void 0 : _a.row; }));
3095
3275
  };
3096
3276
  class_3.prototype.newBcData = function (screenName, bcUrl, context, params) {
3097
3277
  var url = applyParams(buildUrl(templateObject_3 || (templateObject_3 = __makeTemplateObject(["row-meta-new/", "/"], ["row-meta-new/", "/"])), screenName) + bcUrl, params);
3098
- return this.api$.get(url, null, context).pipe(map11(function (response) { return response.data; }));
3278
+ return this.api$.get(url, void 0, context).pipe(map11(function (response) { return response.data; }));
3099
3279
  };
3100
3280
  class_3.prototype.saveBcData = function (screenName, bcUrl, data, context, params) {
3101
3281
  var url = applyParams(buildUrl(templateObject_4 || (templateObject_4 = __makeTemplateObject(["data/", "/"], ["data/", "/"])), screenName) + bcUrl, params);
3102
3282
  return this.api$.put(url, { data: data }, context).pipe(map11(function (response) { return response.data; }));
3103
3283
  };
3104
3284
  class_3.prototype.deleteBcData = function (screenName, bcUrl, context, params) {
3285
+ if (bcUrl === void 0) { bcUrl = ""; }
3105
3286
  var url = applyParams(buildUrl(templateObject_5 || (templateObject_5 = __makeTemplateObject(["data/", "/"], ["data/", "/"])), screenName) + bcUrl, params);
3106
3287
  return this.api$.delete(url, context).pipe(map11(function (response) { return response.data; }));
3107
3288
  };
3108
3289
  class_3.prototype.customAction = function (screenName, bcUrl, data, context, params) {
3109
3290
  var url = applyParams(buildUrl(templateObject_6 || (templateObject_6 = __makeTemplateObject(["custom-action/", "/"], ["custom-action/", "/"])), screenName) + bcUrl, params);
3110
- return this.api$.post(url, { data: data || {} }, null, context).pipe(map11(function (response) { return response.data; }));
3291
+ return this.api$.post(url, { data: data || {} }, void 0, context).pipe(map11(function (response) { return response.data; }));
3111
3292
  };
3112
3293
  class_3.prototype.associate = function (screenName, bcUrl, data, params) {
3113
3294
  var processedData = Array.isArray(data) ? data.map(function (item) { return ({
@@ -3119,9 +3300,27 @@ var Api = /** @class */ (function () {
3119
3300
  return this.api$.post(url, processedData).pipe(map11(function (response) { return response.data; }));
3120
3301
  };
3121
3302
  class_3.prototype.getRmByForceActive = function (screenName, bcUrl, data, params) {
3122
- var url = applyParams(buildUrl(templateObject_8 || (templateObject_8 = __makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"])), screenName) + bcUrl, params);
3303
+ var url = applyParams(buildUrl(templateObject_8 || (templateObject_8 = __makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"])), screenName) + (bcUrl !== null && bcUrl !== void 0 ? bcUrl : ""), params);
3123
3304
  return this.api$.post(url, { data: data }).pipe(map11(function (response) { return response.data.row; }));
3124
3305
  };
3306
+ Object.defineProperty(class_3.prototype, "fileUploadEndpoint", {
3307
+ /**
3308
+ * Get Cxbox API file upload endpoint based on baseURL of axios instance
3309
+ *
3310
+ * Handles empty baseURL and trailing slash
3311
+ *
3312
+ * @returns File upload endpoint
3313
+ */
3314
+ get: function () {
3315
+ var instance = this.api$.instance;
3316
+ if (!instance.defaults.baseURL) {
3317
+ return "/file";
3318
+ }
3319
+ return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
3320
+ },
3321
+ enumerable: false,
3322
+ configurable: true
3323
+ });
3125
3324
  class_3.prototype.refreshMeta = function () {
3126
3325
  return this.api$.get(buildUrl(templateObject_9 || (templateObject_9 = __makeTemplateObject(["bc-registry/refresh-meta"], ["bc-registry/refresh-meta"]))));
3127
3326
  };
@@ -3140,6 +3339,243 @@ var Api = /** @class */ (function () {
3140
3339
  };
3141
3340
  return class_3;
3142
3341
  }());
3143
- export { Api, actions_exports as actions, epics_exports as epics, interfaces_exports as interfaces, reducers_exports as reducers, utils_exports as utils };
3342
+ // src/utils/autosave.ts
3343
+ function autosaveRoutine(action, store, next) {
3344
+ var _a, _b, _c;
3345
+ var state = store.getState();
3346
+ var dispatch = store.dispatch;
3347
+ var pendingDataChanges = state.view.pendingDataChanges;
3348
+ var bcList = Object.keys(pendingDataChanges);
3349
+ var baseBcNameIndex = ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.bcName) && bcHasPendingAutosaveChanges(state, action.payload.bcName, (_b = state.screen.bo.bc[action.payload.bcName]) === null || _b === void 0 ? void 0 : _b.cursor) ? bcList.findIndex(function (bcName) { var _a; return bcName === ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.bcName); }) : bcList.findIndex(function (bcName) { var _a; return bcHasPendingAutosaveChanges(state, bcName, (_a = state.screen.bo.bc[bcName]) === null || _a === void 0 ? void 0 : _a.cursor); });
3350
+ var baseBcName = bcList[baseBcNameIndex];
3351
+ if (baseBcNameIndex > -1) {
3352
+ bcList.splice(baseBcNameIndex, 1);
3353
+ }
3354
+ if (baseBcName) {
3355
+ bcList.forEach(function (bcName) {
3356
+ var _a, _b;
3357
+ var widget = (_a = state.view.widgets) === null || _a === void 0 ? void 0 : _a.find(function (v) { return v.bcName === bcName; });
3358
+ var cursor = (_b = state.screen.bo.bc[bcName]) === null || _b === void 0 ? void 0 : _b.cursor;
3359
+ if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {
3360
+ dispatch(sendOperation({
3361
+ bcName: bcName,
3362
+ operationType: OperationTypeCrud.save,
3363
+ widgetName: widget === null || widget === void 0 ? void 0 : widget.name
3364
+ }));
3365
+ }
3366
+ });
3367
+ var baseWidget = (_c = state.view.widgets) === null || _c === void 0 ? void 0 : _c.find(function (v) { return v.bcName === baseBcName; });
3368
+ return next(sendOperation({
3369
+ bcName: baseBcName,
3370
+ operationType: OperationTypeCrud.save,
3371
+ widgetName: baseWidget === null || baseWidget === void 0 ? void 0 : baseWidget.name,
3372
+ onSuccessAction: action
3373
+ }));
3374
+ }
3375
+ return next(action);
3376
+ }
3377
+ function bcHasPendingAutosaveChanges(store, bcName, cursor) {
3378
+ var _a;
3379
+ var pendingChanges = store.view.pendingDataChanges;
3380
+ var cursorChanges = (_a = pendingChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
3381
+ var result = cursorChanges && !Object.keys(cursorChanges).includes("_associate") && Object.values(cursorChanges).length > 0;
3382
+ return result;
3383
+ }
3384
+ function checkUnsavedChangesOfBc(store, bcName) {
3385
+ var _a, _b;
3386
+ var pendingCursors = Object.keys((_b = (_a = store.view.pendingDataChanges) === null || _a === void 0 ? void 0 : _a[bcName]) !== null && _b !== void 0 ? _b : {});
3387
+ return pendingCursors.some(function (cursor) { return bcHasPendingAutosaveChanges(store, bcName, cursor); });
3388
+ }
3389
+ // src/middlewares/autosaveMiddleware.ts
3390
+ var saveFormMiddleware = function (_a) {
3391
+ var getState = _a.getState, dispatch = _a.dispatch;
3392
+ return function (next) { return function (action) {
3393
+ var _a, _b, _c, _d, _e, _f, _g;
3394
+ var state = getState();
3395
+ var isSendOperation = sendOperation.match(action);
3396
+ var isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType);
3397
+ var isSelectTableCellInit = selectTableCellInit.match(action);
3398
+ var isSaveAction = isSendOperation && action.payload.operationType === OperationTypeCrud.save;
3399
+ var isNotSaveAction = !isSaveAction;
3400
+ var actionBcName = isSendOperation && action.payload.bcName;
3401
+ var hasAnotherUnsavedBc = Object.keys(state.view.pendingDataChanges).filter(function (key) { return key !== actionBcName; }).filter(function (key) { return checkUnsavedChangesOfBc(state, key); }).length > 0;
3402
+ var isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc;
3403
+ var selectedCell = state.view.selectedCell;
3404
+ var isSelectTableCellInitOnAnotherRowOrWidget = selectedCell && isSelectTableCellInit && (selectedCell.widgetName !== action.payload.widgetName || selectedCell.rowId !== action.payload.rowId);
3405
+ var defaultSaveWidget = (_a = state.view.widgets) === null || _a === void 0 ? void 0 : _a.find(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.actionGroups) === null || _b === void 0 ? void 0 : _b.defaultSave; });
3406
+ var defaultCursor = (_c = (_b = state.screen.bo.bc) === null || _b === void 0 ? void 0 : _b[defaultSaveWidget === null || defaultSaveWidget === void 0 ? void 0 : defaultSaveWidget.bcName]) === null || _c === void 0 ? void 0 : _c.cursor;
3407
+ var pendingData = (_f = (_e = (_d = state.view) === null || _d === void 0 ? void 0 : _d.pendingDataChanges) === null || _e === void 0 ? void 0 : _e[defaultSaveWidget === null || defaultSaveWidget === void 0 ? void 0 : defaultSaveWidget.bcName]) === null || _f === void 0 ? void 0 : _f[defaultCursor];
3408
+ var isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0;
3409
+ if (isChangeLocation) {
3410
+ return next(sendOperation({
3411
+ bcName: defaultSaveWidget.bcName,
3412
+ operationType: ((_g = defaultSaveWidget.options) === null || _g === void 0 ? void 0 : _g.actionGroups).defaultSave,
3413
+ widgetName: defaultSaveWidget.name,
3414
+ onSuccessAction: action
3415
+ }));
3416
+ }
3417
+ var isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableCellInitOnAnotherRowOrWidget);
3418
+ if (isNeedSaveCondition) {
3419
+ return autosaveRoutine(action, { getState: getState, dispatch: dispatch }, next);
3420
+ }
3421
+ return next(action);
3422
+ }; };
3423
+ };
3424
+ // src/middlewares/requiredFieldsMiddleware.ts
3425
+ var requiredFields = function (_a) {
3426
+ var getState = _a.getState, dispatch = _a.dispatch;
3427
+ return function (next) { return function (action) {
3428
+ var _a, _b, _c, _d;
3429
+ var state = getState();
3430
+ if (sendOperation.match(action)) {
3431
+ var _e = action.payload, bcName = _e.bcName, operationType = _e.operationType, widgetName_1 = _e.widgetName;
3432
+ var cursor_1 = (_a = state.screen.bo.bc[bcName]) === null || _a === void 0 ? void 0 : _a.cursor;
3433
+ if (cursor_1) {
3434
+ var bcUrl = buildBcUrl(bcName, true, state);
3435
+ var record = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (item) { return item.id === cursor_1; });
3436
+ var rowMeta_1 = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
3437
+ var pendingValues = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[cursor_1];
3438
+ var widget_1 = state.view.widgets.find(function (item) { return item.name === widgetName_1; });
3439
+ if (operationRequiresAutosave(operationType, rowMeta_1 === null || rowMeta_1 === void 0 ? void 0 : rowMeta_1.actions)) {
3440
+ var fieldsToCheck_1 = {};
3441
+ state.view.widgets.filter(function (item) { return item.bcName === (widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.bcName); }).forEach(function (item) {
3442
+ var itemFieldsCalc = item.fields;
3443
+ if (item.fields) {
3444
+ item.fields.forEach(function (block) {
3445
+ if (isWidgetFieldBlock(block)) {
3446
+ block.fields.forEach(function (field) { return itemFieldsCalc.push(field); });
3447
+ }
3448
+ });
3449
+ }
3450
+ itemFieldsCalc.forEach(function (widgetField) {
3451
+ var _a;
3452
+ var matchingRowMeta = (_a = rowMeta_1 === null || rowMeta_1 === void 0 ? void 0 : rowMeta_1.fields) === null || _a === void 0 ? void 0 : _a.find(function (rowMetaField) { return rowMetaField.key === widgetField.key; });
3453
+ if (!fieldsToCheck_1[widgetField.key] && matchingRowMeta && !matchingRowMeta.hidden) {
3454
+ fieldsToCheck_1[widgetField.key] = matchingRowMeta;
3455
+ }
3456
+ });
3457
+ });
3458
+ var dataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck_1));
3459
+ if (dataItem && TableLikeWidgetTypes.includes(widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.type)) {
3460
+ dispatch(selectTableCellInit({ widgetName: widgetName_1, rowId: cursor_1, fieldKey: Object.keys(dataItem)[0] }));
3461
+ }
3462
+ return dataItem ? next(changeDataItem({ bcName: bcName, bcUrl: buildBcUrl(bcName, true, state), cursor: cursor_1, dataItem: dataItem })) : next(action);
3463
+ }
3464
+ if (hasPendingValidationFails(state, bcName)) {
3465
+ return addNotification({
3466
+ key: "requiredFieldsMissing",
3467
+ type: "buttonWarningNotification",
3468
+ message: "Required fields are missing",
3469
+ duration: 0,
3470
+ options: {
3471
+ buttonWarningNotificationOptions: {
3472
+ buttonText: "Cancel changes",
3473
+ actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]
3474
+ }
3475
+ }
3476
+ });
3477
+ }
3478
+ }
3479
+ }
3480
+ return next(action);
3481
+ }; };
3482
+ };
3483
+ function operationRequiresAutosave(operationType, actions) {
3484
+ var result = false;
3485
+ if (!actions) {
3486
+ console.error('rowMeta is missing in the middle of "sendOperation" action');
3487
+ return result;
3488
+ }
3489
+ result = flattenOperations(actions).some(function (action) { return action.type === operationType && action.autoSaveBefore; });
3490
+ return result;
3491
+ }
3492
+ function getRequiredFieldsMissing(record, pendingChanges, fieldsMeta) {
3493
+ var result = {};
3494
+ fieldsMeta.forEach(function (field) {
3495
+ var value = record === null || record === void 0 ? void 0 : record[field.key];
3496
+ var pendingValue = pendingChanges === null || pendingChanges === void 0 ? void 0 : pendingChanges[field.key];
3497
+ var effectiveValue = pendingValue !== void 0 ? pendingValue : value;
3498
+ var falsyValue = false;
3499
+ if (effectiveValue === null || effectiveValue === void 0 || effectiveValue === "") {
3500
+ falsyValue = true;
3501
+ }
3502
+ else if (Array.isArray(effectiveValue) && !effectiveValue.length) {
3503
+ falsyValue = true;
3504
+ }
3505
+ else if (effectiveValue && typeof effectiveValue === "object" && !Object.keys(effectiveValue).length) {
3506
+ falsyValue = true;
3507
+ }
3508
+ if (field.required && falsyValue) {
3509
+ result[field.key] = Array.isArray(effectiveValue) ? [] : null;
3510
+ }
3511
+ });
3512
+ return Object.keys(result).length > 0 ? result : null;
3513
+ }
3514
+ function hasPendingValidationFails(store, bcName) {
3515
+ var _a;
3516
+ if (store.view.pendingValidationFailsFormat !== "target" /* target */ && store.view.pendingValidationFails && Object.keys(store.view.pendingValidationFails).length) {
3517
+ return true;
3518
+ }
3519
+ var checkResult = false;
3520
+ var bcPendingValidations = (_a = store.view.pendingValidationFails) === null || _a === void 0 ? void 0 : _a[bcName];
3521
+ var cursorsList = bcPendingValidations && Object.keys(bcPendingValidations);
3522
+ if (!cursorsList) {
3523
+ return false;
3524
+ }
3525
+ var i = 0;
3526
+ for (; i < cursorsList.length; i++) {
3527
+ if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {
3528
+ checkResult = true;
3529
+ break;
3530
+ }
3531
+ }
3532
+ return checkResult;
3533
+ }
3534
+ // src/middlewares/preInvokeMiddleware.ts
3535
+ var preInvokeAction = function (_a) {
3536
+ var getState = _a.getState;
3537
+ return function (next) { return function (action) {
3538
+ var _a, _b, _c;
3539
+ if (sendOperation.match(action)) {
3540
+ var state = getState();
3541
+ var _d = action.payload, operationType_1 = _d.operationType, widgetName_2 = _d.widgetName, confirm = _d.confirm;
3542
+ var bcName = (_a = state.view.widgets.find(function (widgetItem) { return widgetItem.name === widgetName_2; })) === null || _a === void 0 ? void 0 : _a.bcName;
3543
+ var bcUrl = buildBcUrl(bcName, true, state);
3544
+ var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
3545
+ var actions = rowMeta && flattenOperations(rowMeta.actions);
3546
+ var preInvoke = (_c = actions === null || actions === void 0 ? void 0 : actions.find(function (item) { return item.type === operationType_1; })) === null || _c === void 0 ? void 0 : _c.preInvoke;
3547
+ return preInvoke && !confirm ? next(processPreInvoke({
3548
+ bcName: bcName,
3549
+ operationType: operationType_1,
3550
+ widgetName: widgetName_2,
3551
+ preInvoke: preInvoke
3552
+ })) : next(action);
3553
+ }
3554
+ return next(action);
3555
+ }; };
3556
+ };
3557
+ // src/middlewares/popupMiddleware.ts
3558
+ var popupMiddleware = function (_a) {
3559
+ var getState = _a.getState;
3560
+ return function (next) { return function (action) {
3561
+ var _a, _b, _c;
3562
+ if (showViewPopup.match(action)) {
3563
+ var state = getState();
3564
+ var bcName_1 = action.payload.bcName;
3565
+ var widgetValueKey = (_b = (_a = state.view.widgets.find(function (item) { return item.bcName === bcName_1; })) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.displayedValueKey;
3566
+ var assocValueKey = (_c = action.payload.assocValueKey) !== null && _c !== void 0 ? _c : widgetValueKey;
3567
+ return widgetValueKey ? next(showViewPopup(__assign(__assign({}, action.payload), { assocValueKey: assocValueKey }))) : next(action);
3568
+ }
3569
+ return next(action);
3570
+ }; };
3571
+ };
3572
+ // src/middlewares/index.ts
3573
+ var middlewares = {
3574
+ autosave: saveFormMiddleware,
3575
+ requiredFields: requiredFields,
3576
+ preInvoke: preInvokeAction,
3577
+ popup: popupMiddleware
3578
+ };
3579
+ export { Api, actions_exports as actions, epics_exports as epics, interfaces_exports as interfaces, middlewares, reducers_exports as reducers, utils_exports as utils };
3144
3580
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
3145
3581
  //# sourceMappingURL=cxbox-ui-core.esm.js.map