@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.
@@ -60,6 +60,7 @@ __export(src_exports, {
60
60
  actions: function () { return actions_exports; },
61
61
  epics: function () { return epics_exports; },
62
62
  interfaces: function () { return interfaces_exports; },
63
+ middlewares: function () { return middlewares; },
63
64
  reducers: function () { return reducers_exports; },
64
65
  utils: function () { return utils_exports; }
65
66
  });
@@ -509,6 +510,15 @@ function isViewNavigationCategory(item) {
509
510
  function isViewNavigationGroup(item) {
510
511
  return !!item && "child" in item && !("categoryName" in item);
511
512
  }
513
+ // src/reducers/router.ts
514
+ var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
515
+ var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
516
+ state = __assign(__assign({}, state), action.payload);
517
+ }).addCase(changeLocation, function (state, action) {
518
+ state = __assign(__assign({}, state), action.payload.location);
519
+ }); };
520
+ // src/reducers/screen.ts
521
+ var import_schema6 = require("@cxbox-ui/schema");
512
522
  // src/utils/index.ts
513
523
  var utils_exports = {};
514
524
  __export(utils_exports, {
@@ -529,7 +539,6 @@ __export(utils_exports, {
529
539
  getBcChildren: function () { return getBcChildren; },
530
540
  getDescendants: function () { return getDescendants; },
531
541
  getFieldTitle: function () { return getFieldTitle; },
532
- getFileUploadEndpoint: function () { return getFileUploadEndpoint; },
533
542
  getFilterType: function () { return getFilterType; },
534
543
  getFilters: function () { return getFilters; },
535
544
  getSorters: function () { return getSorters; },
@@ -569,12 +578,6 @@ function applyRawParams(url, qso) {
569
578
  var result = new URLSearchParams(qso).toString();
570
579
  return "".concat(addTailControlSequences(url)).concat(result && "".concat(result));
571
580
  }
572
- function getFileUploadEndpoint(instance) {
573
- if (!instance.defaults.baseURL) {
574
- return "/file";
575
- }
576
- return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
577
- }
578
581
  // src/utils/strings.ts
579
582
  function getTemplate(literals) {
580
583
  var placeholders = [];
@@ -724,7 +727,7 @@ function defaultParseURL(url) {
724
727
  }
725
728
  return {
726
729
  type: type,
727
- path: path,
730
+ path: path.length !== 0 && !path.startsWith("/") ? "/".concat(path) : path,
728
731
  params: params,
729
732
  screenName: screenName,
730
733
  viewName: viewName,
@@ -772,6 +775,7 @@ function getSorters(sorters) {
772
775
  return result;
773
776
  }
774
777
  function parseFilters(defaultFilters) {
778
+ if (defaultFilters === void 0) { defaultFilters = ""; }
775
779
  var result = [];
776
780
  var urlParams = new URL(defaultFilters, window.location.origin).searchParams;
777
781
  urlParams.forEach(function (param) {
@@ -882,12 +886,13 @@ function getBcChildren(originBcName, widgets, bcMap) {
882
886
  return childrenBcMap;
883
887
  }
884
888
  function getHierarchyChildBc(originBcName, hierarchyWidget) {
885
- var nestedBcNames = hierarchyWidget.options.hierarchy.map(function (nestedItem) { return nestedItem.bcName; });
886
- if (originBcName !== hierarchyWidget.bcName && !nestedBcNames.includes(originBcName)) {
889
+ var _a, _b;
890
+ 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; });
891
+ if (originBcName !== hierarchyWidget.bcName && !(nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.includes(originBcName))) {
887
892
  return [];
888
893
  }
889
- var childHierarchyBcIndex = nestedBcNames.findIndex(function (item) { return item === originBcName; });
890
- var childHierarchyBcName = nestedBcNames[childHierarchyBcIndex + 1];
894
+ var childHierarchyBcIndex = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.findIndex(function (item) { return item === originBcName; });
895
+ var childHierarchyBcName = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames[childHierarchyBcIndex + 1];
891
896
  return [childHierarchyBcName, hierarchyWidget.name];
892
897
  }
893
898
  function checkShowCondition(condition, cursor, data, pendingDataChanges) {
@@ -901,9 +906,9 @@ function checkShowCondition(condition, cursor, data, pendingDataChanges) {
901
906
  if (!record) {
902
907
  return false;
903
908
  }
904
- var actualValue = record === null || record === void 0 ? void 0 : record[params.fieldKey];
905
- 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];
906
- return pendingValue !== void 0 ? pendingValue === params.value : actualValue === params.value;
909
+ var actualValue = record === null || record === void 0 ? void 0 : record[params === null || params === void 0 ? void 0 : params.fieldKey];
910
+ 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];
911
+ return pendingValue !== void 0 ? pendingValue === (params === null || params === void 0 ? void 0 : params.value) : actualValue === (params === null || params === void 0 ? void 0 : params.value);
907
912
  }
908
913
  // src/utils/tree.ts
909
914
  function assignTreeLinks(flat) {
@@ -911,6 +916,7 @@ function assignTreeLinks(flat) {
911
916
  var map12 = {};
912
917
  var orphans = [];
913
918
  result.forEach(function (item) {
919
+ var _a, _b;
914
920
  if (!item.parentId || item.parentId === "0") {
915
921
  return;
916
922
  }
@@ -929,7 +935,7 @@ function assignTreeLinks(flat) {
929
935
  result[parentIndex].children = [item];
930
936
  }
931
937
  else {
932
- result[parentIndex].children.push(item);
938
+ (_b = (_a = result[parentIndex]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.push(item);
933
939
  }
934
940
  });
935
941
  if (orphans.length) {
@@ -1007,22 +1013,7 @@ function deleteUndefinedFromObject(obj) {
1007
1013
  }
1008
1014
  });
1009
1015
  }
1010
- // src/reducers/router.ts
1011
- var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
1012
- var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
1013
- state = __assign(__assign({}, state), action.payload);
1014
- }).addCase(changeLocation, function (state, action) {
1015
- var _a = action.payload, url = _a.url, route = _a.route;
1016
- if (url) {
1017
- var path = new URL(url);
1018
- state = __assign(__assign({}, state), defaultParseURL(path));
1019
- }
1020
- if (route !== null) {
1021
- state = __assign(__assign({}, state), route);
1022
- }
1023
- }); };
1024
1016
  // src/reducers/screen.ts
1025
- var import_schema6 = require("@cxbox-ui/schema");
1026
1017
  var initialScreenState = {
1027
1018
  screenName: "",
1028
1019
  bo: { activeBcName: "", bc: {} },
@@ -1034,10 +1025,11 @@ var initialScreenState = {
1034
1025
  };
1035
1026
  var operationsHandledLocally = [import_schema6.OperationTypeCrud.associate, import_schema6.OperationTypeCrud.fileUpload];
1036
1027
  var createScreenReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(selectScreen, function (state, action) {
1028
+ var _a, _b, _c, _d, _e;
1037
1029
  var bcDictionary = {};
1038
1030
  var bcSorters = {};
1039
1031
  var bcFilters = {};
1040
- action.payload.screen.meta.bo.bc.forEach(function (item) {
1032
+ (_a = action.payload.screen.meta) === null || _a === void 0 ? void 0 : _a.bo.bc.forEach(function (item) {
1041
1033
  bcDictionary[item.name] = item;
1042
1034
  var sorter = parseSorters(item.defaultSort);
1043
1035
  var filter56 = parseFilters(item.defaultFilter);
@@ -1049,8 +1041,8 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1049
1041
  }
1050
1042
  });
1051
1043
  state.screenName = action.payload.screen.name;
1052
- state.primaryView = action.payload.screen.meta.primary;
1053
- state.views = action.payload.screen.meta.views;
1044
+ state.primaryView = (_c = (_b = action.payload.screen.meta) === null || _b === void 0 ? void 0 : _b.primary) !== null && _c !== void 0 ? _c : state.primaryView;
1045
+ state.views = (_e = (_d = action.payload.screen.meta) === null || _d === void 0 ? void 0 : _d.views) !== null && _e !== void 0 ? _e : state.views;
1054
1046
  state.bo = { activeBcName: null, bc: bcDictionary };
1055
1047
  state.sorters = __assign(__assign({}, state.sorters), bcSorters);
1056
1048
  state.filters = __assign(__assign({}, state.filters), bcFilters);
@@ -1060,12 +1052,14 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1060
1052
  }).addCase(bcFetchDataRequest, function (state, action) {
1061
1053
  state.bo.bc[action.payload.bcName].loading = true;
1062
1054
  }).addCase(bcLoadMore, function (state, action) {
1055
+ var _a;
1063
1056
  var currentBc = state.bo.bc[action.payload.bcName];
1064
- currentBc.page += 1;
1057
+ currentBc.page = ((_a = currentBc.page) !== null && _a !== void 0 ? _a : 1) + 1;
1065
1058
  currentBc.loading = true;
1066
1059
  }).addCase(selectView, function (state, action) {
1060
+ var _a;
1067
1061
  var newBcs = {};
1068
- Array.from(new Set(action.payload.widgets.map(function (widget) { return widget.bcName; }))
1062
+ Array.from(new Set((_a = action.payload.widgets) === null || _a === void 0 ? void 0 : _a.map(function (widget) { return widget.bcName; }))
1069
1063
  // БК которые есть на вьюхе
1070
1064
  ).filter(function (bcName) { return state.bo.bc[bcName]; }).forEach(function (bcName) {
1071
1065
  newBcs[bcName] = __assign(__assign({}, state.bo.bc[bcName]), { page: 1 });
@@ -1077,9 +1071,10 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1077
1071
  currentBc.loading = false;
1078
1072
  state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
1079
1073
  }).addCase(bcFetchDataFail, function (state, action) {
1080
- if (Object.values(state.bo.bc).some(function (bc) { return bc.name === action.payload.bcName; })) {
1081
- state.bo.bc[action.payload.bcName].loading = false;
1082
- state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
1074
+ var bcName = action.payload.bcName;
1075
+ if (Object.values(state.bo.bc).some(function (bc) { return bc.name === bcName; })) {
1076
+ state.bo.bc[bcName].loading = false;
1077
+ state.cachedBc[bcName] = action.payload.bcUrl;
1083
1078
  }
1084
1079
  }).addCase(sendOperation, function (state, action) {
1085
1080
  if (!operationsHandledLocally.includes(action.payload.operationType)) {
@@ -1107,10 +1102,12 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
1107
1102
  Object.assign(state.bo.bc, newCursors);
1108
1103
  Object.assign(state.cachedBc, newCache);
1109
1104
  }).addCase(bcChangeDepthCursor, function (state, action) {
1105
+ var _a;
1110
1106
  if (action.payload.depth === 1) {
1111
1107
  state.bo.bc[action.payload.bcName].cursor = action.payload.cursor;
1112
1108
  }
1113
1109
  else {
1110
+ state.bo.bc[action.payload.bcName].depthBc = (_a = state.bo.bc[action.payload.bcName].depthBc) !== null && _a !== void 0 ? _a : {};
1114
1111
  state.bo.bc[action.payload.bcName].depthBc[action.payload.depth].cursor = action.payload.cursor;
1115
1112
  }
1116
1113
  }).addCase(bcSelectRecord, function (state, action) {
@@ -1195,9 +1192,11 @@ var createSessionReducerBuilderManager = function (initialState) { return new Re
1195
1192
  }).addCase(switchDebugMode, function (state, action) {
1196
1193
  state.debugMode = action.payload;
1197
1194
  }).addCase(addPendingRequest, function (state, action) {
1198
- state.pendingRequests.push(action.payload.request);
1195
+ var _a;
1196
+ (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.push(action.payload.request);
1199
1197
  }).addCase(removePendingRequest, function (state, action) {
1200
- state.pendingRequests = state.pendingRequests.filter(function (item) { return item.requestId !== action.payload.requestId; });
1198
+ var _a;
1199
+ state.pendingRequests = (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return item.requestId !== action.payload.requestId; });
1201
1200
  }).addCase(addNotification, function (state, action) {
1202
1201
  state.notifications.push(action.payload);
1203
1202
  }).addCase(removeNotifications, function (state, action) {
@@ -1244,14 +1243,15 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1244
1243
  state.metaInProgress[action.payload.bcName] = true;
1245
1244
  }
1246
1245
  }).addCase(bcFetchRowMetaSuccess, function (state, action) {
1247
- if (state.rowMeta[action.payload.bcName]) {
1248
- state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1249
- }
1246
+ var _a;
1247
+ state.rowMeta[action.payload.bcName] = (_a = state.rowMeta[action.payload.bcName]) !== null && _a !== void 0 ? _a : {};
1248
+ state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1250
1249
  state.metaInProgress[action.payload.bcName] = false;
1251
1250
  }).addCase(bcNewDataSuccess, function (state, action) {
1252
1251
  state.selectedCell = initialViewState.selectedCell;
1253
1252
  }).addCase(forceActiveRmUpdate, function (state, action) {
1254
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, currentRecordData = _a.currentRecordData, rowMeta = _a.rowMeta, cursor = _a.cursor;
1253
+ var _a, _b, _c, _d;
1254
+ var _e = action.payload, bcName = _e.bcName, bcUrl = _e.bcUrl, currentRecordData = _e.currentRecordData, rowMeta = _e.rowMeta, cursor = _e.cursor;
1255
1255
  var handledForceActive = {};
1256
1256
  var rowMetaForcedValues = {};
1257
1257
  var newPendingChangesDiff = {};
@@ -1274,11 +1274,15 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1274
1274
  handledForceActive[key] = newPendingDataChanges[key];
1275
1275
  }
1276
1276
  });
1277
+ state.handledForceActive[bcName] = (_a = state.handledForceActive[bcName]) !== null && _a !== void 0 ? _a : {};
1278
+ state.handledForceActive[bcName][cursor] = (_b = state.handledForceActive[bcName][cursor]) !== null && _b !== void 0 ? _b : {};
1277
1279
  Object.assign(state.handledForceActive[bcName][cursor], handledForceActive);
1280
+ state.pendingDataChanges[bcName] = (_c = state.pendingDataChanges[bcName]) !== null && _c !== void 0 ? _c : {};
1278
1281
  state.pendingDataChanges[bcName][cursor] = newPendingDataChanges;
1282
+ state.rowMeta[bcName] = (_d = state.rowMeta[bcName]) !== null && _d !== void 0 ? _d : {};
1279
1283
  state.rowMeta[bcName][bcUrl] = rowMeta;
1280
1284
  }).addCase(changeDataItem, function (state, action) {
1281
- var _a;
1285
+ var _a, _b, _c;
1282
1286
  var actionBcName = action.payload.bcName;
1283
1287
  var prevBc = state.pendingDataChanges[action.payload.bcName] || {};
1284
1288
  var prevCursor = prevBc[action.payload.cursor] || {};
@@ -1295,10 +1299,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1295
1299
  nextValidationFails[fieldKey] = "This field is mandatory";
1296
1300
  }
1297
1301
  });
1302
+ state.pendingDataChanges[action.payload.bcName] = (_b = state.pendingDataChanges[action.payload.bcName]) !== null && _b !== void 0 ? _b : {};
1298
1303
  state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending;
1299
1304
  if (isTargetFormatPVF) {
1300
1305
  ;
1301
- state.pendingValidationFails[actionBcName][action.payload.cursor] = nextValidationFails;
1306
+ ((_c = state.pendingValidationFails) === null || _c === void 0 ? void 0 : _c[actionBcName])[action.payload.cursor] = nextValidationFails;
1302
1307
  }
1303
1308
  else {
1304
1309
  state.pendingValidationFails = nextValidationFails;
@@ -1319,7 +1324,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1319
1324
  pendingDataChanges[bcName] = pendingBcChanges;
1320
1325
  });
1321
1326
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1322
- var pendingValidationFails = __assign({}, state.pendingValidationFails);
1327
+ var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
1323
1328
  if (isTargetFormatPVF) {
1324
1329
  action.payload.bcNames.forEach(function (i) {
1325
1330
  pendingValidationFails[i] = {};
@@ -1334,7 +1339,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1334
1339
  }).addCase(bcFetchRowMetaFail, function (state, action) {
1335
1340
  state.metaInProgress[action.payload.bcName] = false;
1336
1341
  }).addCase(forceActiveChangeFail, function (state, action) {
1337
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1342
+ var _a;
1343
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1338
1344
  var errors = {};
1339
1345
  if (entityError) {
1340
1346
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1342,9 +1348,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1342
1348
  errors[fieldName] = violation;
1343
1349
  });
1344
1350
  }
1351
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1345
1352
  state.rowMeta[bcName][bcUrl].errors = errors;
1346
1353
  }).addCase(bcSaveDataFail, function (state, action) {
1347
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1354
+ var _a;
1355
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1348
1356
  var errors = {};
1349
1357
  if (entityError) {
1350
1358
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1352,9 +1360,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1352
1360
  errors[fieldName] = violation;
1353
1361
  });
1354
1362
  }
1363
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1355
1364
  state.rowMeta[bcName][bcUrl].errors = errors;
1356
1365
  }).addCase(sendOperationFail, function (state, action) {
1357
- var _a = action.payload, bcName = _a.bcName, bcUrl = _a.bcUrl, entityError = _a.entityError;
1366
+ var _a;
1367
+ var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
1358
1368
  var errors = {};
1359
1369
  if (entityError) {
1360
1370
  Object.entries(entityError.fields).forEach(function (_a) {
@@ -1362,30 +1372,38 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1362
1372
  errors[fieldName] = violation;
1363
1373
  });
1364
1374
  }
1375
+ state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
1365
1376
  state.rowMeta[bcName][bcUrl].errors = errors;
1366
1377
  }).addCase(sendOperationSuccess, function (state, action) {
1367
- var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor;
1378
+ var _a, _b, _c;
1379
+ var bcName = action.payload.bcName;
1380
+ var cursor = action.payload.cursor;
1368
1381
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1382
+ state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
1369
1383
  state.pendingDataChanges[bcName][cursor] = {};
1370
1384
  if (isTargetFormatPVF) {
1371
1385
  ;
1372
- state.pendingValidationFails[bcName][cursor] = {};
1386
+ ((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
1373
1387
  }
1374
1388
  else {
1375
1389
  state.pendingValidationFails = initialViewState.pendingValidationFails;
1376
1390
  }
1391
+ state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
1377
1392
  state.handledForceActive[bcName][cursor] = {};
1378
1393
  }).addCase(bcSaveDataSuccess, function (state, action) {
1379
- var _a = action.payload, bcName = _a.bcName, cursor = _a.cursor;
1394
+ var _a, _b, _c;
1395
+ var _d = action.payload, bcName = _d.bcName, cursor = _d.cursor;
1380
1396
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1397
+ state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
1381
1398
  state.pendingDataChanges[bcName][cursor] = {};
1382
1399
  if (isTargetFormatPVF) {
1383
1400
  ;
1384
- state.pendingValidationFails[bcName][cursor] = {};
1401
+ ((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
1385
1402
  }
1386
1403
  else {
1387
1404
  state.pendingValidationFails = initialViewState.pendingValidationFails;
1388
1405
  }
1406
+ state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
1389
1407
  state.handledForceActive[bcName][cursor] = {};
1390
1408
  }).addCase(bcCancelPendingChanges, function (state, action) {
1391
1409
  var _a, _b;
@@ -1396,7 +1414,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1396
1414
  }
1397
1415
  }
1398
1416
  var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
1399
- var pendingValidationFails = __assign({}, state.pendingValidationFails);
1417
+ var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
1400
1418
  if (isTargetFormatPVF) {
1401
1419
  if (((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.bcNames) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1402
1420
  action.payload.bcNames.forEach(function (i) {
@@ -1425,8 +1443,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1425
1443
  isFilter: isFilter
1426
1444
  };
1427
1445
  }).addCase(showFileUploadPopup, function (state, action) {
1428
- var _a;
1429
- var bcName = (_a = state.widgets.find(function (item) { return item.name === action.payload.widgetName; })) === null || _a === void 0 ? void 0 : _a.bcName;
1446
+ var _a, _b;
1447
+ 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;
1430
1448
  state.popupData = {
1431
1449
  type: "file-upload",
1432
1450
  bcName: bcName,
@@ -1438,6 +1456,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1438
1456
  }).addCase(viewClearPickMap, function (state) {
1439
1457
  state.pickMap = null;
1440
1458
  }).addCase(closeViewPopup, function (state) {
1459
+ state.popupData = {};
1441
1460
  state.popupData.bcName = null;
1442
1461
  }).addCase(selectTableCell, function (state, action) {
1443
1462
  state.selectedCell = { widgetName: action.payload.widgetName, rowId: action.payload.rowId, fieldKey: action.payload.fieldKey };
@@ -1445,12 +1464,16 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
1445
1464
  state.pendingDataChanges = initialViewState.pendingDataChanges;
1446
1465
  state.selectedCell = initialViewState.selectedCell;
1447
1466
  }).addCase(showNotification, function (state, action) {
1467
+ var _a, _b;
1468
+ state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
1448
1469
  state.systemNotifications.push({
1449
1470
  type: action.payload.type,
1450
1471
  message: action.payload.message,
1451
- id: state.systemNotifications.length
1472
+ id: (_b = state.systemNotifications) === null || _b === void 0 ? void 0 : _b.length
1452
1473
  });
1453
1474
  }).addCase(closeNotification, function (state, action) {
1475
+ var _a;
1476
+ state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
1454
1477
  state.systemNotifications = state.systemNotifications.filter(function (item) { return item.id !== action.payload.id; });
1455
1478
  }).addCase(showViewError, function (state, action) {
1456
1479
  state.error = action.payload.error;
@@ -1566,7 +1589,7 @@ var sendOperationEpic = function (action$, state$, _a) {
1566
1589
  var record = (_c = state.data[bcName]) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.id === bc.cursor; });
1567
1590
  var filters = state.screen.filters[bcName];
1568
1591
  var sorters = state.screen.sorters[bcName];
1569
- var pendingRecordChange = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor];
1592
+ var pendingRecordChange = __assign({}, (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor]);
1570
1593
  var _loop_2 = function (key) {
1571
1594
  if (fields.find(function (item) { return item.key === key && item.disabled; })) {
1572
1595
  delete pendingRecordChange[key];
@@ -1583,10 +1606,10 @@ var sendOperationEpic = function (action$, state$, _a) {
1583
1606
  }
1584
1607
  var context = { widgetName: action.payload.widgetName };
1585
1608
  return api.customAction(screenName, bcUrl, data, context, params).pipe((0, import_rxjs2.mergeMap)(function (response) {
1586
- var _a;
1587
- var postInvoke = response.postActions[0];
1609
+ var _a, _b;
1610
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
1588
1611
  var preInvoke = response.preInvoke;
1589
- return defaultSaveOperation ? ((_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.onSuccessAction) ? (0, import_rxjs2.concat)((0, import_rxjs2.of)(bcCancelPendingChanges({ bcNames: [bcName] })), (0, import_rxjs2.of)(action.payload.onSuccessAction)) : import_rxjs2.EMPTY : (0, import_rxjs2.concat).apply(void 0, __spreadArray([(0, import_rxjs2.of)(sendOperationSuccess({ bcName: bcName, cursor: cursor })),
1612
+ return defaultSaveOperation ? ((_b = action === null || action === void 0 ? void 0 : action.payload) === null || _b === void 0 ? void 0 : _b.onSuccessAction) ? (0, import_rxjs2.concat)((0, import_rxjs2.of)(bcCancelPendingChanges({ bcNames: [bcName] })), (0, import_rxjs2.of)(action.payload.onSuccessAction)) : import_rxjs2.EMPTY : (0, import_rxjs2.concat).apply(void 0, __spreadArray([(0, import_rxjs2.of)(sendOperationSuccess({ bcName: bcName, cursor: cursor })),
1590
1613
  (0, import_rxjs2.of)(bcForceUpdate({ bcName: bcName }))], postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName), false));
1591
1614
  }), (0, import_rxjs2.catchError)(function (e) {
1592
1615
  var _a, _b, _c, _d, _e, _f;
@@ -1651,16 +1674,17 @@ var import_schema9 = require("@cxbox-ui/schema");
1651
1674
  var fileUploadConfirmEpic = function (action$, state$, _a) {
1652
1675
  var api = _a.api;
1653
1676
  return action$.pipe((0, import_rxjs4.filter)(bulkUploadFiles.match), (0, import_rxjs4.mergeMap)(function (action) {
1654
- var _a;
1677
+ var _a, _b;
1655
1678
  var state = state$.value;
1656
- var bcName = state.view.popupData.bcName;
1679
+ var bcName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.bcName;
1657
1680
  var bcUrl = buildBcUrl(bcName, true, state);
1658
- var widgetName = (_a = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _a === void 0 ? void 0 : _a.name;
1681
+ var widgetName = (_b = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.name;
1659
1682
  var data = {
1660
1683
  bulkIds: action.payload.fileIds
1661
1684
  };
1662
1685
  return api.customAction(state.screen.screenName, bcUrl, data, null, { _action: "file-upload-save" }).pipe((0, import_rxjs4.mergeMap)(function (response) {
1663
- var postInvoke = response.postActions[0];
1686
+ var _a;
1687
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
1664
1688
  var preInvoke = response.preInvoke;
1665
1689
  return (0, import_rxjs4.concat).apply(void 0, __spreadArray([(0, import_rxjs4.of)(sendOperationSuccess({ bcName: bcName, cursor: null })),
1666
1690
  (0, import_rxjs4.of)(bcForceUpdate({ bcName: bcName })),
@@ -1676,14 +1700,14 @@ var selectTableCellInitEpic = function (action$, state$) { return action$.pipe((
1676
1700
  var state = state$.value;
1677
1701
  var _b = action.payload, nextRowId = _b.rowId, fieldKey = _b.fieldKey;
1678
1702
  var nextWidget = state.view.widgets.find(function (widget) { return widget.name === action.payload.widgetName; });
1679
- var nextBcName = nextWidget.bcName;
1703
+ var nextBcName = nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.bcName;
1680
1704
  var nextBcCursor = (_a = state.screen.bo.bc[nextBcName]) === null || _a === void 0 ? void 0 : _a.cursor;
1681
1705
  var selectedCell = state.view.selectedCell;
1682
1706
  if (nextRowId !== nextBcCursor) {
1683
1707
  resultObservables.push((0, import_rxjs5.of)(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })));
1684
1708
  }
1685
- if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || nextWidget.name !== selectedCell.widgetName) {
1686
- resultObservables.push((0, import_rxjs5.of)(selectTableCell({ widgetName: nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
1709
+ if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || (nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name) !== selectedCell.widgetName) {
1710
+ resultObservables.push((0, import_rxjs5.of)(selectTableCell({ widgetName: nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
1687
1711
  }
1688
1712
  return (0, import_rxjs5.concat).apply(void 0, resultObservables);
1689
1713
  })); };
@@ -1731,7 +1755,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1731
1755
  var currentRecordData = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (record) { return record.id === cursor; });
1732
1756
  var fieldsRowMeta = (_d = (_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]) === null || _d === void 0 ? void 0 : _d.fields;
1733
1757
  var changedFiledKey = null;
1734
- var closePopup = (0, import_rxjs8.concat)((0, import_rxjs8.of)(viewClearPickMap(null)), (0, import_rxjs8.of)(closeViewPopup(null)), (0, import_rxjs8.of)(bcRemoveAllFilters({ bcName: bcName })));
1758
+ var closePopup = (0, import_rxjs8.concat)((0, import_rxjs8.of)(closeViewPopup(null)), (0, import_rxjs8.of)(viewClearPickMap(null)), (0, import_rxjs8.of)(bcRemoveAllFilters({ bcName: bcName })));
1735
1759
  var someForceActiveChanged = fieldsRowMeta === null || fieldsRowMeta === void 0 ? void 0 : fieldsRowMeta.filter(function (field) { return field.forceActive && pendingChanges[field.key] !== void 0; }).some(function (field) {
1736
1760
  var result = pendingChanges[field.key] !== handledForceActive[field.key];
1737
1761
  if (result) {
@@ -1741,7 +1765,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1741
1765
  });
1742
1766
  var requestId = (0, import_toolkit2.nanoid)();
1743
1767
  if (someForceActiveChanged && !disableRetry) {
1744
- return (0, import_rxjs8.concat)((0, import_rxjs8.of)(addPendingRequest({ request: { requestId: requestId, type: "force-active" } })), api.getRmByForceActive(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: currentRecordData.vstamp })).pipe((0, import_rxjs8.mergeMap)(function (data) {
1768
+ return (0, import_rxjs8.concat)((0, import_rxjs8.of)(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((0, import_rxjs8.mergeMap)(function (data) {
1745
1769
  var result = [(0, import_rxjs8.of)(removePendingRequest({ requestId: requestId }))];
1746
1770
  if (state.view.url === initUrl) {
1747
1771
  result.push((0, import_rxjs8.of)(forceActiveRmUpdate({
@@ -1771,7 +1795,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
1771
1795
  bcName: bcName,
1772
1796
  bcUrl: buildBcUrl(bcName, true, state),
1773
1797
  cursor: cursor,
1774
- dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData[changedFiledKey], _a),
1798
+ dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData === null || currentRecordData === void 0 ? void 0 : currentRecordData[changedFiledKey], _a),
1775
1799
  disableRetry: true
1776
1800
  })), (0, import_rxjs8.of)(forceActiveChangeFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError }))) : import_rxjs8.EMPTY);
1777
1801
  })));
@@ -1784,9 +1808,14 @@ var import_rxjs9 = require("rxjs");
1784
1808
  var showAllTableRecordsInitEpic = function (action$, state$) { return action$.pipe((0, import_rxjs9.filter)(showAllTableRecordsInit.match), (0, import_rxjs9.mergeMap)(function (action) {
1785
1809
  var _a;
1786
1810
  var resultObservables = [];
1787
- var bcName = action.payload.bcName;
1811
+ var _b = action.payload, bcName = _b.bcName, cursor = _b.cursor;
1812
+ var state = state$.value;
1813
+ var route = state.router;
1788
1814
  resultObservables.push((0, import_rxjs9.of)(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = null, _a) })));
1815
+ var bcPath = route.bcPath.slice(0, route.bcPath.indexOf("".concat(bcName, "/").concat(cursor)));
1816
+ var url = defaultBuildURL(__assign(__assign({}, route), { bcPath: bcPath }));
1789
1817
  resultObservables.push((0, import_rxjs9.of)(bcForceUpdate({ bcName: bcName })));
1818
+ resultObservables.push((0, import_rxjs9.of)(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })));
1790
1819
  return (0, import_rxjs9.concat).apply(void 0, resultObservables);
1791
1820
  })); };
1792
1821
  // src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts
@@ -1810,8 +1839,108 @@ var clearPendingDataChangesAfterCursorChangeEpic = function (action$, state$) {
1810
1839
  // src/epics/router/drilldownEpic.ts
1811
1840
  var import_rxjs11 = require("rxjs");
1812
1841
  var drillDownEpic = function (action$, state$) { return action$.pipe((0, import_rxjs11.filter)(drillDown.match), (0, import_rxjs11.switchMap)(function (action) {
1813
- return import_rxjs11.EMPTY;
1842
+ var _a, _b;
1843
+ var state = state$.value;
1844
+ var url = action.payload.url;
1845
+ var result = [];
1846
+ switch (action.payload.drillDownType) {
1847
+ case import_schema.DrillDownType.external:
1848
+ window.location.href = url;
1849
+ break;
1850
+ case import_schema.DrillDownType.externalNew:
1851
+ if (/^[a-z0-9]+:\/\//i.test(url)) {
1852
+ window.open(url);
1853
+ }
1854
+ break;
1855
+ case import_schema.DrillDownType.relative:
1856
+ window.location.href = "".concat(window.location.origin, "/").concat(url);
1857
+ break;
1858
+ case import_schema.DrillDownType.relativeNew:
1859
+ window.open("".concat(window.location.origin, "/").concat(url), "_blank");
1860
+ break;
1861
+ case import_schema.DrillDownType.inner:
1862
+ default:
1863
+ var urlBase = url.split("?")[0];
1864
+ var urlObject = new URL(url, window.location.origin);
1865
+ var urlFilters = urlObject.searchParams.get("filters");
1866
+ var urlSorters = urlObject.searchParams.get("sorters");
1867
+ var newFilters_1 = {};
1868
+ var newSorters = {};
1869
+ try {
1870
+ newFilters_1 = (_a = JSON.parse(urlFilters)) !== null && _a !== void 0 ? _a : newFilters_1;
1871
+ }
1872
+ catch (_c) {
1873
+ urlFilters && console.warn("Failed to parse filters on drilldown");
1874
+ newFilters_1 = {};
1875
+ }
1876
+ try {
1877
+ newSorters = (_b = JSON.parse(urlSorters)) !== null && _b !== void 0 ? _b : newSorters;
1878
+ }
1879
+ catch (_d) {
1880
+ urlSorters && console.warn("Failed to parse sorters on drilldown");
1881
+ newSorters = {};
1882
+ }
1883
+ var bcToUpdate_1 = {};
1884
+ Object.keys(state.screen.filters).forEach(function (bcName) {
1885
+ if (newFilters_1[bcName] === "" || newFilters_1[bcName]) {
1886
+ bcToUpdate_1[bcName] = true;
1887
+ result.push(bcRemoveAllFilters({ bcName: bcName }));
1888
+ }
1889
+ });
1890
+ var nextState = defaultParseURL(urlObject);
1891
+ var viewName_1 = nextState.viewName;
1892
+ Object.entries(newFilters_1).forEach(function (_a) {
1893
+ var _b;
1894
+ var bcName = _a[0], filterExpression = _a[1];
1895
+ var parsedFilters = (_b = parseFilters(filterExpression)) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), { viewName: viewName_1 })); });
1896
+ parsedFilters === null || parsedFilters === void 0 ? void 0 : parsedFilters.forEach(function (parsedFilter) {
1897
+ bcToUpdate_1[bcName] = true;
1898
+ result.push(bcAddFilter({ bcName: bcName, filter: parsedFilter }));
1899
+ });
1900
+ });
1901
+ Object.entries(newSorters).forEach(function (_a) {
1902
+ var bcName = _a[0], sortExpression = _a[1];
1903
+ var sorter = parseSorters(sortExpression);
1904
+ result.push(bcAddSorter({ bcName: bcName, sorter: sorter }));
1905
+ bcToUpdate_1[bcName] = true;
1906
+ });
1907
+ var prevState = state.router;
1908
+ var willUpdateAnyway = shallowCompare(prevState, nextState, ["params"]).length > 0;
1909
+ if (!willUpdateAnyway) {
1910
+ Object.keys(bcToUpdate_1).forEach(function (bcName) {
1911
+ result.push(bcForceUpdate({ bcName: bcName }));
1912
+ });
1913
+ }
1914
+ result.push(changeLocation({ location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)) }));
1915
+ break;
1916
+ }
1917
+ return result.length ? (0, import_rxjs11.concat)(result) : import_rxjs11.EMPTY;
1814
1918
  })); };
1919
+ function shallowCompare(prevProps, nextProps, ignore) {
1920
+ if (ignore === void 0) { ignore = []; }
1921
+ var diffProps = [];
1922
+ if (!prevProps && !nextProps) {
1923
+ return null;
1924
+ }
1925
+ if (!prevProps) {
1926
+ return Object.keys(nextProps);
1927
+ }
1928
+ if (!nextProps) {
1929
+ return Object.keys(prevProps);
1930
+ }
1931
+ var newKeys = Object.keys(nextProps);
1932
+ newKeys.forEach(function (key) {
1933
+ if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {
1934
+ diffProps.push(key);
1935
+ }
1936
+ });
1937
+ Object.keys(prevProps).forEach(function (key) {
1938
+ if (!newKeys.includes(key)) {
1939
+ diffProps.push(key);
1940
+ }
1941
+ });
1942
+ return diffProps;
1943
+ }
1815
1944
  // src/epics/router/loginDoneEpic.ts
1816
1945
  var import_rxjs12 = require("rxjs");
1817
1946
  var loginDoneEpic = function (action$, state$) { return action$.pipe((0, import_rxjs12.filter)(loginDone.match), (0, import_rxjs12.switchMap)(function (action) {
@@ -1880,7 +2009,7 @@ var userDrillDownEpic = function (action$, state$, _a) {
1880
2009
  var route = state.router;
1881
2010
  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;
1882
2011
  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];
1883
- return customDrillDownUrl || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) !== route.path ? (0, import_rxjs16.concat)(drillDownField.drillDownType !== import_schema.DrillDownType.inner ? (0, import_rxjs16.of)(bcFetchRowMetaSuccess({ bcName: bcName, rowMeta: rowMeta, bcUrl: bcUrl, cursor: cursor })) : import_rxjs16.EMPTY, (0, import_rxjs16.of)(userDrillDownSuccess({ bcName: bcName, bcUrl: bcUrl, cursor: cursor })), (0, import_rxjs16.of)(drillDown({
2012
+ return customDrillDownUrl || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) || (drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDown) !== route.path ? (0, import_rxjs16.concat)((drillDownField === null || drillDownField === void 0 ? void 0 : drillDownField.drillDownType) !== import_schema.DrillDownType.inner ? (0, import_rxjs16.of)(bcFetchRowMetaSuccess({ bcName: bcName, rowMeta: rowMeta, bcUrl: bcUrl, cursor: cursor })) : import_rxjs16.EMPTY, (0, import_rxjs16.of)(userDrillDownSuccess({ bcName: bcName, bcUrl: bcUrl, cursor: cursor })), (0, import_rxjs16.of)(drillDown({
1884
2013
  url: customDrillDownUrl || drillDownField.drillDown,
1885
2014
  drillDownType: drillDownField.drillDownType,
1886
2015
  route: route
@@ -1971,7 +2100,7 @@ var userDrillDownChangeCursorsEpic = function (action$, state$) { return action$
1971
2100
  if (cursor !== action.payload.cursor) {
1972
2101
  return bcChangeCursors({ cursorsMap: (_a = {}, _a[action.payload.bcName] = action.payload.cursor, _a) });
1973
2102
  }
1974
- return void 0;
2103
+ return emptyAction;
1975
2104
  })); };
1976
2105
  // src/epics/screen/apiErrorEpic.ts
1977
2106
  var import_axios = __toESM(require("axios"));
@@ -1999,7 +2128,9 @@ var import_rxjs22 = require("rxjs");
1999
2128
  var downloadFileEpic = function (action$, state$, _a) {
2000
2129
  var api = _a.api;
2001
2130
  return action$.pipe((0, import_rxjs22.filter)(downloadFile.match), (0, import_rxjs22.tap)(function (action) {
2131
+ var fileId = action.payload.fileId;
2002
2132
  var anchor = document.createElement("a");
2133
+ anchor.href = "".concat(api.fileUploadEndpoint, "?id=").concat(encodeURIComponent(fileId));
2003
2134
  anchor.style.display = "none";
2004
2135
  document.body.appendChild(anchor);
2005
2136
  setTimeout(function () {
@@ -2016,8 +2147,8 @@ var httpError401Epic = function (action$) { return action$.pipe((0, import_rxjs2
2016
2147
  // src/epics/screen/httpError409Epic.ts
2017
2148
  var import_rxjs24 = require("rxjs");
2018
2149
  var httpError409Epic = function (action$, state$) { return action$.pipe((0, import_rxjs24.filter)(httpError.match), (0, import_rxjs24.filter)(function (action) { return action.payload.statusCode === 409; }), (0, import_rxjs24.map)(function (action) {
2019
- var _a, _b;
2020
- 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]) || "";
2150
+ var _a, _b, _c;
2151
+ 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]) || "";
2021
2152
  return addNotification({
2022
2153
  key: "action_edit_error",
2023
2154
  message: notificationMessage,
@@ -2033,10 +2164,10 @@ var httpError409Epic = function (action$, state$) { return action$.pipe((0, impo
2033
2164
  // src/epics/screen/httpError418Epic.ts
2034
2165
  var import_rxjs25 = require("rxjs");
2035
2166
  var httpError418Epic = function (action$, state$) { return action$.pipe((0, import_rxjs25.filter)(httpError.match), (0, import_rxjs25.filter)(function (action) { return action.payload.statusCode === 418; }), (0, import_rxjs25.mergeMap)(function (action) {
2036
- var _a;
2037
- var _b = action.payload, error = _b.error, callContext = _b.callContext;
2167
+ var _a, _b;
2168
+ var _c = action.payload, error = _c.error, callContext = _c.callContext;
2038
2169
  var result = [];
2039
- var typedError = error.response.data;
2170
+ var typedError = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
2040
2171
  if (!typedError.error.popup) {
2041
2172
  return import_rxjs25.EMPTY;
2042
2173
  }
@@ -2045,13 +2176,13 @@ var httpError418Epic = function (action$, state$) { return action$.pipe((0, impo
2045
2176
  message: typedError.error.popup[0]
2046
2177
  };
2047
2178
  result.push((0, import_rxjs25.of)(showViewError({ error: businessError })));
2048
- if ((_a = typedError.error.postActions) === null || _a === void 0 ? void 0 : _a[0]) {
2179
+ if ((_b = typedError.error.postActions) === null || _b === void 0 ? void 0 : _b[0]) {
2049
2180
  var widget = state$.value.view.widgets.find(function (item) { return item.name === callContext.widgetName; });
2050
- var bcName = widget.bcName;
2181
+ var bcName = widget === null || widget === void 0 ? void 0 : widget.bcName;
2051
2182
  result.push((0, import_rxjs25.of)(processPostInvoke({
2052
2183
  bcName: bcName,
2053
2184
  postInvoke: typedError.error.postActions[0],
2054
- widgetName: widget.name
2185
+ widgetName: widget === null || widget === void 0 ? void 0 : widget.name
2055
2186
  })));
2056
2187
  }
2057
2188
  return (0, import_rxjs25.concat).apply(void 0, result);
@@ -2071,10 +2202,11 @@ var httpError500Epic = function (action$, state$) { return action$.pipe((0, impo
2071
2202
  var import_rxjs27 = require("rxjs");
2072
2203
  var knownHttpErrors = [401, 409, 418, 500];
2073
2204
  var httpErrorDefaultEpic = function (action$, state$) { return action$.pipe((0, import_rxjs27.filter)(httpError.match), (0, import_rxjs27.filter)(function (action) { return !knownHttpErrors.includes(action.payload.statusCode); }), (0, import_rxjs27.map)(function (action) {
2205
+ var _a, _b;
2074
2206
  var businessError = {
2075
2207
  type: 0 /* BusinessError */,
2076
- code: action.payload.error.response.status,
2077
- details: action.payload.error.response.data
2208
+ code: (_a = action.payload.error.response) === null || _a === void 0 ? void 0 : _a.status,
2209
+ details: (_b = action.payload.error.response) === null || _b === void 0 ? void 0 : _b.data
2078
2210
  };
2079
2211
  return showViewError({ error: businessError });
2080
2212
  })); };
@@ -2095,6 +2227,7 @@ var downloadFileByUrlEpic = function (action$, state$) { return action$.pipe((0,
2095
2227
  var import_rxjs29 = require("rxjs");
2096
2228
  var processPostInvokeEpic = function (action$, state$) { return action$.pipe((0, import_rxjs29.filter)(processPostInvoke.match), (0, import_rxjs29.mergeMap)(function (action) {
2097
2229
  var _a;
2230
+ var _b;
2098
2231
  var state = state$.value;
2099
2232
  switch (action.payload.postInvoke.type) {
2100
2233
  case "drillDown" /* drillDown */:
@@ -2102,7 +2235,10 @@ var processPostInvokeEpic = function (action$, state$) { return action$.pipe((0,
2102
2235
  case "postDelete" /* postDelete */: {
2103
2236
  var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
2104
2237
  var result = [bcChangeCursors({ cursorsMap: cursorsMap })];
2105
- if (state.router.bcPath.includes("".concat(action.payload.bcName, "/"))) {
2238
+ if ((_b = state.router.bcPath) === null || _b === void 0 ? void 0 : _b.includes("".concat(action.payload.bcName, "/"))) {
2239
+ var newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || "";
2240
+ var newUrl = "/screen/".concat(state.router.screenName, "/view/").concat(state.router.viewName, "/").concat(newBcUrl);
2241
+ result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }));
2106
2242
  }
2107
2243
  else {
2108
2244
  result.push(bcFetchDataRequest({
@@ -2187,8 +2323,7 @@ var refreshMetaEpic = function (action$, state$, _a) {
2187
2323
  logoutDone(null),
2188
2324
  login({ login: "", password: "", role: activeRole }),
2189
2325
  changeLocation({
2190
- route: router,
2191
- action: "PUSH"
2326
+ location: router
2192
2327
  })
2193
2328
  ]); }), (0, import_rxjs32.catchError)(function (error) { return (0, import_rxjs32.of)(loginFail(error)); }));
2194
2329
  }));
@@ -2209,9 +2344,26 @@ var loginByAnotherRoleEpic = function (action$, state$, _a) {
2209
2344
  var role = (_a = action.payload.role) !== null && _a !== void 0 ? _a : "";
2210
2345
  var isSwitchRole = role && role !== state$.value.session.activeRole;
2211
2346
  return api.loginByRoleRequest(role).pipe((0, import_rxjs34.mergeMap)(function (data) {
2347
+ var _a;
2348
+ var result = [];
2212
2349
  if (isSwitchRole) {
2350
+ var defaultScreen = data.screens.find(function (screen) { return screen.defaultScreen; }) || data.screens[0];
2351
+ var defaultViewName_1 = (_a = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.primary) !== null && _a !== void 0 ? _a : defaultScreen.meta.views[0].name;
2352
+ var defaultView = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.meta.views.find(function (view) { return defaultViewName_1 === view.name; });
2353
+ if (defaultView)
2354
+ result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }));
2213
2355
  }
2214
- return import_rxjs34.EMPTY;
2356
+ return (0, import_rxjs34.concat)(__spreadArray(__spreadArray([], result, true), [
2357
+ loginDone({
2358
+ devPanelEnabled: data.devPanelEnabled,
2359
+ activeRole: data.activeRole,
2360
+ roles: data.roles,
2361
+ screens: data.screens,
2362
+ firstName: data.firstName,
2363
+ lastName: data.lastName,
2364
+ login: data.login
2365
+ })
2366
+ ], false));
2215
2367
  }), (0, import_rxjs34.catchError)(function (error) {
2216
2368
  console.error(error);
2217
2369
  var errorMsg = error.response ? responseStatusMessages[error.response.status] || "Server application unavailable" : "Empty server response";
@@ -2228,22 +2380,24 @@ var import_schema13 = require("@cxbox-ui/schema");
2228
2380
  var bcNewDataEpic = function (action$, state$, _a) {
2229
2381
  var api = _a.api;
2230
2382
  return action$.pipe((0, import_rxjs36.filter)(sendOperation.match), (0, import_rxjs36.filter)(function (action) { return matchOperationRole(import_schema13.OperationTypeCrud.create, action.payload, state$.value); }), (0, import_rxjs36.mergeMap)(function (action) {
2383
+ var _a;
2231
2384
  var state = state$.value;
2232
2385
  var bcName = action.payload.bcName;
2233
- var bcUrl = buildBcUrl(bcName, false, state);
2386
+ var bcUrl = (_a = buildBcUrl(bcName, false, state)) !== null && _a !== void 0 ? _a : "";
2234
2387
  var context = { widgetName: action.payload.widgetName };
2235
2388
  var params = { _action: action.payload.operationType };
2236
2389
  return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe((0, import_rxjs36.mergeMap)(function (data) {
2390
+ var _a, _b;
2237
2391
  var rowMeta = data.row;
2238
2392
  var dataItem = { id: null, vstamp: -1 };
2239
2393
  data.row.fields.forEach(function (field) {
2240
2394
  dataItem[field.key] = field.currentValue;
2241
2395
  });
2242
- var postInvoke = data.postActions[0];
2396
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2243
2397
  var cursor = dataItem.id;
2244
2398
  return (0, import_rxjs36.concat)((0, import_rxjs36.of)(bcNewDataSuccess({ bcName: bcName, dataItem: dataItem, bcUrl: bcUrl })), (0, import_rxjs36.of)(bcFetchRowMetaSuccess({ bcName: bcName, bcUrl: "".concat(bcUrl, "/").concat(cursor), rowMeta: rowMeta, cursor: cursor })), (0, import_rxjs36.of)(changeDataItem({
2245
2399
  bcName: bcName,
2246
- bcUrl: buildBcUrl(bcName, true, state),
2400
+ bcUrl: (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "",
2247
2401
  cursor: cursor,
2248
2402
  dataItem: {
2249
2403
  id: cursor
@@ -2266,7 +2420,7 @@ function cancelRequestEpic(action$, actionTypes, cancelFn, cancelActionCreator,
2266
2420
  return true;
2267
2421
  }; }
2268
2422
  return action$.pipe((0, import_rxjs37.filter)((0, import_toolkit4.isAnyOf).apply(void 0, actionTypes)), (0, import_rxjs37.filter)(filterFn), (0, import_rxjs37.mergeMap)(function () {
2269
- cancelFn();
2423
+ cancelFn === null || cancelFn === void 0 ? void 0 : cancelFn();
2270
2424
  return (0, import_rxjs37.of)(cancelActionCreator);
2271
2425
  }), (0, import_rxjs37.take)(1));
2272
2426
  }
@@ -2309,16 +2463,16 @@ var import_rxjs39 = require("rxjs");
2309
2463
  var bcSaveDataEpic = function (action$, state$, _a) {
2310
2464
  var api = _a.api;
2311
2465
  return action$.pipe((0, import_rxjs39.filter)(sendOperation.match), (0, import_rxjs39.filter)(function (action) { return matchOperationRole(import_schema5.OperationTypeCrud.save, action.payload, state$.value); }), (0, import_rxjs39.mergeMap)(function (action) {
2312
- var _a, _b, _c;
2466
+ var _a, _b, _c, _d;
2313
2467
  var state = state$.value;
2314
2468
  var bcName = action.payload.bcName;
2315
- var bcUrl = buildBcUrl(bcName, true, state);
2469
+ var bcUrl = (_a = buildBcUrl(bcName, true, state)) !== null && _a !== void 0 ? _a : "";
2316
2470
  var widgetName = action.payload.widgetName;
2317
2471
  var cursor = state.screen.bo.bc[bcName].cursor;
2318
2472
  var dataItem = state.data[bcName].find(function (item) { return item.id === cursor; });
2319
- var pendingChanges = (_a = state.view.pendingDataChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
2320
- var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
2321
- var options = (_c = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _c === void 0 ? void 0 : _c.options;
2473
+ var pendingChanges = __assign({}, (_b = state.view.pendingDataChanges[bcName]) === null || _b === void 0 ? void 0 : _b[cursor]);
2474
+ var rowMeta = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
2475
+ var options = (_d = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _d === void 0 ? void 0 : _d.options;
2322
2476
  if (rowMeta) {
2323
2477
  var fields = rowMeta.fields;
2324
2478
  var _loop_3 = function (key) {
@@ -2335,8 +2489,9 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2335
2489
  return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] });
2336
2490
  });
2337
2491
  var context = { widgetName: action.payload.widgetName };
2338
- return api.saveBcData(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: dataItem.vstamp }), context).pipe((0, import_rxjs39.mergeMap)(function (data) {
2339
- var postInvoke = data.postActions[0];
2492
+ return api.saveBcData(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: dataItem === null || dataItem === void 0 ? void 0 : dataItem.vstamp }), context).pipe((0, import_rxjs39.mergeMap)(function (data) {
2493
+ var _a;
2494
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2340
2495
  var responseDataItem = data.record;
2341
2496
  return (0, import_rxjs39.concat)((0, import_rxjs39.of)(bcSaveDataSuccess({ bcName: bcName, cursor: cursor, dataItem: responseDataItem })), (0, import_rxjs39.of)(bcFetchRowMeta({ widgetName: widgetName, bcName: bcName })), (0, import_rxjs39.of).apply(void 0, fetchChildrenBcData), postInvoke ? (0, import_rxjs39.of)(processPostInvoke({
2342
2497
  bcName: bcName,
@@ -2345,7 +2500,7 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2345
2500
  cursor: responseDataItem.id
2346
2501
  })) : import_rxjs39.EMPTY, action.payload.onSuccessAction ? (0, import_rxjs39.of)(action.payload.onSuccessAction) : import_rxjs39.EMPTY);
2347
2502
  }), (0, import_rxjs39.catchError)(function (e) {
2348
- var _a, _b, _c, _d, _e, _f;
2503
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2349
2504
  console.error(e);
2350
2505
  var notification$ = import_rxjs39.EMPTY;
2351
2506
  if (action.payload.onSuccessAction && !(options === null || options === void 0 ? void 0 : options.disableNotification)) {
@@ -2366,8 +2521,8 @@ var bcSaveDataEpic = function (action$, state$, _a) {
2366
2521
  var entityError = null;
2367
2522
  var operationError = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data;
2368
2523
  if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.data) === Object((_c = e.response) === null || _c === void 0 ? void 0 : _c.data)) {
2369
- entityError = (_d = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _d === void 0 ? void 0 : _d.entity;
2370
- 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];
2524
+ 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;
2525
+ 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;
2371
2526
  }
2372
2527
  return (0, import_rxjs39.concat)((0, import_rxjs39.of)(bcSaveDataFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError })), notification$);
2373
2528
  }));
@@ -2443,41 +2598,41 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2443
2598
  });
2444
2599
  return (0, import_rxjs41.of)(bcFetchDataRequest({
2445
2600
  bcName: childBcName,
2446
- widgetName: nonLazyWidget.name,
2601
+ widgetName: nonLazyWidget === null || nonLazyWidget === void 0 ? void 0 : nonLazyWidget.name,
2447
2602
  ignorePageLimit: ignorePageLimit || showViewPopup.match(action),
2448
2603
  keepDelta: isHierarchy || keepDelta
2449
2604
  }));
2450
2605
  }));
2451
2606
  };
2452
2607
  var bcFetchDataImpl = function () {
2453
- var _a, _b, _c, _d, _e, _f;
2608
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2454
2609
  var state = state$.value;
2455
- var widgetName = action.payload.widgetName;
2456
- var _g = state.view, widgets = _g.widgets, infiniteWidgets = _g.infiniteWidgets;
2457
- 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; });
2610
+ var _j = action.payload.widgetName, widgetName = _j === void 0 ? "" : _j;
2611
+ var _k = state.view, widgets = _k.widgets, infiniteWidgets = _k.infiniteWidgets;
2612
+ 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; });
2458
2613
  if (!widget) {
2459
2614
  return [import_rxjs41.EMPTY];
2460
2615
  }
2461
2616
  var bcName = action.payload.bcName;
2462
2617
  var bc = state.screen.bo.bc[bcName];
2463
- var cursor = bc.cursor, page = bc.page;
2464
- var limit = ((_b = widgets.find(function (i) { return i.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.limit) || bc.limit;
2618
+ var cursor = bc.cursor, _l = bc.page, page = _l === void 0 ? 1 : _l;
2619
+ 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;
2465
2620
  var sorters = state.screen.sorters[bcName];
2466
2621
  if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {
2467
2622
  return [import_rxjs41.EMPTY];
2468
2623
  }
2469
- var anyHierarchyWidget = widgets.find(function (item) {
2624
+ var anyHierarchyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.find(function (item) {
2470
2625
  return item.bcName === widget.bcName && item.type === import_schema14.WidgetTypes.AssocListPopup && isHierarchyWidget(item);
2471
2626
  });
2472
- var fullHierarchyWidget = state.view.widgets.find(function (item) {
2627
+ var fullHierarchyWidget = (_d = state.view.widgets) === null || _d === void 0 ? void 0 : _d.find(function (item) {
2473
2628
  var _a;
2474
2629
  return item.bcName === widget.bcName && item.type === import_schema14.WidgetTypes.AssocListPopup && ((_a = item.options) === null || _a === void 0 ? void 0 : _a.hierarchyFull);
2475
2630
  });
2476
- var limitBySelfCursor = (_c = state.router.bcPath) === null || _c === void 0 ? void 0 : _c.includes("".concat(bcName, "/").concat(cursor));
2631
+ var limitBySelfCursor = (_e = state.router.bcPath) === null || _e === void 0 ? void 0 : _e.includes("".concat(bcName, "/").concat(cursor));
2477
2632
  var bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
2478
2633
  var fetchParams = __assign(__assign({ _page: page, _limit: limit }, getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || [])), getSorters(sorters));
2479
2634
  if (bcForceUpdate.match(action)) {
2480
- 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);
2635
+ 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);
2481
2636
  if (infinityPaginationWidget) {
2482
2637
  fetchParams._page = 1;
2483
2638
  fetchParams._limit = limit * page;
@@ -2487,7 +2642,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2487
2642
  fetchParams._page = action.payload.from || 1;
2488
2643
  fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit;
2489
2644
  }
2490
- 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)) {
2645
+ 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)) {
2491
2646
  fetchParams._limit = 0;
2492
2647
  }
2493
2648
  var canceler = api.createCanceler();
@@ -2499,7 +2654,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
2499
2654
  var normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe((0, import_rxjs41.mergeMap)(function (response) {
2500
2655
  var _a, _b;
2501
2656
  var cursorChange = getCursorChange(response.data, cursor, !!anyHierarchyWidget);
2502
- var parentOfNotLazyWidget = widgets.some(function (item) {
2657
+ var parentOfNotLazyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.some(function (item) {
2503
2658
  var _a;
2504
2659
  return ((_a = state.screen.bo.bc[item.bcName]) === null || _a === void 0 ? void 0 : _a.parentName) === bcName && !PopupWidgetTypes.includes(item.type);
2505
2660
  });
@@ -2559,7 +2714,8 @@ var bcDeleteDataEpic = function (action$, store$, _a) {
2559
2714
  var context = { widgetName: action.payload.widgetName };
2560
2715
  var isTargetFormatPVF = state.view.pendingValidationFailsFormat === "target" /* target */;
2561
2716
  return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe((0, import_rxjs42.mergeMap)(function (data) {
2562
- var postInvoke = data.postActions[0];
2717
+ var _a;
2718
+ var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
2563
2719
  return (0, import_rxjs42.concat)(isTargetFormatPVF ? (0, import_rxjs42.of)(bcCancelPendingChanges({ bcNames: [bcName] })) : import_rxjs42.EMPTY, (0, import_rxjs42.of)(bcFetchDataRequest({ bcName: bcName, widgetName: widgetName })), postInvoke ? (0, import_rxjs42.of)(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: widgetName })) : import_rxjs42.EMPTY);
2564
2720
  }), (0, import_rxjs42.catchError)(function (error) {
2565
2721
  console.error(error);
@@ -2608,19 +2764,19 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe((0,
2608
2764
  fields: widget.fields
2609
2765
  };
2610
2766
  var hierarchy = (_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchy;
2611
- var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
2767
+ var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
2612
2768
  var hierarchyGroupSelection = (_c = widget.options) === null || _c === void 0 ? void 0 : _c.hierarchyGroupSelection;
2613
2769
  var hierarchyTraverse = (_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyTraverse;
2614
- var childrenBc = hierarchy.slice(hierarchy.findIndex(function (item) { return item.bcName === action.payload.bcName; }) + 1).map(function (item) { return item.bcName; });
2770
+ 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; });
2615
2771
  if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {
2616
2772
  result.push((0, import_rxjs44.of)(dropAllAssociations({
2617
2773
  bcNames: childrenBc
2618
2774
  })));
2619
2775
  }
2620
- var parent = isRoot ? null : hierarchy.find(function (item, index) {
2776
+ var parent = isRoot ? null : (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item, index) {
2621
2777
  var _a;
2622
2778
  return ((_a = hierarchy[index + 1]) === null || _a === void 0 ? void 0 : _a.bcName) === action.payload.bcName;
2623
- }) || rootHierarchyDescriptor;
2779
+ })) || rootHierarchyDescriptor;
2624
2780
  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; });
2625
2781
  if (parent && hierarchyTraverse && selected) {
2626
2782
  if (hierarchyDescriptor.radio) {
@@ -2631,7 +2787,7 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe((0,
2631
2787
  result.push((0, import_rxjs44.of)(changeAssociation({
2632
2788
  bcName: parent.bcName,
2633
2789
  widgetName: action.payload.widgetName,
2634
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
2790
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
2635
2791
  assocValueKey: action.payload.assocValueKey
2636
2792
  })));
2637
2793
  }
@@ -2678,7 +2834,8 @@ var bcCancelCreateDataEpic = function (action$, state$, _a) {
2678
2834
  var params = { _action: action.payload.operationType };
2679
2835
  var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
2680
2836
  return api.customAction(screenName, bcUrl, data, context, params).pipe((0, import_rxjs45.mergeMap)(function (response) {
2681
- var postInvoke = response.postActions[0];
2837
+ var _a;
2838
+ var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
2682
2839
  return (0, import_rxjs45.concat)((0, import_rxjs45.of)(sendOperationSuccess({ bcName: bcName, cursor: cursor })), (0, import_rxjs45.of)(bcChangeCursors({ cursorsMap: cursorsMap })), postInvoke ? (0, import_rxjs45.of)(processPostInvoke({ bcName: bcName, postInvoke: postInvoke, cursor: cursor, widgetName: context.widgetName })) : import_rxjs45.EMPTY);
2683
2840
  }), (0, import_rxjs45.catchError)(function (error) {
2684
2841
  console.error(error);
@@ -2714,21 +2871,21 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe((
2714
2871
  var removedItem = data.find(function (item) { return item.id === action.payload.removedItem.id; });
2715
2872
  var associated = action.payload.dataItem.map(function (item) { return item.id; });
2716
2873
  var removedNodes = [];
2717
- if ((_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
2718
- if ((_e = widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
2874
+ if ((_d = widget === null || widget === void 0 ? void 0 : widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
2875
+ if ((_e = widget === null || widget === void 0 ? void 0 : widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
2719
2876
  data = assignTreeLinks(data);
2720
2877
  }
2721
- var removedItemChildren = data.filter(function (item) { return item.parentId === removedItem.id; });
2722
- removedNodes = __spreadArray([removedItem.id], removedItemChildren.filter(function (item) { return associated.includes(item.id); }).map(function (item) { return item.id; }), true);
2723
- if ((_f = widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
2878
+ var removedItemChildren = data.filter(function (item) { return item.parentId === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.id); });
2879
+ 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);
2880
+ if ((_f = widget === null || widget === void 0 ? void 0 : widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
2724
2881
  getDescendants(removedItemChildren, removedNodes);
2725
2882
  removedNodes = data.filter(function (item) { return removedNodes.includes(item.id) && associated.includes(item.id); }).map(function (item) { return item.id; });
2726
2883
  }
2727
- var parent_1 = data.find(function (item) { return item.id === removedItem.parentId; });
2884
+ var parent_1 = data.find(function (item) { return item.id === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.parentId); });
2728
2885
  var siblings = data.filter(function (item) { return item.parentId === (parent_1 === null || parent_1 === void 0 ? void 0 : parent_1.id); });
2729
2886
  var parentEmpty = siblings.every(function (child) { return removedNodes.includes(child.id) || !associated.includes(child.id); });
2730
2887
  if (parent_1 && parentEmpty) {
2731
- if ((_g = widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
2888
+ if ((_g = widget === null || widget === void 0 ? void 0 : widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
2732
2889
  var parentDescendants = [];
2733
2890
  getDescendants(siblings, parentDescendants);
2734
2891
  var parentDeepEmpty = parentDescendants.every(function (descendant) {
@@ -2743,7 +2900,7 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe((
2743
2900
  }
2744
2901
  }
2745
2902
  }
2746
- if ((_h = widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
2903
+ if ((_h = widget === null || widget === void 0 ? void 0 : widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
2747
2904
  return (0, import_rxjs47.of)(changeDataItem({
2748
2905
  bcName: bcName,
2749
2906
  bcUrl: buildBcUrl(bcName, true, state),
@@ -2751,8 +2908,8 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe((
2751
2908
  dataItem: (_a = {}, _a[associateFieldKey] = action.payload.dataItem.filter(function (item) { return !removedNodes.includes(item.id); }), _a)
2752
2909
  }));
2753
2910
  }
2754
- if ((_j = widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
2755
- 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) {
2911
+ if ((_j = widget === null || widget === void 0 ? void 0 : widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
2912
+ 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) {
2756
2913
  var _a;
2757
2914
  return (_a = state.view.pendingDataChanges[hierarchyData.bcName]) === null || _a === void 0 ? void 0 : _a[action.payload.removedItem.id];
2758
2915
  })) === null || _m === void 0 ? void 0 : _m.bcName) !== null && _o !== void 0 ? _o : bcName;
@@ -2791,11 +2948,12 @@ var import_rxjs48 = require("rxjs");
2791
2948
  var bcFetchRowMetaRequestEpic = function (action$, state$, _a) {
2792
2949
  var api = _a.api;
2793
2950
  return action$.pipe((0, import_rxjs48.filter)(bcFetchRowMeta.match), (0, import_rxjs48.mergeMap)(function (action) {
2951
+ var _a, _b;
2794
2952
  var state = state$.value;
2795
2953
  var screenName = state.screen.screenName;
2796
2954
  var bcName = action.payload.bcName;
2797
- var cursor = state.screen.bo.bc[bcName].cursor;
2798
- var bcUrl = buildBcUrl(bcName, true, state);
2955
+ var cursor = (_a = state.screen.bo.bc[bcName].cursor) !== null && _a !== void 0 ? _a : "";
2956
+ var bcUrl = (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "";
2799
2957
  var canceler = api.createCanceler();
2800
2958
  var cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }));
2801
2959
  var cancelByParentBc = cancelRequestEpic(action$, [bcSelectRecord], canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }), function (filteredAction) {
@@ -2872,7 +3030,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
2872
3030
  bcName: bcName,
2873
3031
  depth: parentDepth,
2874
3032
  widgetName: action.payload.widgetName,
2875
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[assocValueKey] }),
3033
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[assocValueKey] }),
2876
3034
  assocValueKey: assocValueKey
2877
3035
  })));
2878
3036
  }
@@ -2900,11 +3058,13 @@ var import_rxjs50 = require("rxjs");
2900
3058
  var saveAssociationsActiveEpic = function (action$, state$, _a) {
2901
3059
  var api = _a.api;
2902
3060
  return action$.pipe((0, import_rxjs50.filter)(saveAssociations.match), (0, import_rxjs50.filter)(function (action) {
2903
- return state$.value.view.popupData.active;
3061
+ var _a;
3062
+ return (_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active;
2904
3063
  }), (0, import_rxjs50.switchMap)(function (action) {
3064
+ var _a, _b;
2905
3065
  var state = state$.value;
2906
- var calleeBCName = state.view.popupData.calleeBCName;
2907
- var calleeWidgetName = state.view.popupData.calleeWidgetName;
3066
+ var calleeBCName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.calleeBCName;
3067
+ var calleeWidgetName = (_b = state.view.popupData) === null || _b === void 0 ? void 0 : _b.calleeWidgetName;
2908
3068
  var bcNames = action.payload.bcNames;
2909
3069
  var bcUrl = buildBcUrl(calleeBCName, true, state);
2910
3070
  var pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {};
@@ -2912,7 +3072,7 @@ var saveAssociationsActiveEpic = function (action$, state$, _a) {
2912
3072
  return api.associate(state.screen.screenName, bcUrl, Object.values(pendingChanges).filter(function (i) { return i._associate; }), params).pipe((0, import_rxjs50.mergeMap)(function (response) {
2913
3073
  var postInvoke = response.postActions[0];
2914
3074
  var calleeWidget = state.view.widgets.find(function (widgetItem) { return widgetItem.bcName === calleeBCName; });
2915
- return (0, import_rxjs50.concat)(postInvoke ? (0, import_rxjs50.of)(processPostInvoke({ bcName: calleeBCName, postInvoke: postInvoke, widgetName: calleeWidget.name })) : import_rxjs50.EMPTY, (0, import_rxjs50.of)(bcCancelPendingChanges({ bcNames: bcNames })), (0, import_rxjs50.of)(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
3075
+ return (0, import_rxjs50.concat)(postInvoke ? (0, import_rxjs50.of)(processPostInvoke({ bcName: calleeBCName, postInvoke: postInvoke, widgetName: calleeWidget === null || calleeWidget === void 0 ? void 0 : calleeWidget.name })) : import_rxjs50.EMPTY, (0, import_rxjs50.of)(bcCancelPendingChanges({ bcNames: bcNames })), (0, import_rxjs50.of)(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
2916
3076
  }), (0, import_rxjs50.catchError)(function (err) {
2917
3077
  console.error(err);
2918
3078
  return import_rxjs50.EMPTY;
@@ -2922,7 +3082,7 @@ var saveAssociationsActiveEpic = function (action$, state$, _a) {
2922
3082
  // src/epics/data/changeAssociationSameBcEpic.ts
2923
3083
  var import_rxjs51 = require("rxjs");
2924
3084
  var changeAssociationSameBcEpic = function (action$, state$) { return action$.pipe((0, import_rxjs51.filter)(changeAssociationSameBc.match), (0, import_rxjs51.mergeMap)(function (action) {
2925
- var _a, _b, _c, _d, _e;
3085
+ var _a, _b, _c, _d, _e, _f;
2926
3086
  var state = state$.value;
2927
3087
  var bcName = action.payload.bcName;
2928
3088
  var result = [
@@ -2939,14 +3099,14 @@ var changeAssociationSameBcEpic = function (action$, state$) { return action$.pi
2939
3099
  var widget = state.view.widgets.find(function (item) { return item.name === action.payload.widgetName; });
2940
3100
  var hierarchyTraverse = (_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchyTraverse;
2941
3101
  var currentData = depth > 1 ? (_b = state.depthData[depth]) === null || _b === void 0 ? void 0 : _b[bcName] : state.data[bcName];
2942
- 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;
2943
- 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;
3102
+ 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;
3103
+ 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;
2944
3104
  if (parentDepth && hierarchyTraverse && selected) {
2945
3105
  result.push((0, import_rxjs51.of)(changeAssociationSameBc({
2946
3106
  bcName: bcName,
2947
3107
  depth: parentDepth,
2948
3108
  widgetName: action.payload.widgetName,
2949
- dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[action.payload.assocValueKey] }),
3109
+ dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[action.payload.assocValueKey] }),
2950
3110
  assocValueKey: action.payload.assocValueKey
2951
3111
  })));
2952
3112
  }
@@ -2987,14 +3147,15 @@ var inlinePickListFetchDataEpic = function (action$, state$, _a) {
2987
3147
  // src/epics/data/saveAssociationsPassiveEpic.ts
2988
3148
  var import_rxjs53 = require("rxjs");
2989
3149
  var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pipe((0, import_rxjs53.filter)(saveAssociations.match), (0, import_rxjs53.filter)(function () {
2990
- return !state$.value.view.popupData.active;
3150
+ var _a;
3151
+ return !((_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active);
2991
3152
  }), (0, import_rxjs53.switchMap)(function (action) {
2992
3153
  var _a, _b;
2993
- var _c;
3154
+ var _c, _d;
2994
3155
  var state = state$.value;
2995
- 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;
3156
+ 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;
2996
3157
  var cursor = state.screen.bo.bc[calleeBCName].cursor;
2997
- var recordPrevData = (_c = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _c !== void 0 ? _c : [];
3158
+ var recordPrevData = (_d = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _d !== void 0 ? _d : [];
2998
3159
  var newValues = [];
2999
3160
  action.payload.bcNames.forEach(function (pendingBc) {
3000
3161
  var pendingChanges = state.view.pendingDataChanges[pendingBc] || {};
@@ -3101,7 +3262,6 @@ var ObservableApiWrapper = /** @class */ (function () {
3101
3262
  this.instance = instance;
3102
3263
  }
3103
3264
  class_2.prototype.get = function (path, config, callContext) {
3104
- if (config === void 0) { config = {}; }
3105
3265
  return (0, import_rxjs57.from)(this.instance.get(path, config)).pipe((0, import_rxjs57.takeWhile)(redirectOccurred), (0, import_rxjs57.map)(function (response) { return response.data; }));
3106
3266
  };
3107
3267
  class_2.prototype.put = function (path, data, callContext) {
@@ -3120,7 +3280,6 @@ var import_axios3 = __toESM(require("axios"));
3120
3280
  var import_rxjs58 = require("rxjs");
3121
3281
  var Api = /** @class */ (function () {
3122
3282
  function class_3(instance) {
3123
- this.api$ = new ObservableApiWrapper();
3124
3283
  this.api$ = new ObservableApiWrapper(instance);
3125
3284
  }
3126
3285
  class_3.prototype.routerRequest = function (path, params) {
@@ -3145,23 +3304,24 @@ var Api = /** @class */ (function () {
3145
3304
  };
3146
3305
  class_3.prototype.fetchRowMeta = function (screenName, bcUrl, params, cancelToken) {
3147
3306
  var url = applyParams(buildUrl(__makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"]), screenName) + bcUrl, params);
3148
- return this.api$.get(url, { cancelToken: cancelToken }).pipe((0, import_rxjs58.map)(function (response) { return response.data.row; }));
3307
+ return this.api$.get(url, { cancelToken: cancelToken }).pipe((0, import_rxjs58.map)(function (response) { var _a; return (_a = response.data) === null || _a === void 0 ? void 0 : _a.row; }));
3149
3308
  };
3150
3309
  class_3.prototype.newBcData = function (screenName, bcUrl, context, params) {
3151
3310
  var url = applyParams(buildUrl(__makeTemplateObject(["row-meta-new/", "/"], ["row-meta-new/", "/"]), screenName) + bcUrl, params);
3152
- return this.api$.get(url, null, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3311
+ return this.api$.get(url, void 0, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3153
3312
  };
3154
3313
  class_3.prototype.saveBcData = function (screenName, bcUrl, data, context, params) {
3155
3314
  var url = applyParams(buildUrl(__makeTemplateObject(["data/", "/"], ["data/", "/"]), screenName) + bcUrl, params);
3156
3315
  return this.api$.put(url, { data: data }, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3157
3316
  };
3158
3317
  class_3.prototype.deleteBcData = function (screenName, bcUrl, context, params) {
3318
+ if (bcUrl === void 0) { bcUrl = ""; }
3159
3319
  var url = applyParams(buildUrl(__makeTemplateObject(["data/", "/"], ["data/", "/"]), screenName) + bcUrl, params);
3160
3320
  return this.api$.delete(url, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3161
3321
  };
3162
3322
  class_3.prototype.customAction = function (screenName, bcUrl, data, context, params) {
3163
3323
  var url = applyParams(buildUrl(__makeTemplateObject(["custom-action/", "/"], ["custom-action/", "/"]), screenName) + bcUrl, params);
3164
- return this.api$.post(url, { data: data || {} }, null, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3324
+ return this.api$.post(url, { data: data || {} }, void 0, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3165
3325
  };
3166
3326
  class_3.prototype.associate = function (screenName, bcUrl, data, params) {
3167
3327
  var processedData = Array.isArray(data) ? data.map(function (item) { return ({
@@ -3173,9 +3333,27 @@ var Api = /** @class */ (function () {
3173
3333
  return this.api$.post(url, processedData).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
3174
3334
  };
3175
3335
  class_3.prototype.getRmByForceActive = function (screenName, bcUrl, data, params) {
3176
- var url = applyParams(buildUrl(__makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"]), screenName) + bcUrl, params);
3336
+ var url = applyParams(buildUrl(__makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"]), screenName) + (bcUrl !== null && bcUrl !== void 0 ? bcUrl : ""), params);
3177
3337
  return this.api$.post(url, { data: data }).pipe((0, import_rxjs58.map)(function (response) { return response.data.row; }));
3178
3338
  };
3339
+ Object.defineProperty(class_3.prototype, "fileUploadEndpoint", {
3340
+ /**
3341
+ * Get Cxbox API file upload endpoint based on baseURL of axios instance
3342
+ *
3343
+ * Handles empty baseURL and trailing slash
3344
+ *
3345
+ * @returns File upload endpoint
3346
+ */
3347
+ get: function () {
3348
+ var instance = this.api$.instance;
3349
+ if (!instance.defaults.baseURL) {
3350
+ return "/file";
3351
+ }
3352
+ return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
3353
+ },
3354
+ enumerable: false,
3355
+ configurable: true
3356
+ });
3179
3357
  class_3.prototype.refreshMeta = function () {
3180
3358
  return this.api$.get(buildUrl(__makeTemplateObject(["bc-registry/refresh-meta"], ["bc-registry/refresh-meta"])));
3181
3359
  };
@@ -3194,4 +3372,241 @@ var Api = /** @class */ (function () {
3194
3372
  };
3195
3373
  return class_3;
3196
3374
  }());
3375
+ // src/utils/autosave.ts
3376
+ function autosaveRoutine(action, store, next) {
3377
+ var _a, _b, _c;
3378
+ var state = store.getState();
3379
+ var dispatch = store.dispatch;
3380
+ var pendingDataChanges = state.view.pendingDataChanges;
3381
+ var bcList = Object.keys(pendingDataChanges);
3382
+ 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); });
3383
+ var baseBcName = bcList[baseBcNameIndex];
3384
+ if (baseBcNameIndex > -1) {
3385
+ bcList.splice(baseBcNameIndex, 1);
3386
+ }
3387
+ if (baseBcName) {
3388
+ bcList.forEach(function (bcName) {
3389
+ var _a, _b;
3390
+ var widget = (_a = state.view.widgets) === null || _a === void 0 ? void 0 : _a.find(function (v) { return v.bcName === bcName; });
3391
+ var cursor = (_b = state.screen.bo.bc[bcName]) === null || _b === void 0 ? void 0 : _b.cursor;
3392
+ if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {
3393
+ dispatch(sendOperation({
3394
+ bcName: bcName,
3395
+ operationType: import_schema5.OperationTypeCrud.save,
3396
+ widgetName: widget === null || widget === void 0 ? void 0 : widget.name
3397
+ }));
3398
+ }
3399
+ });
3400
+ var baseWidget = (_c = state.view.widgets) === null || _c === void 0 ? void 0 : _c.find(function (v) { return v.bcName === baseBcName; });
3401
+ return next(sendOperation({
3402
+ bcName: baseBcName,
3403
+ operationType: import_schema5.OperationTypeCrud.save,
3404
+ widgetName: baseWidget === null || baseWidget === void 0 ? void 0 : baseWidget.name,
3405
+ onSuccessAction: action
3406
+ }));
3407
+ }
3408
+ return next(action);
3409
+ }
3410
+ function bcHasPendingAutosaveChanges(store, bcName, cursor) {
3411
+ var _a;
3412
+ var pendingChanges = store.view.pendingDataChanges;
3413
+ var cursorChanges = (_a = pendingChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
3414
+ var result = cursorChanges && !Object.keys(cursorChanges).includes("_associate") && Object.values(cursorChanges).length > 0;
3415
+ return result;
3416
+ }
3417
+ function checkUnsavedChangesOfBc(store, bcName) {
3418
+ var _a, _b;
3419
+ var pendingCursors = Object.keys((_b = (_a = store.view.pendingDataChanges) === null || _a === void 0 ? void 0 : _a[bcName]) !== null && _b !== void 0 ? _b : {});
3420
+ return pendingCursors.some(function (cursor) { return bcHasPendingAutosaveChanges(store, bcName, cursor); });
3421
+ }
3422
+ // src/middlewares/autosaveMiddleware.ts
3423
+ var saveFormMiddleware = function (_a) {
3424
+ var getState = _a.getState, dispatch = _a.dispatch;
3425
+ return function (next) { return function (action) {
3426
+ var _a, _b, _c, _d, _e, _f, _g;
3427
+ var state = getState();
3428
+ var isSendOperation = sendOperation.match(action);
3429
+ var isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType);
3430
+ var isSelectTableCellInit = selectTableCellInit.match(action);
3431
+ var isSaveAction = isSendOperation && action.payload.operationType === import_schema5.OperationTypeCrud.save;
3432
+ var isNotSaveAction = !isSaveAction;
3433
+ var actionBcName = isSendOperation && action.payload.bcName;
3434
+ var hasAnotherUnsavedBc = Object.keys(state.view.pendingDataChanges).filter(function (key) { return key !== actionBcName; }).filter(function (key) { return checkUnsavedChangesOfBc(state, key); }).length > 0;
3435
+ var isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc;
3436
+ var selectedCell = state.view.selectedCell;
3437
+ var isSelectTableCellInitOnAnotherRowOrWidget = selectedCell && isSelectTableCellInit && (selectedCell.widgetName !== action.payload.widgetName || selectedCell.rowId !== action.payload.rowId);
3438
+ 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; });
3439
+ 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;
3440
+ 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];
3441
+ var isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0;
3442
+ if (isChangeLocation) {
3443
+ return next(sendOperation({
3444
+ bcName: defaultSaveWidget.bcName,
3445
+ operationType: ((_g = defaultSaveWidget.options) === null || _g === void 0 ? void 0 : _g.actionGroups).defaultSave,
3446
+ widgetName: defaultSaveWidget.name,
3447
+ onSuccessAction: action
3448
+ }));
3449
+ }
3450
+ var isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableCellInitOnAnotherRowOrWidget);
3451
+ if (isNeedSaveCondition) {
3452
+ return autosaveRoutine(action, { getState: getState, dispatch: dispatch }, next);
3453
+ }
3454
+ return next(action);
3455
+ }; };
3456
+ };
3457
+ // src/middlewares/requiredFieldsMiddleware.ts
3458
+ var requiredFields = function (_a) {
3459
+ var getState = _a.getState, dispatch = _a.dispatch;
3460
+ return function (next) { return function (action) {
3461
+ var _a, _b, _c, _d;
3462
+ var state = getState();
3463
+ if (sendOperation.match(action)) {
3464
+ var _e = action.payload, bcName = _e.bcName, operationType = _e.operationType, widgetName_1 = _e.widgetName;
3465
+ var cursor_1 = (_a = state.screen.bo.bc[bcName]) === null || _a === void 0 ? void 0 : _a.cursor;
3466
+ if (cursor_1) {
3467
+ var bcUrl = buildBcUrl(bcName, true, state);
3468
+ var record = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (item) { return item.id === cursor_1; });
3469
+ var rowMeta_1 = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
3470
+ var pendingValues = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[cursor_1];
3471
+ var widget_1 = state.view.widgets.find(function (item) { return item.name === widgetName_1; });
3472
+ if (operationRequiresAutosave(operationType, rowMeta_1 === null || rowMeta_1 === void 0 ? void 0 : rowMeta_1.actions)) {
3473
+ var fieldsToCheck_1 = {};
3474
+ state.view.widgets.filter(function (item) { return item.bcName === (widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.bcName); }).forEach(function (item) {
3475
+ var itemFieldsCalc = item.fields;
3476
+ if (item.fields) {
3477
+ item.fields.forEach(function (block) {
3478
+ if (isWidgetFieldBlock(block)) {
3479
+ block.fields.forEach(function (field) { return itemFieldsCalc.push(field); });
3480
+ }
3481
+ });
3482
+ }
3483
+ itemFieldsCalc.forEach(function (widgetField) {
3484
+ var _a;
3485
+ 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; });
3486
+ if (!fieldsToCheck_1[widgetField.key] && matchingRowMeta && !matchingRowMeta.hidden) {
3487
+ fieldsToCheck_1[widgetField.key] = matchingRowMeta;
3488
+ }
3489
+ });
3490
+ });
3491
+ var dataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck_1));
3492
+ if (dataItem && TableLikeWidgetTypes.includes(widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.type)) {
3493
+ dispatch(selectTableCellInit({ widgetName: widgetName_1, rowId: cursor_1, fieldKey: Object.keys(dataItem)[0] }));
3494
+ }
3495
+ return dataItem ? next(changeDataItem({ bcName: bcName, bcUrl: buildBcUrl(bcName, true, state), cursor: cursor_1, dataItem: dataItem })) : next(action);
3496
+ }
3497
+ if (hasPendingValidationFails(state, bcName)) {
3498
+ return addNotification({
3499
+ key: "requiredFieldsMissing",
3500
+ type: "buttonWarningNotification",
3501
+ message: "Required fields are missing",
3502
+ duration: 0,
3503
+ options: {
3504
+ buttonWarningNotificationOptions: {
3505
+ buttonText: "Cancel changes",
3506
+ actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]
3507
+ }
3508
+ }
3509
+ });
3510
+ }
3511
+ }
3512
+ }
3513
+ return next(action);
3514
+ }; };
3515
+ };
3516
+ function operationRequiresAutosave(operationType, actions) {
3517
+ var result = false;
3518
+ if (!actions) {
3519
+ console.error('rowMeta is missing in the middle of "sendOperation" action');
3520
+ return result;
3521
+ }
3522
+ result = flattenOperations(actions).some(function (action) { return action.type === operationType && action.autoSaveBefore; });
3523
+ return result;
3524
+ }
3525
+ function getRequiredFieldsMissing(record, pendingChanges, fieldsMeta) {
3526
+ var result = {};
3527
+ fieldsMeta.forEach(function (field) {
3528
+ var value = record === null || record === void 0 ? void 0 : record[field.key];
3529
+ var pendingValue = pendingChanges === null || pendingChanges === void 0 ? void 0 : pendingChanges[field.key];
3530
+ var effectiveValue = pendingValue !== void 0 ? pendingValue : value;
3531
+ var falsyValue = false;
3532
+ if (effectiveValue === null || effectiveValue === void 0 || effectiveValue === "") {
3533
+ falsyValue = true;
3534
+ }
3535
+ else if (Array.isArray(effectiveValue) && !effectiveValue.length) {
3536
+ falsyValue = true;
3537
+ }
3538
+ else if (effectiveValue && typeof effectiveValue === "object" && !Object.keys(effectiveValue).length) {
3539
+ falsyValue = true;
3540
+ }
3541
+ if (field.required && falsyValue) {
3542
+ result[field.key] = Array.isArray(effectiveValue) ? [] : null;
3543
+ }
3544
+ });
3545
+ return Object.keys(result).length > 0 ? result : null;
3546
+ }
3547
+ function hasPendingValidationFails(store, bcName) {
3548
+ var _a;
3549
+ if (store.view.pendingValidationFailsFormat !== "target" /* target */ && store.view.pendingValidationFails && Object.keys(store.view.pendingValidationFails).length) {
3550
+ return true;
3551
+ }
3552
+ var checkResult = false;
3553
+ var bcPendingValidations = (_a = store.view.pendingValidationFails) === null || _a === void 0 ? void 0 : _a[bcName];
3554
+ var cursorsList = bcPendingValidations && Object.keys(bcPendingValidations);
3555
+ if (!cursorsList) {
3556
+ return false;
3557
+ }
3558
+ var i = 0;
3559
+ for (; i < cursorsList.length; i++) {
3560
+ if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {
3561
+ checkResult = true;
3562
+ break;
3563
+ }
3564
+ }
3565
+ return checkResult;
3566
+ }
3567
+ // src/middlewares/preInvokeMiddleware.ts
3568
+ var preInvokeAction = function (_a) {
3569
+ var getState = _a.getState;
3570
+ return function (next) { return function (action) {
3571
+ var _a, _b, _c;
3572
+ if (sendOperation.match(action)) {
3573
+ var state = getState();
3574
+ var _d = action.payload, operationType_1 = _d.operationType, widgetName_2 = _d.widgetName, confirm = _d.confirm;
3575
+ var bcName = (_a = state.view.widgets.find(function (widgetItem) { return widgetItem.name === widgetName_2; })) === null || _a === void 0 ? void 0 : _a.bcName;
3576
+ var bcUrl = buildBcUrl(bcName, true, state);
3577
+ var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
3578
+ var actions = rowMeta && flattenOperations(rowMeta.actions);
3579
+ 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;
3580
+ return preInvoke && !confirm ? next(processPreInvoke({
3581
+ bcName: bcName,
3582
+ operationType: operationType_1,
3583
+ widgetName: widgetName_2,
3584
+ preInvoke: preInvoke
3585
+ })) : next(action);
3586
+ }
3587
+ return next(action);
3588
+ }; };
3589
+ };
3590
+ // src/middlewares/popupMiddleware.ts
3591
+ var popupMiddleware = function (_a) {
3592
+ var getState = _a.getState;
3593
+ return function (next) { return function (action) {
3594
+ var _a, _b, _c;
3595
+ if (showViewPopup.match(action)) {
3596
+ var state = getState();
3597
+ var bcName_1 = action.payload.bcName;
3598
+ 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;
3599
+ var assocValueKey = (_c = action.payload.assocValueKey) !== null && _c !== void 0 ? _c : widgetValueKey;
3600
+ return widgetValueKey ? next(showViewPopup(__assign(__assign({}, action.payload), { assocValueKey: assocValueKey }))) : next(action);
3601
+ }
3602
+ return next(action);
3603
+ }; };
3604
+ };
3605
+ // src/middlewares/index.ts
3606
+ var middlewares = {
3607
+ autosave: saveFormMiddleware,
3608
+ requiredFields: requiredFields,
3609
+ preInvoke: preInvokeAction,
3610
+ popup: popupMiddleware
3611
+ };
3197
3612
  //# sourceMappingURL=cxbox-ui-core.cjs.development.js.map