@cxbox-ui/core 1.37.2-alpha.7 → 1.37.2-alpha.9

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.
@@ -472,6 +472,15 @@ function isViewNavigationCategory(item) {
472
472
  function isViewNavigationGroup(item) {
473
473
  return !!item && "child" in item && !("categoryName" in item);
474
474
  }
475
+ // src/reducers/router.ts
476
+ var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
477
+ var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
478
+ state = __assign(__assign({}, state), action.payload);
479
+ }).addCase(changeLocation, function (state, action) {
480
+ state = __assign(__assign({}, state), action.payload.location);
481
+ }); };
482
+ // src/reducers/screen.ts
483
+ import { OperationTypeCrud as OperationTypeCrud3 } from "@cxbox-ui/schema";
475
484
  // src/utils/index.ts
476
485
  var utils_exports = {};
477
486
  __export(utils_exports, {
@@ -492,7 +501,6 @@ __export(utils_exports, {
492
501
  getBcChildren: function () { return getBcChildren; },
493
502
  getDescendants: function () { return getDescendants; },
494
503
  getFieldTitle: function () { return getFieldTitle; },
495
- getFileUploadEndpoint: function () { return getFileUploadEndpoint; },
496
504
  getFilterType: function () { return getFilterType; },
497
505
  getFilters: function () { return getFilters; },
498
506
  getSorters: function () { return getSorters; },
@@ -532,12 +540,6 @@ function applyRawParams(url, qso) {
532
540
  var result = new URLSearchParams(qso).toString();
533
541
  return "".concat(addTailControlSequences(url)).concat(result && "".concat(result));
534
542
  }
535
- function getFileUploadEndpoint(instance) {
536
- if (!instance.defaults.baseURL) {
537
- return "/file";
538
- }
539
- return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
540
- }
541
543
  // src/utils/strings.ts
542
544
  function getTemplate(literals) {
543
545
  var placeholders = [];
@@ -687,7 +689,7 @@ function defaultParseURL(url) {
687
689
  }
688
690
  return {
689
691
  type: type,
690
- path: path,
692
+ path: path.length !== 0 && !path.startsWith("/") ? "/".concat(path) : path,
691
693
  params: params,
692
694
  screenName: screenName,
693
695
  viewName: viewName,
@@ -735,6 +737,7 @@ function getSorters(sorters) {
735
737
  return result;
736
738
  }
737
739
  function parseFilters(defaultFilters) {
740
+ if (defaultFilters === void 0) { defaultFilters = ""; }
738
741
  var result = [];
739
742
  var urlParams = new URL(defaultFilters, window.location.origin).searchParams;
740
743
  urlParams.forEach(function (param) {
@@ -845,12 +848,13 @@ function getBcChildren(originBcName, widgets, bcMap) {
845
848
  return childrenBcMap;
846
849
  }
847
850
  function getHierarchyChildBc(originBcName, hierarchyWidget) {
848
- var nestedBcNames = hierarchyWidget.options.hierarchy.map(function (nestedItem) { return nestedItem.bcName; });
849
- if (originBcName !== hierarchyWidget.bcName && !nestedBcNames.includes(originBcName)) {
851
+ var _a, _b;
852
+ 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; });
853
+ if (originBcName !== hierarchyWidget.bcName && !(nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.includes(originBcName))) {
850
854
  return [];
851
855
  }
852
- var childHierarchyBcIndex = nestedBcNames.findIndex(function (item) { return item === originBcName; });
853
- var childHierarchyBcName = nestedBcNames[childHierarchyBcIndex + 1];
856
+ var childHierarchyBcIndex = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.findIndex(function (item) { return item === originBcName; });
857
+ var childHierarchyBcName = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames[childHierarchyBcIndex + 1];
854
858
  return [childHierarchyBcName, hierarchyWidget.name];
855
859
  }
856
860
  function checkShowCondition(condition, cursor, data, pendingDataChanges) {
@@ -864,9 +868,9 @@ function checkShowCondition(condition, cursor, data, pendingDataChanges) {
864
868
  if (!record) {
865
869
  return false;
866
870
  }
867
- var actualValue = record === null || record === void 0 ? void 0 : record[params.fieldKey];
868
- 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];
869
- return pendingValue !== void 0 ? pendingValue === params.value : actualValue === params.value;
871
+ var actualValue = record === null || record === void 0 ? void 0 : record[params === null || params === void 0 ? void 0 : params.fieldKey];
872
+ 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];
873
+ return pendingValue !== void 0 ? pendingValue === (params === null || params === void 0 ? void 0 : params.value) : actualValue === (params === null || params === void 0 ? void 0 : params.value);
870
874
  }
871
875
  // src/utils/tree.ts
872
876
  function assignTreeLinks(flat) {
@@ -874,6 +878,7 @@ function assignTreeLinks(flat) {
874
878
  var map12 = {};
875
879
  var orphans = [];
876
880
  result.forEach(function (item) {
881
+ var _a, _b;
877
882
  if (!item.parentId || item.parentId === "0") {
878
883
  return;
879
884
  }
@@ -892,7 +897,7 @@ function assignTreeLinks(flat) {
892
897
  result[parentIndex].children = [item];
893
898
  }
894
899
  else {
895
- result[parentIndex].children.push(item);
900
+ (_b = (_a = result[parentIndex]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.push(item);
896
901
  }
897
902
  });
898
903
  if (orphans.length) {
@@ -970,22 +975,7 @@ function deleteUndefinedFromObject(obj) {
970
975
  }
971
976
  });
972
977
  }
973
- // src/reducers/router.ts
974
- var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
975
- var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
976
- state = __assign(__assign({}, state), action.payload);
977
- }).addCase(changeLocation, function (state, action) {
978
- var _a = action.payload, url = _a.url, route = _a.route;
979
- if (url) {
980
- var path = new URL(url);
981
- state = __assign(__assign({}, state), defaultParseURL(path));
982
- }
983
- if (route !== null) {
984
- state = __assign(__assign({}, state), route);
985
- }
986
- }); };
987
978
  // src/reducers/screen.ts
988
- import { OperationTypeCrud as OperationTypeCrud3 } from "@cxbox-ui/schema";
989
979
  var initialScreenState = {
990
980
  screenName: "",
991
981
  bo: { activeBcName: "", bc: {} },
@@ -997,10 +987,11 @@ var initialScreenState = {
997
987
  };
998
988
  var operationsHandledLocally = [OperationTypeCrud3.associate, OperationTypeCrud3.fileUpload];
999
989
  var createScreenReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(selectScreen, function (state, action) {
990
+ var _a, _b, _c, _d, _e;
1000
991
  var bcDictionary = {};
1001
992
  var bcSorters = {};
1002
993
  var bcFilters = {};
1003
- action.payload.screen.meta.bo.bc.forEach(function (item) {
994
+ (_a = action.payload.screen.meta) === null || _a === void 0 ? void 0 : _a.bo.bc.forEach(function (item) {
1004
995
  bcDictionary[item.name] = item;
1005
996
  var sorter = parseSorters(item.defaultSort);
1006
997
  var filter56 = parseFilters(item.defaultFilter);
@@ -1012,8 +1003,8 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1012
1003
  }
1013
1004
  });
1014
1005
  state.screenName = action.payload.screen.name;
1015
- state.primaryView = action.payload.screen.meta.primary;
1016
- state.views = action.payload.screen.meta.views;
1006
+ state.primaryView = (_c = (_b = action.payload.screen.meta) === null || _b === void 0 ? void 0 : _b.primary) !== null && _c !== void 0 ? _c : state.primaryView;
1007
+ state.views = (_e = (_d = action.payload.screen.meta) === null || _d === void 0 ? void 0 : _d.views) !== null && _e !== void 0 ? _e : state.views;
1017
1008
  state.bo = { activeBcName: null, bc: bcDictionary };
1018
1009
  state.sorters = __assign(__assign({}, state.sorters), bcSorters);
1019
1010
  state.filters = __assign(__assign({}, state.filters), bcFilters);
@@ -1023,12 +1014,14 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1023
1014
  }).addCase(bcFetchDataRequest, function (state, action) {
1024
1015
  state.bo.bc[action.payload.bcName].loading = true;
1025
1016
  }).addCase(bcLoadMore, function (state, action) {
1017
+ var _a;
1026
1018
  var currentBc = state.bo.bc[action.payload.bcName];
1027
- currentBc.page += 1;
1019
+ currentBc.page = ((_a = currentBc.page) !== null && _a !== void 0 ? _a : 1) + 1;
1028
1020
  currentBc.loading = true;
1029
1021
  }).addCase(selectView, function (state, action) {
1022
+ var _a;
1030
1023
  var newBcs = {};
1031
- Array.from(new Set(action.payload.widgets.map(function (widget) { return widget.bcName; }))
1024
+ Array.from(new Set((_a = action.payload.widgets) === null || _a === void 0 ? void 0 : _a.map(function (widget) { return widget.bcName; }))
1032
1025
  // БК которые есть на вьюхе
1033
1026
  ).filter(function (bcName) { return state.bo.bc[bcName]; }).forEach(function (bcName) {
1034
1027
  newBcs[bcName] = __assign(__assign({}, state.bo.bc[bcName]), { page: 1 });
@@ -1040,9 +1033,10 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1040
1033
  currentBc.loading = false;
1041
1034
  state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
1042
1035
  }).addCase(bcFetchDataFail, function (state, action) {
1043
- if (Object.values(state.bo.bc).some(function (bc) { return bc.name === action.payload.bcName; })) {
1044
- state.bo.bc[action.payload.bcName].loading = false;
1045
- state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
1036
+ var bcName = action.payload.bcName;
1037
+ if (Object.values(state.bo.bc).some(function (bc) { return bc.name === bcName; })) {
1038
+ state.bo.bc[bcName].loading = false;
1039
+ state.cachedBc[bcName] = action.payload.bcUrl;
1046
1040
  }
1047
1041
  }).addCase(sendOperation, function (state, action) {
1048
1042
  if (!operationsHandledLocally.includes(action.payload.operationType)) {
@@ -1070,10 +1064,12 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1070
1064
  Object.assign(state.bo.bc, newCursors);
1071
1065
  Object.assign(state.cachedBc, newCache);
1072
1066
  }).addCase(bcChangeDepthCursor, function (state, action) {
1067
+ var _a;
1073
1068
  if (action.payload.depth === 1) {
1074
1069
  state.bo.bc[action.payload.bcName].cursor = action.payload.cursor;
1075
1070
  }
1076
1071
  else {
1072
+ state.bo.bc[action.payload.bcName].depthBc = (_a = state.bo.bc[action.payload.bcName].depthBc) !== null && _a !== void 0 ? _a : {};
1077
1073
  state.bo.bc[action.payload.bcName].depthBc[action.payload.depth].cursor = action.payload.cursor;
1078
1074
  }
1079
1075
  }).addCase(bcSelectRecord, function (state, action) {
@@ -1158,9 +1154,11 @@ var createSessionReducerBuilderManager = function (initialState) { return new Re
1158
1154
  }).addCase(switchDebugMode, function (state, action) {
1159
1155
  state.debugMode = action.payload;
1160
1156
  }).addCase(addPendingRequest, function (state, action) {
1161
- state.pendingRequests.push(action.payload.request);
1157
+ var _a;
1158
+ (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.push(action.payload.request);
1162
1159
  }).addCase(removePendingRequest, function (state, action) {
1163
- state.pendingRequests = state.pendingRequests.filter(function (item) { return item.requestId !== action.payload.requestId; });
1160
+ var _a;
1161
+ state.pendingRequests = (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return item.requestId !== action.payload.requestId; });
1164
1162
  }).addCase(addNotification, function (state, action) {
1165
1163
  state.notifications.push(action.payload);
1166
1164
  }).addCase(removeNotifications, function (state, action) {
@@ -1207,14 +1205,15 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1207
1205
  state.metaInProgress[action.payload.bcName] = true;
1208
1206
  }
1209
1207
  }).addCase(bcFetchRowMetaSuccess, function (state, action) {
1210
- if (state.rowMeta[action.payload.bcName]) {
1211
- state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1212
- }
1208
+ var _a;
1209
+ state.rowMeta[action.payload.bcName] = (_a = state.rowMeta[action.payload.bcName]) !== null && _a !== void 0 ? _a : {};
1210
+ state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1213
1211
  state.metaInProgress[action.payload.bcName] = false;
1214
1212
  }).addCase(bcNewDataSuccess, function (state, action) {
1215
1213
  state.selectedCell = initialViewState.selectedCell;
1216
1214
  }).addCase(forceActiveRmUpdate, function (state, action) {
1217
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, currentRecordData = _a.currentRecordData, rowMeta = _a.rowMeta, cursor = _a.cursor;
1215
+ var _a, _b, _c, _d;
1216
+ var _e = action.payload, bcName = _e.bcName, bcUrl = _e.bcUrl, currentRecordData = _e.currentRecordData, rowMeta = _e.rowMeta, cursor = _e.cursor;
1218
1217
  var handledForceActive = {};
1219
1218
  var rowMetaForcedValues = {};
1220
1219
  var newPendingChangesDiff = {};
@@ -1237,11 +1236,15 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1237
1236
  handledForceActive[key] = newPendingDataChanges[key];
1238
1237
  }
1239
1238
  });
1239
+ state.handledForceActive[bcName] = (_a = state.handledForceActive[bcName]) !== null && _a !== void 0 ? _a : {};
1240
+ state.handledForceActive[bcName][cursor] = (_b = state.handledForceActive[bcName][cursor]) !== null && _b !== void 0 ? _b : {};
1240
1241
  Object.assign(state.handledForceActive[bcName][cursor], handledForceActive);
1242
+ state.pendingDataChanges[bcName] = (_c = state.pendingDataChanges[bcName]) !== null && _c !== void 0 ? _c : {};
1241
1243
  state.pendingDataChanges[bcName][cursor] = newPendingDataChanges;
1244
+ state.rowMeta[bcName] = (_d = state.rowMeta[bcName]) !== null && _d !== void 0 ? _d : {};
1242
1245
  state.rowMeta[bcName][bcUrl] = rowMeta;
1243
1246
  }).addCase(changeDataItem, function (state, action) {
1244
- var _a;
1247
+ var _a, _b, _c;
1245
1248
  var actionBcName = action.payload.bcName;
1246
1249
  var prevBc = state.pendingDataChanges[action.payload.bcName] || {};
1247
1250
  var prevCursor = prevBc[action.payload.cursor] || {};
@@ -1258,10 +1261,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1258
1261
  nextValidationFails[fieldKey] = "This field is mandatory";
1259
1262
  }
1260
1263
  });
1264
+ state.pendingDataChanges[action.payload.bcName] = (_b = state.pendingDataChanges[action.payload.bcName]) !== null && _b !== void 0 ? _b : {};
1261
1265
  state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending;
1262
1266
  if (isTargetFormatPVF) {
1263
1267
  ;
1264
- state.pendingValidationFails[actionBcName][action.payload.cursor] = nextValidationFails;
1268
+ ((_c = state.pendingValidationFails) === null || _c === void 0 ? void 0 : _c[actionBcName])[action.payload.cursor] = nextValidationFails;
1265
1269
  }
1266
1270
  else {
1267
1271
  state.pendingValidationFails = nextValidationFails;
@@ -1282,7 +1286,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1282
1286
  pendingDataChanges[bcName] = pendingBcChanges;
1283
1287
  });
1284
1288
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1285
- var pendingValidationFails = __assign({}, state.pendingValidationFails);
1289
+ var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
1286
1290
  if (isTargetFormatPVF) {
1287
1291
  action.payload.bcNames.forEach(function (i) {
1288
1292
  pendingValidationFails[i] = {};
@@ -1297,7 +1301,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1297
1301
  }).addCase(bcFetchRowMetaFail, function (state, action) {
1298
1302
  state.metaInProgress[action.payload.bcName] = false;
1299
1303
  }).addCase(forceActiveChangeFail, function (state, action) {
1300
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1304
+ var _a;
1305
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1301
1306
  var errors = {};
1302
1307
  if (entityError) {
1303
1308
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1305,9 +1310,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1305
1310
  errors[fieldName] = violation;
1306
1311
  });
1307
1312
  }
1313
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1308
1314
  state.rowMeta[bcName][bcUrl].errors = errors;
1309
1315
  }).addCase(bcSaveDataFail, function (state, action) {
1310
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1316
+ var _a;
1317
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1311
1318
  var errors = {};
1312
1319
  if (entityError) {
1313
1320
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1315,9 +1322,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1315
1322
  errors[fieldName] = violation;
1316
1323
  });
1317
1324
  }
1325
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1318
1326
  state.rowMeta[bcName][bcUrl].errors = errors;
1319
1327
  }).addCase(sendOperationFail, function (state, action) {
1320
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1328
+ var _a;
1329
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1321
1330
  var errors = {};
1322
1331
  if (entityError) {
1323
1332
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1325,30 +1334,38 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1325
1334
  errors[fieldName] = violation;
1326
1335
  });
1327
1336
  }
1337
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1328
1338
  state.rowMeta[bcName][bcUrl].errors = errors;
1329
1339
  }).addCase(sendOperationSuccess, function (state, action) {
1330
- var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor;
1340
+ var _a, _b, _c;
1341
+ var bcName = action.payload.bcName;
1342
+ var cursor = action.payload.cursor;
1331
1343
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1344
+ state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
1332
1345
  state.pendingDataChanges[bcName][cursor] = {};
1333
1346
  if (isTargetFormatPVF) {
1334
1347
  ;
1335
- state.pendingValidationFails[bcName][cursor] = {};
1348
+ ((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
1336
1349
  }
1337
1350
  else {
1338
1351
  state.pendingValidationFails = initialViewState.pendingValidationFails;
1339
1352
  }
1353
+ state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
1340
1354
  state.handledForceActive[bcName][cursor] = {};
1341
1355
  }).addCase(bcSaveDataSuccess, function (state, action) {
1342
- var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor;
1356
+ var _a, _b, _c;
1357
+ var _d = action.payload, bcName = _d.bcName, cursor = _d.cursor;
1343
1358
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1359
+ state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
1344
1360
  state.pendingDataChanges[bcName][cursor] = {};
1345
1361
  if (isTargetFormatPVF) {
1346
1362
  ;
1347
- state.pendingValidationFails[bcName][cursor] = {};
1363
+ ((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
1348
1364
  }
1349
1365
  else {
1350
1366
  state.pendingValidationFails = initialViewState.pendingValidationFails;
1351
1367
  }
1368
+ state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
1352
1369
  state.handledForceActive[bcName][cursor] = {};
1353
1370
  }).addCase(bcCancelPendingChanges, function (state, action) {
1354
1371
  var _a, _b;
@@ -1359,7 +1376,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1359
1376
  }
1360
1377
  }
1361
1378
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1362
- var pendingValidationFails = __assign({}, state.pendingValidationFails);
1379
+ var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
1363
1380
  if (isTargetFormatPVF) {
1364
1381
  if (((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.bcNames) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1365
1382
  action.payload.bcNames.forEach(function (i) {
@@ -1388,8 +1405,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1388
1405
  isFilter: isFilter
1389
1406
  };
1390
1407
  }).addCase(showFileUploadPopup, function (state, action) {
1391
- var _a;
1392
- var bcName = (_a = state.widgets.find(function (item) { return item.name === action.payload.widgetName; })) === null || _a === void 0 ? void 0 : _a.bcName;
1408
+ var _a, _b;
1409
+ 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;
1393
1410
  state.popupData = {
1394
1411
  type: "file-upload",
1395
1412
  bcName: bcName,
@@ -1401,6 +1418,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1401
1418
  }).addCase(viewClearPickMap, function (state) {
1402
1419
  state.pickMap = null;
1403
1420
  }).addCase(closeViewPopup, function (state) {
1421
+ state.popupData = {};
1404
1422
  state.popupData.bcName = null;
1405
1423
  }).addCase(selectTableCell, function (state, action) {
1406
1424
  state.selectedCell = { widgetName: action.payload.widgetName, rowId: action.payload.rowId, fieldKey: action.payload.fieldKey };
@@ -1408,12 +1426,16 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1408
1426
  state.pendingDataChanges = initialViewState.pendingDataChanges;
1409
1427
  state.selectedCell = initialViewState.selectedCell;
1410
1428
  }).addCase(showNotification, function (state, action) {
1429
+ var _a, _b;
1430
+ state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
1411
1431
  state.systemNotifications.push({
1412
1432
  type: action.payload.type,
1413
1433
  message: action.payload.message,
1414
- id: state.systemNotifications.length
1434
+ id: (_b = state.systemNotifications) === null || _b === void 0 ? void 0 : _b.length
1415
1435
  });
1416
1436
  }).addCase(closeNotification, function (state, action) {
1437
+ var _a;
1438
+ state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
1417
1439
  state.systemNotifications = state.systemNotifications.filter(function (item) { return item.id !== action.payload.id; });
1418
1440
  }).addCase(showViewError, function (state, action) {
1419
1441
  state.error = action.payload.error;
@@ -1529,7 +1551,7 @@ var sendOperationEpic = function (action$, state$, _a) {
1529
1551
  var record = (_c = state.data[bcName]) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.id === bc.cursor; });
1530
1552
  var filters = state.screen.filters[bcName];
1531
1553
  var sorters = state.screen.sorters[bcName];
1532
- var pendingRecordChange = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor];
1554
+ var pendingRecordChange = __assign({}, (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor]);
1533
1555
  var _loop_1 = function (key) {
1534
1556
  if (fields.find(function (item) { return item.key === key && item.disabled; })) {
1535
1557
  delete pendingRecordChange[key];
@@ -1546,10 +1568,10 @@ var sendOperationEpic = function (action$, state$, _a) {
1546
1568
  }
1547
1569
  var context = { widgetName: action.payload.widgetName };
1548
1570
  return api.customAction(screenName, bcUrl, data, context, params).pipe(mergeMap(function (response) {
1549
- var _a;
1550
- var postInvoke = response.postActions[0];
1571
+ var _a, _b;
1572
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
1551
1573
  var preInvoke = response.preInvoke;
1552
- 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 })),
1574
+ 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 })),
1553
1575
  of2(bcForceUpdate({ bcName: bcName }))], postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName), false));
1554
1576
  }), catchError(function (e) {
1555
1577
  var _a, _b, _c, _d, _e, _f;
@@ -1614,16 +1636,17 @@ import { OperationTypeCrud as OperationTypeCrud5 } from "@cxbox-ui/schema";
1614
1636
  var fileUploadConfirmEpic = function (action$, state$, _a) {
1615
1637
  var api = _a.api;
1616
1638
  return action$.pipe(filter3(bulkUploadFiles.match), mergeMap3(function (action) {
1617
- var _a;
1639
+ var _a, _b;
1618
1640
  var state = state$.value;
1619
- var bcName = state.view.popupData.bcName;
1641
+ var bcName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.bcName;
1620
1642
  var bcUrl = buildBcUrl(bcName, true, state);
1621
- var widgetName = (_a = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _a === void 0 ? void 0 : _a.name;
1643
+ var widgetName = (_b = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.name;
1622
1644
  var data = {
1623
1645
  bulkIds: action.payload.fileIds
1624
1646
  };
1625
1647
  return api.customAction(state.screen.screenName, bcUrl, data, null, { _action: "file-upload-save" }).pipe(mergeMap3(function (response) {
1626
- var postInvoke = response.postActions[0];
1648
+ var _a;
1649
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
1627
1650
  var preInvoke = response.preInvoke;
1628
1651
  return concat2.apply(void 0, __spreadArray([of4(sendOperationSuccess({ bcName: bcName, cursor: null })),
1629
1652
  of4(bcForceUpdate({ bcName: bcName })),
@@ -1639,14 +1662,14 @@ var selectTableCellInitEpic = function (action$, state$) { return action$.pipe(f
1639
1662
  var state = state$.value;
1640
1663
  var _b = action.payload, nextRowId = _b.rowId, fieldKey = _b.fieldKey;
1641
1664
  var nextWidget = state.view.widgets.find(function (widget) { return widget.name === action.payload.widgetName; });
1642
- var nextBcName = nextWidget.bcName;
1665
+ var nextBcName = nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.bcName;
1643
1666
  var nextBcCursor = (_a = state.screen.bo.bc[nextBcName]) === null || _a === void 0 ? void 0 : _a.cursor;
1644
1667
  var selectedCell = state.view.selectedCell;
1645
1668
  if (nextRowId !== nextBcCursor) {
1646
1669
  resultObservables.push(of5(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })));
1647
1670
  }
1648
- if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || nextWidget.name !== selectedCell.widgetName) {
1649
- resultObservables.push(of5(selectTableCell({ widgetName: nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
1671
+ if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || (nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name) !== selectedCell.widgetName) {
1672
+ resultObservables.push(of5(selectTableCell({ widgetName: nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
1650
1673
  }
1651
1674
  return concat3.apply(void 0, resultObservables);
1652
1675
  })); };
@@ -1694,7 +1717,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1694
1717
  var currentRecordData = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (record) { return record.id === cursor; });
1695
1718
  var fieldsRowMeta = (_d = (_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]) === null || _d === void 0 ? void 0 : _d.fields;
1696
1719
  var changedFiledKey = null;
1697
- var closePopup = concat5(of7(viewClearPickMap(null)), of7(closeViewPopup(null)), of7(bcRemoveAllFilters({ bcName: bcName })));
1720
+ var closePopup = concat5(of7(closeViewPopup(null)), of7(viewClearPickMap(null)), of7(bcRemoveAllFilters({ bcName: bcName })));
1698
1721
  var someForceActiveChanged = fieldsRowMeta === null || fieldsRowMeta === void 0 ? void 0 : fieldsRowMeta.filter(function (field) { return field.forceActive && pendingChanges[field.key] !== void 0; }).some(function (field) {
1699
1722
  var result = pendingChanges[field.key] !== handledForceActive[field.key];
1700
1723
  if (result) {
@@ -1704,7 +1727,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1704
1727
  });
1705
1728
  var requestId = nanoid();
1706
1729
  if (someForceActiveChanged && !disableRetry) {
1707
- 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) {
1730
+ 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) {
1708
1731
  var result = [of7(removePendingRequest({ requestId: requestId }))];
1709
1732
  if (state.view.url === initUrl) {
1710
1733
  result.push(of7(forceActiveRmUpdate({
@@ -1734,7 +1757,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1734
1757
  bcName: bcName,
1735
1758
  bcUrl: buildBcUrl(bcName, true, state),
1736
1759
  cursor: cursor,
1737
- dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData[changedFiledKey], _a),
1760
+ dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData === null || currentRecordData === void 0 ? void 0 : currentRecordData[changedFiledKey], _a),
1738
1761
  disableRetry: true
1739
1762
  })), of7(forceActiveChangeFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError }))) : EMPTY3);
1740
1763
  })));
@@ -1747,9 +1770,14 @@ import { concat as concat6, filter as filter8, mergeMap as mergeMap7, of as of8
1747
1770
  var showAllTableRecordsInitEpic = function (action$, state$) { return action$.pipe(filter8(showAllTableRecordsInit.match), mergeMap7(function (action) {
1748
1771
  var _a;
1749
1772
  var resultObservables = [];
1750
- var bcName = action.payload.bcName;
1773
+ var _b = action.payload, bcName = _b.bcName, cursor = _b.cursor;
1774
+ var state = state$.value;
1775
+ var route = state.router;
1751
1776
  resultObservables.push(of8(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = null, _a) })));
1777
+ var bcPath = route.bcPath.slice(0, route.bcPath.indexOf("".concat(bcName, "/").concat(cursor)));
1778
+ var url = defaultBuildURL(__assign(__assign({}, route), { bcPath: bcPath }));
1752
1779
  resultObservables.push(of8(bcForceUpdate({ bcName: bcName })));
1780
+ resultObservables.push(of8(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })));
1753
1781
  return concat6.apply(void 0, resultObservables);
1754
1782
  })); };
1755
1783
  // src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts
@@ -1771,10 +1799,110 @@ var clearPendingDataChangesAfterCursorChangeEpic = function (action$, state$) {
1771
1799
  return EMPTY4;
1772
1800
  })); };
1773
1801
  // src/epics/router/drilldownEpic.ts
1774
- import { EMPTY as EMPTY5, filter as filter10, switchMap } from "rxjs";
1802
+ import { concat as concat7, EMPTY as EMPTY5, filter as filter10, switchMap } from "rxjs";
1775
1803
  var drillDownEpic = function (action$, state$) { return action$.pipe(filter10(drillDown.match), switchMap(function (action) {
1776
- return EMPTY5;
1804
+ var _a, _b;
1805
+ var state = state$.value;
1806
+ var url = action.payload.url;
1807
+ var result = [];
1808
+ switch (action.payload.drillDownType) {
1809
+ case DrillDownType.external:
1810
+ window.location.href = url;
1811
+ break;
1812
+ case DrillDownType.externalNew:
1813
+ if (/^[a-z0-9]+:\/\//i.test(url)) {
1814
+ window.open(url);
1815
+ }
1816
+ break;
1817
+ case DrillDownType.relative:
1818
+ window.location.href = "".concat(window.location.origin, "/").concat(url);
1819
+ break;
1820
+ case DrillDownType.relativeNew:
1821
+ window.open("".concat(window.location.origin, "/").concat(url), "_blank");
1822
+ break;
1823
+ case DrillDownType.inner:
1824
+ default:
1825
+ var urlBase = url.split("?")[0];
1826
+ var urlObject = new URL(url, window.location.origin);
1827
+ var urlFilters = urlObject.searchParams.get("filters");
1828
+ var urlSorters = urlObject.searchParams.get("sorters");
1829
+ var newFilters_1 = {};
1830
+ var newSorters = {};
1831
+ try {
1832
+ newFilters_1 = (_a = JSON.parse(urlFilters)) !== null && _a !== void 0 ? _a : newFilters_1;
1833
+ }
1834
+ catch (_c) {
1835
+ urlFilters && console.warn("Failed to parse filters on drilldown");
1836
+ newFilters_1 = {};
1837
+ }
1838
+ try {
1839
+ newSorters = (_b = JSON.parse(urlSorters)) !== null && _b !== void 0 ? _b : newSorters;
1840
+ }
1841
+ catch (_d) {
1842
+ urlSorters && console.warn("Failed to parse sorters on drilldown");
1843
+ newSorters = {};
1844
+ }
1845
+ var bcToUpdate_1 = {};
1846
+ Object.keys(state.screen.filters).forEach(function (bcName) {
1847
+ if (newFilters_1[bcName] === "" || newFilters_1[bcName]) {
1848
+ bcToUpdate_1[bcName] = true;
1849
+ result.push(bcRemoveAllFilters({ bcName: bcName }));
1850
+ }
1851
+ });
1852
+ var nextState = defaultParseURL(urlObject);
1853
+ var viewName_1 = nextState.viewName;
1854
+ Object.entries(newFilters_1).forEach(function (_a) {
1855
+ var _b;
1856
+ var bcName = _a[0], filterExpression = _a[1];
1857
+ var parsedFilters = (_b = parseFilters(filterExpression)) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), { viewName: viewName_1 })); });
1858
+ parsedFilters === null || parsedFilters === void 0 ? void 0 : parsedFilters.forEach(function (parsedFilter) {
1859
+ bcToUpdate_1[bcName] = true;
1860
+ result.push(bcAddFilter({ bcName: bcName, filter: parsedFilter }));
1861
+ });
1862
+ });
1863
+ Object.entries(newSorters).forEach(function (_a) {
1864
+ var bcName = _a[0], sortExpression = _a[1];
1865
+ var sorter = parseSorters(sortExpression);
1866
+ result.push(bcAddSorter({ bcName: bcName, sorter: sorter }));
1867
+ bcToUpdate_1[bcName] = true;
1868
+ });
1869
+ var prevState = state.router;
1870
+ var willUpdateAnyway = shallowCompare(prevState, nextState, ["params"]).length > 0;
1871
+ if (!willUpdateAnyway) {
1872
+ Object.keys(bcToUpdate_1).forEach(function (bcName) {
1873
+ result.push(bcForceUpdate({ bcName: bcName }));
1874
+ });
1875
+ }
1876
+ result.push(changeLocation({ location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)) }));
1877
+ break;
1878
+ }
1879
+ return result.length ? concat7(result) : EMPTY5;
1777
1880
  })); };
1881
+ function shallowCompare(prevProps, nextProps, ignore) {
1882
+ if (ignore === void 0) { ignore = []; }
1883
+ var diffProps = [];
1884
+ if (!prevProps && !nextProps) {
1885
+ return null;
1886
+ }
1887
+ if (!prevProps) {
1888
+ return Object.keys(nextProps);
1889
+ }
1890
+ if (!nextProps) {
1891
+ return Object.keys(prevProps);
1892
+ }
1893
+ var newKeys = Object.keys(nextProps);
1894
+ newKeys.forEach(function (key) {
1895
+ if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {
1896
+ diffProps.push(key);
1897
+ }
1898
+ });
1899
+ Object.keys(prevProps).forEach(function (key) {
1900
+ if (!newKeys.includes(key)) {
1901
+ diffProps.push(key);
1902
+ }
1903
+ });
1904
+ return diffProps;
1905
+ }
1778
1906
  // src/epics/router/loginDoneEpic.ts
1779
1907
  import { filter as filter11, of as of10, switchMap as switchMap2 } from "rxjs";
1780
1908
  var loginDoneEpic = function (action$, state$) { return action$.pipe(filter11(loginDone.match), switchMap2(function (action) {
@@ -1830,7 +1958,7 @@ var changeScreen = function (action$, state$) { return action$.pipe(filter14(sel
1830
1958
  return nextView ? of12(selectView(nextView)) : of12(selectViewFail({ viewName: nextViewName }));
1831
1959
  })); };
1832
1960
  // src/epics/router/userDrillDownEpic.ts
1833
- import { catchError as catchError4, concat as concat7, EMPTY as EMPTY8, filter as filter15, mergeMap as mergeMap10, of as of13, switchMap as switchMap6 } from "rxjs";
1961
+ import { catchError as catchError4, concat as concat8, EMPTY as EMPTY8, filter as filter15, mergeMap as mergeMap10, of as of13, switchMap as switchMap6 } from "rxjs";
1834
1962
  var userDrillDownEpic = function (action$, state$, _a) {
1835
1963
  var api = _a.api;
1836
1964
  return action$.pipe(filter15(userDrillDown.match), switchMap6(function (action) {
@@ -1843,7 +1971,7 @@ var userDrillDownEpic = function (action$, state$, _a) {
1843
1971
  var route = state.router;
1844
1972
  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;
1845
1973
  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];
1846
- 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({
1974
+ 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({
1847
1975
  url: customDrillDownUrl || drillDownField.drillDown,
1848
1976
  drillDownType: drillDownField.drillDownType,
1849
1977
  route: route
@@ -1855,7 +1983,7 @@ var userDrillDownEpic = function (action$, state$, _a) {
1855
1983
  }));
1856
1984
  };
1857
1985
  // src/epics/router/changeLocationEpic.ts
1858
- import { concat as concat8, EMPTY as EMPTY9, filter as filter16, mergeMap as mergeMap11, of as of14 } from "rxjs";
1986
+ import { concat as concat9, EMPTY as EMPTY9, filter as filter16, mergeMap as mergeMap11, of as of14 } from "rxjs";
1859
1987
  var changeLocationEpic = function (action$, state$) { return action$.pipe(filter16(changeLocation.match), mergeMap11(function (action) {
1860
1988
  var _a, _b;
1861
1989
  var state = state$.value;
@@ -1901,7 +2029,7 @@ var changeLocationEpic = function (action$, state$) { return action$.pipe(filter
1901
2029
  }
1902
2030
  });
1903
2031
  }
1904
- return concat8.apply(void 0, resultObservables);
2032
+ return concat9.apply(void 0, resultObservables);
1905
2033
  })); };
1906
2034
  // src/epics/router/selectViewFailEpic.ts
1907
2035
  import { filter as filter17, map as map2 } from "rxjs";
@@ -1934,7 +2062,7 @@ var userDrillDownChangeCursorsEpic = function (action$, state$) { return action$
1934
2062
  if (cursor !== action.payload.cursor) {
1935
2063
  return bcChangeCursors({ cursorsMap: (_a = {}, _a[action.payload.bcName] = action.payload.cursor, _a) });
1936
2064
  }
1937
- return void 0;
2065
+ return emptyAction;
1938
2066
  })); };
1939
2067
  // src/epics/screen/apiErrorEpic.ts
1940
2068
  import axios from "axios";
@@ -1962,7 +2090,9 @@ import { EMPTY as EMPTY11, filter as filter21, mergeMap as mergeMap13, tap } fro
1962
2090
  var downloadFileEpic = function (action$, state$, _a) {
1963
2091
  var api = _a.api;
1964
2092
  return action$.pipe(filter21(downloadFile.match), tap(function (action) {
2093
+ var fileId = action.payload.fileId;
1965
2094
  var anchor = document.createElement("a");
2095
+ anchor.href = "".concat(api.fileUploadEndpoint, "?id=").concat(encodeURIComponent(fileId));
1966
2096
  anchor.style.display = "none";
1967
2097
  document.body.appendChild(anchor);
1968
2098
  setTimeout(function () {
@@ -1979,8 +2109,8 @@ var httpError401Epic = function (action$) { return action$.pipe(filter22(httpErr
1979
2109
  // src/epics/screen/httpError409Epic.ts
1980
2110
  import { filter as filter23, map as map6 } from "rxjs";
1981
2111
  var httpError409Epic = function (action$, state$) { return action$.pipe(filter23(httpError.match), filter23(function (action) { return action.payload.statusCode === 409; }), map6(function (action) {
1982
- var _a, _b;
1983
- 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]) || "";
2112
+ var _a, _b, _c;
2113
+ 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]) || "";
1984
2114
  return addNotification({
1985
2115
  key: "action_edit_error",
1986
2116
  message: notificationMessage,
@@ -1994,12 +2124,12 @@ var httpError409Epic = function (action$, state$) { return action$.pipe(filter23
1994
2124
  });
1995
2125
  })); };
1996
2126
  // src/epics/screen/httpError418Epic.ts
1997
- import { concat as concat9, EMPTY as EMPTY12, filter as filter24, mergeMap as mergeMap14, of as of16 } from "rxjs";
2127
+ import { concat as concat10, EMPTY as EMPTY12, filter as filter24, mergeMap as mergeMap14, of as of16 } from "rxjs";
1998
2128
  var httpError418Epic = function (action$, state$) { return action$.pipe(filter24(httpError.match), filter24(function (action) { return action.payload.statusCode === 418; }), mergeMap14(function (action) {
1999
- var _a;
2000
- var _b = action.payload, error = _b.error, callContext = _b.callContext;
2129
+ var _a, _b;
2130
+ var _c = action.payload, error = _c.error, callContext = _c.callContext;
2001
2131
  var result = [];
2002
- var typedError = error.response.data;
2132
+ var typedError = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
2003
2133
  if (!typedError.error.popup) {
2004
2134
  return EMPTY12;
2005
2135
  }
@@ -2008,16 +2138,16 @@ var httpError418Epic = function (action$, state$) { return action$.pipe(filter24
2008
2138
  message: typedError.error.popup[0]
2009
2139
  };
2010
2140
  result.push(of16(showViewError({ error: businessError })));
2011
- if ((_a = typedError.error.postActions) === null || _a === void 0 ? void 0 : _a[0]) {
2141
+ if ((_b = typedError.error.postActions) === null || _b === void 0 ? void 0 : _b[0]) {
2012
2142
  var widget = state$.value.view.widgets.find(function (item) { return item.name === callContext.widgetName; });
2013
- var bcName = widget.bcName;
2143
+ var bcName = widget === null || widget === void 0 ? void 0 : widget.bcName;
2014
2144
  result.push(of16(processPostInvoke({
2015
2145
  bcName: bcName,
2016
2146
  postInvoke: typedError.error.postActions[0],
2017
- widgetName: widget.name
2147
+ widgetName: widget === null || widget === void 0 ? void 0 : widget.name
2018
2148
  })));
2019
2149
  }
2020
- return concat9.apply(void 0, result);
2150
+ return concat10.apply(void 0, result);
2021
2151
  })); };
2022
2152
  // src/epics/screen/httpError500Epic.ts
2023
2153
  import { filter as filter25, map as map7 } from "rxjs";
@@ -2034,10 +2164,11 @@ var httpError500Epic = function (action$, state$) { return action$.pipe(filter25
2034
2164
  import { filter as filter26, map as map8 } from "rxjs";
2035
2165
  var knownHttpErrors = [401, 409, 418, 500];
2036
2166
  var httpErrorDefaultEpic = function (action$, state$) { return action$.pipe(filter26(httpError.match), filter26(function (action) { return !knownHttpErrors.includes(action.payload.statusCode); }), map8(function (action) {
2167
+ var _a, _b;
2037
2168
  var businessError = {
2038
2169
  type: 0 /* BusinessError */,
2039
- code: action.payload.error.response.status,
2040
- details: action.payload.error.response.data
2170
+ code: (_a = action.payload.error.response) === null || _a === void 0 ? void 0 : _a.status,
2171
+ details: (_b = action.payload.error.response) === null || _b === void 0 ? void 0 : _b.data
2041
2172
  };
2042
2173
  return showViewError({ error: businessError });
2043
2174
  })); };
@@ -2058,6 +2189,7 @@ var downloadFileByUrlEpic = function (action$, state$) { return action$.pipe(fil
2058
2189
  import { EMPTY as EMPTY14, filter as filter28, mergeMap as mergeMap16, of as of17 } from "rxjs";
2059
2190
  var processPostInvokeEpic = function (action$, state$) { return action$.pipe(filter28(processPostInvoke.match), mergeMap16(function (action) {
2060
2191
  var _a;
2192
+ var _b;
2061
2193
  var state = state$.value;
2062
2194
  switch (action.payload.postInvoke.type) {
2063
2195
  case "drillDown" /* drillDown */:
@@ -2065,7 +2197,10 @@ var processPostInvokeEpic = function (action$, state$) { return action$.pipe(fil
2065
2197
  case "postDelete" /* postDelete */: {
2066
2198
  var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
2067
2199
  var result = [bcChangeCursors({ cursorsMap: cursorsMap })];
2068
- if (state.router.bcPath.includes("".concat(action.payload.bcName, "/"))) {
2200
+ if ((_b = state.router.bcPath) === null || _b === void 0 ? void 0 : _b.includes("".concat(action.payload.bcName, "/"))) {
2201
+ var newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || "";
2202
+ var newUrl = "/screen/".concat(state.router.screenName, "/view/").concat(state.router.viewName, "/").concat(newBcUrl);
2203
+ result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }));
2069
2204
  }
2070
2205
  else {
2071
2206
  result.push(bcFetchDataRequest({
@@ -2134,24 +2269,23 @@ var processPostInvokeConfirmEpic = function (action$, state$) { return action$.p
2134
2269
  }
2135
2270
  })); };
2136
2271
  // src/epics/session/switchRoleEpic.ts
2137
- import { concat as concat10, filter as filter30, switchMap as switchMap7 } from "rxjs";
2272
+ import { concat as concat11, filter as filter30, switchMap as switchMap7 } from "rxjs";
2138
2273
  var switchRoleEpic = function (action$, state$) { return action$.pipe(filter30(switchRole.match), switchMap7(function (action) {
2139
- return concat10([logoutDone(null), login({ login: "", password: "", role: action.payload.role })]);
2274
+ return concat11([logoutDone(null), login({ login: "", password: "", role: action.payload.role })]);
2140
2275
  })); };
2141
2276
  // src/epics/session/refreshMetaEpic.ts
2142
- import { catchError as catchError5, concat as concat11, filter as filter31, mergeMap as mergeMap18, of as of19, switchMap as switchMap8 } from "rxjs";
2277
+ import { catchError as catchError5, concat as concat12, filter as filter31, mergeMap as mergeMap18, of as of19, switchMap as switchMap8 } from "rxjs";
2143
2278
  var refreshMetaEpic = function (action$, state$, _a) {
2144
2279
  var api = _a.api;
2145
2280
  return action$.pipe(filter31(refreshMeta.match), mergeMap18(function () {
2146
2281
  var state = state$.value;
2147
2282
  var router = state.router;
2148
2283
  var activeRole = state.session.activeRole;
2149
- return api.refreshMeta().pipe(switchMap8(function () { return concat11([
2284
+ return api.refreshMeta().pipe(switchMap8(function () { return concat12([
2150
2285
  logoutDone(null),
2151
2286
  login({ login: "", password: "", role: activeRole }),
2152
2287
  changeLocation({
2153
- route: router,
2154
- action: "PUSH"
2288
+ location: router
2155
2289
  })
2156
2290
  ]); }), catchError5(function (error) { return of19(loginFail(error)); }));
2157
2291
  }));
@@ -2160,7 +2294,7 @@ var refreshMetaEpic = function (action$, state$, _a) {
2160
2294
  import { EMPTY as EMPTY16, filter as filter32, switchMap as switchMap9 } from "rxjs";
2161
2295
  var loginDoneSessionEpic = function (action$, store) { return action$.pipe(filter32(login.match), switchMap9(function (action) { return EMPTY16; })); };
2162
2296
  // src/epics/session/loginByAnotherRoleEpic.ts
2163
- import { catchError as catchError6, EMPTY as EMPTY17, filter as filter33, mergeMap as mergeMap19, of as of20, switchMap as switchMap10 } from "rxjs";
2297
+ import { catchError as catchError6, concat as concat13, filter as filter33, mergeMap as mergeMap19, of as of20, switchMap as switchMap10 } from "rxjs";
2164
2298
  var responseStatusMessages = {
2165
2299
  401: "Invalid credentials",
2166
2300
  403: "Access denied"
@@ -2172,9 +2306,26 @@ var loginByAnotherRoleEpic = function (action$, state$, _a) {
2172
2306
  var role = (_a = action.payload.role) !== null && _a !== void 0 ? _a : "";
2173
2307
  var isSwitchRole = role && role !== state$.value.session.activeRole;
2174
2308
  return api.loginByRoleRequest(role).pipe(mergeMap19(function (data) {
2309
+ var _a;
2310
+ var result = [];
2175
2311
  if (isSwitchRole) {
2312
+ var defaultScreen = data.screens.find(function (screen) { return screen.defaultScreen; }) || data.screens[0];
2313
+ var defaultViewName_1 = (_a = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.primary) !== null && _a !== void 0 ? _a : defaultScreen.meta.views[0].name;
2314
+ var defaultView = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.meta.views.find(function (view) { return defaultViewName_1 === view.name; });
2315
+ if (defaultView)
2316
+ result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }));
2176
2317
  }
2177
- return EMPTY17;
2318
+ return concat13(__spreadArray(__spreadArray([], result, true), [
2319
+ loginDone({
2320
+ devPanelEnabled: data.devPanelEnabled,
2321
+ activeRole: data.activeRole,
2322
+ roles: data.roles,
2323
+ screens: data.screens,
2324
+ firstName: data.firstName,
2325
+ lastName: data.lastName,
2326
+ login: data.login
2327
+ })
2328
+ ], false));
2178
2329
  }), catchError6(function (error) {
2179
2330
  console.error(error);
2180
2331
  var errorMsg = error.response ? responseStatusMessages[error.response.status] || "Server application unavailable" : "Empty server response";
@@ -2183,35 +2334,37 @@ var loginByAnotherRoleEpic = function (action$, state$, _a) {
2183
2334
  }));
2184
2335
  };
2185
2336
  // src/epics/session/refreshMetaAndReloadPageEpic.ts
2186
- import { concat as concat12, EMPTY as EMPTY18, filter as filter34, of as of21, switchMap as switchMap11, take, tap as tap3 } from "rxjs";
2187
- 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; }))); })); };
2337
+ import { concat as concat14, EMPTY as EMPTY17, filter as filter34, of as of21, switchMap as switchMap11, take, tap as tap3 } from "rxjs";
2338
+ var refreshMetaAndReloadPageEpic = function (action$, state$) { return action$.pipe(filter34(refreshMetaAndReloadPage.match), switchMap11(function () { return concat14(of21(refreshMeta(null)), action$.pipe(filter34(loginDone.match), take(1), tap3(function () { return location.reload(); }), switchMap11(function () { return EMPTY17; }))); })); };
2188
2339
  // src/epics/data/bcNewDataEpic.ts
2189
- import { catchError as catchError7, concat as concat13, EMPTY as EMPTY19, filter as filter35, mergeMap as mergeMap20, of as of22 } from "rxjs";
2340
+ import { catchError as catchError7, concat as concat15, EMPTY as EMPTY18, filter as filter35, mergeMap as mergeMap20, of as of22 } from "rxjs";
2190
2341
  import { OperationTypeCrud as OperationTypeCrud8 } from "@cxbox-ui/schema";
2191
2342
  var bcNewDataEpic = function (action$, state$, _a) {
2192
2343
  var api = _a.api;
2193
2344
  return action$.pipe(filter35(sendOperation.match), filter35(function (action) { return matchOperationRole(OperationTypeCrud8.create, action.payload, state$.value); }), mergeMap20(function (action) {
2345
+ var _a;
2194
2346
  var state = state$.value;
2195
2347
  var bcName = action.payload.bcName;
2196
- var bcUrl = buildBcUrl(bcName, false, state);
2348
+ var bcUrl = (_a = buildBcUrl(bcName, false, state)) !== null && _a !== void 0 ? _a : "";
2197
2349
  var context = { widgetName: action.payload.widgetName };
2198
2350
  var params = { _action: action.payload.operationType };
2199
2351
  return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe(mergeMap20(function (data) {
2352
+ var _a, _b;
2200
2353
  var rowMeta = data.row;
2201
2354
  var dataItem = { id: null, vstamp: -1 };
2202
2355
  data.row.fields.forEach(function (field) {
2203
2356
  dataItem[field.key] = field.currentValue;
2204
2357
  });
2205
- var postInvoke = data.postActions[0];
2358
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2206
2359
  var cursor = dataItem.id;
2207
- 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({
2360
+ return concat15(of22(bcNewDataSuccess({ bcName: bcName, dataItem: dataItem, bcUrl: bcUrl })), of22(bcFetchRowMetaSuccess({ bcName: bcName, bcUrl: "".concat(bcUrl, "/").concat(cursor), rowMeta: rowMeta, cursor: cursor })), of22(changeDataItem({
2208
2361
  bcName: bcName,
2209
- bcUrl: buildBcUrl(bcName, true, state),
2362
+ bcUrl: (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "",
2210
2363
  cursor: cursor,
2211
2364
  dataItem: {
2212
2365
  id: cursor
2213
2366
  }
2214
- })), postInvoke ? of22(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: action.payload.widgetName })) : EMPTY19);
2367
+ })), postInvoke ? of22(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: action.payload.widgetName })) : EMPTY18);
2215
2368
  }), catchError7(function (error) {
2216
2369
  console.error(error);
2217
2370
  return of22(bcNewDataFail({ bcName: bcName }));
@@ -2229,7 +2382,7 @@ function cancelRequestEpic(action$, actionTypes, cancelFn, cancelActionCreator,
2229
2382
  return true;
2230
2383
  }; }
2231
2384
  return action$.pipe(filter36(isAnyOf2.apply(void 0, actionTypes)), filter36(filterFn), mergeMap21(function () {
2232
- cancelFn();
2385
+ cancelFn === null || cancelFn === void 0 ? void 0 : cancelFn();
2233
2386
  return of23(cancelActionCreator);
2234
2387
  }), take2(1));
2235
2388
  }
@@ -2268,20 +2421,20 @@ var bcLoadMoreEpic = function (action$, state$, _a) {
2268
2421
  }));
2269
2422
  };
2270
2423
  // src/epics/data/bcSaveDataEpic.ts
2271
- import { catchError as catchError9, concat as concat14, EMPTY as EMPTY20, filter as filter38, mergeMap as mergeMap23, of as of25 } from "rxjs";
2424
+ import { catchError as catchError9, concat as concat16, EMPTY as EMPTY19, filter as filter38, mergeMap as mergeMap23, of as of25 } from "rxjs";
2272
2425
  var bcSaveDataEpic = function (action$, state$, _a) {
2273
2426
  var api = _a.api;
2274
2427
  return action$.pipe(filter38(sendOperation.match), filter38(function (action) { return matchOperationRole(OperationTypeCrud.save, action.payload, state$.value); }), mergeMap23(function (action) {
2275
- var _a, _b, _c;
2428
+ var _a, _b, _c, _d;
2276
2429
  var state = state$.value;
2277
2430
  var bcName = action.payload.bcName;
2278
- var bcUrl = buildBcUrl(bcName, true, state);
2431
+ var bcUrl = (_a = buildBcUrl(bcName, true, state)) !== null && _a !== void 0 ? _a : "";
2279
2432
  var widgetName = action.payload.widgetName;
2280
2433
  var cursor = state.screen.bo.bc[bcName].cursor;
2281
2434
  var dataItem = state.data[bcName].find(function (item) { return item.id === cursor; });
2282
- var pendingChanges = (_a = state.view.pendingDataChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
2283
- var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
2284
- var options = (_c = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _c === void 0 ? void 0 : _c.options;
2435
+ var pendingChanges = __assign({}, (_b = state.view.pendingDataChanges[bcName]) === null || _b === void 0 ? void 0 : _b[cursor]);
2436
+ var rowMeta = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
2437
+ var options = (_d = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _d === void 0 ? void 0 : _d.options;
2285
2438
  if (rowMeta) {
2286
2439
  var fields = rowMeta.fields;
2287
2440
  var _loop_2 = function (key) {
@@ -2298,19 +2451,20 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2298
2451
  return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] });
2299
2452
  });
2300
2453
  var context = { widgetName: action.payload.widgetName };
2301
- return api.saveBcData(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: dataItem.vstamp }), context).pipe(mergeMap23(function (data) {
2302
- var postInvoke = data.postActions[0];
2454
+ 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) {
2455
+ var _a;
2456
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2303
2457
  var responseDataItem = data.record;
2304
- return concat14(of25(bcSaveDataSuccess({ bcName: bcName, cursor: cursor, dataItem: responseDataItem })), of25(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName })), of25.apply(void 0, fetchChildrenBcData), postInvoke ? of25(processPostInvoke({
2458
+ return concat16(of25(bcSaveDataSuccess({ bcName: bcName, cursor: cursor, dataItem: responseDataItem })), of25(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName })), of25.apply(void 0, fetchChildrenBcData), postInvoke ? of25(processPostInvoke({
2305
2459
  bcName: bcName,
2306
2460
  widgetName: widgetName,
2307
2461
  postInvoke: postInvoke,
2308
2462
  cursor: responseDataItem.id
2309
- })) : EMPTY20, action.payload.onSuccessAction ? of25(action.payload.onSuccessAction) : EMPTY20);
2463
+ })) : EMPTY19, action.payload.onSuccessAction ? of25(action.payload.onSuccessAction) : EMPTY19);
2310
2464
  }), catchError9(function (e) {
2311
- var _a, _b, _c, _d, _e, _f;
2465
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2312
2466
  console.error(e);
2313
- var notification$ = EMPTY20;
2467
+ var notification$ = EMPTY19;
2314
2468
  if (action.payload.onSuccessAction && !(options === null || options === void 0 ? void 0 : options.disableNotification)) {
2315
2469
  notification$ = of25(addNotification({
2316
2470
  key: "data_autosave_undo",
@@ -2329,15 +2483,15 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2329
2483
  var entityError = null;
2330
2484
  var operationError = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data;
2331
2485
  if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.data) === Object((_c = e.response) === null || _c === void 0 ? void 0 : _c.data)) {
2332
- entityError = (_d = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _d === void 0 ? void 0 : _d.entity;
2333
- 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];
2486
+ 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;
2487
+ 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;
2334
2488
  }
2335
- return concat14(of25(bcSaveDataFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError })), notification$);
2489
+ return concat16(of25(bcSaveDataFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError })), notification$);
2336
2490
  }));
2337
2491
  }));
2338
2492
  };
2339
2493
  // src/epics/data/selectViewEpic.ts
2340
- import { EMPTY as EMPTY21, filter as filter39, mergeMap as mergeMap24 } from "rxjs";
2494
+ import { EMPTY as EMPTY20, filter as filter39, mergeMap as mergeMap24 } from "rxjs";
2341
2495
  var selectViewEpic = function (action$, state$) { return action$.pipe(filter39(selectView.match), mergeMap24(function (action) {
2342
2496
  try {
2343
2497
  var state_1 = state$.value;
@@ -2363,11 +2517,11 @@ var selectViewEpic = function (action$, state$) { return action$.pipe(filter39(s
2363
2517
  }
2364
2518
  catch (e) {
2365
2519
  console.error("selectView Epic:: ".concat(e));
2366
- return EMPTY21;
2520
+ return EMPTY20;
2367
2521
  }
2368
2522
  })); };
2369
2523
  // src/epics/data/bcFetchDataEpic.ts
2370
- import { catchError as catchError10, concat as concat15, EMPTY as EMPTY22, filter as filter40, mergeMap as mergeMap25, of as of26, race as race2 } from "rxjs";
2524
+ import { catchError as catchError10, concat as concat17, EMPTY as EMPTY21, filter as filter40, mergeMap as mergeMap25, of as of26, race as race2 } from "rxjs";
2371
2525
  import { WidgetTypes as WidgetTypes5 } from "@cxbox-ui/schema";
2372
2526
  import { isAnyOf as isAnyOf3 } from "@reduxjs/toolkit";
2373
2527
  var bcFetchDataEpic = function (action$, state$, _a) {
@@ -2389,7 +2543,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2389
2543
  var getChildrenData = function (widgets, bcDictionary, isHierarchy, showConditionCheck) {
2390
2544
  var bcName = action.payload.bcName;
2391
2545
  var _a = bcFetchDataRequest.match(action) ? action.payload : { ignorePageLimit: void 0, keepDelta: void 0 }, ignorePageLimit = _a.ignorePageLimit, keepDelta = _a.keepDelta;
2392
- return concat15.apply(void 0, Object.entries(getBcChildren(bcName, widgets, bcDictionary)).filter(function (_a) {
2546
+ return concat17.apply(void 0, Object.entries(getBcChildren(bcName, widgets, bcDictionary)).filter(function (_a) {
2393
2547
  var childBcName = _a[0], widgetNames = _a[1];
2394
2548
  var nonLazyWidget = widgets.find(function (item) {
2395
2549
  return widgetNames.includes(item.name) && !PopupWidgetTypes.includes(item.type) && showConditionCheck(item);
@@ -2406,41 +2560,41 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2406
2560
  });
2407
2561
  return of26(bcFetchDataRequest({
2408
2562
  bcName: childBcName,
2409
- widgetName: nonLazyWidget.name,
2563
+ widgetName: nonLazyWidget === null || nonLazyWidget === void 0 ? void 0 : nonLazyWidget.name,
2410
2564
  ignorePageLimit: ignorePageLimit || showViewPopup.match(action),
2411
2565
  keepDelta: isHierarchy || keepDelta
2412
2566
  }));
2413
2567
  }));
2414
2568
  };
2415
2569
  var bcFetchDataImpl = function () {
2416
- var _a, _b, _c, _d, _e, _f;
2570
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2417
2571
  var state = state$.value;
2418
- var widgetName = action.payload.widgetName;
2419
- var _g = state.view, widgets = _g.widgets, infiniteWidgets = _g.infiniteWidgets;
2420
- 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; });
2572
+ var _j = action.payload.widgetName, widgetName = _j === void 0 ? "" : _j;
2573
+ var _k = state.view, widgets = _k.widgets, infiniteWidgets = _k.infiniteWidgets;
2574
+ 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; });
2421
2575
  if (!widget) {
2422
- return [EMPTY22];
2576
+ return [EMPTY21];
2423
2577
  }
2424
2578
  var bcName = action.payload.bcName;
2425
2579
  var bc = state.screen.bo.bc[bcName];
2426
- var cursor = bc.cursor, page = bc.page;
2427
- var limit = ((_b = widgets.find(function (i) { return i.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.limit) || bc.limit;
2580
+ var cursor = bc.cursor, _l = bc.page, page = _l === void 0 ? 1 : _l;
2581
+ 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;
2428
2582
  var sorters = state.screen.sorters[bcName];
2429
2583
  if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {
2430
- return [EMPTY22];
2584
+ return [EMPTY21];
2431
2585
  }
2432
- var anyHierarchyWidget = widgets.find(function (item) {
2586
+ var anyHierarchyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.find(function (item) {
2433
2587
  return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && isHierarchyWidget(item);
2434
2588
  });
2435
- var fullHierarchyWidget = state.view.widgets.find(function (item) {
2589
+ var fullHierarchyWidget = (_d = state.view.widgets) === null || _d === void 0 ? void 0 : _d.find(function (item) {
2436
2590
  var _a;
2437
2591
  return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && ((_a = item.options) === null || _a === void 0 ? void 0 : _a.hierarchyFull);
2438
2592
  });
2439
- var limitBySelfCursor = (_c = state.router.bcPath) === null || _c === void 0 ? void 0 : _c.includes("".concat(bcName, "/").concat(cursor));
2593
+ var limitBySelfCursor = (_e = state.router.bcPath) === null || _e === void 0 ? void 0 : _e.includes("".concat(bcName, "/").concat(cursor));
2440
2594
  var bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
2441
2595
  var fetchParams = __assign(__assign({ _page: page, _limit: limit }, getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || [])), getSorters(sorters));
2442
2596
  if (bcForceUpdate.match(action)) {
2443
- 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);
2597
+ 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);
2444
2598
  if (infinityPaginationWidget) {
2445
2599
  fetchParams._page = 1;
2446
2600
  fetchParams._limit = limit * page;
@@ -2450,7 +2604,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2450
2604
  fetchParams._page = action.payload.from || 1;
2451
2605
  fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit;
2452
2606
  }
2453
- 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)) {
2607
+ 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)) {
2454
2608
  fetchParams._limit = 0;
2455
2609
  }
2456
2610
  var canceler = api.createCanceler();
@@ -2462,7 +2616,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2462
2616
  var normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(mergeMap25(function (response) {
2463
2617
  var _a, _b;
2464
2618
  var cursorChange = getCursorChange(response.data, cursor, !!anyHierarchyWidget);
2465
- var parentOfNotLazyWidget = widgets.some(function (item) {
2619
+ var parentOfNotLazyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.some(function (item) {
2466
2620
  var _a;
2467
2621
  return ((_a = state.screen.bo.bc[item.bcName]) === null || _a === void 0 ? void 0 : _a.parentName) === bcName && !PopupWidgetTypes.includes(item.type);
2468
2622
  });
@@ -2485,11 +2639,11 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2485
2639
  var lazyWidget = (!isWidgetVisible(widget) || PopupWidgetTypes.includes(widget.type)) && !parentOfNotLazyWidget;
2486
2640
  var skipLazy = ((_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.bcName) !== widget.bcName;
2487
2641
  if (lazyWidget && skipLazy) {
2488
- return EMPTY22;
2642
+ return EMPTY21;
2489
2643
  }
2490
- var fetchChildren = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) ? getChildrenData(widgets, state.screen.bo.bc, !!anyHierarchyWidget, isWidgetVisible) : EMPTY22;
2644
+ var fetchChildren = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) ? getChildrenData(widgets, state.screen.bo.bc, !!anyHierarchyWidget, isWidgetVisible) : EMPTY21;
2491
2645
  var fetchRowMeta = of26(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName }));
2492
- return concat15(cursorChange, of26(bcFetchDataSuccess({
2646
+ return concat17(cursorChange, of26(bcFetchDataSuccess({
2493
2647
  bcName: bcName,
2494
2648
  data: response.data,
2495
2649
  bcUrl: bcUrl,
@@ -2509,7 +2663,7 @@ function isHierarchyWidget(widget) {
2509
2663
  return ((_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchy) || ((_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchyFull);
2510
2664
  }
2511
2665
  // src/epics/data/bcDeleteDataEpic.ts
2512
- import { catchError as catchError11, concat as concat16, EMPTY as EMPTY23, filter as filter41, mergeMap as mergeMap26, of as of27 } from "rxjs";
2666
+ import { catchError as catchError11, concat as concat18, EMPTY as EMPTY22, filter as filter41, mergeMap as mergeMap26, of as of27 } from "rxjs";
2513
2667
  import { OperationTypeCrud as OperationTypeCrud9 } from "@cxbox-ui/schema";
2514
2668
  var bcDeleteDataEpic = function (action$, store$, _a) {
2515
2669
  var api = _a.api;
@@ -2522,8 +2676,9 @@ var bcDeleteDataEpic = function (action$, store$, _a) {
2522
2676
  var context = { widgetName: action.payload.widgetName };
2523
2677
  var isTargetFormatPVF = state.view.pendingValidationFailsFormat === "target" /* target */;
2524
2678
  return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe(mergeMap26(function (data) {
2525
- var postInvoke = data.postActions[0];
2526
- 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);
2679
+ var _a;
2680
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2681
+ return concat18(isTargetFormatPVF ? of27(bcCancelPendingChanges({ bcNames: [bcName] })) : EMPTY22, of27(bcFetchDataRequest({ bcName: bcName, widgetName: widgetName })), postInvoke ? of27(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: widgetName })) : EMPTY22);
2527
2682
  }), catchError11(function (error) {
2528
2683
  console.error(error);
2529
2684
  return of27(bcDeleteDataFail({ bcName: bcName }));
@@ -2531,7 +2686,7 @@ var bcDeleteDataEpic = function (action$, store$, _a) {
2531
2686
  }));
2532
2687
  };
2533
2688
  // src/epics/data/bcSelectRecordEpic.ts
2534
- import { concat as concat17, filter as filter42, mergeMap as mergeMap27, of as of28 } from "rxjs";
2689
+ import { concat as concat19, filter as filter42, mergeMap as mergeMap27, of as of28 } from "rxjs";
2535
2690
  var bcSelectRecordEpic = function (action$, store$) { return action$.pipe(filter42(bcSelectRecord.match), mergeMap27(function (action) {
2536
2691
  var _a;
2537
2692
  var _b = action.payload, bcName = _b.bcName, cursor = _b.cursor;
@@ -2546,10 +2701,10 @@ var bcSelectRecordEpic = function (action$, store$) { return action$.pipe(filter
2546
2701
  keepDelta: action.payload.keepDelta
2547
2702
  });
2548
2703
  });
2549
- return concat17(of28(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = cursor, _a), keepDelta: action.payload.keepDelta })), of28(bcFetchRowMeta({ widgetName: "", bcName: bcName })), fetchChildrenBcData);
2704
+ return concat19(of28(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = cursor, _a), keepDelta: action.payload.keepDelta })), of28(bcFetchRowMeta({ widgetName: "", bcName: bcName })), fetchChildrenBcData);
2550
2705
  })); };
2551
2706
  // src/epics/data/changeAssociationEpic.ts
2552
- import { concat as concat18, filter as filter43, mergeMap as mergeMap28, of as of29 } from "rxjs";
2707
+ import { concat as concat20, filter as filter43, mergeMap as mergeMap28, of as of29 } from "rxjs";
2553
2708
  var changeAssociationEpic = function (action$, state$) { return action$.pipe(filter43(changeAssociation.match), mergeMap28(function (action) {
2554
2709
  var _a, _b, _c, _d, _e;
2555
2710
  var state = state$.value;
@@ -2571,19 +2726,19 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe(fil
2571
2726
  fields: widget.fields
2572
2727
  };
2573
2728
  var hierarchy = (_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchy;
2574
- var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
2729
+ var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
2575
2730
  var hierarchyGroupSelection = (_c = widget.options) === null || _c === void 0 ? void 0 : _c.hierarchyGroupSelection;
2576
2731
  var hierarchyTraverse = (_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyTraverse;
2577
- var childrenBc = hierarchy.slice(hierarchy.findIndex(function (item) { return item.bcName === action.payload.bcName; }) + 1).map(function (item) { return item.bcName; });
2732
+ 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; });
2578
2733
  if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {
2579
2734
  result.push(of29(dropAllAssociations({
2580
2735
  bcNames: childrenBc
2581
2736
  })));
2582
2737
  }
2583
- var parent = isRoot ? null : hierarchy.find(function (item, index) {
2738
+ var parent = isRoot ? null : (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item, index) {
2584
2739
  var _a;
2585
2740
  return ((_a = hierarchy[index + 1]) === null || _a === void 0 ? void 0 : _a.bcName) === action.payload.bcName;
2586
- }) || rootHierarchyDescriptor;
2741
+ })) || rootHierarchyDescriptor;
2587
2742
  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; });
2588
2743
  if (parent && hierarchyTraverse && selected) {
2589
2744
  if (hierarchyDescriptor.radio) {
@@ -2594,7 +2749,7 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe(fil
2594
2749
  result.push(of29(changeAssociation({
2595
2750
  bcName: parent.bcName,
2596
2751
  widgetName: action.payload.widgetName,
2597
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
2752
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
2598
2753
  assocValueKey: action.payload.assocValueKey
2599
2754
  })));
2600
2755
  }
@@ -2616,10 +2771,10 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe(fil
2616
2771
  })));
2617
2772
  }
2618
2773
  }
2619
- return concat18.apply(void 0, result);
2774
+ return concat20.apply(void 0, result);
2620
2775
  })); };
2621
2776
  // src/epics/data/bcCancelCreateDataEpic.ts
2622
- import { catchError as catchError12, concat as concat19, EMPTY as EMPTY24, filter as filter44, mergeMap as mergeMap29, of as of30 } from "rxjs";
2777
+ import { catchError as catchError12, concat as concat21, EMPTY as EMPTY23, filter as filter44, mergeMap as mergeMap29, of as of30 } from "rxjs";
2623
2778
  import { OperationTypeCrud as OperationTypeCrud10 } from "@cxbox-ui/schema";
2624
2779
  import { isAnyOf as isAnyOf4 } from "@reduxjs/toolkit";
2625
2780
  var actionTypesMatcher = isAnyOf4(sendOperation);
@@ -2641,8 +2796,9 @@ var bcCancelCreateDataEpic = function (action$, state$, _a) {
2641
2796
  var params = { _action: action.payload.operationType };
2642
2797
  var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
2643
2798
  return api.customAction(screenName, bcUrl, data, context, params).pipe(mergeMap29(function (response) {
2644
- var postInvoke = response.postActions[0];
2645
- 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);
2799
+ var _a;
2800
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
2801
+ return concat21(of30(sendOperationSuccess({ bcName: bcName, cursor: cursor })), of30(bcChangeCursors({ cursorsMap: cursorsMap })), postInvoke ? of30(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: context.widgetName })) : EMPTY23);
2646
2802
  }), catchError12(function (error) {
2647
2803
  console.error(error);
2648
2804
  return of30(bcDeleteDataFail({ bcName: bcName }));
@@ -2650,10 +2806,10 @@ var bcCancelCreateDataEpic = function (action$, state$, _a) {
2650
2806
  }));
2651
2807
  };
2652
2808
  // src/epics/data/bcSelectDepthRecordEpic.ts
2653
- import { concat as concat20, filter as filter45, mergeMap as mergeMap30, of as of31 } from "rxjs";
2809
+ import { concat as concat22, filter as filter45, mergeMap as mergeMap30, of as of31 } from "rxjs";
2654
2810
  var bcSelectDepthRecordEpic = function (action$) { return action$.pipe(filter45(bcSelectDepthRecord.match), mergeMap30(function (action) {
2655
2811
  var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor, depth = _a.depth;
2656
- return concat20(of31(bcChangeDepthCursor({ bcName: bcName, depth: depth, cursor: cursor })), of31(bcFetchDataRequest({
2812
+ return concat22(of31(bcChangeDepthCursor({ bcName: bcName, depth: depth, cursor: cursor })), of31(bcFetchDataRequest({
2657
2813
  bcName: bcName,
2658
2814
  depth: depth + 1,
2659
2815
  widgetName: "",
@@ -2661,7 +2817,7 @@ var bcSelectDepthRecordEpic = function (action$) { return action$.pipe(filter45(
2661
2817
  })));
2662
2818
  })); };
2663
2819
  // src/epics/data/removeMultivalueTagEpic.ts
2664
- import { concat as concat21, filter as filter46, mergeMap as mergeMap31, of as of32 } from "rxjs";
2820
+ import { concat as concat23, filter as filter46, mergeMap as mergeMap31, of as of32 } from "rxjs";
2665
2821
  var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(filter46(removeMultivalueTag.match), mergeMap31(function (action) {
2666
2822
  var _a, _b, _c;
2667
2823
  var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
@@ -2677,28 +2833,28 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(f
2677
2833
  var removedItem = data.find(function (item) { return item.id === action.payload.removedItem.id; });
2678
2834
  var associated = action.payload.dataItem.map(function (item) { return item.id; });
2679
2835
  var removedNodes = [];
2680
- if ((_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
2681
- if ((_e = widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
2836
+ if ((_d = widget === null || widget === void 0 ? void 0 : widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
2837
+ if ((_e = widget === null || widget === void 0 ? void 0 : widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
2682
2838
  data = assignTreeLinks(data);
2683
2839
  }
2684
- var removedItemChildren = data.filter(function (item) { return item.parentId === removedItem.id; });
2685
- removedNodes = __spreadArray([removedItem.id], removedItemChildren.filter(function (item) { return associated.includes(item.id); }).map(function (item) { return item.id; }), true);
2686
- if ((_f = widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
2840
+ var removedItemChildren = data.filter(function (item) { return item.parentId === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.id); });
2841
+ 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);
2842
+ if ((_f = widget === null || widget === void 0 ? void 0 : widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
2687
2843
  getDescendants(removedItemChildren, removedNodes);
2688
2844
  removedNodes = data.filter(function (item) { return removedNodes.includes(item.id) && associated.includes(item.id); }).map(function (item) { return item.id; });
2689
2845
  }
2690
- var parent_1 = data.find(function (item) { return item.id === removedItem.parentId; });
2846
+ var parent_1 = data.find(function (item) { return item.id === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.parentId); });
2691
2847
  var siblings = data.filter(function (item) { return item.parentId === (parent_1 === null || parent_1 === void 0 ? void 0 : parent_1.id); });
2692
2848
  var parentEmpty = siblings.every(function (child) { return removedNodes.includes(child.id) || !associated.includes(child.id); });
2693
2849
  if (parent_1 && parentEmpty) {
2694
- if ((_g = widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
2850
+ if ((_g = widget === null || widget === void 0 ? void 0 : widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
2695
2851
  var parentDescendants = [];
2696
2852
  getDescendants(siblings, parentDescendants);
2697
2853
  var parentDeepEmpty = parentDescendants.every(function (descendant) {
2698
2854
  return removedNodes.includes(descendant) || !associated.includes(descendant);
2699
2855
  });
2700
2856
  if (parentDeepEmpty) {
2701
- return concat21(of32(removeMultivalueTag(__assign(__assign({}, action.payload), { removedItem: { id: parent_1.id, value: null } }))));
2857
+ return concat23(of32(removeMultivalueTag(__assign(__assign({}, action.payload), { removedItem: { id: parent_1.id, value: null } }))));
2702
2858
  }
2703
2859
  }
2704
2860
  else {
@@ -2706,7 +2862,7 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(f
2706
2862
  }
2707
2863
  }
2708
2864
  }
2709
- if ((_h = widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
2865
+ if ((_h = widget === null || widget === void 0 ? void 0 : widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
2710
2866
  return of32(changeDataItem({
2711
2867
  bcName: bcName,
2712
2868
  bcUrl: buildBcUrl(bcName, true, state),
@@ -2714,12 +2870,12 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(f
2714
2870
  dataItem: (_a = {}, _a[associateFieldKey] = action.payload.dataItem.filter(function (item) { return !removedNodes.includes(item.id); }), _a)
2715
2871
  }));
2716
2872
  }
2717
- if ((_j = widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
2718
- var hierarchyBcName = (_o = (_m = (_l = (_k = widget.options) === null || _k === void 0 ? void 0 : _k.hierarchy) === null || _l === void 0 ? void 0 : _l.find(function (hierarchyData) {
2873
+ if ((_j = widget === null || widget === void 0 ? void 0 : widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
2874
+ 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) {
2719
2875
  var _a;
2720
2876
  return (_a = state.view.pendingDataChanges[hierarchyData.bcName]) === null || _a === void 0 ? void 0 : _a[action.payload.removedItem.id];
2721
2877
  })) === null || _m === void 0 ? void 0 : _m.bcName) !== null && _o !== void 0 ? _o : bcName;
2722
- return concat21(of32(changeDataItem({
2878
+ return concat23(of32(changeDataItem({
2723
2879
  /**
2724
2880
  * This is incorrect and will break if different BC has records with
2725
2881
  * identical ids.
@@ -2737,7 +2893,7 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe(f
2737
2893
  dataItem: (_b = {}, _b[associateFieldKey] = action.payload.dataItem, _b)
2738
2894
  })));
2739
2895
  }
2740
- return concat21(of32(changeDataItem({
2896
+ return concat23(of32(changeDataItem({
2741
2897
  bcName: popupBcName,
2742
2898
  bcUrl: buildBcUrl(popupBcName, true, state),
2743
2899
  cursor: action.payload.removedItem.id,
@@ -2754,11 +2910,12 @@ import { catchError as catchError13, filter as filter47, map as map9, mergeMap a
2754
2910
  var bcFetchRowMetaRequestEpic = function (action$, state$, _a) {
2755
2911
  var api = _a.api;
2756
2912
  return action$.pipe(filter47(bcFetchRowMeta.match), mergeMap32(function (action) {
2913
+ var _a, _b;
2757
2914
  var state = state$.value;
2758
2915
  var screenName = state.screen.screenName;
2759
2916
  var bcName = action.payload.bcName;
2760
- var cursor = state.screen.bo.bc[bcName].cursor;
2761
- var bcUrl = buildBcUrl(bcName, true, state);
2917
+ var cursor = (_a = state.screen.bo.bc[bcName].cursor) !== null && _a !== void 0 ? _a : "";
2918
+ var bcUrl = (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "";
2762
2919
  var canceler = api.createCanceler();
2763
2920
  var cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }));
2764
2921
  var cancelByParentBc = cancelRequestEpic(action$, [bcSelectRecord], canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }), function (filteredAction) {
@@ -2775,7 +2932,7 @@ var bcFetchRowMetaRequestEpic = function (action$, state$, _a) {
2775
2932
  }));
2776
2933
  };
2777
2934
  // src/epics/data/changeAssociationFullEpic.ts
2778
- import { concat as concat22, filter as filter48, mergeMap as mergeMap33, of as of34 } from "rxjs";
2935
+ import { concat as concat24, filter as filter48, mergeMap as mergeMap33, of as of34 } from "rxjs";
2779
2936
  var changeAssociationFullEpic = function (action$, state$) { return action$.pipe(filter48(changeAssociationFull.match), mergeMap33(function (action) {
2780
2937
  var _a, _b, _c, _d, _e;
2781
2938
  var state = state$.value;
@@ -2835,7 +2992,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2835
2992
  bcName: bcName,
2836
2993
  depth: parentDepth,
2837
2994
  widgetName: action.payload.widgetName,
2838
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[assocValueKey] }),
2995
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[assocValueKey] }),
2839
2996
  assocValueKey: assocValueKey
2840
2997
  })));
2841
2998
  }
@@ -2856,18 +3013,20 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2856
3013
  })));
2857
3014
  }
2858
3015
  }
2859
- return concat22.apply(void 0, result);
3016
+ return concat24.apply(void 0, result);
2860
3017
  })); };
2861
3018
  // src/epics/data/saveAssociationsActiveEpic.ts
2862
- import { catchError as catchError14, concat as concat23, EMPTY as EMPTY25, filter as filter49, mergeMap as mergeMap34, of as of35, switchMap as switchMap12 } from "rxjs";
3019
+ import { catchError as catchError14, concat as concat25, EMPTY as EMPTY24, filter as filter49, mergeMap as mergeMap34, of as of35, switchMap as switchMap12 } from "rxjs";
2863
3020
  var saveAssociationsActiveEpic = function (action$, state$, _a) {
2864
3021
  var api = _a.api;
2865
3022
  return action$.pipe(filter49(saveAssociations.match), filter49(function (action) {
2866
- return state$.value.view.popupData.active;
3023
+ var _a;
3024
+ return (_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active;
2867
3025
  }), switchMap12(function (action) {
3026
+ var _a, _b;
2868
3027
  var state = state$.value;
2869
- var calleeBCName = state.view.popupData.calleeBCName;
2870
- var calleeWidgetName = state.view.popupData.calleeWidgetName;
3028
+ var calleeBCName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.calleeBCName;
3029
+ var calleeWidgetName = (_b = state.view.popupData) === null || _b === void 0 ? void 0 : _b.calleeWidgetName;
2871
3030
  var bcNames = action.payload.bcNames;
2872
3031
  var bcUrl = buildBcUrl(calleeBCName, true, state);
2873
3032
  var pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {};
@@ -2875,17 +3034,17 @@ var saveAssociationsActiveEpic = function (action$, state$, _a) {
2875
3034
  return api.associate(state.screen.screenName, bcUrl, Object.values(pendingChanges).filter(function (i) { return i._associate; }), params).pipe(mergeMap34(function (response) {
2876
3035
  var postInvoke = response.postActions[0];
2877
3036
  var calleeWidget = state.view.widgets.find(function (widgetItem) { return widgetItem.bcName === calleeBCName; });
2878
- return concat23(postInvoke ? of35(processPostInvoke({ bcName: calleeBCName, postInvoke: postInvoke, widgetName: calleeWidget.name })) : EMPTY25, of35(bcCancelPendingChanges({ bcNames: bcNames })), of35(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
3037
+ return concat25(postInvoke ? of35(processPostInvoke({ bcName: calleeBCName, postInvoke: postInvoke, widgetName: calleeWidget === null || calleeWidget === void 0 ? void 0 : calleeWidget.name })) : EMPTY24, of35(bcCancelPendingChanges({ bcNames: bcNames })), of35(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
2879
3038
  }), catchError14(function (err) {
2880
3039
  console.error(err);
2881
- return EMPTY25;
3040
+ return EMPTY24;
2882
3041
  }));
2883
3042
  }));
2884
3043
  };
2885
3044
  // src/epics/data/changeAssociationSameBcEpic.ts
2886
- import { concat as concat24, filter as filter50, mergeMap as mergeMap35, of as of36 } from "rxjs";
3045
+ import { concat as concat26, filter as filter50, mergeMap as mergeMap35, of as of36 } from "rxjs";
2887
3046
  var changeAssociationSameBcEpic = function (action$, state$) { return action$.pipe(filter50(changeAssociationSameBc.match), mergeMap35(function (action) {
2888
- var _a, _b, _c, _d, _e;
3047
+ var _a, _b, _c, _d, _e, _f;
2889
3048
  var state = state$.value;
2890
3049
  var bcName = action.payload.bcName;
2891
3050
  var result = [
@@ -2902,14 +3061,14 @@ var changeAssociationSameBcEpic = function (action$, state$) { return action$.pi
2902
3061
  var widget = state.view.widgets.find(function (item) { return item.name === action.payload.widgetName; });
2903
3062
  var hierarchyTraverse = (_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchyTraverse;
2904
3063
  var currentData = depth > 1 ? (_b = state.depthData[depth]) === null || _b === void 0 ? void 0 : _b[bcName] : state.data[bcName];
2905
- 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;
2906
- 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;
3064
+ 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;
3065
+ 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;
2907
3066
  if (parentDepth && hierarchyTraverse && selected) {
2908
3067
  result.push(of36(changeAssociationSameBc({
2909
3068
  bcName: bcName,
2910
3069
  depth: parentDepth,
2911
3070
  widgetName: action.payload.widgetName,
2912
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[action.payload.assocValueKey] }),
3071
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[action.payload.assocValueKey] }),
2913
3072
  assocValueKey: action.payload.assocValueKey
2914
3073
  })));
2915
3074
  }
@@ -2925,7 +3084,7 @@ var changeAssociationSameBcEpic = function (action$, state$) { return action$.pi
2925
3084
  })));
2926
3085
  }
2927
3086
  }
2928
- return concat24.apply(void 0, result);
3087
+ return concat26.apply(void 0, result);
2929
3088
  })); };
2930
3089
  // src/epics/data/inlinePickListFetchDataEpic.ts
2931
3090
  import { catchError as catchError15, filter as filter51, mergeMap as mergeMap36, of as of37, race as race4 } from "rxjs";
@@ -2950,14 +3109,15 @@ var inlinePickListFetchDataEpic = function (action$, state$, _a) {
2950
3109
  // src/epics/data/saveAssociationsPassiveEpic.ts
2951
3110
  import { filter as filter52, of as of38, switchMap as switchMap13 } from "rxjs";
2952
3111
  var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pipe(filter52(saveAssociations.match), filter52(function () {
2953
- return !state$.value.view.popupData.active;
3112
+ var _a;
3113
+ return !((_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active);
2954
3114
  }), switchMap13(function (action) {
2955
3115
  var _a, _b;
2956
- var _c;
3116
+ var _c, _d;
2957
3117
  var state = state$.value;
2958
- 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;
3118
+ 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;
2959
3119
  var cursor = state.screen.bo.bc[calleeBCName].cursor;
2960
- var recordPrevData = (_c = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _c !== void 0 ? _c : [];
3120
+ var recordPrevData = (_d = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _d !== void 0 ? _d : [];
2961
3121
  var newValues = [];
2962
3122
  action.payload.bcNames.forEach(function (pendingBc) {
2963
3123
  var pendingChanges = state.view.pendingDataChanges[pendingBc] || {};
@@ -3017,7 +3177,7 @@ var changeChildrenAssociationsSameBcEpic = function (action$, state$) { return a
3017
3177
  }));
3018
3178
  })); };
3019
3179
  // src/epics/data/changeDescendantsAssociationsFullEpic.ts
3020
- import { concat as concat25, filter as filter55, mergeMap as mergeMap39, of as of41 } from "rxjs";
3180
+ import { concat as concat27, filter as filter55, mergeMap as mergeMap39, of as of41 } from "rxjs";
3021
3181
  var changeDescendantsAssociationsFullEpic = function (action$, state$) { return action$.pipe(filter55(changeDescendantsAssociationsFull.match), mergeMap39(function (action) {
3022
3182
  var state = state$.value;
3023
3183
  var depth = action.payload.depth;
@@ -3035,7 +3195,7 @@ var changeDescendantsAssociationsFullEpic = function (action$, state$) { return
3035
3195
  result.push(of41(changeDescendantsAssociationsFull(__assign(__assign({}, action.payload), { parentId: targetDataItem.id, depth: depth + 1 }))));
3036
3196
  }
3037
3197
  });
3038
- return concat25.apply(void 0, result);
3198
+ return concat27.apply(void 0, result);
3039
3199
  })); };
3040
3200
  // src/api/ObservableApiWrapper.ts
3041
3201
  import axios2 from "axios";
@@ -3064,7 +3224,6 @@ var ObservableApiWrapper = /** @class */ (function () {
3064
3224
  this.instance = instance;
3065
3225
  }
3066
3226
  class_2.prototype.get = function (path, config, callContext) {
3067
- if (config === void 0) { config = {}; }
3068
3227
  return from(this.instance.get(path, config)).pipe(takeWhile(redirectOccurred), map10(function (response) { return response.data; }));
3069
3228
  };
3070
3229
  class_2.prototype.put = function (path, data, callContext) {
@@ -3080,10 +3239,9 @@ var ObservableApiWrapper = /** @class */ (function () {
3080
3239
  }());
3081
3240
  // src/api/ObservableApi.ts
3082
3241
  import axios3 from "axios";
3083
- import { EMPTY as EMPTY26, expand, map as map11, reduce } from "rxjs";
3242
+ import { EMPTY as EMPTY25, expand, map as map11, reduce } from "rxjs";
3084
3243
  var Api = /** @class */ (function () {
3085
3244
  function class_3(instance) {
3086
- this.api$ = new ObservableApiWrapper();
3087
3245
  this.api$ = new ObservableApiWrapper(instance);
3088
3246
  }
3089
3247
  class_3.prototype.routerRequest = function (path, params) {
@@ -3101,30 +3259,31 @@ var Api = /** @class */ (function () {
3101
3259
  if (params === void 0) { params = {}; }
3102
3260
  var currentPage = 1;
3103
3261
  return this.fetchBcData(screenName, bcUrl, __assign(__assign({}, params), { _page: currentPage })).pipe(expand(function (response) {
3104
- return response.hasNext ? _this.fetchBcData(screenName, bcUrl, __assign(__assign({}, params), { _page: ++currentPage })) : EMPTY26;
3262
+ return response.hasNext ? _this.fetchBcData(screenName, bcUrl, __assign(__assign({}, params), { _page: ++currentPage })) : EMPTY25;
3105
3263
  }), reduce(function (items, nextResponse) {
3106
3264
  return __spreadArray(__spreadArray([], items, true), nextResponse.data, true);
3107
3265
  }, []));
3108
3266
  };
3109
3267
  class_3.prototype.fetchRowMeta = function (screenName, bcUrl, params, cancelToken) {
3110
3268
  var url = applyParams(buildUrl(templateObject_2 || (templateObject_2 = __makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"])), screenName) + bcUrl, params);
3111
- return this.api$.get(url, { cancelToken: cancelToken }).pipe(map11(function (response) { return response.data.row; }));
3269
+ 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; }));
3112
3270
  };
3113
3271
  class_3.prototype.newBcData = function (screenName, bcUrl, context, params) {
3114
3272
  var url = applyParams(buildUrl(templateObject_3 || (templateObject_3 = __makeTemplateObject(["row-meta-new/", "/"], ["row-meta-new/", "/"])), screenName) + bcUrl, params);
3115
- return this.api$.get(url, null, context).pipe(map11(function (response) { return response.data; }));
3273
+ return this.api$.get(url, void 0, context).pipe(map11(function (response) { return response.data; }));
3116
3274
  };
3117
3275
  class_3.prototype.saveBcData = function (screenName, bcUrl, data, context, params) {
3118
3276
  var url = applyParams(buildUrl(templateObject_4 || (templateObject_4 = __makeTemplateObject(["data/", "/"], ["data/", "/"])), screenName) + bcUrl, params);
3119
3277
  return this.api$.put(url, { data: data }, context).pipe(map11(function (response) { return response.data; }));
3120
3278
  };
3121
3279
  class_3.prototype.deleteBcData = function (screenName, bcUrl, context, params) {
3280
+ if (bcUrl === void 0) { bcUrl = ""; }
3122
3281
  var url = applyParams(buildUrl(templateObject_5 || (templateObject_5 = __makeTemplateObject(["data/", "/"], ["data/", "/"])), screenName) + bcUrl, params);
3123
3282
  return this.api$.delete(url, context).pipe(map11(function (response) { return response.data; }));
3124
3283
  };
3125
3284
  class_3.prototype.customAction = function (screenName, bcUrl, data, context, params) {
3126
3285
  var url = applyParams(buildUrl(templateObject_6 || (templateObject_6 = __makeTemplateObject(["custom-action/", "/"], ["custom-action/", "/"])), screenName) + bcUrl, params);
3127
- return this.api$.post(url, { data: data || {} }, null, context).pipe(map11(function (response) { return response.data; }));
3286
+ return this.api$.post(url, { data: data || {} }, void 0, context).pipe(map11(function (response) { return response.data; }));
3128
3287
  };
3129
3288
  class_3.prototype.associate = function (screenName, bcUrl, data, params) {
3130
3289
  var processedData = Array.isArray(data) ? data.map(function (item) { return ({
@@ -3136,9 +3295,27 @@ var Api = /** @class */ (function () {
3136
3295
  return this.api$.post(url, processedData).pipe(map11(function (response) { return response.data; }));
3137
3296
  };
3138
3297
  class_3.prototype.getRmByForceActive = function (screenName, bcUrl, data, params) {
3139
- var url = applyParams(buildUrl(templateObject_8 || (templateObject_8 = __makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"])), screenName) + bcUrl, params);
3298
+ var url = applyParams(buildUrl(templateObject_8 || (templateObject_8 = __makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"])), screenName) + (bcUrl !== null && bcUrl !== void 0 ? bcUrl : ""), params);
3140
3299
  return this.api$.post(url, { data: data }).pipe(map11(function (response) { return response.data.row; }));
3141
3300
  };
3301
+ Object.defineProperty(class_3.prototype, "fileUploadEndpoint", {
3302
+ /**
3303
+ * Get Cxbox API file upload endpoint based on baseURL of axios instance
3304
+ *
3305
+ * Handles empty baseURL and trailing slash
3306
+ *
3307
+ * @returns File upload endpoint
3308
+ */
3309
+ get: function () {
3310
+ var instance = this.api$.instance;
3311
+ if (!instance.defaults.baseURL) {
3312
+ return "/file";
3313
+ }
3314
+ return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
3315
+ },
3316
+ enumerable: false,
3317
+ configurable: true
3318
+ });
3142
3319
  class_3.prototype.refreshMeta = function () {
3143
3320
  return this.api$.get(buildUrl(templateObject_9 || (templateObject_9 = __makeTemplateObject(["bc-registry/refresh-meta"], ["bc-registry/refresh-meta"]))));
3144
3321
  };
@@ -3157,6 +3334,243 @@ var Api = /** @class */ (function () {
3157
3334
  };
3158
3335
  return class_3;
3159
3336
  }());
3160
- export { Api, actions_exports as actions, epics_exports as epics, interfaces_exports as interfaces, reducers_exports as reducers, utils_exports as utils };
3337
+ // src/utils/autosave.ts
3338
+ function autosaveRoutine(action, store, next) {
3339
+ var _a, _b, _c;
3340
+ var state = store.getState();
3341
+ var dispatch = store.dispatch;
3342
+ var pendingDataChanges = state.view.pendingDataChanges;
3343
+ var bcList = Object.keys(pendingDataChanges);
3344
+ 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); });
3345
+ var baseBcName = bcList[baseBcNameIndex];
3346
+ if (baseBcNameIndex > -1) {
3347
+ bcList.splice(baseBcNameIndex, 1);
3348
+ }
3349
+ if (baseBcName) {
3350
+ bcList.forEach(function (bcName) {
3351
+ var _a, _b;
3352
+ var widget = (_a = state.view.widgets) === null || _a === void 0 ? void 0 : _a.find(function (v) { return v.bcName === bcName; });
3353
+ var cursor = (_b = state.screen.bo.bc[bcName]) === null || _b === void 0 ? void 0 : _b.cursor;
3354
+ if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {
3355
+ dispatch(sendOperation({
3356
+ bcName: bcName,
3357
+ operationType: OperationTypeCrud.save,
3358
+ widgetName: widget === null || widget === void 0 ? void 0 : widget.name
3359
+ }));
3360
+ }
3361
+ });
3362
+ var baseWidget = (_c = state.view.widgets) === null || _c === void 0 ? void 0 : _c.find(function (v) { return v.bcName === baseBcName; });
3363
+ return next(sendOperation({
3364
+ bcName: baseBcName,
3365
+ operationType: OperationTypeCrud.save,
3366
+ widgetName: baseWidget === null || baseWidget === void 0 ? void 0 : baseWidget.name,
3367
+ onSuccessAction: action
3368
+ }));
3369
+ }
3370
+ return next(action);
3371
+ }
3372
+ function bcHasPendingAutosaveChanges(store, bcName, cursor) {
3373
+ var _a;
3374
+ var pendingChanges = store.view.pendingDataChanges;
3375
+ var cursorChanges = (_a = pendingChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
3376
+ var result = cursorChanges && !Object.keys(cursorChanges).includes("_associate") && Object.values(cursorChanges).length > 0;
3377
+ return result;
3378
+ }
3379
+ function checkUnsavedChangesOfBc(store, bcName) {
3380
+ var _a, _b;
3381
+ var pendingCursors = Object.keys((_b = (_a = store.view.pendingDataChanges) === null || _a === void 0 ? void 0 : _a[bcName]) !== null && _b !== void 0 ? _b : {});
3382
+ return pendingCursors.some(function (cursor) { return bcHasPendingAutosaveChanges(store, bcName, cursor); });
3383
+ }
3384
+ // src/middlewares/autosaveMiddleware.ts
3385
+ var saveFormMiddleware = function (_a) {
3386
+ var getState = _a.getState, dispatch = _a.dispatch;
3387
+ return function (next) { return function (action) {
3388
+ var _a, _b, _c, _d, _e, _f, _g;
3389
+ var state = getState();
3390
+ var isSendOperation = sendOperation.match(action);
3391
+ var isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType);
3392
+ var isSelectTableCellInit = selectTableCellInit.match(action);
3393
+ var isSaveAction = isSendOperation && action.payload.operationType === OperationTypeCrud.save;
3394
+ var isNotSaveAction = !isSaveAction;
3395
+ var actionBcName = isSendOperation && action.payload.bcName;
3396
+ var hasAnotherUnsavedBc = Object.keys(state.view.pendingDataChanges).filter(function (key) { return key !== actionBcName; }).filter(function (key) { return checkUnsavedChangesOfBc(state, key); }).length > 0;
3397
+ var isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc;
3398
+ var selectedCell = state.view.selectedCell;
3399
+ var isSelectTableCellInitOnAnotherRowOrWidget = selectedCell && isSelectTableCellInit && (selectedCell.widgetName !== action.payload.widgetName || selectedCell.rowId !== action.payload.rowId);
3400
+ 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; });
3401
+ 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;
3402
+ 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];
3403
+ var isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0;
3404
+ if (isChangeLocation) {
3405
+ return next(sendOperation({
3406
+ bcName: defaultSaveWidget.bcName,
3407
+ operationType: ((_g = defaultSaveWidget.options) === null || _g === void 0 ? void 0 : _g.actionGroups).defaultSave,
3408
+ widgetName: defaultSaveWidget.name,
3409
+ onSuccessAction: action
3410
+ }));
3411
+ }
3412
+ var isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableCellInitOnAnotherRowOrWidget);
3413
+ if (isNeedSaveCondition) {
3414
+ return autosaveRoutine(action, { getState: getState, dispatch: dispatch }, next);
3415
+ }
3416
+ return next(action);
3417
+ }; };
3418
+ };
3419
+ // src/middlewares/requiredFieldsMiddleware.ts
3420
+ var requiredFields = function (_a) {
3421
+ var getState = _a.getState, dispatch = _a.dispatch;
3422
+ return function (next) { return function (action) {
3423
+ var _a, _b, _c, _d;
3424
+ var state = getState();
3425
+ if (sendOperation.match(action)) {
3426
+ var _e = action.payload, bcName = _e.bcName, operationType = _e.operationType, widgetName_1 = _e.widgetName;
3427
+ var cursor_1 = (_a = state.screen.bo.bc[bcName]) === null || _a === void 0 ? void 0 : _a.cursor;
3428
+ if (cursor_1) {
3429
+ var bcUrl = buildBcUrl(bcName, true, state);
3430
+ var record = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (item) { return item.id === cursor_1; });
3431
+ var rowMeta_1 = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
3432
+ var pendingValues = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[cursor_1];
3433
+ var widget_1 = state.view.widgets.find(function (item) { return item.name === widgetName_1; });
3434
+ if (operationRequiresAutosave(operationType, rowMeta_1 === null || rowMeta_1 === void 0 ? void 0 : rowMeta_1.actions)) {
3435
+ var fieldsToCheck_1 = {};
3436
+ state.view.widgets.filter(function (item) { return item.bcName === (widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.bcName); }).forEach(function (item) {
3437
+ var itemFieldsCalc = item.fields;
3438
+ if (item.fields) {
3439
+ item.fields.forEach(function (block) {
3440
+ if (isWidgetFieldBlock(block)) {
3441
+ block.fields.forEach(function (field) { return itemFieldsCalc.push(field); });
3442
+ }
3443
+ });
3444
+ }
3445
+ itemFieldsCalc.forEach(function (widgetField) {
3446
+ var _a;
3447
+ 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; });
3448
+ if (!fieldsToCheck_1[widgetField.key] && matchingRowMeta && !matchingRowMeta.hidden) {
3449
+ fieldsToCheck_1[widgetField.key] = matchingRowMeta;
3450
+ }
3451
+ });
3452
+ });
3453
+ var dataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck_1));
3454
+ if (dataItem && TableLikeWidgetTypes.includes(widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.type)) {
3455
+ dispatch(selectTableCellInit({ widgetName: widgetName_1, rowId: cursor_1, fieldKey: Object.keys(dataItem)[0] }));
3456
+ }
3457
+ return dataItem ? next(changeDataItem({ bcName: bcName, bcUrl: buildBcUrl(bcName, true, state), cursor: cursor_1, dataItem: dataItem })) : next(action);
3458
+ }
3459
+ if (hasPendingValidationFails(state, bcName)) {
3460
+ return addNotification({
3461
+ key: "requiredFieldsMissing",
3462
+ type: "buttonWarningNotification",
3463
+ message: "Required fields are missing",
3464
+ duration: 0,
3465
+ options: {
3466
+ buttonWarningNotificationOptions: {
3467
+ buttonText: "Cancel changes",
3468
+ actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]
3469
+ }
3470
+ }
3471
+ });
3472
+ }
3473
+ }
3474
+ }
3475
+ return next(action);
3476
+ }; };
3477
+ };
3478
+ function operationRequiresAutosave(operationType, actions) {
3479
+ var result = false;
3480
+ if (!actions) {
3481
+ console.error('rowMeta is missing in the middle of "sendOperation" action');
3482
+ return result;
3483
+ }
3484
+ result = flattenOperations(actions).some(function (action) { return action.type === operationType && action.autoSaveBefore; });
3485
+ return result;
3486
+ }
3487
+ function getRequiredFieldsMissing(record, pendingChanges, fieldsMeta) {
3488
+ var result = {};
3489
+ fieldsMeta.forEach(function (field) {
3490
+ var value = record === null || record === void 0 ? void 0 : record[field.key];
3491
+ var pendingValue = pendingChanges === null || pendingChanges === void 0 ? void 0 : pendingChanges[field.key];
3492
+ var effectiveValue = pendingValue !== void 0 ? pendingValue : value;
3493
+ var falsyValue = false;
3494
+ if (effectiveValue === null || effectiveValue === void 0 || effectiveValue === "") {
3495
+ falsyValue = true;
3496
+ }
3497
+ else if (Array.isArray(effectiveValue) && !effectiveValue.length) {
3498
+ falsyValue = true;
3499
+ }
3500
+ else if (effectiveValue && typeof effectiveValue === "object" && !Object.keys(effectiveValue).length) {
3501
+ falsyValue = true;
3502
+ }
3503
+ if (field.required && falsyValue) {
3504
+ result[field.key] = Array.isArray(effectiveValue) ? [] : null;
3505
+ }
3506
+ });
3507
+ return Object.keys(result).length > 0 ? result : null;
3508
+ }
3509
+ function hasPendingValidationFails(store, bcName) {
3510
+ var _a;
3511
+ if (store.view.pendingValidationFailsFormat !== "target" /* target */ && store.view.pendingValidationFails && Object.keys(store.view.pendingValidationFails).length) {
3512
+ return true;
3513
+ }
3514
+ var checkResult = false;
3515
+ var bcPendingValidations = (_a = store.view.pendingValidationFails) === null || _a === void 0 ? void 0 : _a[bcName];
3516
+ var cursorsList = bcPendingValidations && Object.keys(bcPendingValidations);
3517
+ if (!cursorsList) {
3518
+ return false;
3519
+ }
3520
+ var i = 0;
3521
+ for (; i < cursorsList.length; i++) {
3522
+ if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {
3523
+ checkResult = true;
3524
+ break;
3525
+ }
3526
+ }
3527
+ return checkResult;
3528
+ }
3529
+ // src/middlewares/preInvokeMiddleware.ts
3530
+ var preInvokeAction = function (_a) {
3531
+ var getState = _a.getState;
3532
+ return function (next) { return function (action) {
3533
+ var _a, _b, _c;
3534
+ if (sendOperation.match(action)) {
3535
+ var state = getState();
3536
+ var _d = action.payload, operationType_1 = _d.operationType, widgetName_2 = _d.widgetName, confirm = _d.confirm;
3537
+ var bcName = (_a = state.view.widgets.find(function (widgetItem) { return widgetItem.name === widgetName_2; })) === null || _a === void 0 ? void 0 : _a.bcName;
3538
+ var bcUrl = buildBcUrl(bcName, true, state);
3539
+ var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
3540
+ var actions = rowMeta && flattenOperations(rowMeta.actions);
3541
+ 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;
3542
+ return preInvoke && !confirm ? next(processPreInvoke({
3543
+ bcName: bcName,
3544
+ operationType: operationType_1,
3545
+ widgetName: widgetName_2,
3546
+ preInvoke: preInvoke
3547
+ })) : next(action);
3548
+ }
3549
+ return next(action);
3550
+ }; };
3551
+ };
3552
+ // src/middlewares/popupMiddleware.ts
3553
+ var popupMiddleware = function (_a) {
3554
+ var getState = _a.getState;
3555
+ return function (next) { return function (action) {
3556
+ var _a, _b, _c;
3557
+ if (showViewPopup.match(action)) {
3558
+ var state = getState();
3559
+ var bcName_1 = action.payload.bcName;
3560
+ 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;
3561
+ var assocValueKey = (_c = action.payload.assocValueKey) !== null && _c !== void 0 ? _c : widgetValueKey;
3562
+ return widgetValueKey ? next(showViewPopup(__assign(__assign({}, action.payload), { assocValueKey: assocValueKey }))) : next(action);
3563
+ }
3564
+ return next(action);
3565
+ }; };
3566
+ };
3567
+ // src/middlewares/index.ts
3568
+ var middlewares = {
3569
+ autosave: saveFormMiddleware,
3570
+ requiredFields: requiredFields,
3571
+ preInvoke: preInvokeAction,
3572
+ popup: popupMiddleware
3573
+ };
3574
+ export { Api, actions_exports as actions, epics_exports as epics, interfaces_exports as interfaces, middlewares, reducers_exports as reducers, utils_exports as utils };
3161
3575
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
3162
3576
  //# sourceMappingURL=cxbox-ui-core.esm.js.map