@cxbox-ui/core 1.37.2-alpha.1 → 1.37.2-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.d.ts +12 -17
- package/dist/api/ObservableApi.d.ts +10 -2
- package/dist/api/ObservableApiWrapper.d.ts +1 -1
- package/dist/cxbox-ui-core.cjs.development.js +649 -221
- package/dist/cxbox-ui-core.cjs.production.min.js +1 -1
- package/dist/cxbox-ui-core.esm.js +722 -286
- package/dist/cxbox-ui-core.modern.development.js +715 -285
- package/dist/cxbox-ui-core.modern.js +715 -285
- package/dist/cxbox-ui-core.modern.production.min.js +1 -1
- package/dist/epics/screen/apiErrorEpic.d.ts +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/interfaces/bc.d.ts +5 -4
- package/dist/interfaces/widget.d.ts +2 -1
- package/dist/middlewares/autosaveMiddleware.d.ts +2 -17
- package/dist/middlewares/index.d.ts +2 -12
- package/dist/middlewares/popupMiddleware.d.ts +2 -0
- package/dist/middlewares/preInvokeMiddleware.d.ts +2 -5
- package/dist/middlewares/requiredFieldsMiddleware.d.ts +3 -6
- package/dist/utils/api.d.ts +1 -10
- package/dist/utils/bc.d.ts +1 -1
- package/dist/utils/cancelRequestEpic.d.ts +1 -1
- package/dist/utils/combineMiddlewares.d.ts +1 -12
- package/dist/utils/filters.d.ts +2 -2
- package/dist/utils/strings.d.ts +2 -2
- package/package.json +2 -2
|
@@ -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
|
});
|
|
@@ -152,6 +153,8 @@ __export(actions_exports, {
|
|
|
152
153
|
processPreInvoke: function () { return processPreInvoke; },
|
|
153
154
|
refreshMeta: function () { return refreshMeta; },
|
|
154
155
|
refreshMetaAndReloadPage: function () { return refreshMetaAndReloadPage; },
|
|
156
|
+
refreshMetaDone: function () { return refreshMetaDone; },
|
|
157
|
+
refreshMetaFail: function () { return refreshMetaFail; },
|
|
155
158
|
removeMultivalueTag: function () { return removeMultivalueTag; },
|
|
156
159
|
removeNotifications: function () { return removeNotifications; },
|
|
157
160
|
removePendingRequest: function () { return removePendingRequest; },
|
|
@@ -202,7 +205,7 @@ var bcFetchRowMetaSuccess = (0, import_toolkit.createAction)("bcFetchRowMetaSucc
|
|
|
202
205
|
var bcFetchRowMetaFail = (0, import_toolkit.createAction)("bcFetchRowMetaFail");
|
|
203
206
|
var bcNewData = (0, import_toolkit.createAction)("bcNewData");
|
|
204
207
|
var bcNewDataSuccess = (0, import_toolkit.createAction)("bcNewDataSuccess");
|
|
205
|
-
var bcNewDataFail = (0, import_toolkit.createAction)("
|
|
208
|
+
var bcNewDataFail = (0, import_toolkit.createAction)("bcNewDataFail");
|
|
206
209
|
var bcDeleteDataFail = (0, import_toolkit.createAction)("bcDeleteDataFail");
|
|
207
210
|
var forceActiveChangeFail = (0, import_toolkit.createAction)("forceActiveChangeFail");
|
|
208
211
|
var sendOperation = (0, import_toolkit.createAction)("sendOperation");
|
|
@@ -217,7 +220,7 @@ var drillDown = (0, import_toolkit.createAction)("drillDown");
|
|
|
217
220
|
var bcChangeCursors = (0, import_toolkit.createAction)("bcChangeCursors");
|
|
218
221
|
var bcChangeDepthCursor = (0, import_toolkit.createAction)("bcChangeDepthCursor");
|
|
219
222
|
var changeDataItem = (0, import_toolkit.createAction)("changeDataItem");
|
|
220
|
-
var changeDataItems = (0, import_toolkit.createAction)("
|
|
223
|
+
var changeDataItems = (0, import_toolkit.createAction)("changeDataItems");
|
|
221
224
|
var forceActiveRmUpdate = (0, import_toolkit.createAction)("forceActiveRmUpdate");
|
|
222
225
|
var showViewPopup = (0, import_toolkit.createAction)("showViewPopup");
|
|
223
226
|
var showFileUploadPopup = (0, import_toolkit.createAction)("showFileUploadPopup");
|
|
@@ -271,6 +274,8 @@ var switchDebugMode = (0, import_toolkit.createAction)("switchDebugMode");
|
|
|
271
274
|
var exportState = (0, import_toolkit.createAction)("exportState");
|
|
272
275
|
var emptyAction = (0, import_toolkit.createAction)("emptyAction");
|
|
273
276
|
var refreshMeta = (0, import_toolkit.createAction)("refreshMeta");
|
|
277
|
+
var refreshMetaDone = (0, import_toolkit.createAction)("refreshMetaDone");
|
|
278
|
+
var refreshMetaFail = (0, import_toolkit.createAction)("refreshMetaFail");
|
|
274
279
|
var refreshMetaAndReloadPage = (0, import_toolkit.createAction)("refreshMetaAndReloadPage");
|
|
275
280
|
var switchRole = (0, import_toolkit.createAction)("switchRole");
|
|
276
281
|
var addPendingRequest = (0, import_toolkit.createAction)("addPendingRequest");
|
|
@@ -376,12 +381,14 @@ __export(interfaces_exports, {
|
|
|
376
381
|
OperationPostInvokeConfirmType: function () { return OperationPostInvokeConfirmType; },
|
|
377
382
|
OperationPostInvokeType: function () { return OperationPostInvokeType; },
|
|
378
383
|
OperationPreInvokeType: function () { return OperationPreInvokeType; },
|
|
379
|
-
OperationTypeCrud: function () { return
|
|
384
|
+
OperationTypeCrud: function () { return import_schema5.OperationTypeCrud; },
|
|
380
385
|
PaginationMode: function () { return PaginationMode; },
|
|
381
386
|
PendingValidationFailsFormat: function () { return PendingValidationFailsFormat; },
|
|
382
387
|
PopupWidgetTypes: function () { return PopupWidgetTypes; },
|
|
388
|
+
PositionTypes: function () { return import_schema4.PositionTypes; },
|
|
383
389
|
RouteType: function () { return RouteType; },
|
|
384
390
|
TableLikeWidgetTypes: function () { return TableLikeWidgetTypes; },
|
|
391
|
+
WidgetTypes: function () { return import_schema4.WidgetTypes; },
|
|
385
392
|
coreOperations: function () { return coreOperations; },
|
|
386
393
|
isCustomWidget: function () { return isCustomWidget; },
|
|
387
394
|
isCustomWidgetConfiguration: function () { return isCustomWidgetConfiguration; },
|
|
@@ -424,6 +431,7 @@ var ApplicationErrorType = /* @__PURE__ */ (function (ApplicationErrorType2) {
|
|
|
424
431
|
})(ApplicationErrorType || {});
|
|
425
432
|
// src/interfaces/widget.ts
|
|
426
433
|
var import_schema3 = require("@cxbox-ui/schema");
|
|
434
|
+
var import_schema4 = require("@cxbox-ui/schema");
|
|
427
435
|
var TableLikeWidgetTypes = [
|
|
428
436
|
import_schema3.WidgetTypes.List,
|
|
429
437
|
import_schema3.WidgetTypes.DataGrid,
|
|
@@ -448,14 +456,14 @@ var PaginationMode = /* @__PURE__ */ (function (PaginationMode2) {
|
|
|
448
456
|
return PaginationMode2;
|
|
449
457
|
})(PaginationMode || {});
|
|
450
458
|
// src/interfaces/operation.ts
|
|
451
|
-
var
|
|
459
|
+
var import_schema5 = require("@cxbox-ui/schema");
|
|
452
460
|
var coreOperations = [
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
461
|
+
import_schema5.OperationTypeCrud.create,
|
|
462
|
+
import_schema5.OperationTypeCrud.save,
|
|
463
|
+
import_schema5.OperationTypeCrud.delete,
|
|
464
|
+
import_schema5.OperationTypeCrud.associate,
|
|
465
|
+
import_schema5.OperationTypeCrud.cancelCreate,
|
|
466
|
+
import_schema5.OperationTypeCrud.fileUpload
|
|
459
467
|
];
|
|
460
468
|
function isOperationGroup(operation) {
|
|
461
469
|
return Array.isArray(operation.actions);
|
|
@@ -506,6 +514,15 @@ function isViewNavigationCategory(item) {
|
|
|
506
514
|
function isViewNavigationGroup(item) {
|
|
507
515
|
return !!item && "child" in item && !("categoryName" in item);
|
|
508
516
|
}
|
|
517
|
+
// src/reducers/router.ts
|
|
518
|
+
var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
|
|
519
|
+
var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
|
|
520
|
+
state = __assign(__assign({}, state), action.payload);
|
|
521
|
+
}).addCase(changeLocation, function (state, action) {
|
|
522
|
+
state = __assign(__assign({}, state), action.payload.location);
|
|
523
|
+
}); };
|
|
524
|
+
// src/reducers/screen.ts
|
|
525
|
+
var import_schema6 = require("@cxbox-ui/schema");
|
|
509
526
|
// src/utils/index.ts
|
|
510
527
|
var utils_exports = {};
|
|
511
528
|
__export(utils_exports, {
|
|
@@ -526,7 +543,6 @@ __export(utils_exports, {
|
|
|
526
543
|
getBcChildren: function () { return getBcChildren; },
|
|
527
544
|
getDescendants: function () { return getDescendants; },
|
|
528
545
|
getFieldTitle: function () { return getFieldTitle; },
|
|
529
|
-
getFileUploadEndpoint: function () { return getFileUploadEndpoint; },
|
|
530
546
|
getFilterType: function () { return getFilterType; },
|
|
531
547
|
getFilters: function () { return getFilters; },
|
|
532
548
|
getSorters: function () { return getSorters; },
|
|
@@ -566,12 +582,6 @@ function applyRawParams(url, qso) {
|
|
|
566
582
|
var result = new URLSearchParams(qso).toString();
|
|
567
583
|
return "".concat(addTailControlSequences(url)).concat(result && "".concat(result));
|
|
568
584
|
}
|
|
569
|
-
function getFileUploadEndpoint(instance) {
|
|
570
|
-
if (!instance.defaults.baseURL) {
|
|
571
|
-
return "/file";
|
|
572
|
-
}
|
|
573
|
-
return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
|
|
574
|
-
}
|
|
575
585
|
// src/utils/strings.ts
|
|
576
586
|
function getTemplate(literals) {
|
|
577
587
|
var placeholders = [];
|
|
@@ -586,10 +596,9 @@ function getTemplate(literals) {
|
|
|
586
596
|
result += literals[literals.length - 1];
|
|
587
597
|
return result;
|
|
588
598
|
}
|
|
589
|
-
function buildBcUrl(bcName, includeSelf,
|
|
599
|
+
function buildBcUrl(bcName, includeSelf, state) {
|
|
590
600
|
if (includeSelf === void 0) { includeSelf = false; }
|
|
591
|
-
var
|
|
592
|
-
var bcMap = storeInstance.screen.bo.bc;
|
|
601
|
+
var bcMap = state.screen.bo.bc;
|
|
593
602
|
var bc = bcMap[bcName];
|
|
594
603
|
if (!bc) {
|
|
595
604
|
return null;
|
|
@@ -722,7 +731,7 @@ function defaultParseURL(url) {
|
|
|
722
731
|
}
|
|
723
732
|
return {
|
|
724
733
|
type: type,
|
|
725
|
-
path: path,
|
|
734
|
+
path: path.length !== 0 && !path.startsWith("/") ? "/".concat(path) : path,
|
|
726
735
|
params: params,
|
|
727
736
|
screenName: screenName,
|
|
728
737
|
viewName: viewName,
|
|
@@ -770,8 +779,9 @@ function getSorters(sorters) {
|
|
|
770
779
|
return result;
|
|
771
780
|
}
|
|
772
781
|
function parseFilters(defaultFilters) {
|
|
782
|
+
if (defaultFilters === void 0) { defaultFilters = ""; }
|
|
773
783
|
var result = [];
|
|
774
|
-
var urlParams = new URL(defaultFilters).searchParams;
|
|
784
|
+
var urlParams = new URL(defaultFilters, window.location.origin).searchParams;
|
|
775
785
|
urlParams.forEach(function (param) {
|
|
776
786
|
var _a = param.split("."), fieldName = _a[0], type = _a[1];
|
|
777
787
|
if (fieldName && type && urlParams.get(param)) {
|
|
@@ -801,7 +811,7 @@ function parseSorters(sorters) {
|
|
|
801
811
|
return null;
|
|
802
812
|
}
|
|
803
813
|
var result = [];
|
|
804
|
-
var dictionary = new URL(sorters).searchParams;
|
|
814
|
+
var dictionary = new URL(sorters, window.location.origin).searchParams;
|
|
805
815
|
Object.entries(dictionary).map(function (_a) {
|
|
806
816
|
var sort = _a[0], fieldKey = _a[1];
|
|
807
817
|
var _b = sort.split(".").slice(1), order = _b[0], direction = _b[1];
|
|
@@ -880,12 +890,13 @@ function getBcChildren(originBcName, widgets, bcMap) {
|
|
|
880
890
|
return childrenBcMap;
|
|
881
891
|
}
|
|
882
892
|
function getHierarchyChildBc(originBcName, hierarchyWidget) {
|
|
883
|
-
var
|
|
884
|
-
|
|
893
|
+
var _a, _b;
|
|
894
|
+
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; });
|
|
895
|
+
if (originBcName !== hierarchyWidget.bcName && !(nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.includes(originBcName))) {
|
|
885
896
|
return [];
|
|
886
897
|
}
|
|
887
|
-
var childHierarchyBcIndex = nestedBcNames.findIndex(function (item) { return item === originBcName; });
|
|
888
|
-
var childHierarchyBcName = nestedBcNames[childHierarchyBcIndex + 1];
|
|
898
|
+
var childHierarchyBcIndex = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames.findIndex(function (item) { return item === originBcName; });
|
|
899
|
+
var childHierarchyBcName = nestedBcNames === null || nestedBcNames === void 0 ? void 0 : nestedBcNames[childHierarchyBcIndex + 1];
|
|
889
900
|
return [childHierarchyBcName, hierarchyWidget.name];
|
|
890
901
|
}
|
|
891
902
|
function checkShowCondition(condition, cursor, data, pendingDataChanges) {
|
|
@@ -899,9 +910,9 @@ function checkShowCondition(condition, cursor, data, pendingDataChanges) {
|
|
|
899
910
|
if (!record) {
|
|
900
911
|
return false;
|
|
901
912
|
}
|
|
902
|
-
var actualValue = record === null || record === void 0 ? void 0 : record[params.fieldKey];
|
|
903
|
-
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];
|
|
904
|
-
return pendingValue !== void 0 ? pendingValue === params.value : actualValue === params.value;
|
|
913
|
+
var actualValue = record === null || record === void 0 ? void 0 : record[params === null || params === void 0 ? void 0 : params.fieldKey];
|
|
914
|
+
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];
|
|
915
|
+
return pendingValue !== void 0 ? pendingValue === (params === null || params === void 0 ? void 0 : params.value) : actualValue === (params === null || params === void 0 ? void 0 : params.value);
|
|
905
916
|
}
|
|
906
917
|
// src/utils/tree.ts
|
|
907
918
|
function assignTreeLinks(flat) {
|
|
@@ -909,6 +920,7 @@ function assignTreeLinks(flat) {
|
|
|
909
920
|
var map12 = {};
|
|
910
921
|
var orphans = [];
|
|
911
922
|
result.forEach(function (item) {
|
|
923
|
+
var _a, _b;
|
|
912
924
|
if (!item.parentId || item.parentId === "0") {
|
|
913
925
|
return;
|
|
914
926
|
}
|
|
@@ -927,7 +939,7 @@ function assignTreeLinks(flat) {
|
|
|
927
939
|
result[parentIndex].children = [item];
|
|
928
940
|
}
|
|
929
941
|
else {
|
|
930
|
-
result[parentIndex].children.push(item);
|
|
942
|
+
(_b = (_a = result[parentIndex]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.push(item);
|
|
931
943
|
}
|
|
932
944
|
});
|
|
933
945
|
if (orphans.length) {
|
|
@@ -1005,22 +1017,7 @@ function deleteUndefinedFromObject(obj) {
|
|
|
1005
1017
|
}
|
|
1006
1018
|
});
|
|
1007
1019
|
}
|
|
1008
|
-
// src/reducers/router.ts
|
|
1009
|
-
var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
|
|
1010
|
-
var createRouterReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(loginDone, function (state, action) {
|
|
1011
|
-
state = __assign(__assign({}, state), action.payload);
|
|
1012
|
-
}).addCase(changeLocation, function (state, action) {
|
|
1013
|
-
var _a = action.payload, url = _a.url, route = _a.route;
|
|
1014
|
-
if (url) {
|
|
1015
|
-
var path = new URL(url);
|
|
1016
|
-
state = __assign(__assign({}, state), defaultParseURL(path));
|
|
1017
|
-
}
|
|
1018
|
-
if (route !== null) {
|
|
1019
|
-
state = __assign(__assign({}, state), route);
|
|
1020
|
-
}
|
|
1021
|
-
}); };
|
|
1022
1020
|
// src/reducers/screen.ts
|
|
1023
|
-
var import_schema5 = require("@cxbox-ui/schema");
|
|
1024
1021
|
var initialScreenState = {
|
|
1025
1022
|
screenName: "",
|
|
1026
1023
|
bo: { activeBcName: "", bc: {} },
|
|
@@ -1030,12 +1027,13 @@ var initialScreenState = {
|
|
|
1030
1027
|
filters: {},
|
|
1031
1028
|
sorters: {}
|
|
1032
1029
|
};
|
|
1033
|
-
var operationsHandledLocally = [
|
|
1030
|
+
var operationsHandledLocally = [import_schema6.OperationTypeCrud.associate, import_schema6.OperationTypeCrud.fileUpload];
|
|
1034
1031
|
var createScreenReducerBuilderManager = function (initialState) { return new ReducerBuilderManager().addCase(selectScreen, function (state, action) {
|
|
1032
|
+
var _a, _b, _c, _d, _e;
|
|
1035
1033
|
var bcDictionary = {};
|
|
1036
1034
|
var bcSorters = {};
|
|
1037
1035
|
var bcFilters = {};
|
|
1038
|
-
action.payload.screen.meta.bo.bc.forEach(function (item) {
|
|
1036
|
+
(_a = action.payload.screen.meta) === null || _a === void 0 ? void 0 : _a.bo.bc.forEach(function (item) {
|
|
1039
1037
|
bcDictionary[item.name] = item;
|
|
1040
1038
|
var sorter = parseSorters(item.defaultSort);
|
|
1041
1039
|
var filter56 = parseFilters(item.defaultFilter);
|
|
@@ -1047,8 +1045,8 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
|
|
|
1047
1045
|
}
|
|
1048
1046
|
});
|
|
1049
1047
|
state.screenName = action.payload.screen.name;
|
|
1050
|
-
state.primaryView = action.payload.screen.meta.primary;
|
|
1051
|
-
state.views = action.payload.screen.meta.views;
|
|
1048
|
+
state.primaryView = (_c = (_b = action.payload.screen.meta) === null || _b === void 0 ? void 0 : _b.primary) !== null && _c !== void 0 ? _c : state.primaryView;
|
|
1049
|
+
state.views = (_e = (_d = action.payload.screen.meta) === null || _d === void 0 ? void 0 : _d.views) !== null && _e !== void 0 ? _e : state.views;
|
|
1052
1050
|
state.bo = { activeBcName: null, bc: bcDictionary };
|
|
1053
1051
|
state.sorters = __assign(__assign({}, state.sorters), bcSorters);
|
|
1054
1052
|
state.filters = __assign(__assign({}, state.filters), bcFilters);
|
|
@@ -1058,12 +1056,14 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
|
|
|
1058
1056
|
}).addCase(bcFetchDataRequest, function (state, action) {
|
|
1059
1057
|
state.bo.bc[action.payload.bcName].loading = true;
|
|
1060
1058
|
}).addCase(bcLoadMore, function (state, action) {
|
|
1059
|
+
var _a;
|
|
1061
1060
|
var currentBc = state.bo.bc[action.payload.bcName];
|
|
1062
|
-
currentBc.page
|
|
1061
|
+
currentBc.page = ((_a = currentBc.page) !== null && _a !== void 0 ? _a : 1) + 1;
|
|
1063
1062
|
currentBc.loading = true;
|
|
1064
1063
|
}).addCase(selectView, function (state, action) {
|
|
1064
|
+
var _a;
|
|
1065
1065
|
var newBcs = {};
|
|
1066
|
-
Array.from(new Set(action.payload.widgets.map(function (widget) { return widget.bcName; }))
|
|
1066
|
+
Array.from(new Set((_a = action.payload.widgets) === null || _a === void 0 ? void 0 : _a.map(function (widget) { return widget.bcName; }))
|
|
1067
1067
|
// БК которые есть на вьюхе
|
|
1068
1068
|
).filter(function (bcName) { return state.bo.bc[bcName]; }).forEach(function (bcName) {
|
|
1069
1069
|
newBcs[bcName] = __assign(__assign({}, state.bo.bc[bcName]), { page: 1 });
|
|
@@ -1075,9 +1075,10 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
|
|
|
1075
1075
|
currentBc.loading = false;
|
|
1076
1076
|
state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
|
|
1077
1077
|
}).addCase(bcFetchDataFail, function (state, action) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
state.
|
|
1078
|
+
var bcName = action.payload.bcName;
|
|
1079
|
+
if (Object.values(state.bo.bc).some(function (bc) { return bc.name === bcName; })) {
|
|
1080
|
+
state.bo.bc[bcName].loading = false;
|
|
1081
|
+
state.cachedBc[bcName] = action.payload.bcUrl;
|
|
1081
1082
|
}
|
|
1082
1083
|
}).addCase(sendOperation, function (state, action) {
|
|
1083
1084
|
if (!operationsHandledLocally.includes(action.payload.operationType)) {
|
|
@@ -1105,10 +1106,12 @@ var createScreenReducerBuilderManager = function (initialState) { return new Red
|
|
|
1105
1106
|
Object.assign(state.bo.bc, newCursors);
|
|
1106
1107
|
Object.assign(state.cachedBc, newCache);
|
|
1107
1108
|
}).addCase(bcChangeDepthCursor, function (state, action) {
|
|
1109
|
+
var _a;
|
|
1108
1110
|
if (action.payload.depth === 1) {
|
|
1109
1111
|
state.bo.bc[action.payload.bcName].cursor = action.payload.cursor;
|
|
1110
1112
|
}
|
|
1111
1113
|
else {
|
|
1114
|
+
state.bo.bc[action.payload.bcName].depthBc = (_a = state.bo.bc[action.payload.bcName].depthBc) !== null && _a !== void 0 ? _a : {};
|
|
1112
1115
|
state.bo.bc[action.payload.bcName].depthBc[action.payload.depth].cursor = action.payload.cursor;
|
|
1113
1116
|
}
|
|
1114
1117
|
}).addCase(bcSelectRecord, function (state, action) {
|
|
@@ -1193,9 +1196,11 @@ var createSessionReducerBuilderManager = function (initialState) { return new Re
|
|
|
1193
1196
|
}).addCase(switchDebugMode, function (state, action) {
|
|
1194
1197
|
state.debugMode = action.payload;
|
|
1195
1198
|
}).addCase(addPendingRequest, function (state, action) {
|
|
1196
|
-
|
|
1199
|
+
var _a;
|
|
1200
|
+
(_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.push(action.payload.request);
|
|
1197
1201
|
}).addCase(removePendingRequest, function (state, action) {
|
|
1198
|
-
|
|
1202
|
+
var _a;
|
|
1203
|
+
state.pendingRequests = (_a = state.pendingRequests) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return item.requestId !== action.payload.requestId; });
|
|
1199
1204
|
}).addCase(addNotification, function (state, action) {
|
|
1200
1205
|
state.notifications.push(action.payload);
|
|
1201
1206
|
}).addCase(removeNotifications, function (state, action) {
|
|
@@ -1203,7 +1208,7 @@ var createSessionReducerBuilderManager = function (initialState) { return new Re
|
|
|
1203
1208
|
state.notifications = state.notifications.filter(function (notification) { return !closingKeys.includes(notification.key); });
|
|
1204
1209
|
}); };
|
|
1205
1210
|
// src/reducers/view.ts
|
|
1206
|
-
var
|
|
1211
|
+
var import_schema7 = require("@cxbox-ui/schema");
|
|
1207
1212
|
var initialViewState = {
|
|
1208
1213
|
id: void 0,
|
|
1209
1214
|
name: null,
|
|
@@ -1238,16 +1243,19 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1238
1243
|
}
|
|
1239
1244
|
state.infiniteWidgets = Array.from(new Set(infiniteWidgets));
|
|
1240
1245
|
}).addCase(sendOperation, function (state, action) {
|
|
1241
|
-
if (action.payload.operationType ===
|
|
1246
|
+
if (action.payload.operationType === import_schema7.OperationTypeCrud.create) {
|
|
1242
1247
|
state.metaInProgress[action.payload.bcName] = true;
|
|
1243
1248
|
}
|
|
1244
1249
|
}).addCase(bcFetchRowMetaSuccess, function (state, action) {
|
|
1250
|
+
var _a;
|
|
1251
|
+
state.rowMeta[action.payload.bcName] = (_a = state.rowMeta[action.payload.bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1245
1252
|
state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
|
|
1246
1253
|
state.metaInProgress[action.payload.bcName] = false;
|
|
1247
1254
|
}).addCase(bcNewDataSuccess, function (state, action) {
|
|
1248
1255
|
state.selectedCell = initialViewState.selectedCell;
|
|
1249
1256
|
}).addCase(forceActiveRmUpdate, function (state, action) {
|
|
1250
|
-
var _a
|
|
1257
|
+
var _a, _b, _c, _d;
|
|
1258
|
+
var _e = action.payload, bcName = _e.bcName, bcUrl = _e.bcUrl, currentRecordData = _e.currentRecordData, rowMeta = _e.rowMeta, cursor = _e.cursor;
|
|
1251
1259
|
var handledForceActive = {};
|
|
1252
1260
|
var rowMetaForcedValues = {};
|
|
1253
1261
|
var newPendingChangesDiff = {};
|
|
@@ -1270,17 +1278,21 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1270
1278
|
handledForceActive[key] = newPendingDataChanges[key];
|
|
1271
1279
|
}
|
|
1272
1280
|
});
|
|
1281
|
+
state.handledForceActive[bcName] = (_a = state.handledForceActive[bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1282
|
+
state.handledForceActive[bcName][cursor] = (_b = state.handledForceActive[bcName][cursor]) !== null && _b !== void 0 ? _b : {};
|
|
1273
1283
|
Object.assign(state.handledForceActive[bcName][cursor], handledForceActive);
|
|
1284
|
+
state.pendingDataChanges[bcName] = (_c = state.pendingDataChanges[bcName]) !== null && _c !== void 0 ? _c : {};
|
|
1274
1285
|
state.pendingDataChanges[bcName][cursor] = newPendingDataChanges;
|
|
1286
|
+
state.rowMeta[bcName] = (_d = state.rowMeta[bcName]) !== null && _d !== void 0 ? _d : {};
|
|
1275
1287
|
state.rowMeta[bcName][bcUrl] = rowMeta;
|
|
1276
1288
|
}).addCase(changeDataItem, function (state, action) {
|
|
1277
|
-
var _a;
|
|
1289
|
+
var _a, _b, _c;
|
|
1278
1290
|
var actionBcName = action.payload.bcName;
|
|
1279
1291
|
var prevBc = state.pendingDataChanges[action.payload.bcName] || {};
|
|
1280
1292
|
var prevCursor = prevBc[action.payload.cursor] || {};
|
|
1281
1293
|
var prevPending = prevCursor || {};
|
|
1282
1294
|
var nextPending = __assign(__assign({}, prevPending), action.payload.dataItem);
|
|
1283
|
-
var bcUrl =
|
|
1295
|
+
var bcUrl = action.payload.bcUrl;
|
|
1284
1296
|
var rowMeta = (_a = state.rowMeta[actionBcName]) === null || _a === void 0 ? void 0 : _a[bcUrl];
|
|
1285
1297
|
var nextValidationFails = {};
|
|
1286
1298
|
var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
@@ -1291,10 +1303,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1291
1303
|
nextValidationFails[fieldKey] = "This field is mandatory";
|
|
1292
1304
|
}
|
|
1293
1305
|
});
|
|
1306
|
+
state.pendingDataChanges[action.payload.bcName] = (_b = state.pendingDataChanges[action.payload.bcName]) !== null && _b !== void 0 ? _b : {};
|
|
1294
1307
|
state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending;
|
|
1295
1308
|
if (isTargetFormatPVF) {
|
|
1296
1309
|
;
|
|
1297
|
-
state.pendingValidationFails[actionBcName][action.payload.cursor] = nextValidationFails;
|
|
1310
|
+
((_c = state.pendingValidationFails) === null || _c === void 0 ? void 0 : _c[actionBcName])[action.payload.cursor] = nextValidationFails;
|
|
1298
1311
|
}
|
|
1299
1312
|
else {
|
|
1300
1313
|
state.pendingValidationFails = nextValidationFails;
|
|
@@ -1315,7 +1328,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1315
1328
|
pendingDataChanges[bcName] = pendingBcChanges;
|
|
1316
1329
|
});
|
|
1317
1330
|
var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1318
|
-
var pendingValidationFails = __assign({}, state.pendingValidationFails);
|
|
1331
|
+
var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
|
|
1319
1332
|
if (isTargetFormatPVF) {
|
|
1320
1333
|
action.payload.bcNames.forEach(function (i) {
|
|
1321
1334
|
pendingValidationFails[i] = {};
|
|
@@ -1330,7 +1343,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1330
1343
|
}).addCase(bcFetchRowMetaFail, function (state, action) {
|
|
1331
1344
|
state.metaInProgress[action.payload.bcName] = false;
|
|
1332
1345
|
}).addCase(forceActiveChangeFail, function (state, action) {
|
|
1333
|
-
var _a
|
|
1346
|
+
var _a;
|
|
1347
|
+
var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
|
|
1334
1348
|
var errors = {};
|
|
1335
1349
|
if (entityError) {
|
|
1336
1350
|
Object.entries(entityError.fields).forEach(function (_a) {
|
|
@@ -1338,9 +1352,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1338
1352
|
errors[fieldName] = violation;
|
|
1339
1353
|
});
|
|
1340
1354
|
}
|
|
1355
|
+
state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1341
1356
|
state.rowMeta[bcName][bcUrl].errors = errors;
|
|
1342
1357
|
}).addCase(bcSaveDataFail, function (state, action) {
|
|
1343
|
-
var _a
|
|
1358
|
+
var _a;
|
|
1359
|
+
var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
|
|
1344
1360
|
var errors = {};
|
|
1345
1361
|
if (entityError) {
|
|
1346
1362
|
Object.entries(entityError.fields).forEach(function (_a) {
|
|
@@ -1348,9 +1364,11 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1348
1364
|
errors[fieldName] = violation;
|
|
1349
1365
|
});
|
|
1350
1366
|
}
|
|
1367
|
+
state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1351
1368
|
state.rowMeta[bcName][bcUrl].errors = errors;
|
|
1352
1369
|
}).addCase(sendOperationFail, function (state, action) {
|
|
1353
|
-
var _a
|
|
1370
|
+
var _a;
|
|
1371
|
+
var _b = action.payload, bcName = _b.bcName, bcUrl = _b.bcUrl, entityError = _b.entityError;
|
|
1354
1372
|
var errors = {};
|
|
1355
1373
|
if (entityError) {
|
|
1356
1374
|
Object.entries(entityError.fields).forEach(function (_a) {
|
|
@@ -1358,30 +1376,38 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1358
1376
|
errors[fieldName] = violation;
|
|
1359
1377
|
});
|
|
1360
1378
|
}
|
|
1379
|
+
state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1361
1380
|
state.rowMeta[bcName][bcUrl].errors = errors;
|
|
1362
1381
|
}).addCase(sendOperationSuccess, function (state, action) {
|
|
1363
|
-
var _a
|
|
1382
|
+
var _a, _b, _c;
|
|
1383
|
+
var bcName = action.payload.bcName;
|
|
1384
|
+
var cursor = action.payload.cursor;
|
|
1364
1385
|
var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1386
|
+
state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1365
1387
|
state.pendingDataChanges[bcName][cursor] = {};
|
|
1366
1388
|
if (isTargetFormatPVF) {
|
|
1367
1389
|
;
|
|
1368
|
-
state.pendingValidationFails[bcName][cursor] = {};
|
|
1390
|
+
((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
|
|
1369
1391
|
}
|
|
1370
1392
|
else {
|
|
1371
1393
|
state.pendingValidationFails = initialViewState.pendingValidationFails;
|
|
1372
1394
|
}
|
|
1395
|
+
state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
|
|
1373
1396
|
state.handledForceActive[bcName][cursor] = {};
|
|
1374
1397
|
}).addCase(bcSaveDataSuccess, function (state, action) {
|
|
1375
|
-
var _a
|
|
1398
|
+
var _a, _b, _c;
|
|
1399
|
+
var _d = action.payload, bcName = _d.bcName, cursor = _d.cursor;
|
|
1376
1400
|
var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1401
|
+
state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) !== null && _a !== void 0 ? _a : {};
|
|
1377
1402
|
state.pendingDataChanges[bcName][cursor] = {};
|
|
1378
1403
|
if (isTargetFormatPVF) {
|
|
1379
1404
|
;
|
|
1380
|
-
state.pendingValidationFails[bcName][cursor] = {};
|
|
1405
|
+
((_b = state.pendingValidationFails) === null || _b === void 0 ? void 0 : _b[bcName])[cursor] = {};
|
|
1381
1406
|
}
|
|
1382
1407
|
else {
|
|
1383
1408
|
state.pendingValidationFails = initialViewState.pendingValidationFails;
|
|
1384
1409
|
}
|
|
1410
|
+
state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) !== null && _c !== void 0 ? _c : {};
|
|
1385
1411
|
state.handledForceActive[bcName][cursor] = {};
|
|
1386
1412
|
}).addCase(bcCancelPendingChanges, function (state, action) {
|
|
1387
1413
|
var _a, _b;
|
|
@@ -1392,7 +1418,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1392
1418
|
}
|
|
1393
1419
|
}
|
|
1394
1420
|
var isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1395
|
-
var pendingValidationFails = __assign({}, state.pendingValidationFails);
|
|
1421
|
+
var pendingValidationFails = state.pendingValidationFails ? __assign({}, state.pendingValidationFails) : {};
|
|
1396
1422
|
if (isTargetFormatPVF) {
|
|
1397
1423
|
if (((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.bcNames) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
1398
1424
|
action.payload.bcNames.forEach(function (i) {
|
|
@@ -1421,8 +1447,8 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1421
1447
|
isFilter: isFilter
|
|
1422
1448
|
};
|
|
1423
1449
|
}).addCase(showFileUploadPopup, function (state, action) {
|
|
1424
|
-
var _a;
|
|
1425
|
-
var bcName = (_a = state.widgets.find(function (item) { return item.name === action.payload.widgetName; })) === null ||
|
|
1450
|
+
var _a, _b;
|
|
1451
|
+
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;
|
|
1426
1452
|
state.popupData = {
|
|
1427
1453
|
type: "file-upload",
|
|
1428
1454
|
bcName: bcName,
|
|
@@ -1434,6 +1460,7 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1434
1460
|
}).addCase(viewClearPickMap, function (state) {
|
|
1435
1461
|
state.pickMap = null;
|
|
1436
1462
|
}).addCase(closeViewPopup, function (state) {
|
|
1463
|
+
state.popupData = {};
|
|
1437
1464
|
state.popupData.bcName = null;
|
|
1438
1465
|
}).addCase(selectTableCell, function (state, action) {
|
|
1439
1466
|
state.selectedCell = { widgetName: action.payload.widgetName, rowId: action.payload.rowId, fieldKey: action.payload.fieldKey };
|
|
@@ -1441,12 +1468,16 @@ var createViewReducerBuilderManager = function (initialState) { return new Reduc
|
|
|
1441
1468
|
state.pendingDataChanges = initialViewState.pendingDataChanges;
|
|
1442
1469
|
state.selectedCell = initialViewState.selectedCell;
|
|
1443
1470
|
}).addCase(showNotification, function (state, action) {
|
|
1471
|
+
var _a, _b;
|
|
1472
|
+
state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
|
|
1444
1473
|
state.systemNotifications.push({
|
|
1445
1474
|
type: action.payload.type,
|
|
1446
1475
|
message: action.payload.message,
|
|
1447
|
-
id: state.systemNotifications.length
|
|
1476
|
+
id: (_b = state.systemNotifications) === null || _b === void 0 ? void 0 : _b.length
|
|
1448
1477
|
});
|
|
1449
1478
|
}).addCase(closeNotification, function (state, action) {
|
|
1479
|
+
var _a;
|
|
1480
|
+
state.systemNotifications = (_a = state.systemNotifications) !== null && _a !== void 0 ? _a : [];
|
|
1450
1481
|
state.systemNotifications = state.systemNotifications.filter(function (item) { return item.id !== action.payload.id; });
|
|
1451
1482
|
}).addCase(showViewError, function (state, action) {
|
|
1452
1483
|
state.error = action.payload.error;
|
|
@@ -1494,7 +1525,6 @@ __export(epics_exports, {
|
|
|
1494
1525
|
httpError500Epic: function () { return httpError500Epic; },
|
|
1495
1526
|
httpErrorDefaultEpic: function () { return httpErrorDefaultEpic; },
|
|
1496
1527
|
inlinePickListFetchDataEpic: function () { return inlinePickListFetchDataEpic; },
|
|
1497
|
-
knownHttpErrors: function () { return knownHttpErrors; },
|
|
1498
1528
|
loginByAnotherRoleEpic: function () { return loginByAnotherRoleEpic; },
|
|
1499
1529
|
loginDoneEpic: function () { return loginDoneEpic; },
|
|
1500
1530
|
loginDoneSessionEpic: function () { return loginDoneSessionEpic; },
|
|
@@ -1555,7 +1585,7 @@ var sendOperationEpic = function (action$, state$, _a) {
|
|
|
1555
1585
|
var screenName = state.screen.screenName;
|
|
1556
1586
|
var _l = action.payload, bcName = _l.bcName, operationType = _l.operationType, widgetName = _l.widgetName;
|
|
1557
1587
|
var confirm = ((_a = action.payload.confirmOperation) === null || _a === void 0 ? void 0 : _a.type) || action.payload.confirm;
|
|
1558
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
1588
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
1559
1589
|
var bc = state.screen.bo.bc[bcName];
|
|
1560
1590
|
var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
|
|
1561
1591
|
var fields = rowMeta === null || rowMeta === void 0 ? void 0 : rowMeta.fields;
|
|
@@ -1563,7 +1593,7 @@ var sendOperationEpic = function (action$, state$, _a) {
|
|
|
1563
1593
|
var record = (_c = state.data[bcName]) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.id === bc.cursor; });
|
|
1564
1594
|
var filters = state.screen.filters[bcName];
|
|
1565
1595
|
var sorters = state.screen.sorters[bcName];
|
|
1566
|
-
var pendingRecordChange = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor];
|
|
1596
|
+
var pendingRecordChange = __assign({}, (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[bc.cursor]);
|
|
1567
1597
|
var _loop_2 = function (key) {
|
|
1568
1598
|
if (fields.find(function (item) { return item.key === key && item.disabled; })) {
|
|
1569
1599
|
delete pendingRecordChange[key];
|
|
@@ -1580,10 +1610,10 @@ var sendOperationEpic = function (action$, state$, _a) {
|
|
|
1580
1610
|
}
|
|
1581
1611
|
var context = { widgetName: action.payload.widgetName };
|
|
1582
1612
|
return api.customAction(screenName, bcUrl, data, context, params).pipe((0, import_rxjs2.mergeMap)(function (response) {
|
|
1583
|
-
var _a;
|
|
1584
|
-
var postInvoke = response.postActions[0];
|
|
1613
|
+
var _a, _b;
|
|
1614
|
+
var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
|
|
1585
1615
|
var preInvoke = response.preInvoke;
|
|
1586
|
-
return defaultSaveOperation ? ((
|
|
1616
|
+
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 })),
|
|
1587
1617
|
(0, import_rxjs2.of)(bcForceUpdate({ bcName: bcName }))], postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName), false));
|
|
1588
1618
|
}), (0, import_rxjs2.catchError)(function (e) {
|
|
1589
1619
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -1601,12 +1631,12 @@ var sendOperationEpic = function (action$, state$, _a) {
|
|
|
1601
1631
|
};
|
|
1602
1632
|
// src/epics/view/showAssocPopupEpic.ts
|
|
1603
1633
|
var import_rxjs3 = require("rxjs");
|
|
1604
|
-
var
|
|
1634
|
+
var import_schema8 = require("@cxbox-ui/schema");
|
|
1605
1635
|
var showAssocPopupEpic = function (action$, state$) { return action$.pipe((0, import_rxjs3.filter)(showViewPopup.match), (0, import_rxjs3.filter)(function (action) { return !!(action.payload.calleeBCName && action.payload.associateFieldKey); }), (0, import_rxjs3.mergeMap)(function (action) {
|
|
1606
1636
|
var _a, _b, _c, _d;
|
|
1607
1637
|
var _e = action.payload, bcName = _e.bcName, calleeBCName = _e.calleeBCName;
|
|
1608
1638
|
var state = state$.value;
|
|
1609
|
-
var assocWidget = state.view.widgets.find(function (widget) { return widget.bcName === bcName && widget.type ===
|
|
1639
|
+
var assocWidget = state.view.widgets.find(function (widget) { return widget.bcName === bcName && widget.type === import_schema8.WidgetTypes.AssocListPopup; });
|
|
1610
1640
|
var calleeCursor = (_a = state.screen.bo.bc[calleeBCName]) === null || _a === void 0 ? void 0 : _a.cursor;
|
|
1611
1641
|
var calleePendingChanges = (_b = state.view.pendingDataChanges[calleeBCName]) === null || _b === void 0 ? void 0 : _b[calleeCursor];
|
|
1612
1642
|
var assocFieldKey = action.payload.associateFieldKey;
|
|
@@ -1644,24 +1674,25 @@ var showAssocPopupEpic = function (action$, state$) { return action$.pipe((0, im
|
|
|
1644
1674
|
})); };
|
|
1645
1675
|
// src/epics/view/fileUploadConfirmEpic.ts
|
|
1646
1676
|
var import_rxjs4 = require("rxjs");
|
|
1647
|
-
var
|
|
1677
|
+
var import_schema9 = require("@cxbox-ui/schema");
|
|
1648
1678
|
var fileUploadConfirmEpic = function (action$, state$, _a) {
|
|
1649
1679
|
var api = _a.api;
|
|
1650
1680
|
return action$.pipe((0, import_rxjs4.filter)(bulkUploadFiles.match), (0, import_rxjs4.mergeMap)(function (action) {
|
|
1651
|
-
var _a;
|
|
1681
|
+
var _a, _b;
|
|
1652
1682
|
var state = state$.value;
|
|
1653
|
-
var bcName = state.view.popupData.bcName;
|
|
1654
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
1655
|
-
var widgetName = (
|
|
1683
|
+
var bcName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.bcName;
|
|
1684
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
1685
|
+
var widgetName = (_b = state.view.widgets.find(function (item) { return item.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.name;
|
|
1656
1686
|
var data = {
|
|
1657
1687
|
bulkIds: action.payload.fileIds
|
|
1658
1688
|
};
|
|
1659
1689
|
return api.customAction(state.screen.screenName, bcUrl, data, null, { _action: "file-upload-save" }).pipe((0, import_rxjs4.mergeMap)(function (response) {
|
|
1660
|
-
var
|
|
1690
|
+
var _a;
|
|
1691
|
+
var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
|
|
1661
1692
|
var preInvoke = response.preInvoke;
|
|
1662
1693
|
return (0, import_rxjs4.concat).apply(void 0, __spreadArray([(0, import_rxjs4.of)(sendOperationSuccess({ bcName: bcName, cursor: null })),
|
|
1663
1694
|
(0, import_rxjs4.of)(bcForceUpdate({ bcName: bcName })),
|
|
1664
|
-
(0, import_rxjs4.of)(closeViewPopup(null))], postOperationRoutine(widgetName, postInvoke, preInvoke,
|
|
1695
|
+
(0, import_rxjs4.of)(closeViewPopup(null))], postOperationRoutine(widgetName, postInvoke, preInvoke, import_schema9.OperationTypeCrud.save, bcName), false));
|
|
1665
1696
|
}));
|
|
1666
1697
|
}));
|
|
1667
1698
|
};
|
|
@@ -1673,28 +1704,28 @@ var selectTableCellInitEpic = function (action$, state$) { return action$.pipe((
|
|
|
1673
1704
|
var state = state$.value;
|
|
1674
1705
|
var _b = action.payload, nextRowId = _b.rowId, fieldKey = _b.fieldKey;
|
|
1675
1706
|
var nextWidget = state.view.widgets.find(function (widget) { return widget.name === action.payload.widgetName; });
|
|
1676
|
-
var nextBcName = nextWidget.bcName;
|
|
1707
|
+
var nextBcName = nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.bcName;
|
|
1677
1708
|
var nextBcCursor = (_a = state.screen.bo.bc[nextBcName]) === null || _a === void 0 ? void 0 : _a.cursor;
|
|
1678
1709
|
var selectedCell = state.view.selectedCell;
|
|
1679
1710
|
if (nextRowId !== nextBcCursor) {
|
|
1680
1711
|
resultObservables.push((0, import_rxjs5.of)(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })));
|
|
1681
1712
|
}
|
|
1682
|
-
if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || nextWidget.name !== selectedCell.widgetName) {
|
|
1683
|
-
resultObservables.push((0, import_rxjs5.of)(selectTableCell({ widgetName: nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
|
|
1713
|
+
if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || (nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name) !== selectedCell.widgetName) {
|
|
1714
|
+
resultObservables.push((0, import_rxjs5.of)(selectTableCell({ widgetName: nextWidget === null || nextWidget === void 0 ? void 0 : nextWidget.name, rowId: nextRowId, fieldKey: fieldKey })));
|
|
1684
1715
|
}
|
|
1685
1716
|
return (0, import_rxjs5.concat).apply(void 0, resultObservables);
|
|
1686
1717
|
})); };
|
|
1687
1718
|
// src/epics/view/showFileUploadPopupEpic.ts
|
|
1688
1719
|
var import_rxjs6 = require("rxjs");
|
|
1689
|
-
var
|
|
1690
|
-
var showFileUploadPopupEpic = function (action$, state$) { return action$.pipe((0, import_rxjs6.filter)(sendOperation.match), (0, import_rxjs6.filter)(function (action) { return matchOperationRole(
|
|
1720
|
+
var import_schema10 = require("@cxbox-ui/schema");
|
|
1721
|
+
var showFileUploadPopupEpic = function (action$, state$) { return action$.pipe((0, import_rxjs6.filter)(sendOperation.match), (0, import_rxjs6.filter)(function (action) { return matchOperationRole(import_schema10.OperationTypeCrud.fileUpload, action.payload, state$.value); }), (0, import_rxjs6.mergeMap)(function (action) {
|
|
1691
1722
|
var _a;
|
|
1692
1723
|
return (0, import_rxjs6.concat)((0, import_rxjs6.of)(bcChangeCursors({ cursorsMap: (_a = {}, _a[action.payload.bcName] = null, _a) })), (0, import_rxjs6.of)(showFileUploadPopup({ widgetName: action.payload.widgetName })));
|
|
1693
1724
|
})); };
|
|
1694
1725
|
// src/epics/view/sendOperationAssociateEpic.ts
|
|
1695
1726
|
var import_rxjs7 = require("rxjs");
|
|
1696
|
-
var
|
|
1697
|
-
var sendOperationAssociateEpic = function (action$, state$) { return action$.pipe((0, import_rxjs7.filter)(sendOperation.match), (0, import_rxjs7.filter)(function (action) { return matchOperationRole(
|
|
1727
|
+
var import_schema11 = require("@cxbox-ui/schema");
|
|
1728
|
+
var sendOperationAssociateEpic = function (action$, state$) { return action$.pipe((0, import_rxjs7.filter)(sendOperation.match), (0, import_rxjs7.filter)(function (action) { return matchOperationRole(import_schema11.OperationTypeCrud.associate, action.payload, state$.value); }), (0, import_rxjs7.map)(function (action) {
|
|
1698
1729
|
return showViewPopup({
|
|
1699
1730
|
// TODO: 2.0.0 bcKey and bcName will be removed in favor `widgetName`
|
|
1700
1731
|
bcName: action.payload.bcKey ? "".concat(action.payload.bcKey) : "".concat(action.payload.bcName, "Assoc"),
|
|
@@ -1705,7 +1736,7 @@ var sendOperationAssociateEpic = function (action$, state$) { return action$.pip
|
|
|
1705
1736
|
})); };
|
|
1706
1737
|
// src/epics/view/getRowMetaByForceActiveEpic.ts
|
|
1707
1738
|
var import_rxjs8 = require("rxjs");
|
|
1708
|
-
var
|
|
1739
|
+
var import_schema12 = require("@cxbox-ui/schema");
|
|
1709
1740
|
var import_toolkit2 = require("@reduxjs/toolkit");
|
|
1710
1741
|
var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
|
|
1711
1742
|
var api = _a.api;
|
|
@@ -1716,19 +1747,19 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
|
|
|
1716
1747
|
var _e = action.payload, bcName = _e.bcName, cursor = _e.cursor, disableRetry = _e.disableRetry;
|
|
1717
1748
|
var isBcHierarchy = state.view.widgets.some(function (widget) {
|
|
1718
1749
|
var _a, _b;
|
|
1719
|
-
return widget.bcName === bcName && widget.type ===
|
|
1750
|
+
return widget.bcName === bcName && widget.type === import_schema12.WidgetTypes.AssocListPopup && (((_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchySameBc) || ((_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchyFull));
|
|
1720
1751
|
});
|
|
1721
1752
|
if (isBcHierarchy) {
|
|
1722
1753
|
return import_rxjs8.EMPTY;
|
|
1723
1754
|
}
|
|
1724
|
-
var isPickListPopup = state.view.widgets.find(function (item) { var _a; return item.name === ((_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.widgetName) && [
|
|
1725
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
1755
|
+
var isPickListPopup = state.view.widgets.find(function (item) { var _a; return item.name === ((_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.widgetName) && [import_schema12.WidgetTypes.PickListPopup, import_schema12.WidgetTypes.FlatTreePopup].includes(item.type); });
|
|
1756
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
1726
1757
|
var pendingChanges = state.view.pendingDataChanges[bcName][cursor];
|
|
1727
1758
|
var handledForceActive = ((_a = state.view.handledForceActive[bcName]) === null || _a === void 0 ? void 0 : _a[cursor]) || {};
|
|
1728
1759
|
var currentRecordData = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (record) { return record.id === cursor; });
|
|
1729
1760
|
var fieldsRowMeta = (_d = (_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]) === null || _d === void 0 ? void 0 : _d.fields;
|
|
1730
1761
|
var changedFiledKey = null;
|
|
1731
|
-
var closePopup = (0, import_rxjs8.concat)((0, import_rxjs8.of)(
|
|
1762
|
+
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 })));
|
|
1732
1763
|
var someForceActiveChanged = fieldsRowMeta === null || fieldsRowMeta === void 0 ? void 0 : fieldsRowMeta.filter(function (field) { return field.forceActive && pendingChanges[field.key] !== void 0; }).some(function (field) {
|
|
1733
1764
|
var result = pendingChanges[field.key] !== handledForceActive[field.key];
|
|
1734
1765
|
if (result) {
|
|
@@ -1738,7 +1769,7 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
|
|
|
1738
1769
|
});
|
|
1739
1770
|
var requestId = (0, import_toolkit2.nanoid)();
|
|
1740
1771
|
if (someForceActiveChanged && !disableRetry) {
|
|
1741
|
-
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) {
|
|
1772
|
+
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) {
|
|
1742
1773
|
var result = [(0, import_rxjs8.of)(removePendingRequest({ requestId: requestId }))];
|
|
1743
1774
|
if (state.view.url === initUrl) {
|
|
1744
1775
|
result.push((0, import_rxjs8.of)(forceActiveRmUpdate({
|
|
@@ -1766,8 +1797,9 @@ var getRowMetaByForceActiveEpic = function (action$, state$, _a) {
|
|
|
1766
1797
|
}
|
|
1767
1798
|
return (0, import_rxjs8.concat)((0, import_rxjs8.of)(removePendingRequest({ requestId: requestId })), state.view.url === initUrl ? (0, import_rxjs8.concat)((0, import_rxjs8.of)(changeDataItem({
|
|
1768
1799
|
bcName: bcName,
|
|
1800
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
1769
1801
|
cursor: cursor,
|
|
1770
|
-
dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData[changedFiledKey], _a),
|
|
1802
|
+
dataItem: (_a = {}, _a[changedFiledKey] = currentRecordData === null || currentRecordData === void 0 ? void 0 : currentRecordData[changedFiledKey], _a),
|
|
1771
1803
|
disableRetry: true
|
|
1772
1804
|
})), (0, import_rxjs8.of)(forceActiveChangeFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError }))) : import_rxjs8.EMPTY);
|
|
1773
1805
|
})));
|
|
@@ -1780,9 +1812,14 @@ var import_rxjs9 = require("rxjs");
|
|
|
1780
1812
|
var showAllTableRecordsInitEpic = function (action$, state$) { return action$.pipe((0, import_rxjs9.filter)(showAllTableRecordsInit.match), (0, import_rxjs9.mergeMap)(function (action) {
|
|
1781
1813
|
var _a;
|
|
1782
1814
|
var resultObservables = [];
|
|
1783
|
-
var
|
|
1815
|
+
var _b = action.payload, bcName = _b.bcName, cursor = _b.cursor;
|
|
1816
|
+
var state = state$.value;
|
|
1817
|
+
var route = state.router;
|
|
1784
1818
|
resultObservables.push((0, import_rxjs9.of)(bcChangeCursors({ cursorsMap: (_a = {}, _a[bcName] = null, _a) })));
|
|
1819
|
+
var bcPath = route.bcPath.slice(0, route.bcPath.indexOf("".concat(bcName, "/").concat(cursor)));
|
|
1820
|
+
var url = defaultBuildURL(__assign(__assign({}, route), { bcPath: bcPath }));
|
|
1785
1821
|
resultObservables.push((0, import_rxjs9.of)(bcForceUpdate({ bcName: bcName })));
|
|
1822
|
+
resultObservables.push((0, import_rxjs9.of)(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })));
|
|
1786
1823
|
return (0, import_rxjs9.concat).apply(void 0, resultObservables);
|
|
1787
1824
|
})); };
|
|
1788
1825
|
// src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts
|
|
@@ -1806,8 +1843,108 @@ var clearPendingDataChangesAfterCursorChangeEpic = function (action$, state$) {
|
|
|
1806
1843
|
// src/epics/router/drilldownEpic.ts
|
|
1807
1844
|
var import_rxjs11 = require("rxjs");
|
|
1808
1845
|
var drillDownEpic = function (action$, state$) { return action$.pipe((0, import_rxjs11.filter)(drillDown.match), (0, import_rxjs11.switchMap)(function (action) {
|
|
1809
|
-
|
|
1846
|
+
var _a, _b;
|
|
1847
|
+
var state = state$.value;
|
|
1848
|
+
var url = action.payload.url;
|
|
1849
|
+
var result = [];
|
|
1850
|
+
switch (action.payload.drillDownType) {
|
|
1851
|
+
case import_schema.DrillDownType.external:
|
|
1852
|
+
window.location.href = url;
|
|
1853
|
+
break;
|
|
1854
|
+
case import_schema.DrillDownType.externalNew:
|
|
1855
|
+
if (/^[a-z0-9]+:\/\//i.test(url)) {
|
|
1856
|
+
window.open(url);
|
|
1857
|
+
}
|
|
1858
|
+
break;
|
|
1859
|
+
case import_schema.DrillDownType.relative:
|
|
1860
|
+
window.location.href = "".concat(window.location.origin, "/").concat(url);
|
|
1861
|
+
break;
|
|
1862
|
+
case import_schema.DrillDownType.relativeNew:
|
|
1863
|
+
window.open("".concat(window.location.origin, "/").concat(url), "_blank");
|
|
1864
|
+
break;
|
|
1865
|
+
case import_schema.DrillDownType.inner:
|
|
1866
|
+
default:
|
|
1867
|
+
var urlBase = url.split("?")[0];
|
|
1868
|
+
var urlObject = new URL(url, window.location.origin);
|
|
1869
|
+
var urlFilters = urlObject.searchParams.get("filters");
|
|
1870
|
+
var urlSorters = urlObject.searchParams.get("sorters");
|
|
1871
|
+
var newFilters_1 = {};
|
|
1872
|
+
var newSorters = {};
|
|
1873
|
+
try {
|
|
1874
|
+
newFilters_1 = (_a = JSON.parse(urlFilters)) !== null && _a !== void 0 ? _a : newFilters_1;
|
|
1875
|
+
}
|
|
1876
|
+
catch (_c) {
|
|
1877
|
+
urlFilters && console.warn("Failed to parse filters on drilldown");
|
|
1878
|
+
newFilters_1 = {};
|
|
1879
|
+
}
|
|
1880
|
+
try {
|
|
1881
|
+
newSorters = (_b = JSON.parse(urlSorters)) !== null && _b !== void 0 ? _b : newSorters;
|
|
1882
|
+
}
|
|
1883
|
+
catch (_d) {
|
|
1884
|
+
urlSorters && console.warn("Failed to parse sorters on drilldown");
|
|
1885
|
+
newSorters = {};
|
|
1886
|
+
}
|
|
1887
|
+
var bcToUpdate_1 = {};
|
|
1888
|
+
Object.keys(state.screen.filters).forEach(function (bcName) {
|
|
1889
|
+
if (newFilters_1[bcName] === "" || newFilters_1[bcName]) {
|
|
1890
|
+
bcToUpdate_1[bcName] = true;
|
|
1891
|
+
result.push(bcRemoveAllFilters({ bcName: bcName }));
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
var nextState = defaultParseURL(urlObject);
|
|
1895
|
+
var viewName_1 = nextState.viewName;
|
|
1896
|
+
Object.entries(newFilters_1).forEach(function (_a) {
|
|
1897
|
+
var _b;
|
|
1898
|
+
var bcName = _a[0], filterExpression = _a[1];
|
|
1899
|
+
var parsedFilters = (_b = parseFilters(filterExpression)) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), { viewName: viewName_1 })); });
|
|
1900
|
+
parsedFilters === null || parsedFilters === void 0 ? void 0 : parsedFilters.forEach(function (parsedFilter) {
|
|
1901
|
+
bcToUpdate_1[bcName] = true;
|
|
1902
|
+
result.push(bcAddFilter({ bcName: bcName, filter: parsedFilter }));
|
|
1903
|
+
});
|
|
1904
|
+
});
|
|
1905
|
+
Object.entries(newSorters).forEach(function (_a) {
|
|
1906
|
+
var bcName = _a[0], sortExpression = _a[1];
|
|
1907
|
+
var sorter = parseSorters(sortExpression);
|
|
1908
|
+
result.push(bcAddSorter({ bcName: bcName, sorter: sorter }));
|
|
1909
|
+
bcToUpdate_1[bcName] = true;
|
|
1910
|
+
});
|
|
1911
|
+
var prevState = state.router;
|
|
1912
|
+
var willUpdateAnyway = shallowCompare(prevState, nextState, ["params"]).length > 0;
|
|
1913
|
+
if (!willUpdateAnyway) {
|
|
1914
|
+
Object.keys(bcToUpdate_1).forEach(function (bcName) {
|
|
1915
|
+
result.push(bcForceUpdate({ bcName: bcName }));
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
result.push(changeLocation({ location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)) }));
|
|
1919
|
+
break;
|
|
1920
|
+
}
|
|
1921
|
+
return result.length ? (0, import_rxjs11.concat)(result) : import_rxjs11.EMPTY;
|
|
1810
1922
|
})); };
|
|
1923
|
+
function shallowCompare(prevProps, nextProps, ignore) {
|
|
1924
|
+
if (ignore === void 0) { ignore = []; }
|
|
1925
|
+
var diffProps = [];
|
|
1926
|
+
if (!prevProps && !nextProps) {
|
|
1927
|
+
return null;
|
|
1928
|
+
}
|
|
1929
|
+
if (!prevProps) {
|
|
1930
|
+
return Object.keys(nextProps);
|
|
1931
|
+
}
|
|
1932
|
+
if (!nextProps) {
|
|
1933
|
+
return Object.keys(prevProps);
|
|
1934
|
+
}
|
|
1935
|
+
var newKeys = Object.keys(nextProps);
|
|
1936
|
+
newKeys.forEach(function (key) {
|
|
1937
|
+
if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {
|
|
1938
|
+
diffProps.push(key);
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
Object.keys(prevProps).forEach(function (key) {
|
|
1942
|
+
if (!newKeys.includes(key)) {
|
|
1943
|
+
diffProps.push(key);
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
return diffProps;
|
|
1947
|
+
}
|
|
1811
1948
|
// src/epics/router/loginDoneEpic.ts
|
|
1812
1949
|
var import_rxjs12 = require("rxjs");
|
|
1813
1950
|
var loginDoneEpic = function (action$, state$) { return action$.pipe((0, import_rxjs12.filter)(loginDone.match), (0, import_rxjs12.switchMap)(function (action) {
|
|
@@ -1869,14 +2006,14 @@ var userDrillDownEpic = function (action$, state$, _a) {
|
|
|
1869
2006
|
return action$.pipe((0, import_rxjs16.filter)(userDrillDown.match), (0, import_rxjs16.switchMap)(function (action) {
|
|
1870
2007
|
var state = state$.value;
|
|
1871
2008
|
var _a = action.payload, bcName = _a.bcName, fieldKey = _a.fieldKey, cursor = _a.cursor;
|
|
1872
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
2009
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
1873
2010
|
return api.fetchRowMeta(state.screen.screenName, bcUrl).pipe((0, import_rxjs16.mergeMap)(function (rowMeta) {
|
|
1874
2011
|
var _a, _b, _c, _d;
|
|
1875
2012
|
var drillDownField = rowMeta.fields.find(function (field) { return field.key === fieldKey; });
|
|
1876
2013
|
var route = state.router;
|
|
1877
2014
|
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;
|
|
1878
2015
|
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];
|
|
1879
|
-
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({
|
|
2016
|
+
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({
|
|
1880
2017
|
url: customDrillDownUrl || drillDownField.drillDown,
|
|
1881
2018
|
drillDownType: drillDownField.drillDownType,
|
|
1882
2019
|
route: route
|
|
@@ -1967,12 +2104,11 @@ var userDrillDownChangeCursorsEpic = function (action$, state$) { return action$
|
|
|
1967
2104
|
if (cursor !== action.payload.cursor) {
|
|
1968
2105
|
return bcChangeCursors({ cursorsMap: (_a = {}, _a[action.payload.bcName] = action.payload.cursor, _a) });
|
|
1969
2106
|
}
|
|
1970
|
-
return
|
|
2107
|
+
return emptyAction;
|
|
1971
2108
|
})); };
|
|
1972
2109
|
// src/epics/screen/apiErrorEpic.ts
|
|
1973
2110
|
var import_axios = __toESM(require("axios"));
|
|
1974
2111
|
var import_rxjs21 = require("rxjs");
|
|
1975
|
-
var knownHttpErrors = [401, 409, 418, 500];
|
|
1976
2112
|
var apiErrorEpic = function (action$) { return action$.pipe((0, import_rxjs21.filter)(apiError.match), (0, import_rxjs21.mergeMap)(function (action) {
|
|
1977
2113
|
var _a = action.payload, error = _a.error, callContext = _a.callContext;
|
|
1978
2114
|
if (error.response) {
|
|
@@ -1996,7 +2132,9 @@ var import_rxjs22 = require("rxjs");
|
|
|
1996
2132
|
var downloadFileEpic = function (action$, state$, _a) {
|
|
1997
2133
|
var api = _a.api;
|
|
1998
2134
|
return action$.pipe((0, import_rxjs22.filter)(downloadFile.match), (0, import_rxjs22.tap)(function (action) {
|
|
2135
|
+
var fileId = action.payload.fileId;
|
|
1999
2136
|
var anchor = document.createElement("a");
|
|
2137
|
+
anchor.href = "".concat(api.fileUploadEndpoint, "?id=").concat(encodeURIComponent(fileId));
|
|
2000
2138
|
anchor.style.display = "none";
|
|
2001
2139
|
document.body.appendChild(anchor);
|
|
2002
2140
|
setTimeout(function () {
|
|
@@ -2013,8 +2151,8 @@ var httpError401Epic = function (action$) { return action$.pipe((0, import_rxjs2
|
|
|
2013
2151
|
// src/epics/screen/httpError409Epic.ts
|
|
2014
2152
|
var import_rxjs24 = require("rxjs");
|
|
2015
2153
|
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) {
|
|
2016
|
-
var _a, _b;
|
|
2017
|
-
var notificationMessage = ((_b = (_a = action.payload.error.response.data.error) === null ||
|
|
2154
|
+
var _a, _b, _c;
|
|
2155
|
+
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]) || "";
|
|
2018
2156
|
return addNotification({
|
|
2019
2157
|
key: "action_edit_error",
|
|
2020
2158
|
message: notificationMessage,
|
|
@@ -2030,10 +2168,10 @@ var httpError409Epic = function (action$, state$) { return action$.pipe((0, impo
|
|
|
2030
2168
|
// src/epics/screen/httpError418Epic.ts
|
|
2031
2169
|
var import_rxjs25 = require("rxjs");
|
|
2032
2170
|
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) {
|
|
2033
|
-
var _a;
|
|
2034
|
-
var
|
|
2171
|
+
var _a, _b;
|
|
2172
|
+
var _c = action.payload, error = _c.error, callContext = _c.callContext;
|
|
2035
2173
|
var result = [];
|
|
2036
|
-
var typedError = error.response.data;
|
|
2174
|
+
var typedError = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
2037
2175
|
if (!typedError.error.popup) {
|
|
2038
2176
|
return import_rxjs25.EMPTY;
|
|
2039
2177
|
}
|
|
@@ -2042,13 +2180,13 @@ var httpError418Epic = function (action$, state$) { return action$.pipe((0, impo
|
|
|
2042
2180
|
message: typedError.error.popup[0]
|
|
2043
2181
|
};
|
|
2044
2182
|
result.push((0, import_rxjs25.of)(showViewError({ error: businessError })));
|
|
2045
|
-
if ((
|
|
2183
|
+
if ((_b = typedError.error.postActions) === null || _b === void 0 ? void 0 : _b[0]) {
|
|
2046
2184
|
var widget = state$.value.view.widgets.find(function (item) { return item.name === callContext.widgetName; });
|
|
2047
|
-
var bcName = widget.bcName;
|
|
2185
|
+
var bcName = widget === null || widget === void 0 ? void 0 : widget.bcName;
|
|
2048
2186
|
result.push((0, import_rxjs25.of)(processPostInvoke({
|
|
2049
2187
|
bcName: bcName,
|
|
2050
2188
|
postInvoke: typedError.error.postActions[0],
|
|
2051
|
-
widgetName: widget.name
|
|
2189
|
+
widgetName: widget === null || widget === void 0 ? void 0 : widget.name
|
|
2052
2190
|
})));
|
|
2053
2191
|
}
|
|
2054
2192
|
return (0, import_rxjs25.concat).apply(void 0, result);
|
|
@@ -2066,11 +2204,13 @@ var httpError500Epic = function (action$, state$) { return action$.pipe((0, impo
|
|
|
2066
2204
|
})); };
|
|
2067
2205
|
// src/epics/screen/httpErrorDefaultEpic.ts
|
|
2068
2206
|
var import_rxjs27 = require("rxjs");
|
|
2069
|
-
var
|
|
2207
|
+
var knownHttpErrors = [401, 409, 418, 500];
|
|
2208
|
+
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) {
|
|
2209
|
+
var _a, _b;
|
|
2070
2210
|
var businessError = {
|
|
2071
2211
|
type: 0 /* BusinessError */,
|
|
2072
|
-
code: action.payload.error.response.status,
|
|
2073
|
-
details: action.payload.error.response.data
|
|
2212
|
+
code: (_a = action.payload.error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
2213
|
+
details: (_b = action.payload.error.response) === null || _b === void 0 ? void 0 : _b.data
|
|
2074
2214
|
};
|
|
2075
2215
|
return showViewError({ error: businessError });
|
|
2076
2216
|
})); };
|
|
@@ -2091,6 +2231,7 @@ var downloadFileByUrlEpic = function (action$, state$) { return action$.pipe((0,
|
|
|
2091
2231
|
var import_rxjs29 = require("rxjs");
|
|
2092
2232
|
var processPostInvokeEpic = function (action$, state$) { return action$.pipe((0, import_rxjs29.filter)(processPostInvoke.match), (0, import_rxjs29.mergeMap)(function (action) {
|
|
2093
2233
|
var _a;
|
|
2234
|
+
var _b;
|
|
2094
2235
|
var state = state$.value;
|
|
2095
2236
|
switch (action.payload.postInvoke.type) {
|
|
2096
2237
|
case "drillDown" /* drillDown */:
|
|
@@ -2098,7 +2239,10 @@ var processPostInvokeEpic = function (action$, state$) { return action$.pipe((0,
|
|
|
2098
2239
|
case "postDelete" /* postDelete */: {
|
|
2099
2240
|
var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
|
|
2100
2241
|
var result = [bcChangeCursors({ cursorsMap: cursorsMap })];
|
|
2101
|
-
if (state.router.bcPath.includes("".concat(action.payload.bcName, "/"))) {
|
|
2242
|
+
if ((_b = state.router.bcPath) === null || _b === void 0 ? void 0 : _b.includes("".concat(action.payload.bcName, "/"))) {
|
|
2243
|
+
var newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || "";
|
|
2244
|
+
var newUrl = "/screen/".concat(state.router.screenName, "/view/").concat(state.router.viewName, "/").concat(newBcUrl);
|
|
2245
|
+
result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }));
|
|
2102
2246
|
}
|
|
2103
2247
|
else {
|
|
2104
2248
|
result.push(bcFetchDataRequest({
|
|
@@ -2180,13 +2324,13 @@ var refreshMetaEpic = function (action$, state$, _a) {
|
|
|
2180
2324
|
var router = state.router;
|
|
2181
2325
|
var activeRole = state.session.activeRole;
|
|
2182
2326
|
return api.refreshMeta().pipe((0, import_rxjs32.switchMap)(function () { return (0, import_rxjs32.concat)([
|
|
2327
|
+
refreshMetaDone(),
|
|
2183
2328
|
logoutDone(null),
|
|
2184
2329
|
login({ login: "", password: "", role: activeRole }),
|
|
2185
2330
|
changeLocation({
|
|
2186
|
-
|
|
2187
|
-
action: "PUSH"
|
|
2331
|
+
location: router
|
|
2188
2332
|
})
|
|
2189
|
-
]); }), (0, import_rxjs32.catchError)(function (error) { return (0, import_rxjs32.
|
|
2333
|
+
]); }), (0, import_rxjs32.catchError)(function (error) { return (0, import_rxjs32.concat)([loginFail(error), refreshMetaFail()]); }));
|
|
2190
2334
|
}));
|
|
2191
2335
|
};
|
|
2192
2336
|
// src/epics/session/loginDoneEpic.ts
|
|
@@ -2205,9 +2349,26 @@ var loginByAnotherRoleEpic = function (action$, state$, _a) {
|
|
|
2205
2349
|
var role = (_a = action.payload.role) !== null && _a !== void 0 ? _a : "";
|
|
2206
2350
|
var isSwitchRole = role && role !== state$.value.session.activeRole;
|
|
2207
2351
|
return api.loginByRoleRequest(role).pipe((0, import_rxjs34.mergeMap)(function (data) {
|
|
2352
|
+
var _a;
|
|
2353
|
+
var result = [];
|
|
2208
2354
|
if (isSwitchRole) {
|
|
2355
|
+
var defaultScreen = data.screens.find(function (screen) { return screen.defaultScreen; }) || data.screens[0];
|
|
2356
|
+
var defaultViewName_1 = (_a = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.primary) !== null && _a !== void 0 ? _a : defaultScreen.meta.views[0].name;
|
|
2357
|
+
var defaultView = defaultScreen === null || defaultScreen === void 0 ? void 0 : defaultScreen.meta.views.find(function (view) { return defaultViewName_1 === view.name; });
|
|
2358
|
+
if (defaultView)
|
|
2359
|
+
result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }));
|
|
2209
2360
|
}
|
|
2210
|
-
return import_rxjs34.
|
|
2361
|
+
return (0, import_rxjs34.concat)(__spreadArray(__spreadArray([], result, true), [
|
|
2362
|
+
loginDone({
|
|
2363
|
+
devPanelEnabled: data.devPanelEnabled,
|
|
2364
|
+
activeRole: data.activeRole,
|
|
2365
|
+
roles: data.roles,
|
|
2366
|
+
screens: data.screens,
|
|
2367
|
+
firstName: data.firstName,
|
|
2368
|
+
lastName: data.lastName,
|
|
2369
|
+
login: data.login
|
|
2370
|
+
})
|
|
2371
|
+
], false));
|
|
2211
2372
|
}), (0, import_rxjs34.catchError)(function (error) {
|
|
2212
2373
|
console.error(error);
|
|
2213
2374
|
var errorMsg = error.response ? responseStatusMessages[error.response.status] || "Server application unavailable" : "Empty server response";
|
|
@@ -2220,25 +2381,28 @@ var import_rxjs35 = require("rxjs");
|
|
|
2220
2381
|
var refreshMetaAndReloadPageEpic = function (action$, state$) { return action$.pipe((0, import_rxjs35.filter)(refreshMetaAndReloadPage.match), (0, import_rxjs35.switchMap)(function () { return (0, import_rxjs35.concat)((0, import_rxjs35.of)(refreshMeta(null)), action$.pipe((0, import_rxjs35.filter)(loginDone.match), (0, import_rxjs35.take)(1), (0, import_rxjs35.tap)(function () { return location.reload(); }), (0, import_rxjs35.switchMap)(function () { return import_rxjs35.EMPTY; }))); })); };
|
|
2221
2382
|
// src/epics/data/bcNewDataEpic.ts
|
|
2222
2383
|
var import_rxjs36 = require("rxjs");
|
|
2223
|
-
var
|
|
2384
|
+
var import_schema13 = require("@cxbox-ui/schema");
|
|
2224
2385
|
var bcNewDataEpic = function (action$, state$, _a) {
|
|
2225
2386
|
var api = _a.api;
|
|
2226
|
-
return action$.pipe((0, import_rxjs36.filter)(sendOperation.match), (0, import_rxjs36.filter)(function (action) { return matchOperationRole(
|
|
2387
|
+
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) {
|
|
2388
|
+
var _a;
|
|
2227
2389
|
var state = state$.value;
|
|
2228
2390
|
var bcName = action.payload.bcName;
|
|
2229
|
-
var bcUrl = buildBcUrl(bcName);
|
|
2391
|
+
var bcUrl = (_a = buildBcUrl(bcName, false, state)) !== null && _a !== void 0 ? _a : "";
|
|
2230
2392
|
var context = { widgetName: action.payload.widgetName };
|
|
2231
2393
|
var params = { _action: action.payload.operationType };
|
|
2232
2394
|
return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe((0, import_rxjs36.mergeMap)(function (data) {
|
|
2395
|
+
var _a, _b;
|
|
2233
2396
|
var rowMeta = data.row;
|
|
2234
2397
|
var dataItem = { id: null, vstamp: -1 };
|
|
2235
2398
|
data.row.fields.forEach(function (field) {
|
|
2236
2399
|
dataItem[field.key] = field.currentValue;
|
|
2237
2400
|
});
|
|
2238
|
-
var postInvoke = data.postActions[0];
|
|
2401
|
+
var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
|
|
2239
2402
|
var cursor = dataItem.id;
|
|
2240
2403
|
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({
|
|
2241
|
-
bcName:
|
|
2404
|
+
bcName: bcName,
|
|
2405
|
+
bcUrl: (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "",
|
|
2242
2406
|
cursor: cursor,
|
|
2243
2407
|
dataItem: {
|
|
2244
2408
|
id: cursor
|
|
@@ -2261,7 +2425,7 @@ function cancelRequestEpic(action$, actionTypes, cancelFn, cancelActionCreator,
|
|
|
2261
2425
|
return true;
|
|
2262
2426
|
}; }
|
|
2263
2427
|
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 () {
|
|
2264
|
-
cancelFn();
|
|
2428
|
+
cancelFn === null || cancelFn === void 0 ? void 0 : cancelFn();
|
|
2265
2429
|
return (0, import_rxjs37.of)(cancelActionCreator);
|
|
2266
2430
|
}), (0, import_rxjs37.take)(1));
|
|
2267
2431
|
}
|
|
@@ -2276,7 +2440,7 @@ var bcLoadMoreEpic = function (action$, state$, _a) {
|
|
|
2276
2440
|
var cursor = bc.cursor, page = bc.page;
|
|
2277
2441
|
var limit = ((_a = state.view.widgets.find(function (i) { return i.bcName === bcName; })) === null || _a === void 0 ? void 0 : _a.limit) || bc.limit;
|
|
2278
2442
|
var limitBySelfCursor = (_b = state.router.bcPath) === null || _b === void 0 ? void 0 : _b.includes("".concat(bcName, "/").concat(cursor));
|
|
2279
|
-
var bcUrl = buildBcUrl(bcName, limitBySelfCursor);
|
|
2443
|
+
var bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
|
|
2280
2444
|
var filters = state.screen.filters[bcName] || [];
|
|
2281
2445
|
var sorters = state.screen.sorters[bcName];
|
|
2282
2446
|
var fetchParams = __assign(__assign({ _page: page, _limit: limit }, getFilters(filters)), getSorters(sorters));
|
|
@@ -2303,17 +2467,17 @@ var bcLoadMoreEpic = function (action$, state$, _a) {
|
|
|
2303
2467
|
var import_rxjs39 = require("rxjs");
|
|
2304
2468
|
var bcSaveDataEpic = function (action$, state$, _a) {
|
|
2305
2469
|
var api = _a.api;
|
|
2306
|
-
return action$.pipe((0, import_rxjs39.filter)(sendOperation.match), (0, import_rxjs39.filter)(function (action) { return matchOperationRole(
|
|
2307
|
-
var _a, _b, _c;
|
|
2470
|
+
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) {
|
|
2471
|
+
var _a, _b, _c, _d;
|
|
2308
2472
|
var state = state$.value;
|
|
2309
2473
|
var bcName = action.payload.bcName;
|
|
2310
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
2474
|
+
var bcUrl = (_a = buildBcUrl(bcName, true, state)) !== null && _a !== void 0 ? _a : "";
|
|
2311
2475
|
var widgetName = action.payload.widgetName;
|
|
2312
2476
|
var cursor = state.screen.bo.bc[bcName].cursor;
|
|
2313
2477
|
var dataItem = state.data[bcName].find(function (item) { return item.id === cursor; });
|
|
2314
|
-
var pendingChanges = (
|
|
2315
|
-
var rowMeta = bcUrl && ((
|
|
2316
|
-
var options = (
|
|
2478
|
+
var pendingChanges = __assign({}, (_b = state.view.pendingDataChanges[bcName]) === null || _b === void 0 ? void 0 : _b[cursor]);
|
|
2479
|
+
var rowMeta = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
|
|
2480
|
+
var options = (_d = state.view.widgets.find(function (widget) { return widget.name === widgetName; })) === null || _d === void 0 ? void 0 : _d.options;
|
|
2317
2481
|
if (rowMeta) {
|
|
2318
2482
|
var fields = rowMeta.fields;
|
|
2319
2483
|
var _loop_3 = function (key) {
|
|
@@ -2330,8 +2494,9 @@ var bcSaveDataEpic = function (action$, state$, _a) {
|
|
|
2330
2494
|
return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] });
|
|
2331
2495
|
});
|
|
2332
2496
|
var context = { widgetName: action.payload.widgetName };
|
|
2333
|
-
return api.saveBcData(state.screen.screenName, bcUrl, __assign(__assign({}, pendingChanges), { vstamp: dataItem.vstamp }), context).pipe((0, import_rxjs39.mergeMap)(function (data) {
|
|
2334
|
-
var
|
|
2497
|
+
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) {
|
|
2498
|
+
var _a;
|
|
2499
|
+
var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
|
|
2335
2500
|
var responseDataItem = data.record;
|
|
2336
2501
|
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({
|
|
2337
2502
|
bcName: bcName,
|
|
@@ -2340,7 +2505,7 @@ var bcSaveDataEpic = function (action$, state$, _a) {
|
|
|
2340
2505
|
cursor: responseDataItem.id
|
|
2341
2506
|
})) : import_rxjs39.EMPTY, action.payload.onSuccessAction ? (0, import_rxjs39.of)(action.payload.onSuccessAction) : import_rxjs39.EMPTY);
|
|
2342
2507
|
}), (0, import_rxjs39.catchError)(function (e) {
|
|
2343
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2508
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2344
2509
|
console.error(e);
|
|
2345
2510
|
var notification$ = import_rxjs39.EMPTY;
|
|
2346
2511
|
if (action.payload.onSuccessAction && !(options === null || options === void 0 ? void 0 : options.disableNotification)) {
|
|
@@ -2361,8 +2526,8 @@ var bcSaveDataEpic = function (action$, state$, _a) {
|
|
|
2361
2526
|
var entityError = null;
|
|
2362
2527
|
var operationError = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
2363
2528
|
if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.data) === Object((_c = e.response) === null || _c === void 0 ? void 0 : _c.data)) {
|
|
2364
|
-
entityError = (_d = operationError === null || operationError === void 0 ? void 0 : operationError.error) === null || _d === void 0 ? void 0 : _d.entity;
|
|
2365
|
-
viewError = (
|
|
2529
|
+
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;
|
|
2530
|
+
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;
|
|
2366
2531
|
}
|
|
2367
2532
|
return (0, import_rxjs39.concat)((0, import_rxjs39.of)(bcSaveDataFail({ bcName: bcName, bcUrl: bcUrl, viewError: viewError, entityError: entityError })), notification$);
|
|
2368
2533
|
}));
|
|
@@ -2400,7 +2565,7 @@ var selectViewEpic = function (action$, state$) { return action$.pipe((0, import
|
|
|
2400
2565
|
})); };
|
|
2401
2566
|
// src/epics/data/bcFetchDataEpic.ts
|
|
2402
2567
|
var import_rxjs41 = require("rxjs");
|
|
2403
|
-
var
|
|
2568
|
+
var import_schema14 = require("@cxbox-ui/schema");
|
|
2404
2569
|
var import_toolkit5 = require("@reduxjs/toolkit");
|
|
2405
2570
|
var bcFetchDataEpic = function (action$, state$, _a) {
|
|
2406
2571
|
var api = _a.api;
|
|
@@ -2438,41 +2603,41 @@ var bcFetchDataEpic = function (action$, state$, _a) {
|
|
|
2438
2603
|
});
|
|
2439
2604
|
return (0, import_rxjs41.of)(bcFetchDataRequest({
|
|
2440
2605
|
bcName: childBcName,
|
|
2441
|
-
widgetName: nonLazyWidget.name,
|
|
2606
|
+
widgetName: nonLazyWidget === null || nonLazyWidget === void 0 ? void 0 : nonLazyWidget.name,
|
|
2442
2607
|
ignorePageLimit: ignorePageLimit || showViewPopup.match(action),
|
|
2443
2608
|
keepDelta: isHierarchy || keepDelta
|
|
2444
2609
|
}));
|
|
2445
2610
|
}));
|
|
2446
2611
|
};
|
|
2447
2612
|
var bcFetchDataImpl = function () {
|
|
2448
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2613
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2449
2614
|
var state = state$.value;
|
|
2450
|
-
var
|
|
2451
|
-
var
|
|
2452
|
-
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; });
|
|
2615
|
+
var _j = action.payload.widgetName, widgetName = _j === void 0 ? "" : _j;
|
|
2616
|
+
var _k = state.view, widgets = _k.widgets, infiniteWidgets = _k.infiniteWidgets;
|
|
2617
|
+
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; });
|
|
2453
2618
|
if (!widget) {
|
|
2454
2619
|
return [import_rxjs41.EMPTY];
|
|
2455
2620
|
}
|
|
2456
2621
|
var bcName = action.payload.bcName;
|
|
2457
2622
|
var bc = state.screen.bo.bc[bcName];
|
|
2458
|
-
var cursor = bc.cursor,
|
|
2459
|
-
var limit = ((_b = widgets.find(function (i) { return i.bcName === bcName; })) === null || _b === void 0 ? void 0 : _b.limit) || bc.limit;
|
|
2623
|
+
var cursor = bc.cursor, _l = bc.page, page = _l === void 0 ? 1 : _l;
|
|
2624
|
+
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;
|
|
2460
2625
|
var sorters = state.screen.sorters[bcName];
|
|
2461
2626
|
if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {
|
|
2462
2627
|
return [import_rxjs41.EMPTY];
|
|
2463
2628
|
}
|
|
2464
|
-
var anyHierarchyWidget = widgets.find(function (item) {
|
|
2465
|
-
return item.bcName === widget.bcName && item.type ===
|
|
2629
|
+
var anyHierarchyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.find(function (item) {
|
|
2630
|
+
return item.bcName === widget.bcName && item.type === import_schema14.WidgetTypes.AssocListPopup && isHierarchyWidget(item);
|
|
2466
2631
|
});
|
|
2467
|
-
var fullHierarchyWidget = state.view.widgets.find(function (item) {
|
|
2632
|
+
var fullHierarchyWidget = (_d = state.view.widgets) === null || _d === void 0 ? void 0 : _d.find(function (item) {
|
|
2468
2633
|
var _a;
|
|
2469
|
-
return item.bcName === widget.bcName && item.type ===
|
|
2634
|
+
return item.bcName === widget.bcName && item.type === import_schema14.WidgetTypes.AssocListPopup && ((_a = item.options) === null || _a === void 0 ? void 0 : _a.hierarchyFull);
|
|
2470
2635
|
});
|
|
2471
|
-
var limitBySelfCursor = (
|
|
2472
|
-
var bcUrl = buildBcUrl(bcName, limitBySelfCursor);
|
|
2636
|
+
var limitBySelfCursor = (_e = state.router.bcPath) === null || _e === void 0 ? void 0 : _e.includes("".concat(bcName, "/").concat(cursor));
|
|
2637
|
+
var bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
|
|
2473
2638
|
var fetchParams = __assign(__assign({ _page: page, _limit: limit }, getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || [])), getSorters(sorters));
|
|
2474
2639
|
if (bcForceUpdate.match(action)) {
|
|
2475
|
-
var infinityPaginationWidget = widgetName && infiniteWidgets.includes(widgetName) || ((
|
|
2640
|
+
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);
|
|
2476
2641
|
if (infinityPaginationWidget) {
|
|
2477
2642
|
fetchParams._page = 1;
|
|
2478
2643
|
fetchParams._limit = limit * page;
|
|
@@ -2482,7 +2647,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
|
|
|
2482
2647
|
fetchParams._page = action.payload.from || 1;
|
|
2483
2648
|
fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit;
|
|
2484
2649
|
}
|
|
2485
|
-
if (bcFetchDataRequest.match(action) && action.payload.ignorePageLimit || ((
|
|
2650
|
+
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)) {
|
|
2486
2651
|
fetchParams._limit = 0;
|
|
2487
2652
|
}
|
|
2488
2653
|
var canceler = api.createCanceler();
|
|
@@ -2494,7 +2659,7 @@ var bcFetchDataEpic = function (action$, state$, _a) {
|
|
|
2494
2659
|
var normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe((0, import_rxjs41.mergeMap)(function (response) {
|
|
2495
2660
|
var _a, _b;
|
|
2496
2661
|
var cursorChange = getCursorChange(response.data, cursor, !!anyHierarchyWidget);
|
|
2497
|
-
var parentOfNotLazyWidget = widgets.some(function (item) {
|
|
2662
|
+
var parentOfNotLazyWidget = widgets === null || widgets === void 0 ? void 0 : widgets.some(function (item) {
|
|
2498
2663
|
var _a;
|
|
2499
2664
|
return ((_a = state.screen.bo.bc[item.bcName]) === null || _a === void 0 ? void 0 : _a.parentName) === bcName && !PopupWidgetTypes.includes(item.type);
|
|
2500
2665
|
});
|
|
@@ -2542,19 +2707,20 @@ function isHierarchyWidget(widget) {
|
|
|
2542
2707
|
}
|
|
2543
2708
|
// src/epics/data/bcDeleteDataEpic.ts
|
|
2544
2709
|
var import_rxjs42 = require("rxjs");
|
|
2545
|
-
var
|
|
2710
|
+
var import_schema15 = require("@cxbox-ui/schema");
|
|
2546
2711
|
var bcDeleteDataEpic = function (action$, store$, _a) {
|
|
2547
2712
|
var api = _a.api;
|
|
2548
|
-
return action$.pipe((0, import_rxjs42.filter)(sendOperation.match), (0, import_rxjs42.filter)(function (action) { return matchOperationRole(
|
|
2713
|
+
return action$.pipe((0, import_rxjs42.filter)(sendOperation.match), (0, import_rxjs42.filter)(function (action) { return matchOperationRole(import_schema15.OperationTypeCrud.delete, action.payload, store$.value); }), (0, import_rxjs42.mergeMap)(function (action) {
|
|
2549
2714
|
var widgetName = action.payload.widgetName;
|
|
2550
2715
|
var state = store$.value;
|
|
2551
2716
|
var bcName = action.payload.bcName;
|
|
2552
2717
|
var cursor = state.screen.bo.bc[bcName].cursor;
|
|
2553
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
2718
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
2554
2719
|
var context = { widgetName: action.payload.widgetName };
|
|
2555
2720
|
var isTargetFormatPVF = state.view.pendingValidationFailsFormat === "target" /* target */;
|
|
2556
2721
|
return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe((0, import_rxjs42.mergeMap)(function (data) {
|
|
2557
|
-
var
|
|
2722
|
+
var _a;
|
|
2723
|
+
var postInvoke = (_a = data.postActions) === null || _a === void 0 ? void 0 : _a[0];
|
|
2558
2724
|
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);
|
|
2559
2725
|
}), (0, import_rxjs42.catchError)(function (error) {
|
|
2560
2726
|
console.error(error);
|
|
@@ -2586,9 +2752,11 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe((0,
|
|
|
2586
2752
|
var _a, _b, _c, _d, _e;
|
|
2587
2753
|
var state = state$.value;
|
|
2588
2754
|
var selected = action.payload.dataItem._associate;
|
|
2755
|
+
var bcName = action.payload.bcName;
|
|
2589
2756
|
var result = [
|
|
2590
2757
|
(0, import_rxjs44.of)(changeDataItem({
|
|
2591
|
-
bcName:
|
|
2758
|
+
bcName: bcName,
|
|
2759
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2592
2760
|
cursor: action.payload.dataItem.id,
|
|
2593
2761
|
dataItem: action.payload.dataItem
|
|
2594
2762
|
}))
|
|
@@ -2601,19 +2769,19 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe((0,
|
|
|
2601
2769
|
fields: widget.fields
|
|
2602
2770
|
};
|
|
2603
2771
|
var hierarchy = (_b = widget.options) === null || _b === void 0 ? void 0 : _b.hierarchy;
|
|
2604
|
-
var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
|
|
2772
|
+
var hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item) { return item.bcName === action.payload.bcName; });
|
|
2605
2773
|
var hierarchyGroupSelection = (_c = widget.options) === null || _c === void 0 ? void 0 : _c.hierarchyGroupSelection;
|
|
2606
2774
|
var hierarchyTraverse = (_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyTraverse;
|
|
2607
|
-
var childrenBc = hierarchy.slice(hierarchy.findIndex(function (item) { return item.bcName === action.payload.bcName; }) + 1).map(function (item) { return item.bcName; });
|
|
2775
|
+
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; });
|
|
2608
2776
|
if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {
|
|
2609
2777
|
result.push((0, import_rxjs44.of)(dropAllAssociations({
|
|
2610
2778
|
bcNames: childrenBc
|
|
2611
2779
|
})));
|
|
2612
2780
|
}
|
|
2613
|
-
var parent = isRoot ? null : hierarchy.find(function (item, index) {
|
|
2781
|
+
var parent = isRoot ? null : (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.find(function (item, index) {
|
|
2614
2782
|
var _a;
|
|
2615
2783
|
return ((_a = hierarchy[index + 1]) === null || _a === void 0 ? void 0 : _a.bcName) === action.payload.bcName;
|
|
2616
|
-
}) || rootHierarchyDescriptor;
|
|
2784
|
+
})) || rootHierarchyDescriptor;
|
|
2617
2785
|
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; });
|
|
2618
2786
|
if (parent && hierarchyTraverse && selected) {
|
|
2619
2787
|
if (hierarchyDescriptor.radio) {
|
|
@@ -2624,7 +2792,7 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe((0,
|
|
|
2624
2792
|
result.push((0, import_rxjs44.of)(changeAssociation({
|
|
2625
2793
|
bcName: parent.bcName,
|
|
2626
2794
|
widgetName: action.payload.widgetName,
|
|
2627
|
-
dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
|
|
2795
|
+
dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[parent.assocValueKey || action.payload.assocValueKey] }),
|
|
2628
2796
|
assocValueKey: action.payload.assocValueKey
|
|
2629
2797
|
})));
|
|
2630
2798
|
}
|
|
@@ -2650,18 +2818,18 @@ var changeAssociationEpic = function (action$, state$) { return action$.pipe((0,
|
|
|
2650
2818
|
})); };
|
|
2651
2819
|
// src/epics/data/bcCancelCreateDataEpic.ts
|
|
2652
2820
|
var import_rxjs45 = require("rxjs");
|
|
2653
|
-
var
|
|
2821
|
+
var import_schema16 = require("@cxbox-ui/schema");
|
|
2654
2822
|
var import_toolkit6 = require("@reduxjs/toolkit");
|
|
2655
2823
|
var actionTypesMatcher = (0, import_toolkit6.isAnyOf)(sendOperation);
|
|
2656
2824
|
var bcCancelCreateDataEpic = function (action$, state$, _a) {
|
|
2657
2825
|
var api = _a.api;
|
|
2658
|
-
return action$.pipe((0, import_rxjs45.filter)(actionTypesMatcher), (0, import_rxjs45.filter)(function (action) { return matchOperationRole(
|
|
2826
|
+
return action$.pipe((0, import_rxjs45.filter)(actionTypesMatcher), (0, import_rxjs45.filter)(function (action) { return matchOperationRole(import_schema16.OperationTypeCrud.cancelCreate, action.payload, state$.value); }), (0, import_rxjs45.mergeMap)(function (action) {
|
|
2659
2827
|
var _a;
|
|
2660
2828
|
var _b, _c;
|
|
2661
2829
|
var state = state$.value;
|
|
2662
2830
|
var screenName = state.screen.screenName;
|
|
2663
2831
|
var bcName = action.payload.bcName;
|
|
2664
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
2832
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
2665
2833
|
var bc = state.screen.bo.bc[bcName];
|
|
2666
2834
|
var cursor = bc === null || bc === void 0 ? void 0 : bc.cursor;
|
|
2667
2835
|
var context = { widgetName: action.payload.widgetName };
|
|
@@ -2671,7 +2839,8 @@ var bcCancelCreateDataEpic = function (action$, state$, _a) {
|
|
|
2671
2839
|
var params = { _action: action.payload.operationType };
|
|
2672
2840
|
var cursorsMap = (_a = {}, _a[action.payload.bcName] = null, _a);
|
|
2673
2841
|
return api.customAction(screenName, bcUrl, data, context, params).pipe((0, import_rxjs45.mergeMap)(function (response) {
|
|
2674
|
-
var
|
|
2842
|
+
var _a;
|
|
2843
|
+
var postInvoke = (_a = response.postActions) === null || _a === void 0 ? void 0 : _a[0];
|
|
2675
2844
|
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);
|
|
2676
2845
|
}), (0, import_rxjs45.catchError)(function (error) {
|
|
2677
2846
|
console.error(error);
|
|
@@ -2707,21 +2876,21 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe((
|
|
|
2707
2876
|
var removedItem = data.find(function (item) { return item.id === action.payload.removedItem.id; });
|
|
2708
2877
|
var associated = action.payload.dataItem.map(function (item) { return item.id; });
|
|
2709
2878
|
var removedNodes = [];
|
|
2710
|
-
if ((_d = widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
|
|
2711
|
-
if ((_e = widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
|
|
2879
|
+
if ((_d = widget === null || widget === void 0 ? void 0 : widget.options) === null || _d === void 0 ? void 0 : _d.hierarchyGroupDeselection) {
|
|
2880
|
+
if ((_e = widget === null || widget === void 0 ? void 0 : widget.options) === null || _e === void 0 ? void 0 : _e.hierarchyTraverse) {
|
|
2712
2881
|
data = assignTreeLinks(data);
|
|
2713
2882
|
}
|
|
2714
|
-
var removedItemChildren = data.filter(function (item) { return item.parentId === removedItem.id; });
|
|
2715
|
-
removedNodes = __spreadArray([removedItem.id], removedItemChildren.filter(function (item) { return associated.includes(item.id); }).map(function (item) { return item.id; }), true);
|
|
2716
|
-
if ((_f = widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
|
|
2883
|
+
var removedItemChildren = data.filter(function (item) { return item.parentId === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.id); });
|
|
2884
|
+
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);
|
|
2885
|
+
if ((_f = widget === null || widget === void 0 ? void 0 : widget.options) === null || _f === void 0 ? void 0 : _f.hierarchyTraverse) {
|
|
2717
2886
|
getDescendants(removedItemChildren, removedNodes);
|
|
2718
2887
|
removedNodes = data.filter(function (item) { return removedNodes.includes(item.id) && associated.includes(item.id); }).map(function (item) { return item.id; });
|
|
2719
2888
|
}
|
|
2720
|
-
var parent_1 = data.find(function (item) { return item.id === removedItem.parentId; });
|
|
2889
|
+
var parent_1 = data.find(function (item) { return item.id === (removedItem === null || removedItem === void 0 ? void 0 : removedItem.parentId); });
|
|
2721
2890
|
var siblings = data.filter(function (item) { return item.parentId === (parent_1 === null || parent_1 === void 0 ? void 0 : parent_1.id); });
|
|
2722
2891
|
var parentEmpty = siblings.every(function (child) { return removedNodes.includes(child.id) || !associated.includes(child.id); });
|
|
2723
2892
|
if (parent_1 && parentEmpty) {
|
|
2724
|
-
if ((_g = widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
|
|
2893
|
+
if ((_g = widget === null || widget === void 0 ? void 0 : widget.options) === null || _g === void 0 ? void 0 : _g.hierarchyTraverse) {
|
|
2725
2894
|
var parentDescendants = [];
|
|
2726
2895
|
getDescendants(siblings, parentDescendants);
|
|
2727
2896
|
var parentDeepEmpty = parentDescendants.every(function (descendant) {
|
|
@@ -2736,14 +2905,19 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe((
|
|
|
2736
2905
|
}
|
|
2737
2906
|
}
|
|
2738
2907
|
}
|
|
2739
|
-
if ((_h = widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
|
|
2908
|
+
if ((_h = widget === null || widget === void 0 ? void 0 : widget.options) === null || _h === void 0 ? void 0 : _h.hierarchyFull) {
|
|
2740
2909
|
return (0, import_rxjs47.of)(changeDataItem({
|
|
2741
2910
|
bcName: bcName,
|
|
2911
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2742
2912
|
cursor: cursor,
|
|
2743
2913
|
dataItem: (_a = {}, _a[associateFieldKey] = action.payload.dataItem.filter(function (item) { return !removedNodes.includes(item.id); }), _a)
|
|
2744
2914
|
}));
|
|
2745
2915
|
}
|
|
2746
|
-
if ((_j = widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
|
|
2916
|
+
if ((_j = widget === null || widget === void 0 ? void 0 : widget.options) === null || _j === void 0 ? void 0 : _j.hierarchy) {
|
|
2917
|
+
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) {
|
|
2918
|
+
var _a;
|
|
2919
|
+
return (_a = state.view.pendingDataChanges[hierarchyData.bcName]) === null || _a === void 0 ? void 0 : _a[action.payload.removedItem.id];
|
|
2920
|
+
})) === null || _m === void 0 ? void 0 : _m.bcName) !== null && _o !== void 0 ? _o : bcName;
|
|
2747
2921
|
return (0, import_rxjs47.concat)((0, import_rxjs47.of)(changeDataItem({
|
|
2748
2922
|
/**
|
|
2749
2923
|
* This is incorrect and will break if different BC has records with
|
|
@@ -2751,24 +2925,25 @@ var removeMultivalueTagEpic = function (action$, state$) { return action$.pipe((
|
|
|
2751
2925
|
*
|
|
2752
2926
|
* TODO: Record `level` should be mapped to hierarchyData index instead
|
|
2753
2927
|
*/
|
|
2754
|
-
bcName:
|
|
2755
|
-
|
|
2756
|
-
return (_a = state.view.pendingDataChanges[hierarchyData.bcName]) === null || _a === void 0 ? void 0 : _a[action.payload.removedItem.id];
|
|
2757
|
-
})) === null || _m === void 0 ? void 0 : _m.bcName) !== null && _o !== void 0 ? _o : bcName,
|
|
2928
|
+
bcName: hierarchyBcName,
|
|
2929
|
+
bcUrl: buildBcUrl(hierarchyBcName, true, state),
|
|
2758
2930
|
cursor: action.payload.removedItem.id,
|
|
2759
2931
|
dataItem: __assign(__assign({}, action.payload.removedItem), { _associate: false })
|
|
2760
2932
|
})), (0, import_rxjs47.of)(changeDataItem({
|
|
2761
2933
|
bcName: bcName,
|
|
2934
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2762
2935
|
cursor: cursor,
|
|
2763
2936
|
dataItem: (_b = {}, _b[associateFieldKey] = action.payload.dataItem, _b)
|
|
2764
2937
|
})));
|
|
2765
2938
|
}
|
|
2766
2939
|
return (0, import_rxjs47.concat)((0, import_rxjs47.of)(changeDataItem({
|
|
2767
2940
|
bcName: popupBcName,
|
|
2941
|
+
bcUrl: buildBcUrl(popupBcName, true, state),
|
|
2768
2942
|
cursor: action.payload.removedItem.id,
|
|
2769
2943
|
dataItem: __assign(__assign({}, action.payload.removedItem), { _associate: false })
|
|
2770
2944
|
})), (0, import_rxjs47.of)(changeDataItem({
|
|
2771
2945
|
bcName: bcName,
|
|
2946
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2772
2947
|
cursor: cursor,
|
|
2773
2948
|
dataItem: (_c = {}, _c[associateFieldKey] = action.payload.dataItem, _c)
|
|
2774
2949
|
})));
|
|
@@ -2778,11 +2953,12 @@ var import_rxjs48 = require("rxjs");
|
|
|
2778
2953
|
var bcFetchRowMetaRequestEpic = function (action$, state$, _a) {
|
|
2779
2954
|
var api = _a.api;
|
|
2780
2955
|
return action$.pipe((0, import_rxjs48.filter)(bcFetchRowMeta.match), (0, import_rxjs48.mergeMap)(function (action) {
|
|
2956
|
+
var _a, _b;
|
|
2781
2957
|
var state = state$.value;
|
|
2782
2958
|
var screenName = state.screen.screenName;
|
|
2783
2959
|
var bcName = action.payload.bcName;
|
|
2784
|
-
var cursor = state.screen.bo.bc[bcName].cursor;
|
|
2785
|
-
var bcUrl = buildBcUrl(bcName, true);
|
|
2960
|
+
var cursor = (_a = state.screen.bo.bc[bcName].cursor) !== null && _a !== void 0 ? _a : "";
|
|
2961
|
+
var bcUrl = (_b = buildBcUrl(bcName, true, state)) !== null && _b !== void 0 ? _b : "";
|
|
2786
2962
|
var canceler = api.createCanceler();
|
|
2787
2963
|
var cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }));
|
|
2788
2964
|
var cancelByParentBc = cancelRequestEpic(action$, [bcSelectRecord], canceler.cancel, bcFetchRowMetaFail({ bcName: bcName }), function (filteredAction) {
|
|
@@ -2850,6 +3026,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
|
|
|
2850
3026
|
}
|
|
2851
3027
|
result.push((0, import_rxjs49.of)(changeDataItem({
|
|
2852
3028
|
bcName: action.payload.bcName,
|
|
3029
|
+
bcUrl: buildBcUrl(action.payload.bcName, true, state),
|
|
2853
3030
|
cursor: action.payload.dataItem.id,
|
|
2854
3031
|
dataItem: action.payload.dataItem
|
|
2855
3032
|
})));
|
|
@@ -2858,7 +3035,7 @@ var changeAssociationFullEpic = function (action$, state$) { return action$.pipe
|
|
|
2858
3035
|
bcName: bcName,
|
|
2859
3036
|
depth: parentDepth,
|
|
2860
3037
|
widgetName: action.payload.widgetName,
|
|
2861
|
-
dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[assocValueKey] }),
|
|
3038
|
+
dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[assocValueKey] }),
|
|
2862
3039
|
assocValueKey: assocValueKey
|
|
2863
3040
|
})));
|
|
2864
3041
|
}
|
|
@@ -2886,19 +3063,21 @@ var import_rxjs50 = require("rxjs");
|
|
|
2886
3063
|
var saveAssociationsActiveEpic = function (action$, state$, _a) {
|
|
2887
3064
|
var api = _a.api;
|
|
2888
3065
|
return action$.pipe((0, import_rxjs50.filter)(saveAssociations.match), (0, import_rxjs50.filter)(function (action) {
|
|
2889
|
-
|
|
3066
|
+
var _a;
|
|
3067
|
+
return (_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active;
|
|
2890
3068
|
}), (0, import_rxjs50.switchMap)(function (action) {
|
|
3069
|
+
var _a, _b;
|
|
2891
3070
|
var state = state$.value;
|
|
2892
|
-
var calleeBCName = state.view.popupData.calleeBCName;
|
|
2893
|
-
var calleeWidgetName = state.view.popupData.calleeWidgetName;
|
|
3071
|
+
var calleeBCName = (_a = state.view.popupData) === null || _a === void 0 ? void 0 : _a.calleeBCName;
|
|
3072
|
+
var calleeWidgetName = (_b = state.view.popupData) === null || _b === void 0 ? void 0 : _b.calleeWidgetName;
|
|
2894
3073
|
var bcNames = action.payload.bcNames;
|
|
2895
|
-
var bcUrl = buildBcUrl(calleeBCName, true);
|
|
3074
|
+
var bcUrl = buildBcUrl(calleeBCName, true, state);
|
|
2896
3075
|
var pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {};
|
|
2897
3076
|
var params = bcNames.length ? { _bcName: bcNames[bcNames.length - 1] } : {};
|
|
2898
3077
|
return api.associate(state.screen.screenName, bcUrl, Object.values(pendingChanges).filter(function (i) { return i._associate; }), params).pipe((0, import_rxjs50.mergeMap)(function (response) {
|
|
2899
3078
|
var postInvoke = response.postActions[0];
|
|
2900
3079
|
var calleeWidget = state.view.widgets.find(function (widgetItem) { return widgetItem.bcName === calleeBCName; });
|
|
2901
|
-
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 })));
|
|
3080
|
+
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 })));
|
|
2902
3081
|
}), (0, import_rxjs50.catchError)(function (err) {
|
|
2903
3082
|
console.error(err);
|
|
2904
3083
|
return import_rxjs50.EMPTY;
|
|
@@ -2908,30 +3087,31 @@ var saveAssociationsActiveEpic = function (action$, state$, _a) {
|
|
|
2908
3087
|
// src/epics/data/changeAssociationSameBcEpic.ts
|
|
2909
3088
|
var import_rxjs51 = require("rxjs");
|
|
2910
3089
|
var changeAssociationSameBcEpic = function (action$, state$) { return action$.pipe((0, import_rxjs51.filter)(changeAssociationSameBc.match), (0, import_rxjs51.mergeMap)(function (action) {
|
|
2911
|
-
var _a, _b, _c, _d, _e;
|
|
3090
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3091
|
+
var state = state$.value;
|
|
2912
3092
|
var bcName = action.payload.bcName;
|
|
2913
3093
|
var result = [
|
|
2914
3094
|
(0, import_rxjs51.of)(changeDataItem({
|
|
2915
3095
|
bcName: bcName,
|
|
3096
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2916
3097
|
cursor: action.payload.dataItem.id,
|
|
2917
3098
|
dataItem: action.payload.dataItem
|
|
2918
3099
|
}))
|
|
2919
3100
|
];
|
|
2920
|
-
var state = state$.value;
|
|
2921
3101
|
var selected = action.payload.dataItem._associate;
|
|
2922
3102
|
var depth = action.payload.depth || 1;
|
|
2923
3103
|
var parentDepth = depth - 1;
|
|
2924
3104
|
var widget = state.view.widgets.find(function (item) { return item.name === action.payload.widgetName; });
|
|
2925
3105
|
var hierarchyTraverse = (_a = widget.options) === null || _a === void 0 ? void 0 : _a.hierarchyTraverse;
|
|
2926
3106
|
var currentData = depth > 1 ? (_b = state.depthData[depth]) === null || _b === void 0 ? void 0 : _b[bcName] : state.data[bcName];
|
|
2927
|
-
var parentCursor = parentDepth ? parentDepth > 1 ? (_c = state.screen.bo.bc[bcName].depthBc[parentDepth]) === null ||
|
|
2928
|
-
var parentItem = parentCursor ? parentDepth > 1 ? (
|
|
3107
|
+
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;
|
|
3108
|
+
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;
|
|
2929
3109
|
if (parentDepth && hierarchyTraverse && selected) {
|
|
2930
3110
|
result.push((0, import_rxjs51.of)(changeAssociationSameBc({
|
|
2931
3111
|
bcName: bcName,
|
|
2932
3112
|
depth: parentDepth,
|
|
2933
3113
|
widgetName: action.payload.widgetName,
|
|
2934
|
-
dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem[action.payload.assocValueKey] }),
|
|
3114
|
+
dataItem: __assign(__assign({}, parentItem), { _associate: true, _value: parentItem === null || parentItem === void 0 ? void 0 : parentItem[action.payload.assocValueKey] }),
|
|
2935
3115
|
assocValueKey: action.payload.assocValueKey
|
|
2936
3116
|
})));
|
|
2937
3117
|
}
|
|
@@ -2956,7 +3136,8 @@ var inlinePickListFetchDataEpic = function (action$, state$, _a) {
|
|
|
2956
3136
|
return action$.pipe((0, import_rxjs52.filter)(inlinePickListFetchDataRequest.match), (0, import_rxjs52.mergeMap)(function (action) {
|
|
2957
3137
|
var _a;
|
|
2958
3138
|
var _b = action.payload, bcName = _b.bcName, searchSpec = _b.searchSpec, searchString = _b.searchString;
|
|
2959
|
-
var
|
|
3139
|
+
var state = state$.value;
|
|
3140
|
+
var bcUrl = buildBcUrl(bcName, false, state);
|
|
2960
3141
|
var canceler = api.createCanceler();
|
|
2961
3142
|
var cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName: bcName, bcUrl: bcUrl }));
|
|
2962
3143
|
var normalFlow = api.fetchBcData(state$.value.screen.screenName, bcUrl, (_a = {}, _a[searchSpec + ".contains"] = searchString, _a), canceler.cancelToken).pipe((0, import_rxjs52.mergeMap)(function (data) {
|
|
@@ -2971,14 +3152,15 @@ var inlinePickListFetchDataEpic = function (action$, state$, _a) {
|
|
|
2971
3152
|
// src/epics/data/saveAssociationsPassiveEpic.ts
|
|
2972
3153
|
var import_rxjs53 = require("rxjs");
|
|
2973
3154
|
var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pipe((0, import_rxjs53.filter)(saveAssociations.match), (0, import_rxjs53.filter)(function () {
|
|
2974
|
-
|
|
3155
|
+
var _a;
|
|
3156
|
+
return !((_a = state$.value.view.popupData) === null || _a === void 0 ? void 0 : _a.active);
|
|
2975
3157
|
}), (0, import_rxjs53.switchMap)(function (action) {
|
|
2976
3158
|
var _a, _b;
|
|
2977
|
-
var _c;
|
|
3159
|
+
var _c, _d;
|
|
2978
3160
|
var state = state$.value;
|
|
2979
|
-
var
|
|
3161
|
+
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;
|
|
2980
3162
|
var cursor = state.screen.bo.bc[calleeBCName].cursor;
|
|
2981
|
-
var recordPrevData = (
|
|
3163
|
+
var recordPrevData = (_d = state.data[calleeBCName].find(function (dataStateRecord) { return dataStateRecord.id === cursor; })[associateFieldKey]) !== null && _d !== void 0 ? _d : [];
|
|
2982
3164
|
var newValues = [];
|
|
2983
3165
|
action.payload.bcNames.forEach(function (pendingBc) {
|
|
2984
3166
|
var pendingChanges = state.view.pendingDataChanges[pendingBc] || {};
|
|
@@ -3004,6 +3186,7 @@ var saveAssociationsPassiveEpic = function (action$, state$) { return action$.pi
|
|
|
3004
3186
|
})).concat.apply(_a, addedItems);
|
|
3005
3187
|
return (0, import_rxjs53.of)(changeDataItem({
|
|
3006
3188
|
bcName: calleeBCName,
|
|
3189
|
+
bcUrl: buildBcUrl(calleeBCName, true, state),
|
|
3007
3190
|
cursor: cursor,
|
|
3008
3191
|
dataItem: (_b = {},
|
|
3009
3192
|
_b[associateFieldKey] = result,
|
|
@@ -3084,7 +3267,6 @@ var ObservableApiWrapper = /** @class */ (function () {
|
|
|
3084
3267
|
this.instance = instance;
|
|
3085
3268
|
}
|
|
3086
3269
|
class_2.prototype.get = function (path, config, callContext) {
|
|
3087
|
-
if (config === void 0) { config = {}; }
|
|
3088
3270
|
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; }));
|
|
3089
3271
|
};
|
|
3090
3272
|
class_2.prototype.put = function (path, data, callContext) {
|
|
@@ -3103,7 +3285,6 @@ var import_axios3 = __toESM(require("axios"));
|
|
|
3103
3285
|
var import_rxjs58 = require("rxjs");
|
|
3104
3286
|
var Api = /** @class */ (function () {
|
|
3105
3287
|
function class_3(instance) {
|
|
3106
|
-
this.api$ = new ObservableApiWrapper();
|
|
3107
3288
|
this.api$ = new ObservableApiWrapper(instance);
|
|
3108
3289
|
}
|
|
3109
3290
|
class_3.prototype.routerRequest = function (path, params) {
|
|
@@ -3128,23 +3309,24 @@ var Api = /** @class */ (function () {
|
|
|
3128
3309
|
};
|
|
3129
3310
|
class_3.prototype.fetchRowMeta = function (screenName, bcUrl, params, cancelToken) {
|
|
3130
3311
|
var url = applyParams(buildUrl(__makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"]), screenName) + bcUrl, params);
|
|
3131
|
-
return this.api$.get(url, { cancelToken: cancelToken }).pipe((0, import_rxjs58.map)(function (response) { return response.data.row; }));
|
|
3312
|
+
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; }));
|
|
3132
3313
|
};
|
|
3133
3314
|
class_3.prototype.newBcData = function (screenName, bcUrl, context, params) {
|
|
3134
3315
|
var url = applyParams(buildUrl(__makeTemplateObject(["row-meta-new/", "/"], ["row-meta-new/", "/"]), screenName) + bcUrl, params);
|
|
3135
|
-
return this.api$.get(url,
|
|
3316
|
+
return this.api$.get(url, void 0, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
|
|
3136
3317
|
};
|
|
3137
3318
|
class_3.prototype.saveBcData = function (screenName, bcUrl, data, context, params) {
|
|
3138
3319
|
var url = applyParams(buildUrl(__makeTemplateObject(["data/", "/"], ["data/", "/"]), screenName) + bcUrl, params);
|
|
3139
3320
|
return this.api$.put(url, { data: data }, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
|
|
3140
3321
|
};
|
|
3141
3322
|
class_3.prototype.deleteBcData = function (screenName, bcUrl, context, params) {
|
|
3323
|
+
if (bcUrl === void 0) { bcUrl = ""; }
|
|
3142
3324
|
var url = applyParams(buildUrl(__makeTemplateObject(["data/", "/"], ["data/", "/"]), screenName) + bcUrl, params);
|
|
3143
3325
|
return this.api$.delete(url, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
|
|
3144
3326
|
};
|
|
3145
3327
|
class_3.prototype.customAction = function (screenName, bcUrl, data, context, params) {
|
|
3146
3328
|
var url = applyParams(buildUrl(__makeTemplateObject(["custom-action/", "/"], ["custom-action/", "/"]), screenName) + bcUrl, params);
|
|
3147
|
-
return this.api$.post(url, { data: data || {} },
|
|
3329
|
+
return this.api$.post(url, { data: data || {} }, void 0, context).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
|
|
3148
3330
|
};
|
|
3149
3331
|
class_3.prototype.associate = function (screenName, bcUrl, data, params) {
|
|
3150
3332
|
var processedData = Array.isArray(data) ? data.map(function (item) { return ({
|
|
@@ -3156,9 +3338,27 @@ var Api = /** @class */ (function () {
|
|
|
3156
3338
|
return this.api$.post(url, processedData).pipe((0, import_rxjs58.map)(function (response) { return response.data; }));
|
|
3157
3339
|
};
|
|
3158
3340
|
class_3.prototype.getRmByForceActive = function (screenName, bcUrl, data, params) {
|
|
3159
|
-
var url = applyParams(buildUrl(__makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"]), screenName) + bcUrl, params);
|
|
3341
|
+
var url = applyParams(buildUrl(__makeTemplateObject(["row-meta/", "/"], ["row-meta/", "/"]), screenName) + (bcUrl !== null && bcUrl !== void 0 ? bcUrl : ""), params);
|
|
3160
3342
|
return this.api$.post(url, { data: data }).pipe((0, import_rxjs58.map)(function (response) { return response.data.row; }));
|
|
3161
3343
|
};
|
|
3344
|
+
Object.defineProperty(class_3.prototype, "fileUploadEndpoint", {
|
|
3345
|
+
/**
|
|
3346
|
+
* Get Cxbox API file upload endpoint based on baseURL of axios instance
|
|
3347
|
+
*
|
|
3348
|
+
* Handles empty baseURL and trailing slash
|
|
3349
|
+
*
|
|
3350
|
+
* @returns File upload endpoint
|
|
3351
|
+
*/
|
|
3352
|
+
get: function () {
|
|
3353
|
+
var instance = this.api$.instance;
|
|
3354
|
+
if (!instance.defaults.baseURL) {
|
|
3355
|
+
return "/file";
|
|
3356
|
+
}
|
|
3357
|
+
return instance.defaults.baseURL.endsWith("/") ? "".concat(instance.defaults.baseURL, "file") : "".concat(instance.defaults.baseURL, "/file");
|
|
3358
|
+
},
|
|
3359
|
+
enumerable: false,
|
|
3360
|
+
configurable: true
|
|
3361
|
+
});
|
|
3162
3362
|
class_3.prototype.refreshMeta = function () {
|
|
3163
3363
|
return this.api$.get(buildUrl(__makeTemplateObject(["bc-registry/refresh-meta"], ["bc-registry/refresh-meta"])));
|
|
3164
3364
|
};
|
|
@@ -3177,13 +3377,241 @@ var Api = /** @class */ (function () {
|
|
|
3177
3377
|
};
|
|
3178
3378
|
return class_3;
|
|
3179
3379
|
}());
|
|
3180
|
-
//
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3380
|
+
// src/utils/autosave.ts
|
|
3381
|
+
function autosaveRoutine(action, store, next) {
|
|
3382
|
+
var _a, _b, _c;
|
|
3383
|
+
var state = store.getState();
|
|
3384
|
+
var dispatch = store.dispatch;
|
|
3385
|
+
var pendingDataChanges = state.view.pendingDataChanges;
|
|
3386
|
+
var bcList = Object.keys(pendingDataChanges);
|
|
3387
|
+
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); });
|
|
3388
|
+
var baseBcName = bcList[baseBcNameIndex];
|
|
3389
|
+
if (baseBcNameIndex > -1) {
|
|
3390
|
+
bcList.splice(baseBcNameIndex, 1);
|
|
3391
|
+
}
|
|
3392
|
+
if (baseBcName) {
|
|
3393
|
+
bcList.forEach(function (bcName) {
|
|
3394
|
+
var _a, _b;
|
|
3395
|
+
var widget = (_a = state.view.widgets) === null || _a === void 0 ? void 0 : _a.find(function (v) { return v.bcName === bcName; });
|
|
3396
|
+
var cursor = (_b = state.screen.bo.bc[bcName]) === null || _b === void 0 ? void 0 : _b.cursor;
|
|
3397
|
+
if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {
|
|
3398
|
+
dispatch(sendOperation({
|
|
3399
|
+
bcName: bcName,
|
|
3400
|
+
operationType: import_schema5.OperationTypeCrud.save,
|
|
3401
|
+
widgetName: widget === null || widget === void 0 ? void 0 : widget.name
|
|
3402
|
+
}));
|
|
3403
|
+
}
|
|
3404
|
+
});
|
|
3405
|
+
var baseWidget = (_c = state.view.widgets) === null || _c === void 0 ? void 0 : _c.find(function (v) { return v.bcName === baseBcName; });
|
|
3406
|
+
return next(sendOperation({
|
|
3407
|
+
bcName: baseBcName,
|
|
3408
|
+
operationType: import_schema5.OperationTypeCrud.save,
|
|
3409
|
+
widgetName: baseWidget === null || baseWidget === void 0 ? void 0 : baseWidget.name,
|
|
3410
|
+
onSuccessAction: action
|
|
3411
|
+
}));
|
|
3412
|
+
}
|
|
3413
|
+
return next(action);
|
|
3414
|
+
}
|
|
3415
|
+
function bcHasPendingAutosaveChanges(store, bcName, cursor) {
|
|
3416
|
+
var _a;
|
|
3417
|
+
var pendingChanges = store.view.pendingDataChanges;
|
|
3418
|
+
var cursorChanges = (_a = pendingChanges[bcName]) === null || _a === void 0 ? void 0 : _a[cursor];
|
|
3419
|
+
var result = cursorChanges && !Object.keys(cursorChanges).includes("_associate") && Object.values(cursorChanges).length > 0;
|
|
3420
|
+
return result;
|
|
3421
|
+
}
|
|
3422
|
+
function checkUnsavedChangesOfBc(store, bcName) {
|
|
3423
|
+
var _a, _b;
|
|
3424
|
+
var pendingCursors = Object.keys((_b = (_a = store.view.pendingDataChanges) === null || _a === void 0 ? void 0 : _a[bcName]) !== null && _b !== void 0 ? _b : {});
|
|
3425
|
+
return pendingCursors.some(function (cursor) { return bcHasPendingAutosaveChanges(store, bcName, cursor); });
|
|
3426
|
+
}
|
|
3427
|
+
// src/middlewares/autosaveMiddleware.ts
|
|
3428
|
+
var saveFormMiddleware = function (_a) {
|
|
3429
|
+
var getState = _a.getState, dispatch = _a.dispatch;
|
|
3430
|
+
return function (next) { return function (action) {
|
|
3431
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3432
|
+
var state = getState();
|
|
3433
|
+
var isSendOperation = sendOperation.match(action);
|
|
3434
|
+
var isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType);
|
|
3435
|
+
var isSelectTableCellInit = selectTableCellInit.match(action);
|
|
3436
|
+
var isSaveAction = isSendOperation && action.payload.operationType === import_schema5.OperationTypeCrud.save;
|
|
3437
|
+
var isNotSaveAction = !isSaveAction;
|
|
3438
|
+
var actionBcName = isSendOperation && action.payload.bcName;
|
|
3439
|
+
var hasAnotherUnsavedBc = Object.keys(state.view.pendingDataChanges).filter(function (key) { return key !== actionBcName; }).filter(function (key) { return checkUnsavedChangesOfBc(state, key); }).length > 0;
|
|
3440
|
+
var isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc;
|
|
3441
|
+
var selectedCell = state.view.selectedCell;
|
|
3442
|
+
var isSelectTableCellInitOnAnotherRowOrWidget = selectedCell && isSelectTableCellInit && (selectedCell.widgetName !== action.payload.widgetName || selectedCell.rowId !== action.payload.rowId);
|
|
3443
|
+
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; });
|
|
3444
|
+
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;
|
|
3445
|
+
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];
|
|
3446
|
+
var isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0;
|
|
3447
|
+
if (isChangeLocation) {
|
|
3448
|
+
return next(sendOperation({
|
|
3449
|
+
bcName: defaultSaveWidget.bcName,
|
|
3450
|
+
operationType: ((_g = defaultSaveWidget.options) === null || _g === void 0 ? void 0 : _g.actionGroups).defaultSave,
|
|
3451
|
+
widgetName: defaultSaveWidget.name,
|
|
3452
|
+
onSuccessAction: action
|
|
3453
|
+
}));
|
|
3454
|
+
}
|
|
3455
|
+
var isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableCellInitOnAnotherRowOrWidget);
|
|
3456
|
+
if (isNeedSaveCondition) {
|
|
3457
|
+
return autosaveRoutine(action, { getState: getState, dispatch: dispatch }, next);
|
|
3458
|
+
}
|
|
3459
|
+
return next(action);
|
|
3460
|
+
}; };
|
|
3461
|
+
};
|
|
3462
|
+
// src/middlewares/requiredFieldsMiddleware.ts
|
|
3463
|
+
var requiredFields = function (_a) {
|
|
3464
|
+
var getState = _a.getState, dispatch = _a.dispatch;
|
|
3465
|
+
return function (next) { return function (action) {
|
|
3466
|
+
var _a, _b, _c, _d;
|
|
3467
|
+
var state = getState();
|
|
3468
|
+
if (sendOperation.match(action)) {
|
|
3469
|
+
var _e = action.payload, bcName = _e.bcName, operationType = _e.operationType, widgetName_1 = _e.widgetName;
|
|
3470
|
+
var cursor_1 = (_a = state.screen.bo.bc[bcName]) === null || _a === void 0 ? void 0 : _a.cursor;
|
|
3471
|
+
if (cursor_1) {
|
|
3472
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
3473
|
+
var record = (_b = state.data[bcName]) === null || _b === void 0 ? void 0 : _b.find(function (item) { return item.id === cursor_1; });
|
|
3474
|
+
var rowMeta_1 = bcUrl && ((_c = state.view.rowMeta[bcName]) === null || _c === void 0 ? void 0 : _c[bcUrl]);
|
|
3475
|
+
var pendingValues = (_d = state.view.pendingDataChanges[bcName]) === null || _d === void 0 ? void 0 : _d[cursor_1];
|
|
3476
|
+
var widget_1 = state.view.widgets.find(function (item) { return item.name === widgetName_1; });
|
|
3477
|
+
if (operationRequiresAutosave(operationType, rowMeta_1 === null || rowMeta_1 === void 0 ? void 0 : rowMeta_1.actions)) {
|
|
3478
|
+
var fieldsToCheck_1 = {};
|
|
3479
|
+
state.view.widgets.filter(function (item) { return item.bcName === (widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.bcName); }).forEach(function (item) {
|
|
3480
|
+
var itemFieldsCalc = item.fields;
|
|
3481
|
+
if (item.fields) {
|
|
3482
|
+
item.fields.forEach(function (block) {
|
|
3483
|
+
if (isWidgetFieldBlock(block)) {
|
|
3484
|
+
block.fields.forEach(function (field) { return itemFieldsCalc.push(field); });
|
|
3485
|
+
}
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
itemFieldsCalc.forEach(function (widgetField) {
|
|
3489
|
+
var _a;
|
|
3490
|
+
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; });
|
|
3491
|
+
if (!fieldsToCheck_1[widgetField.key] && matchingRowMeta && !matchingRowMeta.hidden) {
|
|
3492
|
+
fieldsToCheck_1[widgetField.key] = matchingRowMeta;
|
|
3493
|
+
}
|
|
3494
|
+
});
|
|
3495
|
+
});
|
|
3496
|
+
var dataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck_1));
|
|
3497
|
+
if (dataItem && TableLikeWidgetTypes.includes(widget_1 === null || widget_1 === void 0 ? void 0 : widget_1.type)) {
|
|
3498
|
+
dispatch(selectTableCellInit({ widgetName: widgetName_1, rowId: cursor_1, fieldKey: Object.keys(dataItem)[0] }));
|
|
3499
|
+
}
|
|
3500
|
+
return dataItem ? next(changeDataItem({ bcName: bcName, bcUrl: buildBcUrl(bcName, true, state), cursor: cursor_1, dataItem: dataItem })) : next(action);
|
|
3501
|
+
}
|
|
3502
|
+
if (hasPendingValidationFails(state, bcName)) {
|
|
3503
|
+
return addNotification({
|
|
3504
|
+
key: "requiredFieldsMissing",
|
|
3505
|
+
type: "buttonWarningNotification",
|
|
3506
|
+
message: "Required fields are missing",
|
|
3507
|
+
duration: 0,
|
|
3508
|
+
options: {
|
|
3509
|
+
buttonWarningNotificationOptions: {
|
|
3510
|
+
buttonText: "Cancel changes",
|
|
3511
|
+
actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
return next(action);
|
|
3519
|
+
}; };
|
|
3520
|
+
};
|
|
3521
|
+
function operationRequiresAutosave(operationType, actions) {
|
|
3522
|
+
var result = false;
|
|
3523
|
+
if (!actions) {
|
|
3524
|
+
console.error('rowMeta is missing in the middle of "sendOperation" action');
|
|
3525
|
+
return result;
|
|
3526
|
+
}
|
|
3527
|
+
result = flattenOperations(actions).some(function (action) { return action.type === operationType && action.autoSaveBefore; });
|
|
3528
|
+
return result;
|
|
3529
|
+
}
|
|
3530
|
+
function getRequiredFieldsMissing(record, pendingChanges, fieldsMeta) {
|
|
3531
|
+
var result = {};
|
|
3532
|
+
fieldsMeta.forEach(function (field) {
|
|
3533
|
+
var value = record === null || record === void 0 ? void 0 : record[field.key];
|
|
3534
|
+
var pendingValue = pendingChanges === null || pendingChanges === void 0 ? void 0 : pendingChanges[field.key];
|
|
3535
|
+
var effectiveValue = pendingValue !== void 0 ? pendingValue : value;
|
|
3536
|
+
var falsyValue = false;
|
|
3537
|
+
if (effectiveValue === null || effectiveValue === void 0 || effectiveValue === "") {
|
|
3538
|
+
falsyValue = true;
|
|
3539
|
+
}
|
|
3540
|
+
else if (Array.isArray(effectiveValue) && !effectiveValue.length) {
|
|
3541
|
+
falsyValue = true;
|
|
3542
|
+
}
|
|
3543
|
+
else if (effectiveValue && typeof effectiveValue === "object" && !Object.keys(effectiveValue).length) {
|
|
3544
|
+
falsyValue = true;
|
|
3545
|
+
}
|
|
3546
|
+
if (field.required && falsyValue) {
|
|
3547
|
+
result[field.key] = Array.isArray(effectiveValue) ? [] : null;
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
3551
|
+
}
|
|
3552
|
+
function hasPendingValidationFails(store, bcName) {
|
|
3553
|
+
var _a;
|
|
3554
|
+
if (store.view.pendingValidationFailsFormat !== "target" /* target */ && store.view.pendingValidationFails && Object.keys(store.view.pendingValidationFails).length) {
|
|
3555
|
+
return true;
|
|
3556
|
+
}
|
|
3557
|
+
var checkResult = false;
|
|
3558
|
+
var bcPendingValidations = (_a = store.view.pendingValidationFails) === null || _a === void 0 ? void 0 : _a[bcName];
|
|
3559
|
+
var cursorsList = bcPendingValidations && Object.keys(bcPendingValidations);
|
|
3560
|
+
if (!cursorsList) {
|
|
3561
|
+
return false;
|
|
3562
|
+
}
|
|
3563
|
+
var i = 0;
|
|
3564
|
+
for (; i < cursorsList.length; i++) {
|
|
3565
|
+
if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {
|
|
3566
|
+
checkResult = true;
|
|
3567
|
+
break;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
return checkResult;
|
|
3571
|
+
}
|
|
3572
|
+
// src/middlewares/preInvokeMiddleware.ts
|
|
3573
|
+
var preInvokeAction = function (_a) {
|
|
3574
|
+
var getState = _a.getState;
|
|
3575
|
+
return function (next) { return function (action) {
|
|
3576
|
+
var _a, _b, _c;
|
|
3577
|
+
if (sendOperation.match(action)) {
|
|
3578
|
+
var state = getState();
|
|
3579
|
+
var _d = action.payload, operationType_1 = _d.operationType, widgetName_2 = _d.widgetName, confirm = _d.confirm;
|
|
3580
|
+
var bcName = (_a = state.view.widgets.find(function (widgetItem) { return widgetItem.name === widgetName_2; })) === null || _a === void 0 ? void 0 : _a.bcName;
|
|
3581
|
+
var bcUrl = buildBcUrl(bcName, true, state);
|
|
3582
|
+
var rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) === null || _b === void 0 ? void 0 : _b[bcUrl]);
|
|
3583
|
+
var actions = rowMeta && flattenOperations(rowMeta.actions);
|
|
3584
|
+
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;
|
|
3585
|
+
return preInvoke && !confirm ? next(processPreInvoke({
|
|
3586
|
+
bcName: bcName,
|
|
3587
|
+
operationType: operationType_1,
|
|
3588
|
+
widgetName: widgetName_2,
|
|
3589
|
+
preInvoke: preInvoke
|
|
3590
|
+
})) : next(action);
|
|
3591
|
+
}
|
|
3592
|
+
return next(action);
|
|
3593
|
+
}; };
|
|
3594
|
+
};
|
|
3595
|
+
// src/middlewares/popupMiddleware.ts
|
|
3596
|
+
var popupMiddleware = function (_a) {
|
|
3597
|
+
var getState = _a.getState;
|
|
3598
|
+
return function (next) { return function (action) {
|
|
3599
|
+
var _a, _b, _c;
|
|
3600
|
+
if (showViewPopup.match(action)) {
|
|
3601
|
+
var state = getState();
|
|
3602
|
+
var bcName_1 = action.payload.bcName;
|
|
3603
|
+
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;
|
|
3604
|
+
var assocValueKey = (_c = action.payload.assocValueKey) !== null && _c !== void 0 ? _c : widgetValueKey;
|
|
3605
|
+
return widgetValueKey ? next(showViewPopup(__assign(__assign({}, action.payload), { assocValueKey: assocValueKey }))) : next(action);
|
|
3606
|
+
}
|
|
3607
|
+
return next(action);
|
|
3608
|
+
}; };
|
|
3609
|
+
};
|
|
3610
|
+
// src/middlewares/index.ts
|
|
3611
|
+
var middlewares = {
|
|
3612
|
+
autosave: saveFormMiddleware,
|
|
3613
|
+
requiredFields: requiredFields,
|
|
3614
|
+
preInvoke: preInvokeAction,
|
|
3615
|
+
popup: popupMiddleware
|
|
3616
|
+
};
|
|
3189
3617
|
//# sourceMappingURL=cxbox-ui-core.cjs.development.js.map
|