@cxbox-ui/core 1.37.2-alpha.1 → 1.37.2-alpha.11
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 +14 -18
- package/dist/api/ObservableApi.d.ts +10 -2
- package/dist/api/ObservableApiWrapper.d.ts +1 -1
- package/dist/cxbox-ui-core.cjs.development.js +956 -500
- package/dist/cxbox-ui-core.cjs.production.min.js +1 -1
- package/dist/cxbox-ui-core.esm.js +799 -335
- package/dist/cxbox-ui-core.modern.development.js +788 -331
- package/dist/cxbox-ui-core.modern.js +788 -331
- 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/session.d.ts +1 -0
- 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/apiError.d.ts +19 -0
- 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/index.d.ts +1 -0
- package/dist/utils/strings.d.ts +2 -2
- package/package.json +2 -2
|
@@ -113,6 +113,8 @@ __export(actions_exports, {
|
|
|
113
113
|
processPreInvoke: () => processPreInvoke,
|
|
114
114
|
refreshMeta: () => refreshMeta,
|
|
115
115
|
refreshMetaAndReloadPage: () => refreshMetaAndReloadPage,
|
|
116
|
+
refreshMetaDone: () => refreshMetaDone,
|
|
117
|
+
refreshMetaFail: () => refreshMetaFail,
|
|
116
118
|
removeMultivalueTag: () => removeMultivalueTag,
|
|
117
119
|
removeNotifications: () => removeNotifications,
|
|
118
120
|
removePendingRequest: () => removePendingRequest,
|
|
@@ -163,7 +165,7 @@ var bcFetchRowMetaSuccess = createAction("bcFetchRowMetaSuccess");
|
|
|
163
165
|
var bcFetchRowMetaFail = createAction("bcFetchRowMetaFail");
|
|
164
166
|
var bcNewData = createAction("bcNewData");
|
|
165
167
|
var bcNewDataSuccess = createAction("bcNewDataSuccess");
|
|
166
|
-
var bcNewDataFail = createAction("
|
|
168
|
+
var bcNewDataFail = createAction("bcNewDataFail");
|
|
167
169
|
var bcDeleteDataFail = createAction("bcDeleteDataFail");
|
|
168
170
|
var forceActiveChangeFail = createAction("forceActiveChangeFail");
|
|
169
171
|
var sendOperation = createAction("sendOperation");
|
|
@@ -178,7 +180,7 @@ var drillDown = createAction("drillDown");
|
|
|
178
180
|
var bcChangeCursors = createAction("bcChangeCursors");
|
|
179
181
|
var bcChangeDepthCursor = createAction("bcChangeDepthCursor");
|
|
180
182
|
var changeDataItem = createAction("changeDataItem");
|
|
181
|
-
var changeDataItems = createAction("
|
|
183
|
+
var changeDataItems = createAction("changeDataItems");
|
|
182
184
|
var forceActiveRmUpdate = createAction("forceActiveRmUpdate");
|
|
183
185
|
var showViewPopup = createAction("showViewPopup");
|
|
184
186
|
var showFileUploadPopup = createAction("showFileUploadPopup");
|
|
@@ -232,6 +234,8 @@ var switchDebugMode = createAction("switchDebugMode");
|
|
|
232
234
|
var exportState = createAction("exportState");
|
|
233
235
|
var emptyAction = createAction("emptyAction");
|
|
234
236
|
var refreshMeta = createAction("refreshMeta");
|
|
237
|
+
var refreshMetaDone = createAction("refreshMetaDone");
|
|
238
|
+
var refreshMetaFail = createAction("refreshMetaFail");
|
|
235
239
|
var refreshMetaAndReloadPage = createAction("refreshMetaAndReloadPage");
|
|
236
240
|
var switchRole = createAction("switchRole");
|
|
237
241
|
var addPendingRequest = createAction("addPendingRequest");
|
|
@@ -339,8 +343,10 @@ __export(interfaces_exports, {
|
|
|
339
343
|
PaginationMode: () => PaginationMode,
|
|
340
344
|
PendingValidationFailsFormat: () => PendingValidationFailsFormat,
|
|
341
345
|
PopupWidgetTypes: () => PopupWidgetTypes,
|
|
346
|
+
PositionTypes: () => PositionTypes,
|
|
342
347
|
RouteType: () => RouteType,
|
|
343
348
|
TableLikeWidgetTypes: () => TableLikeWidgetTypes,
|
|
349
|
+
WidgetTypes: () => WidgetTypes2,
|
|
344
350
|
coreOperations: () => coreOperations,
|
|
345
351
|
isCustomWidget: () => isCustomWidget,
|
|
346
352
|
isCustomWidgetConfiguration: () => isCustomWidgetConfiguration,
|
|
@@ -383,6 +389,7 @@ var ApplicationErrorType = /* @__PURE__ */ ((ApplicationErrorType2) => {
|
|
|
383
389
|
})(ApplicationErrorType || {});
|
|
384
390
|
// src/interfaces/widget.ts
|
|
385
391
|
import { WidgetTypes } from "@cxbox-ui/schema";
|
|
392
|
+
import { WidgetTypes as WidgetTypes2, PositionTypes } from "@cxbox-ui/schema";
|
|
386
393
|
var TableLikeWidgetTypes = [
|
|
387
394
|
WidgetTypes.List,
|
|
388
395
|
WidgetTypes.DataGrid,
|
|
@@ -465,6 +472,15 @@ function isViewNavigationCategory(item) {
|
|
|
465
472
|
function isViewNavigationGroup(item) {
|
|
466
473
|
return !!item && "child" in item && !("categoryName" in item);
|
|
467
474
|
}
|
|
475
|
+
// src/reducers/router.ts
|
|
476
|
+
var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
|
|
477
|
+
var createRouterReducerBuilderManager = (initialState) => new ReducerBuilderManager().addCase(loginDone, (state, action) => {
|
|
478
|
+
state = __spreadValues(__spreadValues({}, state), action.payload);
|
|
479
|
+
}).addCase(changeLocation, (state, action) => {
|
|
480
|
+
state = __spreadValues(__spreadValues({}, state), action.payload.location);
|
|
481
|
+
});
|
|
482
|
+
// src/reducers/screen.ts
|
|
483
|
+
import { OperationTypeCrud as OperationTypeCrud3 } from "@cxbox-ui/schema";
|
|
468
484
|
// src/utils/index.ts
|
|
469
485
|
var utils_exports = {};
|
|
470
486
|
__export(utils_exports, {
|
|
@@ -477,6 +493,8 @@ __export(utils_exports, {
|
|
|
477
493
|
buildSearchResultTree: () => buildSearchResultTree,
|
|
478
494
|
buildUrl: () => buildUrl,
|
|
479
495
|
checkShowCondition: () => checkShowCondition,
|
|
496
|
+
createApiError: () => createApiError,
|
|
497
|
+
createApiErrorObservable: () => createApiErrorObservable,
|
|
480
498
|
defaultBuildURL: () => defaultBuildURL,
|
|
481
499
|
defaultParseURL: () => defaultParseURL,
|
|
482
500
|
deleteUndefinedFromObject: () => deleteUndefinedFromObject,
|
|
@@ -485,7 +503,6 @@ __export(utils_exports, {
|
|
|
485
503
|
getBcChildren: () => getBcChildren,
|
|
486
504
|
getDescendants: () => getDescendants,
|
|
487
505
|
getFieldTitle: () => getFieldTitle,
|
|
488
|
-
getFileUploadEndpoint: () => getFileUploadEndpoint,
|
|
489
506
|
getFilterType: () => getFilterType,
|
|
490
507
|
getFilters: () => getFilters,
|
|
491
508
|
getSorters: () => getSorters,
|
|
@@ -525,11 +542,17 @@ function applyRawParams(url, qso) {
|
|
|
525
542
|
const result = new URLSearchParams(qso).toString();
|
|
526
543
|
return `${addTailControlSequences(url)}${result && `${result}`}`;
|
|
527
544
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
545
|
+
// src/utils/apiError.ts
|
|
546
|
+
import { actions } from "@cxbox-ui/core";
|
|
547
|
+
import { EMPTY, of } from "rxjs";
|
|
548
|
+
function createApiError(error, context = { widgetName: "unknown" }) {
|
|
549
|
+
if (!error.isAxiosError)
|
|
550
|
+
return void 0;
|
|
551
|
+
return actions.apiError({ error, callContext: context });
|
|
552
|
+
}
|
|
553
|
+
function createApiErrorObservable(error, context) {
|
|
554
|
+
const apiError2 = createApiError(error, context);
|
|
555
|
+
return apiError2 ? of(apiError2) : EMPTY;
|
|
533
556
|
}
|
|
534
557
|
// src/utils/strings.ts
|
|
535
558
|
function getTemplate(literals, ...placeholders) {
|
|
@@ -541,9 +564,8 @@ function getTemplate(literals, ...placeholders) {
|
|
|
541
564
|
result += literals[literals.length - 1];
|
|
542
565
|
return result;
|
|
543
566
|
}
|
|
544
|
-
function buildBcUrl(bcName, includeSelf = false,
|
|
545
|
-
const
|
|
546
|
-
const bcMap = storeInstance.screen.bo.bc;
|
|
567
|
+
function buildBcUrl(bcName, includeSelf = false, state) {
|
|
568
|
+
const bcMap = state.screen.bo.bc;
|
|
547
569
|
const bc = bcMap[bcName];
|
|
548
570
|
if (!bc) {
|
|
549
571
|
return null;
|
|
@@ -672,7 +694,7 @@ function defaultParseURL(url) {
|
|
|
672
694
|
}
|
|
673
695
|
return {
|
|
674
696
|
type,
|
|
675
|
-
path,
|
|
697
|
+
path: path.length !== 0 && !path.startsWith("/") ? `/${path}` : path,
|
|
676
698
|
params,
|
|
677
699
|
screenName,
|
|
678
700
|
viewName,
|
|
@@ -719,9 +741,9 @@ function getSorters(sorters) {
|
|
|
719
741
|
});
|
|
720
742
|
return result;
|
|
721
743
|
}
|
|
722
|
-
function parseFilters(defaultFilters) {
|
|
744
|
+
function parseFilters(defaultFilters = "") {
|
|
723
745
|
const result = [];
|
|
724
|
-
const urlParams = new URL(defaultFilters).searchParams;
|
|
746
|
+
const urlParams = new URL(defaultFilters, window.location.origin).searchParams;
|
|
725
747
|
urlParams.forEach((param) => {
|
|
726
748
|
const [fieldName, type] = param.split(".");
|
|
727
749
|
if (fieldName && type && urlParams.get(param)) {
|
|
@@ -751,7 +773,7 @@ function parseSorters(sorters) {
|
|
|
751
773
|
return null;
|
|
752
774
|
}
|
|
753
775
|
const result = [];
|
|
754
|
-
const dictionary = new URL(sorters).searchParams;
|
|
776
|
+
const dictionary = new URL(sorters, window.location.origin).searchParams;
|
|
755
777
|
Object.entries(dictionary).map(([sort, fieldKey]) => {
|
|
756
778
|
const [order, direction] = sort.split(".").slice(1);
|
|
757
779
|
return { fieldName: fieldKey, order: Number.parseInt(order, 10), direction };
|
|
@@ -832,12 +854,13 @@ function getBcChildren(originBcName, widgets, bcMap) {
|
|
|
832
854
|
return childrenBcMap;
|
|
833
855
|
}
|
|
834
856
|
function getHierarchyChildBc(originBcName, hierarchyWidget) {
|
|
835
|
-
|
|
836
|
-
|
|
857
|
+
var _a, _b;
|
|
858
|
+
const nestedBcNames = (_b = (_a = hierarchyWidget == null ? void 0 : hierarchyWidget.options) == null ? void 0 : _a.hierarchy) == null ? void 0 : _b.map((nestedItem) => nestedItem.bcName);
|
|
859
|
+
if (originBcName !== hierarchyWidget.bcName && !(nestedBcNames == null ? void 0 : nestedBcNames.includes(originBcName))) {
|
|
837
860
|
return [];
|
|
838
861
|
}
|
|
839
|
-
const childHierarchyBcIndex = nestedBcNames.findIndex((item) => item === originBcName);
|
|
840
|
-
const childHierarchyBcName = nestedBcNames[childHierarchyBcIndex + 1];
|
|
862
|
+
const childHierarchyBcIndex = nestedBcNames == null ? void 0 : nestedBcNames.findIndex((item) => item === originBcName);
|
|
863
|
+
const childHierarchyBcName = nestedBcNames == null ? void 0 : nestedBcNames[childHierarchyBcIndex + 1];
|
|
841
864
|
return [childHierarchyBcName, hierarchyWidget.name];
|
|
842
865
|
}
|
|
843
866
|
function checkShowCondition(condition, cursor, data, pendingDataChanges) {
|
|
@@ -851,9 +874,9 @@ function checkShowCondition(condition, cursor, data, pendingDataChanges) {
|
|
|
851
874
|
if (!record) {
|
|
852
875
|
return false;
|
|
853
876
|
}
|
|
854
|
-
const actualValue = record == null ? void 0 : record[params.fieldKey];
|
|
855
|
-
const pendingValue = (_b = (_a = pendingDataChanges == null ? void 0 : pendingDataChanges[bcName]) == null ? void 0 : _a[cursor]) == null ? void 0 : _b[params.fieldKey];
|
|
856
|
-
return pendingValue !== void 0 ? pendingValue === params.value : actualValue === params.value;
|
|
877
|
+
const actualValue = record == null ? void 0 : record[params == null ? void 0 : params.fieldKey];
|
|
878
|
+
const pendingValue = (_b = (_a = pendingDataChanges == null ? void 0 : pendingDataChanges[bcName]) == null ? void 0 : _a[cursor]) == null ? void 0 : _b[params == null ? void 0 : params.fieldKey];
|
|
879
|
+
return pendingValue !== void 0 ? pendingValue === (params == null ? void 0 : params.value) : actualValue === (params == null ? void 0 : params.value);
|
|
857
880
|
}
|
|
858
881
|
// src/utils/tree.ts
|
|
859
882
|
function assignTreeLinks(flat) {
|
|
@@ -861,6 +884,7 @@ function assignTreeLinks(flat) {
|
|
|
861
884
|
const map12 = {};
|
|
862
885
|
const orphans = [];
|
|
863
886
|
result.forEach((item) => {
|
|
887
|
+
var _a, _b;
|
|
864
888
|
if (!item.parentId || item.parentId === "0") {
|
|
865
889
|
return;
|
|
866
890
|
}
|
|
@@ -879,7 +903,7 @@ function assignTreeLinks(flat) {
|
|
|
879
903
|
result[parentIndex].children = [item];
|
|
880
904
|
}
|
|
881
905
|
else {
|
|
882
|
-
result[parentIndex].children.push(item);
|
|
906
|
+
(_b = (_a = result[parentIndex]) == null ? void 0 : _a.children) == null ? void 0 : _b.push(item);
|
|
883
907
|
}
|
|
884
908
|
});
|
|
885
909
|
if (orphans.length) {
|
|
@@ -955,22 +979,7 @@ function deleteUndefinedFromObject(obj) {
|
|
|
955
979
|
}
|
|
956
980
|
});
|
|
957
981
|
}
|
|
958
|
-
// src/reducers/router.ts
|
|
959
|
-
var initialRouterState = { type: "default" /* default */, path: "/", params: null, screenName: null };
|
|
960
|
-
var createRouterReducerBuilderManager = (initialState) => new ReducerBuilderManager().addCase(loginDone, (state, action) => {
|
|
961
|
-
state = __spreadValues(__spreadValues({}, state), action.payload);
|
|
962
|
-
}).addCase(changeLocation, (state, action) => {
|
|
963
|
-
const { url, route } = action.payload;
|
|
964
|
-
if (url) {
|
|
965
|
-
const path = new URL(url);
|
|
966
|
-
state = __spreadValues(__spreadValues({}, state), defaultParseURL(path));
|
|
967
|
-
}
|
|
968
|
-
if (route !== null) {
|
|
969
|
-
state = __spreadValues(__spreadValues({}, state), route);
|
|
970
|
-
}
|
|
971
|
-
});
|
|
972
982
|
// src/reducers/screen.ts
|
|
973
|
-
import { OperationTypeCrud as OperationTypeCrud3 } from "@cxbox-ui/schema";
|
|
974
983
|
var initialScreenState = {
|
|
975
984
|
screenName: "",
|
|
976
985
|
bo: { activeBcName: "", bc: {} },
|
|
@@ -982,10 +991,11 @@ var initialScreenState = {
|
|
|
982
991
|
};
|
|
983
992
|
var operationsHandledLocally = [OperationTypeCrud3.associate, OperationTypeCrud3.fileUpload];
|
|
984
993
|
var createScreenReducerBuilderManager = (initialState) => new ReducerBuilderManager().addCase(selectScreen, (state, action) => {
|
|
994
|
+
var _a, _b, _c, _d, _e;
|
|
985
995
|
const bcDictionary = {};
|
|
986
996
|
const bcSorters = {};
|
|
987
997
|
const bcFilters = {};
|
|
988
|
-
action.payload.screen.meta.bo.bc.forEach((item) => {
|
|
998
|
+
(_a = action.payload.screen.meta) == null ? void 0 : _a.bo.bc.forEach((item) => {
|
|
989
999
|
bcDictionary[item.name] = item;
|
|
990
1000
|
const sorter = parseSorters(item.defaultSort);
|
|
991
1001
|
const filter56 = parseFilters(item.defaultFilter);
|
|
@@ -997,8 +1007,8 @@ var createScreenReducerBuilderManager = (initialState) => new ReducerBuilderMana
|
|
|
997
1007
|
}
|
|
998
1008
|
});
|
|
999
1009
|
state.screenName = action.payload.screen.name;
|
|
1000
|
-
state.primaryView = action.payload.screen.meta.primary;
|
|
1001
|
-
state.views = action.payload.screen.meta.views;
|
|
1010
|
+
state.primaryView = (_c = (_b = action.payload.screen.meta) == null ? void 0 : _b.primary) != null ? _c : state.primaryView;
|
|
1011
|
+
state.views = (_e = (_d = action.payload.screen.meta) == null ? void 0 : _d.views) != null ? _e : state.views;
|
|
1002
1012
|
state.bo = { activeBcName: null, bc: bcDictionary };
|
|
1003
1013
|
state.sorters = __spreadValues(__spreadValues({}, state.sorters), bcSorters);
|
|
1004
1014
|
state.filters = __spreadValues(__spreadValues({}, state.filters), bcFilters);
|
|
@@ -1008,12 +1018,14 @@ var createScreenReducerBuilderManager = (initialState) => new ReducerBuilderMana
|
|
|
1008
1018
|
}).addCase(bcFetchDataRequest, (state, action) => {
|
|
1009
1019
|
state.bo.bc[action.payload.bcName].loading = true;
|
|
1010
1020
|
}).addCase(bcLoadMore, (state, action) => {
|
|
1021
|
+
var _a;
|
|
1011
1022
|
const currentBc = state.bo.bc[action.payload.bcName];
|
|
1012
|
-
currentBc.page
|
|
1023
|
+
currentBc.page = ((_a = currentBc.page) != null ? _a : 1) + 1;
|
|
1013
1024
|
currentBc.loading = true;
|
|
1014
1025
|
}).addCase(selectView, (state, action) => {
|
|
1026
|
+
var _a;
|
|
1015
1027
|
const newBcs = {};
|
|
1016
|
-
Array.from(new Set(action.payload.widgets.map((widget) => widget.bcName))
|
|
1028
|
+
Array.from(new Set((_a = action.payload.widgets) == null ? void 0 : _a.map((widget) => widget.bcName))
|
|
1017
1029
|
// БК которые есть на вьюхе
|
|
1018
1030
|
).filter((bcName) => state.bo.bc[bcName]).forEach((bcName) => {
|
|
1019
1031
|
newBcs[bcName] = __spreadProps(__spreadValues({}, state.bo.bc[bcName]), { page: 1 });
|
|
@@ -1025,9 +1037,10 @@ var createScreenReducerBuilderManager = (initialState) => new ReducerBuilderMana
|
|
|
1025
1037
|
currentBc.loading = false;
|
|
1026
1038
|
state.cachedBc[action.payload.bcName] = action.payload.bcUrl;
|
|
1027
1039
|
}).addCase(bcFetchDataFail, (state, action) => {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
state.
|
|
1040
|
+
const bcName = action.payload.bcName;
|
|
1041
|
+
if (Object.values(state.bo.bc).some((bc) => bc.name === bcName)) {
|
|
1042
|
+
state.bo.bc[bcName].loading = false;
|
|
1043
|
+
state.cachedBc[bcName] = action.payload.bcUrl;
|
|
1031
1044
|
}
|
|
1032
1045
|
}).addCase(sendOperation, (state, action) => {
|
|
1033
1046
|
if (!operationsHandledLocally.includes(action.payload.operationType)) {
|
|
@@ -1055,10 +1068,12 @@ var createScreenReducerBuilderManager = (initialState) => new ReducerBuilderMana
|
|
|
1055
1068
|
Object.assign(state.bo.bc, newCursors);
|
|
1056
1069
|
Object.assign(state.cachedBc, newCache);
|
|
1057
1070
|
}).addCase(bcChangeDepthCursor, (state, action) => {
|
|
1071
|
+
var _a;
|
|
1058
1072
|
if (action.payload.depth === 1) {
|
|
1059
1073
|
state.bo.bc[action.payload.bcName].cursor = action.payload.cursor;
|
|
1060
1074
|
}
|
|
1061
1075
|
else {
|
|
1076
|
+
state.bo.bc[action.payload.bcName].depthBc = (_a = state.bo.bc[action.payload.bcName].depthBc) != null ? _a : {};
|
|
1062
1077
|
state.bo.bc[action.payload.bcName].depthBc[action.payload.depth].cursor = action.payload.cursor;
|
|
1063
1078
|
}
|
|
1064
1079
|
}).addCase(bcSelectRecord, (state, action) => {
|
|
@@ -1093,7 +1108,9 @@ var createScreenReducerBuilderManager = (initialState) => new ReducerBuilderMana
|
|
|
1093
1108
|
state.bo.bc[action.payload.bcName].page = action.payload.page;
|
|
1094
1109
|
state.bo.bc[action.payload.bcName].loading = true;
|
|
1095
1110
|
}).addCase(showViewPopup, (state, action) => {
|
|
1096
|
-
|
|
1111
|
+
var _a, _b;
|
|
1112
|
+
const currentPage = (_b = (_a = state.bo.bc[action.payload.bcName]) == null ? void 0 : _a.page) != null ? _b : 1;
|
|
1113
|
+
state.bo.bc[action.payload.bcName].page = action.payload.bcName === action.payload.calleeBCName ? currentPage : 1;
|
|
1097
1114
|
state.bo.bc[action.payload.bcName].loading = action.payload.bcName !== action.payload.calleeBCName;
|
|
1098
1115
|
}).addCase(sendOperationSuccess, (state, action) => {
|
|
1099
1116
|
state.bo.bc[action.payload.bcName].loading = false;
|
|
@@ -1122,7 +1139,8 @@ var initialSessionState = {
|
|
|
1122
1139
|
errorMsg: null,
|
|
1123
1140
|
screens: [],
|
|
1124
1141
|
pendingRequests: [],
|
|
1125
|
-
notifications: []
|
|
1142
|
+
notifications: [],
|
|
1143
|
+
isMetaRefreshing: false
|
|
1126
1144
|
};
|
|
1127
1145
|
var createSessionReducerBuilderManager = (initialState) => new ReducerBuilderManager().addCase(login, (state) => {
|
|
1128
1146
|
state.loginSpin = true;
|
|
@@ -1142,14 +1160,22 @@ var createSessionReducerBuilderManager = (initialState) => new ReducerBuilderMan
|
|
|
1142
1160
|
}).addCase(switchDebugMode, (state, action) => {
|
|
1143
1161
|
state.debugMode = action.payload;
|
|
1144
1162
|
}).addCase(addPendingRequest, (state, action) => {
|
|
1145
|
-
|
|
1163
|
+
var _a;
|
|
1164
|
+
(_a = state.pendingRequests) == null ? void 0 : _a.push(action.payload.request);
|
|
1146
1165
|
}).addCase(removePendingRequest, (state, action) => {
|
|
1147
|
-
|
|
1166
|
+
var _a;
|
|
1167
|
+
state.pendingRequests = (_a = state.pendingRequests) == null ? void 0 : _a.filter((item) => item.requestId !== action.payload.requestId);
|
|
1148
1168
|
}).addCase(addNotification, (state, action) => {
|
|
1149
1169
|
state.notifications.push(action.payload);
|
|
1150
1170
|
}).addCase(removeNotifications, (state, action) => {
|
|
1151
1171
|
const closingKeys = action.payload;
|
|
1152
1172
|
state.notifications = state.notifications.filter((notification) => !closingKeys.includes(notification.key));
|
|
1173
|
+
}).addCase(refreshMeta, (state) => {
|
|
1174
|
+
state.isMetaRefreshing = true;
|
|
1175
|
+
}).addCase(refreshMetaDone, (state) => {
|
|
1176
|
+
state.isMetaRefreshing = false;
|
|
1177
|
+
}).addCase(refreshMetaFail, (state) => {
|
|
1178
|
+
state.isMetaRefreshing = false;
|
|
1153
1179
|
});
|
|
1154
1180
|
// src/reducers/view.ts
|
|
1155
1181
|
import { OperationTypeCrud as OperationTypeCrud4 } from "@cxbox-ui/schema";
|
|
@@ -1191,11 +1217,14 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1191
1217
|
state.metaInProgress[action.payload.bcName] = true;
|
|
1192
1218
|
}
|
|
1193
1219
|
}).addCase(bcFetchRowMetaSuccess, (state, action) => {
|
|
1220
|
+
var _a;
|
|
1221
|
+
state.rowMeta[action.payload.bcName] = (_a = state.rowMeta[action.payload.bcName]) != null ? _a : {};
|
|
1194
1222
|
state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
|
|
1195
1223
|
state.metaInProgress[action.payload.bcName] = false;
|
|
1196
1224
|
}).addCase(bcNewDataSuccess, (state, action) => {
|
|
1197
1225
|
state.selectedCell = initialViewState.selectedCell;
|
|
1198
1226
|
}).addCase(forceActiveRmUpdate, (state, action) => {
|
|
1227
|
+
var _a, _b, _c, _d, _e;
|
|
1199
1228
|
const { bcName, bcUrl, currentRecordData, rowMeta, cursor } = action.payload;
|
|
1200
1229
|
const handledForceActive = {};
|
|
1201
1230
|
const rowMetaForcedValues = {};
|
|
@@ -1207,6 +1236,7 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1207
1236
|
forceActiveFieldKeys.push(field.key);
|
|
1208
1237
|
}
|
|
1209
1238
|
});
|
|
1239
|
+
state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) != null ? _a : {};
|
|
1210
1240
|
const consolidatedFrontData = __spreadValues(__spreadValues({}, currentRecordData), state.pendingDataChanges[bcName][cursor]);
|
|
1211
1241
|
Object.keys(consolidatedFrontData).forEach((key) => {
|
|
1212
1242
|
if (rowMetaForcedValues[key] !== void 0 && consolidatedFrontData[key] !== rowMetaForcedValues[key]) {
|
|
@@ -1219,17 +1249,21 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1219
1249
|
handledForceActive[key] = newPendingDataChanges[key];
|
|
1220
1250
|
}
|
|
1221
1251
|
});
|
|
1252
|
+
state.handledForceActive[bcName] = (_b = state.handledForceActive[bcName]) != null ? _b : {};
|
|
1253
|
+
state.handledForceActive[bcName][cursor] = (_c = state.handledForceActive[bcName][cursor]) != null ? _c : {};
|
|
1222
1254
|
Object.assign(state.handledForceActive[bcName][cursor], handledForceActive);
|
|
1255
|
+
state.pendingDataChanges[bcName] = (_d = state.pendingDataChanges[bcName]) != null ? _d : {};
|
|
1223
1256
|
state.pendingDataChanges[bcName][cursor] = newPendingDataChanges;
|
|
1257
|
+
state.rowMeta[bcName] = (_e = state.rowMeta[bcName]) != null ? _e : {};
|
|
1224
1258
|
state.rowMeta[bcName][bcUrl] = rowMeta;
|
|
1225
1259
|
}).addCase(changeDataItem, (state, action) => {
|
|
1226
|
-
var _a;
|
|
1260
|
+
var _a, _b, _c;
|
|
1227
1261
|
const actionBcName = action.payload.bcName;
|
|
1228
1262
|
const prevBc = state.pendingDataChanges[action.payload.bcName] || {};
|
|
1229
1263
|
const prevCursor = prevBc[action.payload.cursor] || {};
|
|
1230
1264
|
const prevPending = prevCursor || {};
|
|
1231
1265
|
const nextPending = __spreadValues(__spreadValues({}, prevPending), action.payload.dataItem);
|
|
1232
|
-
const bcUrl =
|
|
1266
|
+
const bcUrl = action.payload.bcUrl;
|
|
1233
1267
|
const rowMeta = (_a = state.rowMeta[actionBcName]) == null ? void 0 : _a[bcUrl];
|
|
1234
1268
|
const nextValidationFails = {};
|
|
1235
1269
|
const isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
@@ -1240,10 +1274,11 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1240
1274
|
nextValidationFails[fieldKey] = "This field is mandatory";
|
|
1241
1275
|
}
|
|
1242
1276
|
});
|
|
1277
|
+
state.pendingDataChanges[action.payload.bcName] = (_b = state.pendingDataChanges[action.payload.bcName]) != null ? _b : {};
|
|
1243
1278
|
state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending;
|
|
1244
1279
|
if (isTargetFormatPVF) {
|
|
1245
1280
|
;
|
|
1246
|
-
state.pendingValidationFails[actionBcName][action.payload.cursor] = nextValidationFails;
|
|
1281
|
+
((_c = state.pendingValidationFails) == null ? void 0 : _c[actionBcName])[action.payload.cursor] = nextValidationFails;
|
|
1247
1282
|
}
|
|
1248
1283
|
else {
|
|
1249
1284
|
state.pendingValidationFails = nextValidationFails;
|
|
@@ -1264,7 +1299,7 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1264
1299
|
pendingDataChanges[bcName] = pendingBcChanges;
|
|
1265
1300
|
});
|
|
1266
1301
|
const isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1267
|
-
const pendingValidationFails = __spreadValues({}, state.pendingValidationFails);
|
|
1302
|
+
const pendingValidationFails = state.pendingValidationFails ? __spreadValues({}, state.pendingValidationFails) : {};
|
|
1268
1303
|
if (isTargetFormatPVF) {
|
|
1269
1304
|
action.payload.bcNames.forEach((i) => {
|
|
1270
1305
|
pendingValidationFails[i] = {};
|
|
@@ -1279,6 +1314,7 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1279
1314
|
}).addCase(bcFetchRowMetaFail, (state, action) => {
|
|
1280
1315
|
state.metaInProgress[action.payload.bcName] = false;
|
|
1281
1316
|
}).addCase(forceActiveChangeFail, (state, action) => {
|
|
1317
|
+
var _a;
|
|
1282
1318
|
const { bcName, bcUrl, entityError } = action.payload;
|
|
1283
1319
|
const errors = {};
|
|
1284
1320
|
if (entityError) {
|
|
@@ -1286,8 +1322,10 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1286
1322
|
errors[fieldName] = violation;
|
|
1287
1323
|
});
|
|
1288
1324
|
}
|
|
1325
|
+
state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) != null ? _a : {};
|
|
1289
1326
|
state.rowMeta[bcName][bcUrl].errors = errors;
|
|
1290
1327
|
}).addCase(bcSaveDataFail, (state, action) => {
|
|
1328
|
+
var _a;
|
|
1291
1329
|
const { bcName, bcUrl, entityError } = action.payload;
|
|
1292
1330
|
const errors = {};
|
|
1293
1331
|
if (entityError) {
|
|
@@ -1295,8 +1333,10 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1295
1333
|
errors[fieldName] = violation;
|
|
1296
1334
|
});
|
|
1297
1335
|
}
|
|
1336
|
+
state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) != null ? _a : {};
|
|
1298
1337
|
state.rowMeta[bcName][bcUrl].errors = errors;
|
|
1299
1338
|
}).addCase(sendOperationFail, (state, action) => {
|
|
1339
|
+
var _a;
|
|
1300
1340
|
const { bcName, bcUrl, entityError } = action.payload;
|
|
1301
1341
|
const errors = {};
|
|
1302
1342
|
if (entityError) {
|
|
@@ -1304,30 +1344,38 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1304
1344
|
errors[fieldName] = violation;
|
|
1305
1345
|
});
|
|
1306
1346
|
}
|
|
1347
|
+
state.rowMeta[bcName] = (_a = state.rowMeta[bcName]) != null ? _a : {};
|
|
1307
1348
|
state.rowMeta[bcName][bcUrl].errors = errors;
|
|
1308
1349
|
}).addCase(sendOperationSuccess, (state, action) => {
|
|
1309
|
-
|
|
1350
|
+
var _a, _b, _c;
|
|
1351
|
+
const bcName = action.payload.bcName;
|
|
1352
|
+
const cursor = action.payload.cursor;
|
|
1310
1353
|
const isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1354
|
+
state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) != null ? _a : {};
|
|
1311
1355
|
state.pendingDataChanges[bcName][cursor] = {};
|
|
1312
1356
|
if (isTargetFormatPVF) {
|
|
1313
1357
|
;
|
|
1314
|
-
state.pendingValidationFails[bcName][cursor] = {};
|
|
1358
|
+
((_b = state.pendingValidationFails) == null ? void 0 : _b[bcName])[cursor] = {};
|
|
1315
1359
|
}
|
|
1316
1360
|
else {
|
|
1317
1361
|
state.pendingValidationFails = initialViewState.pendingValidationFails;
|
|
1318
1362
|
}
|
|
1363
|
+
state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) != null ? _c : {};
|
|
1319
1364
|
state.handledForceActive[bcName][cursor] = {};
|
|
1320
1365
|
}).addCase(bcSaveDataSuccess, (state, action) => {
|
|
1366
|
+
var _a, _b, _c;
|
|
1321
1367
|
const { bcName, cursor } = action.payload;
|
|
1322
1368
|
const isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1369
|
+
state.pendingDataChanges[bcName] = (_a = state.pendingDataChanges[bcName]) != null ? _a : {};
|
|
1323
1370
|
state.pendingDataChanges[bcName][cursor] = {};
|
|
1324
1371
|
if (isTargetFormatPVF) {
|
|
1325
1372
|
;
|
|
1326
|
-
state.pendingValidationFails[bcName][cursor] = {};
|
|
1373
|
+
((_b = state.pendingValidationFails) == null ? void 0 : _b[bcName])[cursor] = {};
|
|
1327
1374
|
}
|
|
1328
1375
|
else {
|
|
1329
1376
|
state.pendingValidationFails = initialViewState.pendingValidationFails;
|
|
1330
1377
|
}
|
|
1378
|
+
state.handledForceActive[bcName] = (_c = state.handledForceActive[bcName]) != null ? _c : {};
|
|
1331
1379
|
state.handledForceActive[bcName][cursor] = {};
|
|
1332
1380
|
}).addCase(bcCancelPendingChanges, (state, action) => {
|
|
1333
1381
|
var _a, _b;
|
|
@@ -1338,7 +1386,7 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1338
1386
|
}
|
|
1339
1387
|
}
|
|
1340
1388
|
const isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
|
|
1341
|
-
let pendingValidationFails = __spreadValues({}, state.pendingValidationFails);
|
|
1389
|
+
let pendingValidationFails = state.pendingValidationFails ? __spreadValues({}, state.pendingValidationFails) : {};
|
|
1342
1390
|
if (isTargetFormatPVF) {
|
|
1343
1391
|
if (((_b = (_a = action.payload) == null ? void 0 : _a.bcNames) == null ? void 0 : _b.length) > 0) {
|
|
1344
1392
|
action.payload.bcNames.forEach((i) => {
|
|
@@ -1367,8 +1415,8 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1367
1415
|
isFilter
|
|
1368
1416
|
};
|
|
1369
1417
|
}).addCase(showFileUploadPopup, (state, action) => {
|
|
1370
|
-
var _a;
|
|
1371
|
-
const bcName = (_a = state.widgets.find((item) => item.name === action.payload.widgetName)) == null ? void 0 :
|
|
1418
|
+
var _a, _b;
|
|
1419
|
+
const bcName = (_b = (_a = state.widgets) == null ? void 0 : _a.find((item) => item.name === action.payload.widgetName)) == null ? void 0 : _b.bcName;
|
|
1372
1420
|
state.popupData = {
|
|
1373
1421
|
type: "file-upload",
|
|
1374
1422
|
bcName,
|
|
@@ -1380,6 +1428,7 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1380
1428
|
}).addCase(viewClearPickMap, (state) => {
|
|
1381
1429
|
state.pickMap = null;
|
|
1382
1430
|
}).addCase(closeViewPopup, (state) => {
|
|
1431
|
+
state.popupData = {};
|
|
1383
1432
|
state.popupData.bcName = null;
|
|
1384
1433
|
}).addCase(selectTableCell, (state, action) => {
|
|
1385
1434
|
state.selectedCell = { widgetName: action.payload.widgetName, rowId: action.payload.rowId, fieldKey: action.payload.fieldKey };
|
|
@@ -1387,12 +1436,16 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
|
|
|
1387
1436
|
state.pendingDataChanges = initialViewState.pendingDataChanges;
|
|
1388
1437
|
state.selectedCell = initialViewState.selectedCell;
|
|
1389
1438
|
}).addCase(showNotification, (state, action) => {
|
|
1439
|
+
var _a, _b;
|
|
1440
|
+
state.systemNotifications = (_a = state.systemNotifications) != null ? _a : [];
|
|
1390
1441
|
state.systemNotifications.push({
|
|
1391
1442
|
type: action.payload.type,
|
|
1392
1443
|
message: action.payload.message,
|
|
1393
|
-
id: state.systemNotifications.length
|
|
1444
|
+
id: (_b = state.systemNotifications) == null ? void 0 : _b.length
|
|
1394
1445
|
});
|
|
1395
1446
|
}).addCase(closeNotification, (state, action) => {
|
|
1447
|
+
var _a;
|
|
1448
|
+
state.systemNotifications = (_a = state.systemNotifications) != null ? _a : [];
|
|
1396
1449
|
state.systemNotifications = state.systemNotifications.filter((item) => item.id !== action.payload.id);
|
|
1397
1450
|
}).addCase(showViewError, (state, action) => {
|
|
1398
1451
|
state.error = action.payload.error;
|
|
@@ -1440,7 +1493,6 @@ __export(epics_exports, {
|
|
|
1440
1493
|
httpError500Epic: () => httpError500Epic,
|
|
1441
1494
|
httpErrorDefaultEpic: () => httpErrorDefaultEpic,
|
|
1442
1495
|
inlinePickListFetchDataEpic: () => inlinePickListFetchDataEpic,
|
|
1443
|
-
knownHttpErrors: () => knownHttpErrors,
|
|
1444
1496
|
loginByAnotherRoleEpic: () => loginByAnotherRoleEpic,
|
|
1445
1497
|
loginDoneEpic: () => loginDoneEpic,
|
|
1446
1498
|
loginDoneSessionEpic: () => loginDoneSessionEpic,
|
|
@@ -1465,9 +1517,9 @@ __export(epics_exports, {
|
|
|
1465
1517
|
userDrillDownEpic: () => userDrillDownEpic
|
|
1466
1518
|
});
|
|
1467
1519
|
// src/epics/view/sendOperationEpic.ts
|
|
1468
|
-
import { catchError, concat, EMPTY, filter, mergeMap, of as
|
|
1520
|
+
import { catchError, concat, EMPTY as EMPTY2, filter, mergeMap, of as of3 } from "rxjs";
|
|
1469
1521
|
// src/epics/utils/postOperationRoutine.ts
|
|
1470
|
-
import { of } from "rxjs";
|
|
1522
|
+
import { of as of2 } from "rxjs";
|
|
1471
1523
|
function postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName) {
|
|
1472
1524
|
const postInvokeConfirm = Object.values(OperationPostInvokeConfirmType).includes(postInvoke == null ? void 0 : postInvoke.type);
|
|
1473
1525
|
const result = [];
|
|
@@ -1490,7 +1542,7 @@ function postOperationRoutine(widgetName, postInvoke, preInvoke, operationType,
|
|
|
1490
1542
|
preInvoke
|
|
1491
1543
|
}));
|
|
1492
1544
|
}
|
|
1493
|
-
return result.map((item) =>
|
|
1545
|
+
return result.map((item) => of2(item));
|
|
1494
1546
|
}
|
|
1495
1547
|
// src/epics/view/sendOperationEpic.ts
|
|
1496
1548
|
var sendOperationEpic = (action$, state$, { api }) => action$.pipe(filter(sendOperation.match), filter((action) => matchOperationRole("none", action.payload, state$.value)), mergeMap((action) => {
|
|
@@ -1499,7 +1551,7 @@ var sendOperationEpic = (action$, state$, { api }) => action$.pipe(filter(sendOp
|
|
|
1499
1551
|
const screenName = state.screen.screenName;
|
|
1500
1552
|
const { bcName, operationType, widgetName } = action.payload;
|
|
1501
1553
|
const confirm = ((_a = action.payload.confirmOperation) == null ? void 0 : _a.type) || action.payload.confirm;
|
|
1502
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
1554
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
1503
1555
|
const bc = state.screen.bo.bc[bcName];
|
|
1504
1556
|
const rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) == null ? void 0 : _b[bcUrl]);
|
|
1505
1557
|
const fields = rowMeta == null ? void 0 : rowMeta.fields;
|
|
@@ -1507,7 +1559,7 @@ var sendOperationEpic = (action$, state$, { api }) => action$.pipe(filter(sendOp
|
|
|
1507
1559
|
const record = (_c = state.data[bcName]) == null ? void 0 : _c.find((item) => item.id === bc.cursor);
|
|
1508
1560
|
const filters = state.screen.filters[bcName];
|
|
1509
1561
|
const sorters = state.screen.sorters[bcName];
|
|
1510
|
-
const pendingRecordChange = (_d = state.view.pendingDataChanges[bcName]) == null ? void 0 : _d[bc.cursor];
|
|
1562
|
+
const pendingRecordChange = __spreadValues({}, (_d = state.view.pendingDataChanges[bcName]) == null ? void 0 : _d[bc.cursor]);
|
|
1511
1563
|
for (const key in pendingRecordChange) {
|
|
1512
1564
|
if (fields.find((item) => item.key === key && item.disabled)) {
|
|
1513
1565
|
delete pendingRecordChange[key];
|
|
@@ -1523,10 +1575,10 @@ var sendOperationEpic = (action$, state$, { api }) => action$.pipe(filter(sendOp
|
|
|
1523
1575
|
}
|
|
1524
1576
|
const context = { widgetName: action.payload.widgetName };
|
|
1525
1577
|
return api.customAction(screenName, bcUrl, data, context, params).pipe(mergeMap((response) => {
|
|
1526
|
-
var _a2;
|
|
1527
|
-
const postInvoke = response.postActions[0];
|
|
1578
|
+
var _a2, _b2;
|
|
1579
|
+
const postInvoke = (_a2 = response.postActions) == null ? void 0 : _a2[0];
|
|
1528
1580
|
const preInvoke = response.preInvoke;
|
|
1529
|
-
return defaultSaveOperation ? ((
|
|
1581
|
+
return defaultSaveOperation ? ((_b2 = action == null ? void 0 : action.payload) == null ? void 0 : _b2.onSuccessAction) ? concat(of3(bcCancelPendingChanges({ bcNames: [bcName] })), of3(action.payload.onSuccessAction)) : EMPTY2 : concat(of3(sendOperationSuccess({ bcName, cursor })), of3(bcForceUpdate({ bcName })), ...postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName));
|
|
1530
1582
|
}), catchError((e) => {
|
|
1531
1583
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1532
1584
|
console.error(e);
|
|
@@ -1537,24 +1589,24 @@ var sendOperationEpic = (action$, state$, { api }) => action$.pipe(filter(sendOp
|
|
|
1537
1589
|
entityError = (_d2 = operationError == null ? void 0 : operationError.error) == null ? void 0 : _d2.entity;
|
|
1538
1590
|
viewError = (_f2 = (_e2 = operationError == null ? void 0 : operationError.error) == null ? void 0 : _e2.popup) == null ? void 0 : _f2[0];
|
|
1539
1591
|
}
|
|
1540
|
-
return
|
|
1592
|
+
return concat(of3(sendOperationFail({ bcName, bcUrl, viewError, entityError })), createApiErrorObservable(e, context));
|
|
1541
1593
|
}));
|
|
1542
1594
|
}));
|
|
1543
1595
|
// src/epics/view/showAssocPopupEpic.ts
|
|
1544
|
-
import { EMPTY as
|
|
1545
|
-
import { WidgetTypes as
|
|
1596
|
+
import { EMPTY as EMPTY3, filter as filter2, mergeMap as mergeMap2, of as of4 } from "rxjs";
|
|
1597
|
+
import { WidgetTypes as WidgetTypes3 } from "@cxbox-ui/schema";
|
|
1546
1598
|
var showAssocPopupEpic = (action$, state$) => action$.pipe(filter2(showViewPopup.match), filter2((action) => !!(action.payload.calleeBCName && action.payload.associateFieldKey)), mergeMap2((action) => {
|
|
1547
1599
|
var _a, _b, _c, _d;
|
|
1548
1600
|
const { bcName, calleeBCName } = action.payload;
|
|
1549
1601
|
const state = state$.value;
|
|
1550
|
-
const assocWidget = state.view.widgets.find((widget) => widget.bcName === bcName && widget.type ===
|
|
1602
|
+
const assocWidget = state.view.widgets.find((widget) => widget.bcName === bcName && widget.type === WidgetTypes3.AssocListPopup);
|
|
1551
1603
|
const calleeCursor = (_a = state.screen.bo.bc[calleeBCName]) == null ? void 0 : _a.cursor;
|
|
1552
1604
|
const calleePendingChanges = (_b = state.view.pendingDataChanges[calleeBCName]) == null ? void 0 : _b[calleeCursor];
|
|
1553
1605
|
const assocFieldKey = action.payload.associateFieldKey;
|
|
1554
1606
|
const assocFieldChanges = calleePendingChanges == null ? void 0 : calleePendingChanges[assocFieldKey];
|
|
1555
1607
|
const somethingMissing = !assocWidget || !calleePendingChanges || !assocFieldChanges || !assocFieldChanges;
|
|
1556
1608
|
if (somethingMissing || assocWidget.options && !assocWidget.options.hierarchyFull) {
|
|
1557
|
-
return
|
|
1609
|
+
return EMPTY3;
|
|
1558
1610
|
}
|
|
1559
1611
|
const popupInitPendingChanges = {};
|
|
1560
1612
|
assocFieldChanges.forEach((record) => {
|
|
@@ -1577,54 +1629,58 @@ var showAssocPopupEpic = (action$, state$) => action$.pipe(filter2(showViewPopup
|
|
|
1577
1629
|
}
|
|
1578
1630
|
});
|
|
1579
1631
|
}
|
|
1580
|
-
return
|
|
1632
|
+
return of4(changeDataItems({
|
|
1581
1633
|
bcName,
|
|
1582
1634
|
cursors: Object.keys(popupInitPendingChanges),
|
|
1583
1635
|
dataItems: Object.values(popupInitPendingChanges)
|
|
1584
1636
|
}));
|
|
1585
1637
|
}));
|
|
1586
1638
|
// src/epics/view/fileUploadConfirmEpic.ts
|
|
1587
|
-
import { concat as concat2, filter as filter3, mergeMap as mergeMap3, of as
|
|
1639
|
+
import { catchError as catchError2, concat as concat2, filter as filter3, mergeMap as mergeMap3, of as of5 } from "rxjs";
|
|
1588
1640
|
import { OperationTypeCrud as OperationTypeCrud5 } from "@cxbox-ui/schema";
|
|
1589
1641
|
var fileUploadConfirmEpic = (action$, state$, { api }) => action$.pipe(filter3(bulkUploadFiles.match), mergeMap3((action) => {
|
|
1590
|
-
var _a;
|
|
1642
|
+
var _a, _b;
|
|
1591
1643
|
const state = state$.value;
|
|
1592
|
-
const bcName = state.view.popupData.bcName;
|
|
1593
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
1594
|
-
const widgetName = (
|
|
1644
|
+
const bcName = (_a = state.view.popupData) == null ? void 0 : _a.bcName;
|
|
1645
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
1646
|
+
const widgetName = (_b = state.view.widgets.find((item) => item.bcName === bcName)) == null ? void 0 : _b.name;
|
|
1595
1647
|
const data = {
|
|
1596
1648
|
bulkIds: action.payload.fileIds
|
|
1597
1649
|
};
|
|
1598
1650
|
return api.customAction(state.screen.screenName, bcUrl, data, null, { _action: "file-upload-save" }).pipe(mergeMap3((response) => {
|
|
1599
|
-
|
|
1651
|
+
var _a2;
|
|
1652
|
+
const postInvoke = (_a2 = response.postActions) == null ? void 0 : _a2[0];
|
|
1600
1653
|
const preInvoke = response.preInvoke;
|
|
1601
|
-
return concat2(
|
|
1654
|
+
return concat2(of5(sendOperationSuccess({ bcName, cursor: null })), of5(bcForceUpdate({ bcName })), of5(closeViewPopup(null)), ...postOperationRoutine(widgetName, postInvoke, preInvoke, OperationTypeCrud5.save, bcName));
|
|
1655
|
+
}), catchError2((error) => {
|
|
1656
|
+
console.error(error);
|
|
1657
|
+
return createApiErrorObservable(error);
|
|
1602
1658
|
}));
|
|
1603
1659
|
}));
|
|
1604
1660
|
// src/epics/view/selectTableCellInitEpic.ts
|
|
1605
|
-
import { concat as concat3, filter as filter4, mergeMap as mergeMap4, of as
|
|
1661
|
+
import { concat as concat3, filter as filter4, mergeMap as mergeMap4, of as of6 } from "rxjs";
|
|
1606
1662
|
var selectTableCellInitEpic = (action$, state$) => action$.pipe(filter4(selectTableCellInit.match), mergeMap4((action) => {
|
|
1607
1663
|
var _a;
|
|
1608
1664
|
const resultObservables = [];
|
|
1609
1665
|
const state = state$.value;
|
|
1610
1666
|
const { rowId: nextRowId, fieldKey } = action.payload;
|
|
1611
1667
|
const nextWidget = state.view.widgets.find((widget) => widget.name === action.payload.widgetName);
|
|
1612
|
-
const nextBcName = nextWidget.bcName;
|
|
1668
|
+
const nextBcName = nextWidget == null ? void 0 : nextWidget.bcName;
|
|
1613
1669
|
const nextBcCursor = (_a = state.screen.bo.bc[nextBcName]) == null ? void 0 : _a.cursor;
|
|
1614
1670
|
const selectedCell = state.view.selectedCell;
|
|
1615
1671
|
if (nextRowId !== nextBcCursor) {
|
|
1616
|
-
resultObservables.push(
|
|
1672
|
+
resultObservables.push(of6(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })));
|
|
1617
1673
|
}
|
|
1618
|
-
if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || nextWidget.name !== selectedCell.widgetName) {
|
|
1619
|
-
resultObservables.push(
|
|
1674
|
+
if (!selectedCell || fieldKey !== selectedCell.fieldKey || nextRowId !== selectedCell.rowId || (nextWidget == null ? void 0 : nextWidget.name) !== selectedCell.widgetName) {
|
|
1675
|
+
resultObservables.push(of6(selectTableCell({ widgetName: nextWidget == null ? void 0 : nextWidget.name, rowId: nextRowId, fieldKey })));
|
|
1620
1676
|
}
|
|
1621
1677
|
return concat3(...resultObservables);
|
|
1622
1678
|
}));
|
|
1623
1679
|
// src/epics/view/showFileUploadPopupEpic.ts
|
|
1624
|
-
import { concat as concat4, filter as filter5, mergeMap as mergeMap5, of as
|
|
1680
|
+
import { concat as concat4, filter as filter5, mergeMap as mergeMap5, of as of7 } from "rxjs";
|
|
1625
1681
|
import { OperationTypeCrud as OperationTypeCrud6 } from "@cxbox-ui/schema";
|
|
1626
1682
|
var showFileUploadPopupEpic = (action$, state$) => action$.pipe(filter5(sendOperation.match), filter5((action) => matchOperationRole(OperationTypeCrud6.fileUpload, action.payload, state$.value)), mergeMap5((action) => {
|
|
1627
|
-
return concat4(
|
|
1683
|
+
return concat4(of7(bcChangeCursors({ cursorsMap: { [action.payload.bcName]: null } })), of7(showFileUploadPopup({ widgetName: action.payload.widgetName })));
|
|
1628
1684
|
}));
|
|
1629
1685
|
// src/epics/view/sendOperationAssociateEpic.ts
|
|
1630
1686
|
import { filter as filter6, map } from "rxjs";
|
|
@@ -1639,32 +1695,32 @@ var sendOperationAssociateEpic = (action$, state$) => action$.pipe(filter6(sendO
|
|
|
1639
1695
|
});
|
|
1640
1696
|
}));
|
|
1641
1697
|
// src/epics/view/getRowMetaByForceActiveEpic.ts
|
|
1642
|
-
import { EMPTY as
|
|
1643
|
-
import { WidgetTypes as
|
|
1698
|
+
import { EMPTY as EMPTY4, concat as concat5, filter as filter7, mergeMap as mergeMap6, of as of8, catchError as catchError3 } from "rxjs";
|
|
1699
|
+
import { WidgetTypes as WidgetTypes4 } from "@cxbox-ui/schema";
|
|
1644
1700
|
import { nanoid } from "@reduxjs/toolkit";
|
|
1645
1701
|
var getRowMetaByForceActiveEpic = (action$, state$, { api }) => action$.pipe(filter7(changeDataItem.match), mergeMap6((action) => {
|
|
1646
|
-
var _a, _b, _c, _d;
|
|
1702
|
+
var _a, _b, _c, _d, _e;
|
|
1647
1703
|
const state = state$.value;
|
|
1648
1704
|
const initUrl = state.view.url;
|
|
1649
1705
|
const { bcName, cursor, disableRetry } = action.payload;
|
|
1650
1706
|
const isBcHierarchy = state.view.widgets.some((widget) => {
|
|
1651
1707
|
var _a2, _b2;
|
|
1652
|
-
return widget.bcName === bcName && widget.type ===
|
|
1708
|
+
return widget.bcName === bcName && widget.type === WidgetTypes4.AssocListPopup && (((_a2 = widget.options) == null ? void 0 : _a2.hierarchySameBc) || ((_b2 = widget.options) == null ? void 0 : _b2.hierarchyFull));
|
|
1653
1709
|
});
|
|
1654
1710
|
if (isBcHierarchy) {
|
|
1655
|
-
return
|
|
1711
|
+
return EMPTY4;
|
|
1656
1712
|
}
|
|
1657
1713
|
const isPickListPopup = state.view.widgets.find((item) => {
|
|
1658
1714
|
var _a2;
|
|
1659
|
-
return item.name === ((_a2 = state.view.popupData) == null ? void 0 : _a2.widgetName) && [
|
|
1715
|
+
return item.name === ((_a2 = state.view.popupData) == null ? void 0 : _a2.widgetName) && [WidgetTypes4.PickListPopup, WidgetTypes4.FlatTreePopup].includes(item.type);
|
|
1660
1716
|
});
|
|
1661
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
1662
|
-
const pendingChanges = state.view.pendingDataChanges[bcName][cursor];
|
|
1663
|
-
const handledForceActive = ((
|
|
1664
|
-
const currentRecordData = (
|
|
1665
|
-
const fieldsRowMeta = (
|
|
1717
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
1718
|
+
const pendingChanges = (_a = state.view.pendingDataChanges[bcName]) == null ? void 0 : _a[cursor];
|
|
1719
|
+
const handledForceActive = ((_b = state.view.handledForceActive[bcName]) == null ? void 0 : _b[cursor]) || {};
|
|
1720
|
+
const currentRecordData = (_c = state.data[bcName]) == null ? void 0 : _c.find((record) => record.id === cursor);
|
|
1721
|
+
const fieldsRowMeta = (_e = (_d = state.view.rowMeta[bcName]) == null ? void 0 : _d[bcUrl]) == null ? void 0 : _e.fields;
|
|
1666
1722
|
let changedFiledKey = null;
|
|
1667
|
-
const closePopup = concat5(
|
|
1723
|
+
const closePopup = concat5(of8(closeViewPopup(null)), of8(viewClearPickMap(null)), of8(bcRemoveAllFilters({ bcName })));
|
|
1668
1724
|
const someForceActiveChanged = fieldsRowMeta == null ? void 0 : fieldsRowMeta.filter((field) => field.forceActive && pendingChanges[field.key] !== void 0).some((field) => {
|
|
1669
1725
|
const result = pendingChanges[field.key] !== handledForceActive[field.key];
|
|
1670
1726
|
if (result) {
|
|
@@ -1674,10 +1730,10 @@ var getRowMetaByForceActiveEpic = (action$, state$, { api }) => action$.pipe(fil
|
|
|
1674
1730
|
});
|
|
1675
1731
|
const requestId = nanoid();
|
|
1676
1732
|
if (someForceActiveChanged && !disableRetry) {
|
|
1677
|
-
return concat5(
|
|
1678
|
-
const result = [
|
|
1733
|
+
return concat5(of8(addPendingRequest({ request: { requestId, type: "force-active" } })), api.getRmByForceActive(state.screen.screenName, bcUrl, __spreadProps(__spreadValues({}, pendingChanges), { vstamp: currentRecordData == null ? void 0 : currentRecordData.vstamp })).pipe(mergeMap6((data) => {
|
|
1734
|
+
const result = [of8(removePendingRequest({ requestId }))];
|
|
1679
1735
|
if (state.view.url === initUrl) {
|
|
1680
|
-
result.push(
|
|
1736
|
+
result.push(of8(forceActiveRmUpdate({
|
|
1681
1737
|
rowMeta: data,
|
|
1682
1738
|
currentRecordData,
|
|
1683
1739
|
bcName,
|
|
@@ -1689,37 +1745,43 @@ var getRowMetaByForceActiveEpic = (action$, state$, { api }) => action$.pipe(fil
|
|
|
1689
1745
|
result.push(closePopup);
|
|
1690
1746
|
}
|
|
1691
1747
|
return concat5(...result);
|
|
1692
|
-
}),
|
|
1693
|
-
var _a2, _b2, _c2, _d2,
|
|
1748
|
+
}), catchError3((e) => {
|
|
1749
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
1694
1750
|
console.error(e);
|
|
1695
1751
|
let viewError = null;
|
|
1696
1752
|
let entityError = null;
|
|
1697
1753
|
const operationError = (_a2 = e.response) == null ? void 0 : _a2.data;
|
|
1698
1754
|
if (((_b2 = e.response) == null ? void 0 : _b2.data) === Object((_c2 = e.response) == null ? void 0 : _c2.data)) {
|
|
1699
1755
|
entityError = (_d2 = operationError == null ? void 0 : operationError.error) == null ? void 0 : _d2.entity;
|
|
1700
|
-
viewError = (_f = (
|
|
1756
|
+
viewError = (_f = (_e2 = operationError == null ? void 0 : operationError.error) == null ? void 0 : _e2.popup) == null ? void 0 : _f[0];
|
|
1701
1757
|
}
|
|
1702
|
-
return concat5(
|
|
1758
|
+
return concat5(of8(removePendingRequest({ requestId })), state.view.url === initUrl ? concat5(of8(changeDataItem({
|
|
1703
1759
|
bcName,
|
|
1760
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
1704
1761
|
cursor,
|
|
1705
|
-
dataItem: { [changedFiledKey]: currentRecordData[changedFiledKey] },
|
|
1762
|
+
dataItem: { [changedFiledKey]: currentRecordData == null ? void 0 : currentRecordData[changedFiledKey] },
|
|
1706
1763
|
disableRetry: true
|
|
1707
|
-
})),
|
|
1764
|
+
})), of8(forceActiveChangeFail({ bcName, bcUrl, viewError, entityError }))) : EMPTY4, createApiErrorObservable(e));
|
|
1708
1765
|
})));
|
|
1709
1766
|
}
|
|
1710
|
-
return isPickListPopup ? closePopup :
|
|
1767
|
+
return isPickListPopup ? closePopup : EMPTY4;
|
|
1711
1768
|
}));
|
|
1712
1769
|
// src/epics/view/showAllTableRecordsInitEpic.ts
|
|
1713
|
-
import { concat as concat6, filter as filter8, mergeMap as mergeMap7, of as
|
|
1770
|
+
import { concat as concat6, filter as filter8, mergeMap as mergeMap7, of as of9 } from "rxjs";
|
|
1714
1771
|
var showAllTableRecordsInitEpic = (action$, state$) => action$.pipe(filter8(showAllTableRecordsInit.match), mergeMap7((action) => {
|
|
1715
1772
|
const resultObservables = [];
|
|
1716
|
-
const { bcName } = action.payload;
|
|
1717
|
-
|
|
1718
|
-
|
|
1773
|
+
const { bcName, cursor } = action.payload;
|
|
1774
|
+
const state = state$.value;
|
|
1775
|
+
const route = state.router;
|
|
1776
|
+
resultObservables.push(of9(bcChangeCursors({ cursorsMap: { [bcName]: null } })));
|
|
1777
|
+
const bcPath = route.bcPath.slice(0, route.bcPath.indexOf(`${bcName}/${cursor}`));
|
|
1778
|
+
const url = defaultBuildURL(__spreadProps(__spreadValues({}, route), { bcPath }));
|
|
1779
|
+
resultObservables.push(of9(bcForceUpdate({ bcName })));
|
|
1780
|
+
resultObservables.push(of9(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })));
|
|
1719
1781
|
return concat6(...resultObservables);
|
|
1720
1782
|
}));
|
|
1721
1783
|
// src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts
|
|
1722
|
-
import { EMPTY as
|
|
1784
|
+
import { EMPTY as EMPTY5, filter as filter9, mergeMap as mergeMap8, of as of10 } from "rxjs";
|
|
1723
1785
|
var clearPendingDataChangesAfterCursorChangeEpic = (action$, state$) => action$.pipe(filter9(bcChangeCursors.match), mergeMap8((action) => {
|
|
1724
1786
|
const state = state$.value;
|
|
1725
1787
|
const nextCursors = parseBcCursors(state.router.bcPath) || {};
|
|
@@ -1732,28 +1794,125 @@ var clearPendingDataChangesAfterCursorChangeEpic = (action$, state$) => action$.
|
|
|
1732
1794
|
}
|
|
1733
1795
|
});
|
|
1734
1796
|
if (Object.keys(cursorsDiffMap).length) {
|
|
1735
|
-
return
|
|
1797
|
+
return of10(bcChangeCursors({ cursorsMap: cursorsDiffMap }));
|
|
1736
1798
|
}
|
|
1737
|
-
return
|
|
1799
|
+
return EMPTY5;
|
|
1738
1800
|
}));
|
|
1739
1801
|
// src/epics/router/drilldownEpic.ts
|
|
1740
|
-
import { EMPTY as
|
|
1802
|
+
import { concat as concat7, EMPTY as EMPTY6, filter as filter10, switchMap } from "rxjs";
|
|
1741
1803
|
var drillDownEpic = (action$, state$) => action$.pipe(filter10(drillDown.match), switchMap((action) => {
|
|
1742
|
-
|
|
1804
|
+
var _a, _b;
|
|
1805
|
+
const state = state$.value;
|
|
1806
|
+
const url = action.payload.url;
|
|
1807
|
+
const result = [];
|
|
1808
|
+
switch (action.payload.drillDownType) {
|
|
1809
|
+
case DrillDownType.external:
|
|
1810
|
+
window.location.href = url;
|
|
1811
|
+
break;
|
|
1812
|
+
case DrillDownType.externalNew:
|
|
1813
|
+
if (/^[a-z0-9]+:\/\//i.test(url)) {
|
|
1814
|
+
window.open(url);
|
|
1815
|
+
}
|
|
1816
|
+
break;
|
|
1817
|
+
case DrillDownType.relative:
|
|
1818
|
+
window.location.href = `${window.location.origin}/${url}`;
|
|
1819
|
+
break;
|
|
1820
|
+
case DrillDownType.relativeNew:
|
|
1821
|
+
window.open(`${window.location.origin}/${url}`, "_blank");
|
|
1822
|
+
break;
|
|
1823
|
+
case DrillDownType.inner:
|
|
1824
|
+
default:
|
|
1825
|
+
const [urlBase] = url.split("?");
|
|
1826
|
+
const urlObject = new URL(url, window.location.origin);
|
|
1827
|
+
const urlFilters = urlObject.searchParams.get("filters");
|
|
1828
|
+
const urlSorters = urlObject.searchParams.get("sorters");
|
|
1829
|
+
let newFilters = {};
|
|
1830
|
+
let newSorters = {};
|
|
1831
|
+
try {
|
|
1832
|
+
newFilters = (_a = JSON.parse(urlFilters)) != null ? _a : newFilters;
|
|
1833
|
+
}
|
|
1834
|
+
catch (e) {
|
|
1835
|
+
urlFilters && console.warn("Failed to parse filters on drilldown");
|
|
1836
|
+
newFilters = {};
|
|
1837
|
+
}
|
|
1838
|
+
try {
|
|
1839
|
+
newSorters = (_b = JSON.parse(urlSorters)) != null ? _b : newSorters;
|
|
1840
|
+
}
|
|
1841
|
+
catch (e) {
|
|
1842
|
+
urlSorters && console.warn("Failed to parse sorters on drilldown");
|
|
1843
|
+
newSorters = {};
|
|
1844
|
+
}
|
|
1845
|
+
const bcToUpdate = {};
|
|
1846
|
+
Object.keys(state.screen.filters).forEach((bcName) => {
|
|
1847
|
+
if (newFilters[bcName] === "" || newFilters[bcName]) {
|
|
1848
|
+
bcToUpdate[bcName] = true;
|
|
1849
|
+
result.push(bcRemoveAllFilters({ bcName }));
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
const nextState = defaultParseURL(urlObject);
|
|
1853
|
+
const viewName = nextState.viewName;
|
|
1854
|
+
Object.entries(newFilters).forEach(([bcName, filterExpression]) => {
|
|
1855
|
+
var _a2;
|
|
1856
|
+
const parsedFilters = (_a2 = parseFilters(filterExpression)) == null ? void 0 : _a2.map((item) => __spreadProps(__spreadValues({}, item), { viewName }));
|
|
1857
|
+
parsedFilters == null ? void 0 : parsedFilters.forEach((parsedFilter) => {
|
|
1858
|
+
bcToUpdate[bcName] = true;
|
|
1859
|
+
result.push(bcAddFilter({ bcName, filter: parsedFilter }));
|
|
1860
|
+
});
|
|
1861
|
+
});
|
|
1862
|
+
Object.entries(newSorters).forEach(([bcName, sortExpression]) => {
|
|
1863
|
+
const sorter = parseSorters(sortExpression);
|
|
1864
|
+
result.push(bcAddSorter({ bcName, sorter }));
|
|
1865
|
+
bcToUpdate[bcName] = true;
|
|
1866
|
+
});
|
|
1867
|
+
const prevState = state.router;
|
|
1868
|
+
const willUpdateAnyway = shallowCompare(prevState, nextState, ["params"]).length > 0;
|
|
1869
|
+
if (!willUpdateAnyway) {
|
|
1870
|
+
Object.keys(bcToUpdate).forEach((bcName) => {
|
|
1871
|
+
result.push(bcForceUpdate({ bcName }));
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
result.push(changeLocation({ location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)) }));
|
|
1875
|
+
break;
|
|
1876
|
+
}
|
|
1877
|
+
return result.length ? concat7(result) : EMPTY6;
|
|
1743
1878
|
}));
|
|
1879
|
+
function shallowCompare(prevProps, nextProps, ignore = []) {
|
|
1880
|
+
const diffProps = [];
|
|
1881
|
+
if (!prevProps && !nextProps) {
|
|
1882
|
+
return null;
|
|
1883
|
+
}
|
|
1884
|
+
if (!prevProps) {
|
|
1885
|
+
return Object.keys(nextProps);
|
|
1886
|
+
}
|
|
1887
|
+
if (!nextProps) {
|
|
1888
|
+
return Object.keys(prevProps);
|
|
1889
|
+
}
|
|
1890
|
+
const newKeys = Object.keys(nextProps);
|
|
1891
|
+
newKeys.forEach((key) => {
|
|
1892
|
+
if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {
|
|
1893
|
+
diffProps.push(key);
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
Object.keys(prevProps).forEach((key) => {
|
|
1897
|
+
if (!newKeys.includes(key)) {
|
|
1898
|
+
diffProps.push(key);
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
return diffProps;
|
|
1902
|
+
}
|
|
1744
1903
|
// src/epics/router/loginDoneEpic.ts
|
|
1745
|
-
import { filter as filter11, of as
|
|
1904
|
+
import { filter as filter11, of as of11, switchMap as switchMap2 } from "rxjs";
|
|
1746
1905
|
var loginDoneEpic = (action$, state$) => action$.pipe(filter11(loginDone.match), switchMap2((action) => {
|
|
1747
1906
|
const state = state$.value;
|
|
1748
1907
|
if (state.router.type === "router" /* router */) {
|
|
1749
|
-
return
|
|
1908
|
+
return of11(handleRouter(state.router));
|
|
1750
1909
|
}
|
|
1751
1910
|
const nextScreenName = state.router.screenName;
|
|
1752
1911
|
const nextScreen = state.session.screens.find((item) => nextScreenName ? item.name === nextScreenName : item.defaultScreen) || state.session.screens[0];
|
|
1753
|
-
return nextScreen ?
|
|
1912
|
+
return nextScreen ? of11(selectScreen({ screen: nextScreen })) : of11(selectScreenFail({ screenName: nextScreenName }));
|
|
1754
1913
|
}));
|
|
1755
1914
|
// src/epics/router/selectViewEpic.ts
|
|
1756
|
-
import { EMPTY as
|
|
1915
|
+
import { EMPTY as EMPTY7, filter as filter12, of as of12, switchMap as switchMap3 } from "rxjs";
|
|
1757
1916
|
var changeViewEpic = (action$, state$) => action$.pipe(filter12(selectView.match), switchMap3((action) => {
|
|
1758
1917
|
const state = state$.value;
|
|
1759
1918
|
const nextCursors = parseBcCursors(state.router.bcPath) || {};
|
|
@@ -1766,71 +1925,71 @@ var changeViewEpic = (action$, state$) => action$.pipe(filter12(selectView.match
|
|
|
1766
1925
|
}
|
|
1767
1926
|
});
|
|
1768
1927
|
if (Object.keys(cursorsDiffMap).length) {
|
|
1769
|
-
return
|
|
1928
|
+
return of12(bcChangeCursors({ cursorsMap: cursorsDiffMap }));
|
|
1770
1929
|
}
|
|
1771
|
-
return
|
|
1930
|
+
return EMPTY7;
|
|
1772
1931
|
}));
|
|
1773
1932
|
// src/epics/router/handleRouterEpic.ts
|
|
1774
|
-
import { catchError as
|
|
1933
|
+
import { catchError as catchError4, EMPTY as EMPTY8, filter as filter13, mergeMap as mergeMap9, switchMap as switchMap4 } from "rxjs";
|
|
1775
1934
|
var handleRouterEpic = (action$, state$, { api }) => action$.pipe(filter13(handleRouter.match), switchMap4((action) => {
|
|
1776
1935
|
const path = action.payload.path;
|
|
1777
1936
|
const params = action.payload.params;
|
|
1778
1937
|
return api.routerRequest(path, params).pipe(mergeMap9(() => {
|
|
1779
|
-
return
|
|
1780
|
-
}),
|
|
1938
|
+
return EMPTY8;
|
|
1939
|
+
}), catchError4((error) => {
|
|
1781
1940
|
console.error(error);
|
|
1782
|
-
return
|
|
1941
|
+
return createApiErrorObservable(error);
|
|
1783
1942
|
}));
|
|
1784
1943
|
}));
|
|
1785
1944
|
// src/epics/router/selectScreenEpic.ts
|
|
1786
|
-
import { filter as filter14, of as
|
|
1945
|
+
import { filter as filter14, of as of13, switchMap as switchMap5 } from "rxjs";
|
|
1787
1946
|
var changeScreen = (action$, state$) => action$.pipe(filter14(selectScreen.match), switchMap5((action) => {
|
|
1788
1947
|
const state = state$.value;
|
|
1789
1948
|
const nextViewName = state.router.viewName;
|
|
1790
1949
|
const requestedView = state.screen.views.find((item) => item.name === nextViewName);
|
|
1791
1950
|
const defaultView = !nextViewName && state.screen.primaryView && state.screen.views.find((item) => item.name === state.screen.primaryView);
|
|
1792
1951
|
const nextView = requestedView || defaultView || state.screen.views[0];
|
|
1793
|
-
return nextView ?
|
|
1952
|
+
return nextView ? of13(selectView(nextView)) : of13(selectViewFail({ viewName: nextViewName }));
|
|
1794
1953
|
}));
|
|
1795
1954
|
// src/epics/router/userDrillDownEpic.ts
|
|
1796
|
-
import { catchError as
|
|
1955
|
+
import { catchError as catchError5, concat as concat8, EMPTY as EMPTY9, filter as filter15, mergeMap as mergeMap10, of as of14, switchMap as switchMap6 } from "rxjs";
|
|
1797
1956
|
var userDrillDownEpic = (action$, state$, { api }) => action$.pipe(filter15(userDrillDown.match), switchMap6((action) => {
|
|
1798
1957
|
const state = state$.value;
|
|
1799
1958
|
const { bcName, fieldKey, cursor } = action.payload;
|
|
1800
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
1959
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
1801
1960
|
return api.fetchRowMeta(state.screen.screenName, bcUrl).pipe(mergeMap10((rowMeta) => {
|
|
1802
1961
|
var _a, _b, _c, _d;
|
|
1803
1962
|
const drillDownField = rowMeta.fields.find((field) => field.key === fieldKey);
|
|
1804
1963
|
const route = state.router;
|
|
1805
1964
|
const drillDownKey = (_b = (_a = state.view.widgets.find((widget) => widget.bcName === bcName)) == null ? void 0 : _a.fields.find((field) => field.key === fieldKey)) == null ? void 0 : _b.drillDownKey;
|
|
1806
1965
|
const customDrillDownUrl = (_d = (_c = state.data[bcName]) == null ? void 0 : _c.find((record) => record.id === cursor)) == null ? void 0 : _d[drillDownKey];
|
|
1807
|
-
return customDrillDownUrl || (drillDownField == null ? void 0 : drillDownField.drillDown) || (drillDownField == null ? void 0 : drillDownField.drillDown) !== route.path ?
|
|
1966
|
+
return customDrillDownUrl || (drillDownField == null ? void 0 : drillDownField.drillDown) || (drillDownField == null ? void 0 : drillDownField.drillDown) !== route.path ? concat8((drillDownField == null ? void 0 : drillDownField.drillDownType) !== DrillDownType.inner ? of14(bcFetchRowMetaSuccess({ bcName, rowMeta, bcUrl, cursor })) : EMPTY9, of14(userDrillDownSuccess({ bcName, bcUrl, cursor })), of14(drillDown({
|
|
1808
1967
|
url: customDrillDownUrl || drillDownField.drillDown,
|
|
1809
1968
|
drillDownType: drillDownField.drillDownType,
|
|
1810
1969
|
route
|
|
1811
|
-
}))) :
|
|
1812
|
-
}),
|
|
1970
|
+
}))) : EMPTY9;
|
|
1971
|
+
}), catchError5((error) => {
|
|
1813
1972
|
console.error(error);
|
|
1814
|
-
return
|
|
1973
|
+
return createApiErrorObservable(error);
|
|
1815
1974
|
}));
|
|
1816
1975
|
}));
|
|
1817
1976
|
// src/epics/router/changeLocationEpic.ts
|
|
1818
|
-
import { concat as
|
|
1977
|
+
import { concat as concat9, EMPTY as EMPTY10, filter as filter16, mergeMap as mergeMap11, of as of15 } from "rxjs";
|
|
1819
1978
|
var changeLocationEpic = (action$, state$) => action$.pipe(filter16(changeLocation.match), mergeMap11((action) => {
|
|
1820
1979
|
var _a, _b;
|
|
1821
1980
|
const state = state$.value;
|
|
1822
1981
|
if (!state.session.active) {
|
|
1823
|
-
return
|
|
1982
|
+
return EMPTY10;
|
|
1824
1983
|
}
|
|
1825
1984
|
if (state.router.type === "router" /* router */) {
|
|
1826
|
-
return
|
|
1985
|
+
return of15(handleRouter(state.router));
|
|
1827
1986
|
}
|
|
1828
1987
|
const currentScreenName = state.screen.screenName;
|
|
1829
1988
|
const defaultScreenName = ((_a = state.session.screens.find((screen) => screen.defaultScreen)) == null ? void 0 : _a.name) || ((_b = state.session.screens[0]) == null ? void 0 : _b.name);
|
|
1830
1989
|
const nextScreenName = state.router.type === "default" /* default */ ? defaultScreenName : state.router.screenName;
|
|
1831
1990
|
if (nextScreenName !== currentScreenName) {
|
|
1832
1991
|
const nextScreen = state.session.screens.find((item) => item.name === nextScreenName);
|
|
1833
|
-
return nextScreen ?
|
|
1992
|
+
return nextScreen ? of15(selectScreen({ screen: nextScreen })) : of15(selectScreenFail({ screenName: nextScreenName }));
|
|
1834
1993
|
}
|
|
1835
1994
|
const currentViewName = state.view.name;
|
|
1836
1995
|
const nextViewName = state.router.viewName;
|
|
@@ -1847,21 +2006,21 @@ var changeLocationEpic = (action$, state$) => action$.pipe(filter16(changeLocati
|
|
|
1847
2006
|
const needUpdateViews = nextViewName !== currentViewName;
|
|
1848
2007
|
const resultObservables = [];
|
|
1849
2008
|
if (needUpdateCursors) {
|
|
1850
|
-
resultObservables.push(
|
|
2009
|
+
resultObservables.push(of15(bcChangeCursors({ cursorsMap: cursorsDiffMap })));
|
|
1851
2010
|
}
|
|
1852
2011
|
if (needUpdateViews) {
|
|
1853
2012
|
const nextView = nextViewName ? state.screen.views.find((item) => item.name === nextViewName) : state.screen.primaryView ? state.screen.views.find((item) => item.name === state.screen.primaryView) : state.screen.views[0];
|
|
1854
|
-
resultObservables.push(nextView ?
|
|
2013
|
+
resultObservables.push(nextView ? of15(selectView(nextView)) : of15(selectViewFail({ viewName: nextViewName })));
|
|
1855
2014
|
}
|
|
1856
2015
|
if (needUpdateCursors && !needUpdateViews) {
|
|
1857
2016
|
Object.entries(nextCursors).forEach((entry) => {
|
|
1858
2017
|
const [bcName, cursor] = entry;
|
|
1859
2018
|
if (!state.data[bcName].find((item) => item.id === cursor)) {
|
|
1860
|
-
resultObservables.push(
|
|
2019
|
+
resultObservables.push(of15(bcForceUpdate({ bcName })));
|
|
1861
2020
|
}
|
|
1862
2021
|
});
|
|
1863
2022
|
}
|
|
1864
|
-
return
|
|
2023
|
+
return concat9(...resultObservables);
|
|
1865
2024
|
}));
|
|
1866
2025
|
// src/epics/router/selectViewFailEpic.ts
|
|
1867
2026
|
import { filter as filter17, map as map2 } from "rxjs";
|
|
@@ -1893,41 +2052,42 @@ var userDrillDownChangeCursorsEpic = (action$, state$) => action$.pipe(filter19(
|
|
|
1893
2052
|
if (cursor !== action.payload.cursor) {
|
|
1894
2053
|
return bcChangeCursors({ cursorsMap: { [action.payload.bcName]: action.payload.cursor } });
|
|
1895
2054
|
}
|
|
1896
|
-
return
|
|
2055
|
+
return emptyAction;
|
|
1897
2056
|
}));
|
|
1898
2057
|
// src/epics/screen/apiErrorEpic.ts
|
|
1899
2058
|
import axios from "axios";
|
|
1900
|
-
import { EMPTY as
|
|
1901
|
-
var knownHttpErrors = [401, 409, 418, 500];
|
|
2059
|
+
import { EMPTY as EMPTY11, filter as filter20, mergeMap as mergeMap12, of as of16 } from "rxjs";
|
|
1902
2060
|
var apiErrorEpic = (action$) => action$.pipe(filter20(apiError.match), mergeMap12((action) => {
|
|
1903
2061
|
const { error, callContext } = action.payload;
|
|
1904
2062
|
if (error.response) {
|
|
1905
|
-
return
|
|
2063
|
+
return of16(httpError({
|
|
1906
2064
|
statusCode: error.response.status,
|
|
1907
2065
|
error,
|
|
1908
2066
|
callContext
|
|
1909
2067
|
}));
|
|
1910
2068
|
}
|
|
1911
2069
|
else if (!axios.isCancel(error)) {
|
|
1912
|
-
return
|
|
2070
|
+
return of16(showViewError({
|
|
1913
2071
|
error: {
|
|
1914
2072
|
type: 2 /* NetworkError */
|
|
1915
2073
|
}
|
|
1916
2074
|
}));
|
|
1917
2075
|
}
|
|
1918
|
-
return
|
|
2076
|
+
return EMPTY11;
|
|
1919
2077
|
}));
|
|
1920
2078
|
// src/epics/screen/downloadFileEpic.ts
|
|
1921
|
-
import { EMPTY as
|
|
2079
|
+
import { EMPTY as EMPTY12, filter as filter21, mergeMap as mergeMap13, tap } from "rxjs";
|
|
1922
2080
|
var downloadFileEpic = (action$, state$, { api }) => action$.pipe(filter21(downloadFile.match), tap((action) => {
|
|
2081
|
+
const { fileId } = action.payload;
|
|
1923
2082
|
const anchor = document.createElement("a");
|
|
2083
|
+
anchor.href = `${api.fileUploadEndpoint}?id=${encodeURIComponent(fileId)}`;
|
|
1924
2084
|
anchor.style.display = "none";
|
|
1925
2085
|
document.body.appendChild(anchor);
|
|
1926
2086
|
setTimeout(() => {
|
|
1927
2087
|
anchor.click();
|
|
1928
2088
|
document.body.removeChild(anchor);
|
|
1929
2089
|
}, 100);
|
|
1930
|
-
}), mergeMap13(() =>
|
|
2090
|
+
}), mergeMap13(() => EMPTY12));
|
|
1931
2091
|
// src/epics/screen/httpError401Epic.ts
|
|
1932
2092
|
import { filter as filter22, map as map5 } from "rxjs";
|
|
1933
2093
|
var httpError401Epic = (action$) => action$.pipe(filter22(httpError.match), filter22((action) => action.payload.statusCode === 401), map5((action) => {
|
|
@@ -1936,8 +2096,8 @@ var httpError401Epic = (action$) => action$.pipe(filter22(httpError.match), filt
|
|
|
1936
2096
|
// src/epics/screen/httpError409Epic.ts
|
|
1937
2097
|
import { filter as filter23, map as map6 } from "rxjs";
|
|
1938
2098
|
var httpError409Epic = (action$, state$) => action$.pipe(filter23(httpError.match), filter23((action) => action.payload.statusCode === 409), map6((action) => {
|
|
1939
|
-
var _a, _b;
|
|
1940
|
-
const notificationMessage = ((_b = (_a = action.payload.error.response.data.error) == null ? void 0 :
|
|
2099
|
+
var _a, _b, _c;
|
|
2100
|
+
const notificationMessage = ((_c = (_b = ((_a = action.payload.error.response) == null ? void 0 : _a.data).error) == null ? void 0 : _b.popup) == null ? void 0 : _c[0]) || "";
|
|
1941
2101
|
return addNotification({
|
|
1942
2102
|
key: "action_edit_error",
|
|
1943
2103
|
message: notificationMessage,
|
|
@@ -1951,30 +2111,30 @@ var httpError409Epic = (action$, state$) => action$.pipe(filter23(httpError.matc
|
|
|
1951
2111
|
});
|
|
1952
2112
|
}));
|
|
1953
2113
|
// src/epics/screen/httpError418Epic.ts
|
|
1954
|
-
import { concat as
|
|
2114
|
+
import { concat as concat10, EMPTY as EMPTY13, filter as filter24, mergeMap as mergeMap14, of as of17 } from "rxjs";
|
|
1955
2115
|
var httpError418Epic = (action$, state$) => action$.pipe(filter24(httpError.match), filter24((action) => action.payload.statusCode === 418), mergeMap14((action) => {
|
|
1956
|
-
var _a;
|
|
2116
|
+
var _a, _b;
|
|
1957
2117
|
const { error, callContext } = action.payload;
|
|
1958
2118
|
const result = [];
|
|
1959
|
-
const typedError = error.response.data;
|
|
2119
|
+
const typedError = (_a = error.response) == null ? void 0 : _a.data;
|
|
1960
2120
|
if (!typedError.error.popup) {
|
|
1961
|
-
return
|
|
2121
|
+
return EMPTY13;
|
|
1962
2122
|
}
|
|
1963
2123
|
const businessError = {
|
|
1964
2124
|
type: 0 /* BusinessError */,
|
|
1965
2125
|
message: typedError.error.popup[0]
|
|
1966
2126
|
};
|
|
1967
|
-
result.push(
|
|
1968
|
-
if ((
|
|
2127
|
+
result.push(of17(showViewError({ error: businessError })));
|
|
2128
|
+
if ((_b = typedError.error.postActions) == null ? void 0 : _b[0]) {
|
|
1969
2129
|
const widget = state$.value.view.widgets.find((item) => item.name === callContext.widgetName);
|
|
1970
|
-
const bcName = widget.bcName;
|
|
1971
|
-
result.push(
|
|
2130
|
+
const bcName = widget == null ? void 0 : widget.bcName;
|
|
2131
|
+
result.push(of17(processPostInvoke({
|
|
1972
2132
|
bcName,
|
|
1973
2133
|
postInvoke: typedError.error.postActions[0],
|
|
1974
|
-
widgetName: widget.name
|
|
2134
|
+
widgetName: widget == null ? void 0 : widget.name
|
|
1975
2135
|
})));
|
|
1976
2136
|
}
|
|
1977
|
-
return
|
|
2137
|
+
return concat10(...result);
|
|
1978
2138
|
}));
|
|
1979
2139
|
// src/epics/screen/httpError500Epic.ts
|
|
1980
2140
|
import { filter as filter25, map as map7 } from "rxjs";
|
|
@@ -1989,16 +2149,18 @@ var httpError500Epic = (action$, state$) => action$.pipe(filter25(httpError.matc
|
|
|
1989
2149
|
}));
|
|
1990
2150
|
// src/epics/screen/httpErrorDefaultEpic.ts
|
|
1991
2151
|
import { filter as filter26, map as map8 } from "rxjs";
|
|
1992
|
-
var
|
|
2152
|
+
var knownHttpErrors = [401, 409, 418, 500];
|
|
2153
|
+
var httpErrorDefaultEpic = (action$, state$) => action$.pipe(filter26(httpError.match), filter26((action) => !knownHttpErrors.includes(action.payload.statusCode)), map8((action) => {
|
|
2154
|
+
var _a, _b;
|
|
1993
2155
|
const businessError = {
|
|
1994
2156
|
type: 0 /* BusinessError */,
|
|
1995
|
-
code: action.payload.error.response.status,
|
|
1996
|
-
details: action.payload.error.response.data
|
|
2157
|
+
code: (_a = action.payload.error.response) == null ? void 0 : _a.status,
|
|
2158
|
+
details: (_b = action.payload.error.response) == null ? void 0 : _b.data
|
|
1997
2159
|
};
|
|
1998
2160
|
return showViewError({ error: businessError });
|
|
1999
2161
|
}));
|
|
2000
2162
|
// src/epics/screen/downloadFileByUrlEpic.ts
|
|
2001
|
-
import { EMPTY as
|
|
2163
|
+
import { EMPTY as EMPTY14, filter as filter27, mergeMap as mergeMap15, tap as tap2 } from "rxjs";
|
|
2002
2164
|
var downloadFileByUrlEpic = (action$, state$) => action$.pipe(filter27(downloadFileByUrl.match), tap2((action) => {
|
|
2003
2165
|
const { url } = action.payload;
|
|
2004
2166
|
const anchor = document.createElement("a");
|
|
@@ -2009,21 +2171,25 @@ var downloadFileByUrlEpic = (action$, state$) => action$.pipe(filter27(downloadF
|
|
|
2009
2171
|
anchor.click();
|
|
2010
2172
|
document.body.removeChild(anchor);
|
|
2011
2173
|
}, 100);
|
|
2012
|
-
}), mergeMap15(() =>
|
|
2174
|
+
}), mergeMap15(() => EMPTY14));
|
|
2013
2175
|
// src/epics/screen/processPostInvokeEpic.ts
|
|
2014
|
-
import { EMPTY as
|
|
2176
|
+
import { EMPTY as EMPTY15, filter as filter28, mergeMap as mergeMap16, of as of18 } from "rxjs";
|
|
2015
2177
|
var processPostInvokeEpic = (action$, state$) => action$.pipe(filter28(processPostInvoke.match), mergeMap16((action) => {
|
|
2178
|
+
var _a;
|
|
2016
2179
|
const state = state$.value;
|
|
2017
2180
|
switch (action.payload.postInvoke.type) {
|
|
2018
2181
|
case "drillDown" /* drillDown */:
|
|
2019
|
-
return
|
|
2182
|
+
return of18(drillDown(__spreadProps(__spreadValues({}, action.payload.postInvoke), {
|
|
2020
2183
|
route: state.router,
|
|
2021
2184
|
widgetName: action.payload.widgetName
|
|
2022
2185
|
})));
|
|
2023
2186
|
case "postDelete" /* postDelete */: {
|
|
2024
2187
|
const cursorsMap = { [action.payload.bcName]: null };
|
|
2025
2188
|
const result = [bcChangeCursors({ cursorsMap })];
|
|
2026
|
-
if (state.router.bcPath.includes(`${action.payload.bcName}/`)) {
|
|
2189
|
+
if ((_a = state.router.bcPath) == null ? void 0 : _a.includes(`${action.payload.bcName}/`)) {
|
|
2190
|
+
const newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || "";
|
|
2191
|
+
const newUrl = `/screen/${state.router.screenName}/view/${state.router.viewName}/${newBcUrl}`;
|
|
2192
|
+
result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }));
|
|
2027
2193
|
}
|
|
2028
2194
|
else {
|
|
2029
2195
|
result.push(bcFetchDataRequest({
|
|
@@ -2031,7 +2197,7 @@ var processPostInvokeEpic = (action$, state$) => action$.pipe(filter28(processPo
|
|
|
2031
2197
|
widgetName: action.payload.widgetName
|
|
2032
2198
|
}));
|
|
2033
2199
|
}
|
|
2034
|
-
return
|
|
2200
|
+
return of18(...result);
|
|
2035
2201
|
}
|
|
2036
2202
|
case "refreshBC" /* refreshBC */: {
|
|
2037
2203
|
const bo = state.screen.bo;
|
|
@@ -2041,34 +2207,34 @@ var processPostInvokeEpic = (action$, state$) => action$.pipe(filter28(processPo
|
|
|
2041
2207
|
const widgetName = action.payload.widgetName || "";
|
|
2042
2208
|
const infiniteWidgets = state.view.infiniteWidgets || [];
|
|
2043
2209
|
const infinitePagination = state.view.widgets.some((item) => item.bcName === postInvokeBC && infiniteWidgets.includes(item.name));
|
|
2044
|
-
return infinitePagination ?
|
|
2210
|
+
return infinitePagination ? of18(bcFetchDataPages({
|
|
2045
2211
|
bcName: postInvokeBCItem.name,
|
|
2046
2212
|
widgetName,
|
|
2047
2213
|
from: 1,
|
|
2048
2214
|
to: postInvokeBCItem.page
|
|
2049
|
-
})) :
|
|
2215
|
+
})) : of18(bcFetchDataRequest({
|
|
2050
2216
|
bcName: postInvokeBCItem.name,
|
|
2051
2217
|
widgetName
|
|
2052
2218
|
}));
|
|
2053
2219
|
}
|
|
2054
2220
|
case "showMessage" /* showMessage */: {
|
|
2055
2221
|
const postInvoke = action.payload.postInvoke;
|
|
2056
|
-
return
|
|
2222
|
+
return of18(showNotification({ type: postInvoke.messageType, message: postInvoke.messageText }));
|
|
2057
2223
|
}
|
|
2058
2224
|
case "downloadFile" /* downloadFile */: {
|
|
2059
2225
|
const postInvoke = action.payload.postInvoke;
|
|
2060
|
-
return
|
|
2226
|
+
return of18(downloadFile({ fileId: postInvoke.fileId }));
|
|
2061
2227
|
}
|
|
2062
2228
|
case "downloadFileByUrl" /* downloadFileByUrl */: {
|
|
2063
2229
|
const postInvoke = action.payload.postInvoke;
|
|
2064
|
-
return
|
|
2230
|
+
return of18(downloadFileByUrl({ url: postInvoke.url }));
|
|
2065
2231
|
}
|
|
2066
2232
|
default:
|
|
2067
|
-
return
|
|
2233
|
+
return EMPTY15;
|
|
2068
2234
|
}
|
|
2069
2235
|
}));
|
|
2070
2236
|
// src/epics/screen/processPostInvokeConfirmEpic.ts
|
|
2071
|
-
import { EMPTY as
|
|
2237
|
+
import { EMPTY as EMPTY16, filter as filter29, mergeMap as mergeMap17, of as of19 } from "rxjs";
|
|
2072
2238
|
import { isAnyOf } from "@reduxjs/toolkit";
|
|
2073
2239
|
var processPostInvokeConfirmEpic = (action$, state$) => action$.pipe(filter29(isAnyOf(processPostInvokeConfirm, processPreInvoke)), mergeMap17((action) => {
|
|
2074
2240
|
const { bcName, operationType, widgetName } = action.payload;
|
|
@@ -2078,7 +2244,7 @@ var processPostInvokeConfirmEpic = (action$, state$) => action$.pipe(filter29(is
|
|
|
2078
2244
|
case "info" /* info */:
|
|
2079
2245
|
case "error" /* error */:
|
|
2080
2246
|
case "confirmText" /* confirmText */: {
|
|
2081
|
-
return
|
|
2247
|
+
return of19(operationConfirmation({
|
|
2082
2248
|
operation: {
|
|
2083
2249
|
bcName,
|
|
2084
2250
|
operationType,
|
|
@@ -2088,34 +2254,34 @@ var processPostInvokeConfirmEpic = (action$, state$) => action$.pipe(filter29(is
|
|
|
2088
2254
|
}));
|
|
2089
2255
|
}
|
|
2090
2256
|
default:
|
|
2091
|
-
return
|
|
2257
|
+
return EMPTY16;
|
|
2092
2258
|
}
|
|
2093
2259
|
}));
|
|
2094
2260
|
// src/epics/session/switchRoleEpic.ts
|
|
2095
|
-
import { concat as
|
|
2261
|
+
import { concat as concat11, filter as filter30, switchMap as switchMap7 } from "rxjs";
|
|
2096
2262
|
var switchRoleEpic = (action$, state$) => action$.pipe(filter30(switchRole.match), switchMap7((action) => {
|
|
2097
|
-
return
|
|
2263
|
+
return concat11([logoutDone(null), login({ login: "", password: "", role: action.payload.role })]);
|
|
2098
2264
|
}));
|
|
2099
2265
|
// src/epics/session/refreshMetaEpic.ts
|
|
2100
|
-
import { catchError as
|
|
2266
|
+
import { catchError as catchError6, concat as concat12, filter as filter31, mergeMap as mergeMap18, switchMap as switchMap8 } from "rxjs";
|
|
2101
2267
|
var refreshMetaEpic = (action$, state$, { api }) => action$.pipe(filter31(refreshMeta.match), mergeMap18(() => {
|
|
2102
2268
|
const state = state$.value;
|
|
2103
2269
|
const { router } = state;
|
|
2104
2270
|
const { activeRole } = state.session;
|
|
2105
|
-
return api.refreshMeta().pipe(switchMap8(() =>
|
|
2271
|
+
return api.refreshMeta().pipe(switchMap8(() => concat12([
|
|
2272
|
+
refreshMetaDone(),
|
|
2106
2273
|
logoutDone(null),
|
|
2107
2274
|
login({ login: "", password: "", role: activeRole }),
|
|
2108
2275
|
changeLocation({
|
|
2109
|
-
|
|
2110
|
-
action: "PUSH"
|
|
2276
|
+
location: router
|
|
2111
2277
|
})
|
|
2112
|
-
])),
|
|
2278
|
+
])), catchError6((error) => concat12([loginFail(error), refreshMetaFail(), createApiError(error)])));
|
|
2113
2279
|
}));
|
|
2114
2280
|
// src/epics/session/loginDoneEpic.ts
|
|
2115
|
-
import { EMPTY as
|
|
2116
|
-
var loginDoneSessionEpic = (action$, store) => action$.pipe(filter32(login.match), switchMap9((action) =>
|
|
2281
|
+
import { EMPTY as EMPTY17, filter as filter32, switchMap as switchMap9 } from "rxjs";
|
|
2282
|
+
var loginDoneSessionEpic = (action$, store) => action$.pipe(filter32(login.match), switchMap9((action) => EMPTY17));
|
|
2117
2283
|
// src/epics/session/loginByAnotherRoleEpic.ts
|
|
2118
|
-
import { catchError as
|
|
2284
|
+
import { catchError as catchError7, concat as concat13, filter as filter33, mergeMap as mergeMap19, of as of20, switchMap as switchMap10 } from "rxjs";
|
|
2119
2285
|
var responseStatusMessages = {
|
|
2120
2286
|
401: "Invalid credentials",
|
|
2121
2287
|
403: "Access denied"
|
|
@@ -2128,49 +2294,70 @@ var loginByAnotherRoleEpic = (action$, state$, { api }) => action$.pipe(filter33
|
|
|
2128
2294
|
const role = (_a = action.payload.role) != null ? _a : "";
|
|
2129
2295
|
const isSwitchRole = role && role !== state$.value.session.activeRole;
|
|
2130
2296
|
return api.loginByRoleRequest(role).pipe(mergeMap19((data) => {
|
|
2297
|
+
var _a2;
|
|
2298
|
+
const result = [];
|
|
2131
2299
|
if (isSwitchRole) {
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2300
|
+
const defaultScreen = data.screens.find((screen) => screen.defaultScreen) || data.screens[0];
|
|
2301
|
+
const defaultViewName = (_a2 = defaultScreen == null ? void 0 : defaultScreen.primary) != null ? _a2 : defaultScreen.meta.views[0].name;
|
|
2302
|
+
const defaultView = defaultScreen == null ? void 0 : defaultScreen.meta.views.find((view) => defaultViewName === view.name);
|
|
2303
|
+
if (defaultView)
|
|
2304
|
+
result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }));
|
|
2305
|
+
}
|
|
2306
|
+
return concat13([
|
|
2307
|
+
...result,
|
|
2308
|
+
loginDone({
|
|
2309
|
+
devPanelEnabled: data.devPanelEnabled,
|
|
2310
|
+
activeRole: data.activeRole,
|
|
2311
|
+
roles: data.roles,
|
|
2312
|
+
screens: data.screens,
|
|
2313
|
+
firstName: data.firstName,
|
|
2314
|
+
lastName: data.lastName,
|
|
2315
|
+
login: data.login
|
|
2316
|
+
})
|
|
2317
|
+
]);
|
|
2318
|
+
}), catchError7((error) => {
|
|
2135
2319
|
console.error(error);
|
|
2136
2320
|
const errorMsg = error.response ? responseStatusMessages[error.response.status] || "Server application unavailable" : "Empty server response";
|
|
2137
|
-
return of20(loginFail({ errorMsg }));
|
|
2321
|
+
return concat13(of20(loginFail({ errorMsg })), createApiErrorObservable(error));
|
|
2138
2322
|
}));
|
|
2139
2323
|
}));
|
|
2140
2324
|
// src/epics/session/refreshMetaAndReloadPageEpic.ts
|
|
2141
|
-
import { concat as
|
|
2142
|
-
var refreshMetaAndReloadPageEpic = (action$, state$) => action$.pipe(filter34(refreshMetaAndReloadPage.match), switchMap11(() =>
|
|
2325
|
+
import { concat as concat14, EMPTY as EMPTY18, filter as filter34, of as of21, switchMap as switchMap11, take, tap as tap3 } from "rxjs";
|
|
2326
|
+
var refreshMetaAndReloadPageEpic = (action$, state$) => action$.pipe(filter34(refreshMetaAndReloadPage.match), switchMap11(() => concat14(of21(refreshMeta()), action$.pipe(filter34(loginDone.match), take(1), tap3(() => location.reload()), switchMap11(() => EMPTY18)))));
|
|
2143
2327
|
// src/epics/data/bcNewDataEpic.ts
|
|
2144
|
-
import { catchError as
|
|
2328
|
+
import { catchError as catchError8, concat as concat15, EMPTY as EMPTY19, filter as filter35, mergeMap as mergeMap20, of as of22 } from "rxjs";
|
|
2145
2329
|
import { OperationTypeCrud as OperationTypeCrud8 } from "@cxbox-ui/schema";
|
|
2146
2330
|
var bcNewDataEpic = (action$, state$, { api }) => action$.pipe(filter35(sendOperation.match), filter35((action) => matchOperationRole(OperationTypeCrud8.create, action.payload, state$.value)), mergeMap20((action) => {
|
|
2331
|
+
var _a;
|
|
2147
2332
|
const state = state$.value;
|
|
2148
2333
|
const bcName = action.payload.bcName;
|
|
2149
|
-
const bcUrl = buildBcUrl(bcName);
|
|
2334
|
+
const bcUrl = (_a = buildBcUrl(bcName, false, state)) != null ? _a : "";
|
|
2150
2335
|
const context = { widgetName: action.payload.widgetName };
|
|
2151
2336
|
const params = { _action: action.payload.operationType };
|
|
2152
2337
|
return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe(mergeMap20((data) => {
|
|
2338
|
+
var _a2, _b;
|
|
2153
2339
|
const rowMeta = data.row;
|
|
2154
2340
|
const dataItem = { id: null, vstamp: -1 };
|
|
2155
2341
|
data.row.fields.forEach((field) => {
|
|
2156
2342
|
dataItem[field.key] = field.currentValue;
|
|
2157
2343
|
});
|
|
2158
|
-
const postInvoke = data.postActions[0];
|
|
2344
|
+
const postInvoke = (_a2 = data.postActions) == null ? void 0 : _a2[0];
|
|
2159
2345
|
const cursor = dataItem.id;
|
|
2160
|
-
return
|
|
2161
|
-
bcName
|
|
2346
|
+
return concat15(of22(bcNewDataSuccess({ bcName, dataItem, bcUrl })), of22(bcFetchRowMetaSuccess({ bcName, bcUrl: `${bcUrl}/${cursor}`, rowMeta, cursor })), of22(changeDataItem({
|
|
2347
|
+
bcName,
|
|
2348
|
+
bcUrl: (_b = buildBcUrl(bcName, true, state)) != null ? _b : "",
|
|
2162
2349
|
cursor,
|
|
2163
2350
|
dataItem: {
|
|
2164
2351
|
id: cursor
|
|
2165
2352
|
}
|
|
2166
2353
|
})), postInvoke ? of22(processPostInvoke({ bcName, postInvoke, cursor, widgetName: action.payload.widgetName })) : EMPTY19);
|
|
2167
|
-
}),
|
|
2354
|
+
}), catchError8((error) => {
|
|
2168
2355
|
console.error(error);
|
|
2169
|
-
return of22(bcNewDataFail({ bcName }));
|
|
2356
|
+
return concat15(of22(bcNewDataFail({ bcName })), createApiErrorObservable(error, context));
|
|
2170
2357
|
}));
|
|
2171
2358
|
}));
|
|
2172
2359
|
// src/epics/data/bcLoadMoreEpic.ts
|
|
2173
|
-
import { catchError as
|
|
2360
|
+
import { catchError as catchError9, concat as concat16, filter as filter37, mergeMap as mergeMap22, of as of24, race } from "rxjs";
|
|
2174
2361
|
// src/utils/cancelRequestEpic.ts
|
|
2175
2362
|
import { filter as filter36, mergeMap as mergeMap21, of as of23, take as take2 } from "rxjs";
|
|
2176
2363
|
import { isAnyOf as isAnyOf2 } from "@reduxjs/toolkit";
|
|
@@ -2179,7 +2366,7 @@ function cancelRequestEpic(action$, actionTypes, cancelFn, cancelActionCreator,
|
|
|
2179
2366
|
return true;
|
|
2180
2367
|
}) {
|
|
2181
2368
|
return action$.pipe(filter36(isAnyOf2(...actionTypes)), filter36(filterFn), mergeMap21(() => {
|
|
2182
|
-
cancelFn();
|
|
2369
|
+
cancelFn == null ? void 0 : cancelFn();
|
|
2183
2370
|
return of23(cancelActionCreator);
|
|
2184
2371
|
}), take2(1));
|
|
2185
2372
|
}
|
|
@@ -2192,7 +2379,7 @@ var bcLoadMoreEpic = (action$, state$, { api }) => action$.pipe(filter37(bcLoadM
|
|
|
2192
2379
|
const { cursor, page } = bc;
|
|
2193
2380
|
const limit = ((_a = state.view.widgets.find((i) => i.bcName === bcName)) == null ? void 0 : _a.limit) || bc.limit;
|
|
2194
2381
|
const limitBySelfCursor = (_b = state.router.bcPath) == null ? void 0 : _b.includes(`${bcName}/${cursor}`);
|
|
2195
|
-
const bcUrl = buildBcUrl(bcName, limitBySelfCursor);
|
|
2382
|
+
const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
|
|
2196
2383
|
const filters = state.screen.filters[bcName] || [];
|
|
2197
2384
|
const sorters = state.screen.sorters[bcName];
|
|
2198
2385
|
const fetchParams = __spreadValues(__spreadValues({
|
|
@@ -2211,25 +2398,25 @@ var bcLoadMoreEpic = (action$, state$, { api }) => action$.pipe(filter37(bcLoadM
|
|
|
2211
2398
|
bcUrl,
|
|
2212
2399
|
hasNext: data.hasNext
|
|
2213
2400
|
}));
|
|
2214
|
-
}),
|
|
2401
|
+
}), catchError9((error) => {
|
|
2215
2402
|
console.error(error);
|
|
2216
|
-
return of24(bcFetchDataFail({ bcName, bcUrl }));
|
|
2403
|
+
return concat16(of24(bcFetchDataFail({ bcName, bcUrl })), createApiErrorObservable(error));
|
|
2217
2404
|
}));
|
|
2218
2405
|
return race(cancelFlow, normalFlow);
|
|
2219
2406
|
}));
|
|
2220
2407
|
// src/epics/data/bcSaveDataEpic.ts
|
|
2221
|
-
import { catchError as
|
|
2408
|
+
import { catchError as catchError10, concat as concat17, EMPTY as EMPTY20, filter as filter38, mergeMap as mergeMap23, of as of25 } from "rxjs";
|
|
2222
2409
|
var bcSaveDataEpic = (action$, state$, { api }) => action$.pipe(filter38(sendOperation.match), filter38((action) => matchOperationRole(OperationTypeCrud.save, action.payload, state$.value)), mergeMap23((action) => {
|
|
2223
|
-
var _a, _b, _c;
|
|
2410
|
+
var _a, _b, _c, _d;
|
|
2224
2411
|
const state = state$.value;
|
|
2225
2412
|
const bcName = action.payload.bcName;
|
|
2226
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
2413
|
+
const bcUrl = (_a = buildBcUrl(bcName, true, state)) != null ? _a : "";
|
|
2227
2414
|
const widgetName = action.payload.widgetName;
|
|
2228
2415
|
const cursor = state.screen.bo.bc[bcName].cursor;
|
|
2229
2416
|
const dataItem = state.data[bcName].find((item) => item.id === cursor);
|
|
2230
|
-
const pendingChanges = (
|
|
2231
|
-
const rowMeta = bcUrl && ((
|
|
2232
|
-
const options = (
|
|
2417
|
+
const pendingChanges = __spreadValues({}, (_b = state.view.pendingDataChanges[bcName]) == null ? void 0 : _b[cursor]);
|
|
2418
|
+
const rowMeta = bcUrl && ((_c = state.view.rowMeta[bcName]) == null ? void 0 : _c[bcUrl]);
|
|
2419
|
+
const options = (_d = state.view.widgets.find((widget) => widget.name === widgetName)) == null ? void 0 : _d.options;
|
|
2233
2420
|
if (rowMeta) {
|
|
2234
2421
|
const fields = rowMeta.fields;
|
|
2235
2422
|
for (const key in pendingChanges) {
|
|
@@ -2243,17 +2430,18 @@ var bcSaveDataEpic = (action$, state$, { api }) => action$.pipe(filter38(sendOpe
|
|
|
2243
2430
|
return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] });
|
|
2244
2431
|
});
|
|
2245
2432
|
const context = { widgetName: action.payload.widgetName };
|
|
2246
|
-
return api.saveBcData(state.screen.screenName, bcUrl, __spreadProps(__spreadValues({}, pendingChanges), { vstamp: dataItem.vstamp }), context).pipe(mergeMap23((data) => {
|
|
2247
|
-
|
|
2433
|
+
return api.saveBcData(state.screen.screenName, bcUrl, __spreadProps(__spreadValues({}, pendingChanges), { vstamp: dataItem == null ? void 0 : dataItem.vstamp }), context).pipe(mergeMap23((data) => {
|
|
2434
|
+
var _a2;
|
|
2435
|
+
const postInvoke = (_a2 = data.postActions) == null ? void 0 : _a2[0];
|
|
2248
2436
|
const responseDataItem = data.record;
|
|
2249
|
-
return
|
|
2437
|
+
return concat17(of25(bcSaveDataSuccess({ bcName, cursor, dataItem: responseDataItem })), of25(bcFetchRowMeta({ widgetName, bcName })), of25(...fetchChildrenBcData), postInvoke ? of25(processPostInvoke({
|
|
2250
2438
|
bcName,
|
|
2251
2439
|
widgetName,
|
|
2252
2440
|
postInvoke,
|
|
2253
2441
|
cursor: responseDataItem.id
|
|
2254
2442
|
})) : EMPTY20, action.payload.onSuccessAction ? of25(action.payload.onSuccessAction) : EMPTY20);
|
|
2255
|
-
}),
|
|
2256
|
-
var _a2, _b2, _c2,
|
|
2443
|
+
}), catchError10((e) => {
|
|
2444
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
|
|
2257
2445
|
console.error(e);
|
|
2258
2446
|
let notification$ = EMPTY20;
|
|
2259
2447
|
if (action.payload.onSuccessAction && !(options == null ? void 0 : options.disableNotification)) {
|
|
@@ -2274,10 +2462,10 @@ var bcSaveDataEpic = (action$, state$, { api }) => action$.pipe(filter38(sendOpe
|
|
|
2274
2462
|
let entityError = null;
|
|
2275
2463
|
const operationError = (_a2 = e.response) == null ? void 0 : _a2.data;
|
|
2276
2464
|
if (((_b2 = e.response) == null ? void 0 : _b2.data) === Object((_c2 = e.response) == null ? void 0 : _c2.data)) {
|
|
2277
|
-
entityError = (
|
|
2278
|
-
viewError = (
|
|
2465
|
+
entityError = (_e = (_d2 = operationError == null ? void 0 : operationError.error) == null ? void 0 : _d2.entity) != null ? _e : entityError;
|
|
2466
|
+
viewError = (_h = (_g = (_f = operationError == null ? void 0 : operationError.error) == null ? void 0 : _f.popup) == null ? void 0 : _g[0]) != null ? _h : viewError;
|
|
2279
2467
|
}
|
|
2280
|
-
return
|
|
2468
|
+
return concat17(of25(bcSaveDataFail({ bcName, bcUrl, viewError, entityError })), notification$, createApiErrorObservable(e, context));
|
|
2281
2469
|
}));
|
|
2282
2470
|
}));
|
|
2283
2471
|
// src/epics/data/selectViewEpic.ts
|
|
@@ -2310,8 +2498,8 @@ var selectViewEpic = (action$, state$) => action$.pipe(filter39(selectView.match
|
|
|
2310
2498
|
}
|
|
2311
2499
|
}));
|
|
2312
2500
|
// src/epics/data/bcFetchDataEpic.ts
|
|
2313
|
-
import { catchError as
|
|
2314
|
-
import { WidgetTypes as
|
|
2501
|
+
import { catchError as catchError11, concat as concat18, EMPTY as EMPTY22, filter as filter40, mergeMap as mergeMap25, of as of26, race as race2 } from "rxjs";
|
|
2502
|
+
import { WidgetTypes as WidgetTypes5 } from "@cxbox-ui/schema";
|
|
2315
2503
|
import { isAnyOf as isAnyOf3 } from "@reduxjs/toolkit";
|
|
2316
2504
|
var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyOf3(bcFetchDataRequest, bcFetchDataPages, showViewPopup, bcForceUpdate, bcChangePage)), mergeMap25((action) => {
|
|
2317
2505
|
const getCursorChange = (data, prevCursor, isHierarchy) => {
|
|
@@ -2329,7 +2517,7 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
|
|
|
2329
2517
|
const getChildrenData = (widgets, bcDictionary, isHierarchy, showConditionCheck) => {
|
|
2330
2518
|
const { bcName } = action.payload;
|
|
2331
2519
|
const { ignorePageLimit, keepDelta } = bcFetchDataRequest.match(action) ? action.payload : { ignorePageLimit: void 0, keepDelta: void 0 };
|
|
2332
|
-
return
|
|
2520
|
+
return concat18(...Object.entries(getBcChildren(bcName, widgets, bcDictionary)).filter(([childBcName, widgetNames]) => {
|
|
2333
2521
|
const nonLazyWidget = widgets.find((item) => {
|
|
2334
2522
|
return widgetNames.includes(item.name) && !PopupWidgetTypes.includes(item.type) && showConditionCheck(item);
|
|
2335
2523
|
});
|
|
@@ -2344,44 +2532,44 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
|
|
|
2344
2532
|
});
|
|
2345
2533
|
return of26(bcFetchDataRequest({
|
|
2346
2534
|
bcName: childBcName,
|
|
2347
|
-
widgetName: nonLazyWidget.name,
|
|
2535
|
+
widgetName: nonLazyWidget == null ? void 0 : nonLazyWidget.name,
|
|
2348
2536
|
ignorePageLimit: ignorePageLimit || showViewPopup.match(action),
|
|
2349
2537
|
keepDelta: isHierarchy || keepDelta
|
|
2350
2538
|
}));
|
|
2351
2539
|
}));
|
|
2352
2540
|
};
|
|
2353
2541
|
const bcFetchDataImpl = () => {
|
|
2354
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2542
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2355
2543
|
const state = state$.value;
|
|
2356
|
-
const { widgetName } = action.payload;
|
|
2544
|
+
const { widgetName = "" } = action.payload;
|
|
2357
2545
|
const { widgets, infiniteWidgets } = state.view;
|
|
2358
|
-
const widget = (_a = widgets.find((item) => item.name === widgetName)) != null ? _a : widgets.find((item) => item.bcName === action.payload.bcName);
|
|
2546
|
+
const widget = (_a = widgets == null ? void 0 : widgets.find((item) => item.name === widgetName)) != null ? _a : widgets == null ? void 0 : widgets.find((item) => item.bcName === action.payload.bcName);
|
|
2359
2547
|
if (!widget) {
|
|
2360
2548
|
return [EMPTY22];
|
|
2361
2549
|
}
|
|
2362
2550
|
const bcName = action.payload.bcName;
|
|
2363
2551
|
const bc = state.screen.bo.bc[bcName];
|
|
2364
|
-
const { cursor, page } = bc;
|
|
2365
|
-
const limit = ((_b = widgets.find((i) => i.bcName === bcName)) == null ? void 0 : _b.limit) || bc.limit;
|
|
2552
|
+
const { cursor, page = 1 } = bc;
|
|
2553
|
+
const limit = (_c = ((_b = widgets == null ? void 0 : widgets.find((i) => i.bcName === bcName)) == null ? void 0 : _b.limit) || bc.limit) != null ? _c : 5;
|
|
2366
2554
|
const sorters = state.screen.sorters[bcName];
|
|
2367
2555
|
if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {
|
|
2368
2556
|
return [EMPTY22];
|
|
2369
2557
|
}
|
|
2370
|
-
const anyHierarchyWidget = widgets.find((item) => {
|
|
2371
|
-
return item.bcName === widget.bcName && item.type ===
|
|
2558
|
+
const anyHierarchyWidget = widgets == null ? void 0 : widgets.find((item) => {
|
|
2559
|
+
return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && isHierarchyWidget(item);
|
|
2372
2560
|
});
|
|
2373
|
-
const fullHierarchyWidget = state.view.widgets.find((item) => {
|
|
2561
|
+
const fullHierarchyWidget = (_d = state.view.widgets) == null ? void 0 : _d.find((item) => {
|
|
2374
2562
|
var _a2;
|
|
2375
|
-
return item.bcName === widget.bcName && item.type ===
|
|
2563
|
+
return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && ((_a2 = item.options) == null ? void 0 : _a2.hierarchyFull);
|
|
2376
2564
|
});
|
|
2377
|
-
const limitBySelfCursor = (
|
|
2378
|
-
const bcUrl = buildBcUrl(bcName, limitBySelfCursor);
|
|
2565
|
+
const limitBySelfCursor = (_e = state.router.bcPath) == null ? void 0 : _e.includes(`${bcName}/${cursor}`);
|
|
2566
|
+
const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
|
|
2379
2567
|
const fetchParams = __spreadValues(__spreadValues({
|
|
2380
2568
|
_page: page,
|
|
2381
2569
|
_limit: limit
|
|
2382
2570
|
}, getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || [])), getSorters(sorters));
|
|
2383
2571
|
if (bcForceUpdate.match(action)) {
|
|
2384
|
-
const infinityPaginationWidget = widgetName && infiniteWidgets.includes(widgetName) || ((
|
|
2572
|
+
const infinityPaginationWidget = widgetName && (infiniteWidgets == null ? void 0 : infiniteWidgets.includes(widgetName)) || ((_g = (_f = widgets == null ? void 0 : widgets.filter((item) => item.bcName === bcName)) == null ? void 0 : _f.find((item) => infiniteWidgets == null ? void 0 : infiniteWidgets.includes(item.name))) == null ? void 0 : _g.name);
|
|
2385
2573
|
if (infinityPaginationWidget) {
|
|
2386
2574
|
fetchParams._page = 1;
|
|
2387
2575
|
fetchParams._limit = limit * page;
|
|
@@ -2391,7 +2579,7 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
|
|
|
2391
2579
|
fetchParams._page = action.payload.from || 1;
|
|
2392
2580
|
fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit;
|
|
2393
2581
|
}
|
|
2394
|
-
if (bcFetchDataRequest.match(action) && action.payload.ignorePageLimit || ((
|
|
2582
|
+
if (bcFetchDataRequest.match(action) && action.payload.ignorePageLimit || ((_h = anyHierarchyWidget == null ? void 0 : anyHierarchyWidget.options) == null ? void 0 : _h.hierarchyFull)) {
|
|
2395
2583
|
fetchParams._limit = 0;
|
|
2396
2584
|
}
|
|
2397
2585
|
const canceler = api.createCanceler();
|
|
@@ -2403,12 +2591,12 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
|
|
|
2403
2591
|
const normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(mergeMap25((response) => {
|
|
2404
2592
|
var _a2, _b2;
|
|
2405
2593
|
const cursorChange = getCursorChange(response.data, cursor, !!anyHierarchyWidget);
|
|
2406
|
-
const parentOfNotLazyWidget = widgets.some((item) => {
|
|
2594
|
+
const parentOfNotLazyWidget = widgets == null ? void 0 : widgets.some((item) => {
|
|
2407
2595
|
var _a3;
|
|
2408
2596
|
return ((_a3 = state.screen.bo.bc[item.bcName]) == null ? void 0 : _a3.parentName) === bcName && !PopupWidgetTypes.includes(item.type);
|
|
2409
2597
|
});
|
|
2410
2598
|
const isWidgetVisible = (w) => {
|
|
2411
|
-
var _a3, _b3, _c2, _d2, _e2, _f2,
|
|
2599
|
+
var _a3, _b3, _c2, _d2, _e2, _f2, _g2, _h2, _i;
|
|
2412
2600
|
if (((_a3 = w.showCondition) == null ? void 0 : _a3.bcName) === ((_b3 = state.screen.bo.bc[w.bcName]) == null ? void 0 : _b3.parentName)) {
|
|
2413
2601
|
let parentName = (_d2 = state.screen.bo.bc[(_c2 = w.showCondition) == null ? void 0 : _c2.bcName]) == null ? void 0 : _d2.parentName;
|
|
2414
2602
|
let parent = parentName === bcName;
|
|
@@ -2420,8 +2608,8 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
|
|
|
2420
2608
|
return true;
|
|
2421
2609
|
}
|
|
2422
2610
|
}
|
|
2423
|
-
const dataToCheck = bcName === ((_f2 = w.showCondition) == null ? void 0 : _f2.bcName) ? response.data : state.data[(
|
|
2424
|
-
return checkShowCondition(w.showCondition, (_i = state.screen.bo.bc[(
|
|
2611
|
+
const dataToCheck = bcName === ((_f2 = w.showCondition) == null ? void 0 : _f2.bcName) ? response.data : state.data[(_g2 = w.showCondition) == null ? void 0 : _g2.bcName];
|
|
2612
|
+
return checkShowCondition(w.showCondition, (_i = state.screen.bo.bc[(_h2 = w.showCondition) == null ? void 0 : _h2.bcName]) == null ? void 0 : _i.cursor, dataToCheck, state.view.pendingDataChanges);
|
|
2425
2613
|
};
|
|
2426
2614
|
const lazyWidget = (!isWidgetVisible(widget) || PopupWidgetTypes.includes(widget.type)) && !parentOfNotLazyWidget;
|
|
2427
2615
|
const skipLazy = ((_a2 = state.view.popupData) == null ? void 0 : _a2.bcName) !== widget.bcName;
|
|
@@ -2430,15 +2618,15 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
|
|
|
2430
2618
|
}
|
|
2431
2619
|
const fetchChildren = ((_b2 = response.data) == null ? void 0 : _b2.length) ? getChildrenData(widgets, state.screen.bo.bc, !!anyHierarchyWidget, isWidgetVisible) : EMPTY22;
|
|
2432
2620
|
const fetchRowMeta = of26(bcFetchRowMeta({ widgetName, bcName }));
|
|
2433
|
-
return
|
|
2621
|
+
return concat18(cursorChange, of26(bcFetchDataSuccess({
|
|
2434
2622
|
bcName,
|
|
2435
2623
|
data: response.data,
|
|
2436
2624
|
bcUrl,
|
|
2437
2625
|
hasNext: response.hasNext
|
|
2438
2626
|
})), fetchRowMeta, fetchChildren);
|
|
2439
|
-
}),
|
|
2627
|
+
}), catchError11((error) => {
|
|
2440
2628
|
console.error(error);
|
|
2441
|
-
return of26(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl }));
|
|
2629
|
+
return concat18(of26(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl })), createApiErrorObservable(error));
|
|
2442
2630
|
}));
|
|
2443
2631
|
return [cancelFlow, cancelByParentBc, normalFlow];
|
|
2444
2632
|
};
|
|
@@ -2449,26 +2637,27 @@ function isHierarchyWidget(widget) {
|
|
|
2449
2637
|
return ((_a = widget.options) == null ? void 0 : _a.hierarchy) || ((_b = widget.options) == null ? void 0 : _b.hierarchyFull);
|
|
2450
2638
|
}
|
|
2451
2639
|
// src/epics/data/bcDeleteDataEpic.ts
|
|
2452
|
-
import { catchError as
|
|
2640
|
+
import { catchError as catchError12, concat as concat19, EMPTY as EMPTY23, filter as filter41, mergeMap as mergeMap26, of as of27 } from "rxjs";
|
|
2453
2641
|
import { OperationTypeCrud as OperationTypeCrud9 } from "@cxbox-ui/schema";
|
|
2454
2642
|
var bcDeleteDataEpic = (action$, store$, { api }) => action$.pipe(filter41(sendOperation.match), filter41((action) => matchOperationRole(OperationTypeCrud9.delete, action.payload, store$.value)), mergeMap26((action) => {
|
|
2455
2643
|
const widgetName = action.payload.widgetName;
|
|
2456
2644
|
const state = store$.value;
|
|
2457
2645
|
const bcName = action.payload.bcName;
|
|
2458
2646
|
const cursor = state.screen.bo.bc[bcName].cursor;
|
|
2459
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
2647
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
2460
2648
|
const context = { widgetName: action.payload.widgetName };
|
|
2461
2649
|
const isTargetFormatPVF = state.view.pendingValidationFailsFormat === "target" /* target */;
|
|
2462
2650
|
return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe(mergeMap26((data) => {
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2651
|
+
var _a;
|
|
2652
|
+
const postInvoke = (_a = data.postActions) == null ? void 0 : _a[0];
|
|
2653
|
+
return concat19(isTargetFormatPVF ? of27(bcCancelPendingChanges({ bcNames: [bcName] })) : EMPTY23, of27(bcFetchDataRequest({ bcName, widgetName })), postInvoke ? of27(processPostInvoke({ bcName, postInvoke, cursor, widgetName })) : EMPTY23);
|
|
2654
|
+
}), catchError12((error) => {
|
|
2466
2655
|
console.error(error);
|
|
2467
|
-
return of27(bcDeleteDataFail({ bcName }));
|
|
2656
|
+
return concat19(of27(bcDeleteDataFail({ bcName })), createApiErrorObservable(error, context));
|
|
2468
2657
|
}));
|
|
2469
2658
|
}));
|
|
2470
2659
|
// src/epics/data/bcSelectRecordEpic.ts
|
|
2471
|
-
import { concat as
|
|
2660
|
+
import { concat as concat20, filter as filter42, mergeMap as mergeMap27, of as of28 } from "rxjs";
|
|
2472
2661
|
var bcSelectRecordEpic = (action$, store$) => action$.pipe(filter42(bcSelectRecord.match), mergeMap27((action) => {
|
|
2473
2662
|
const { bcName, cursor } = action.payload;
|
|
2474
2663
|
const widgets = store$.value.view.widgets;
|
|
@@ -2482,17 +2671,19 @@ var bcSelectRecordEpic = (action$, store$) => action$.pipe(filter42(bcSelectReco
|
|
|
2482
2671
|
keepDelta: action.payload.keepDelta
|
|
2483
2672
|
});
|
|
2484
2673
|
});
|
|
2485
|
-
return
|
|
2674
|
+
return concat20(of28(bcChangeCursors({ cursorsMap: { [bcName]: cursor }, keepDelta: action.payload.keepDelta })), of28(bcFetchRowMeta({ widgetName: "", bcName })), fetchChildrenBcData);
|
|
2486
2675
|
}));
|
|
2487
2676
|
// src/epics/data/changeAssociationEpic.ts
|
|
2488
|
-
import { concat as
|
|
2677
|
+
import { concat as concat21, filter as filter43, mergeMap as mergeMap28, of as of29 } from "rxjs";
|
|
2489
2678
|
var changeAssociationEpic = (action$, state$) => action$.pipe(filter43(changeAssociation.match), mergeMap28((action) => {
|
|
2490
2679
|
var _a, _b, _c, _d, _e;
|
|
2491
2680
|
const state = state$.value;
|
|
2492
2681
|
const selected = action.payload.dataItem._associate;
|
|
2682
|
+
const bcName = action.payload.bcName;
|
|
2493
2683
|
const result = [
|
|
2494
2684
|
of29(changeDataItem({
|
|
2495
|
-
bcName
|
|
2685
|
+
bcName,
|
|
2686
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2496
2687
|
cursor: action.payload.dataItem.id,
|
|
2497
2688
|
dataItem: action.payload.dataItem
|
|
2498
2689
|
}))
|
|
@@ -2505,19 +2696,19 @@ var changeAssociationEpic = (action$, state$) => action$.pipe(filter43(changeAss
|
|
|
2505
2696
|
fields: widget.fields
|
|
2506
2697
|
};
|
|
2507
2698
|
const hierarchy = (_b = widget.options) == null ? void 0 : _b.hierarchy;
|
|
2508
|
-
const hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy.find((item) => item.bcName === action.payload.bcName);
|
|
2699
|
+
const hierarchyDescriptor = isRoot ? rootHierarchyDescriptor : hierarchy == null ? void 0 : hierarchy.find((item) => item.bcName === action.payload.bcName);
|
|
2509
2700
|
const hierarchyGroupSelection = (_c = widget.options) == null ? void 0 : _c.hierarchyGroupSelection;
|
|
2510
2701
|
const hierarchyTraverse = (_d = widget.options) == null ? void 0 : _d.hierarchyTraverse;
|
|
2511
|
-
const childrenBc = hierarchy.slice(hierarchy.findIndex((item) => item.bcName === action.payload.bcName) + 1).map((item) => item.bcName);
|
|
2702
|
+
const childrenBc = hierarchy == null ? void 0 : hierarchy.slice(hierarchy.findIndex((item) => item.bcName === action.payload.bcName) + 1).map((item) => item.bcName);
|
|
2512
2703
|
if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {
|
|
2513
2704
|
result.push(of29(dropAllAssociations({
|
|
2514
2705
|
bcNames: childrenBc
|
|
2515
2706
|
})));
|
|
2516
2707
|
}
|
|
2517
|
-
const parent = isRoot ? null : hierarchy.find((item, index) => {
|
|
2708
|
+
const parent = isRoot ? null : (hierarchy == null ? void 0 : hierarchy.find((item, index) => {
|
|
2518
2709
|
var _a2;
|
|
2519
2710
|
return ((_a2 = hierarchy[index + 1]) == null ? void 0 : _a2.bcName) === action.payload.bcName;
|
|
2520
|
-
}) || rootHierarchyDescriptor;
|
|
2711
|
+
})) || rootHierarchyDescriptor;
|
|
2521
2712
|
const parentItem = (_e = state.data[parent == null ? void 0 : parent.bcName]) == null ? void 0 : _e.find((item) => item.id === state.screen.bo.bc[parent == null ? void 0 : parent.bcName].cursor);
|
|
2522
2713
|
if (parent && hierarchyTraverse && selected) {
|
|
2523
2714
|
if (hierarchyDescriptor.radio) {
|
|
@@ -2530,7 +2721,7 @@ var changeAssociationEpic = (action$, state$) => action$.pipe(filter43(changeAss
|
|
|
2530
2721
|
widgetName: action.payload.widgetName,
|
|
2531
2722
|
dataItem: __spreadProps(__spreadValues({}, parentItem), {
|
|
2532
2723
|
_associate: true,
|
|
2533
|
-
_value: parentItem[parent.assocValueKey || action.payload.assocValueKey]
|
|
2724
|
+
_value: parentItem == null ? void 0 : parentItem[parent.assocValueKey || action.payload.assocValueKey]
|
|
2534
2725
|
}),
|
|
2535
2726
|
assocValueKey: action.payload.assocValueKey
|
|
2536
2727
|
})));
|
|
@@ -2553,10 +2744,10 @@ var changeAssociationEpic = (action$, state$) => action$.pipe(filter43(changeAss
|
|
|
2553
2744
|
})));
|
|
2554
2745
|
}
|
|
2555
2746
|
}
|
|
2556
|
-
return
|
|
2747
|
+
return concat21(...result);
|
|
2557
2748
|
}));
|
|
2558
2749
|
// src/epics/data/bcCancelCreateDataEpic.ts
|
|
2559
|
-
import { catchError as
|
|
2750
|
+
import { catchError as catchError13, concat as concat22, EMPTY as EMPTY24, filter as filter44, mergeMap as mergeMap29, of as of30 } from "rxjs";
|
|
2560
2751
|
import { OperationTypeCrud as OperationTypeCrud10 } from "@cxbox-ui/schema";
|
|
2561
2752
|
import { isAnyOf as isAnyOf4 } from "@reduxjs/toolkit";
|
|
2562
2753
|
var actionTypesMatcher = isAnyOf4(sendOperation);
|
|
@@ -2565,7 +2756,7 @@ var bcCancelCreateDataEpic = (action$, state$, { api }) => action$.pipe(filter44
|
|
|
2565
2756
|
const state = state$.value;
|
|
2566
2757
|
const screenName = state.screen.screenName;
|
|
2567
2758
|
const bcName = action.payload.bcName;
|
|
2568
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
2759
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
2569
2760
|
const bc = state.screen.bo.bc[bcName];
|
|
2570
2761
|
const cursor = bc == null ? void 0 : bc.cursor;
|
|
2571
2762
|
const context = { widgetName: action.payload.widgetName };
|
|
@@ -2575,18 +2766,19 @@ var bcCancelCreateDataEpic = (action$, state$, { api }) => action$.pipe(filter44
|
|
|
2575
2766
|
const params = { _action: action.payload.operationType };
|
|
2576
2767
|
const cursorsMap = { [action.payload.bcName]: null };
|
|
2577
2768
|
return api.customAction(screenName, bcUrl, data, context, params).pipe(mergeMap29((response) => {
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2769
|
+
var _a2;
|
|
2770
|
+
const postInvoke = (_a2 = response.postActions) == null ? void 0 : _a2[0];
|
|
2771
|
+
return concat22(of30(sendOperationSuccess({ bcName, cursor })), of30(bcChangeCursors({ cursorsMap })), postInvoke ? of30(processPostInvoke({ bcName, postInvoke, cursor, widgetName: context.widgetName })) : EMPTY24);
|
|
2772
|
+
}), catchError13((error) => {
|
|
2581
2773
|
console.error(error);
|
|
2582
|
-
return of30(bcDeleteDataFail({ bcName }));
|
|
2774
|
+
return concat22(of30(bcDeleteDataFail({ bcName })), createApiErrorObservable(error, context));
|
|
2583
2775
|
}));
|
|
2584
2776
|
}));
|
|
2585
2777
|
// src/epics/data/bcSelectDepthRecordEpic.ts
|
|
2586
|
-
import { concat as
|
|
2778
|
+
import { concat as concat23, filter as filter45, mergeMap as mergeMap30, of as of31 } from "rxjs";
|
|
2587
2779
|
var bcSelectDepthRecordEpic = (action$) => action$.pipe(filter45(bcSelectDepthRecord.match), mergeMap30((action) => {
|
|
2588
2780
|
const { bcName, cursor, depth } = action.payload;
|
|
2589
|
-
return
|
|
2781
|
+
return concat23(of31(bcChangeDepthCursor({ bcName, depth, cursor })), of31(bcFetchDataRequest({
|
|
2590
2782
|
bcName,
|
|
2591
2783
|
depth: depth + 1,
|
|
2592
2784
|
widgetName: "",
|
|
@@ -2594,7 +2786,7 @@ var bcSelectDepthRecordEpic = (action$) => action$.pipe(filter45(bcSelectDepthRe
|
|
|
2594
2786
|
})));
|
|
2595
2787
|
}));
|
|
2596
2788
|
// src/epics/data/removeMultivalueTagEpic.ts
|
|
2597
|
-
import { concat as
|
|
2789
|
+
import { concat as concat24, filter as filter46, mergeMap as mergeMap31, of as of32 } from "rxjs";
|
|
2598
2790
|
var removeMultivalueTagEpic = (action$, state$) => action$.pipe(filter46(removeMultivalueTag.match), mergeMap31((action) => {
|
|
2599
2791
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2600
2792
|
const state = state$.value;
|
|
@@ -2609,28 +2801,28 @@ var removeMultivalueTagEpic = (action$, state$) => action$.pipe(filter46(removeM
|
|
|
2609
2801
|
const removedItem = data.find((item) => item.id === action.payload.removedItem.id);
|
|
2610
2802
|
const associated = action.payload.dataItem.map((item) => item.id);
|
|
2611
2803
|
let removedNodes = [];
|
|
2612
|
-
if ((_a = widget.options) == null ? void 0 : _a.hierarchyGroupDeselection) {
|
|
2613
|
-
if ((_b = widget.options) == null ? void 0 : _b.hierarchyTraverse) {
|
|
2804
|
+
if ((_a = widget == null ? void 0 : widget.options) == null ? void 0 : _a.hierarchyGroupDeselection) {
|
|
2805
|
+
if ((_b = widget == null ? void 0 : widget.options) == null ? void 0 : _b.hierarchyTraverse) {
|
|
2614
2806
|
data = assignTreeLinks(data);
|
|
2615
2807
|
}
|
|
2616
|
-
const removedItemChildren = data.filter((item) => item.parentId === removedItem.id);
|
|
2617
|
-
removedNodes = [removedItem.id, ...removedItemChildren.filter((item) => associated.includes(item.id)).map((item) => item.id)];
|
|
2618
|
-
if ((_c = widget.options) == null ? void 0 : _c.hierarchyTraverse) {
|
|
2808
|
+
const removedItemChildren = data.filter((item) => item.parentId === (removedItem == null ? void 0 : removedItem.id));
|
|
2809
|
+
removedNodes = [removedItem == null ? void 0 : removedItem.id, ...removedItemChildren.filter((item) => associated.includes(item.id)).map((item) => item.id)];
|
|
2810
|
+
if ((_c = widget == null ? void 0 : widget.options) == null ? void 0 : _c.hierarchyTraverse) {
|
|
2619
2811
|
getDescendants(removedItemChildren, removedNodes);
|
|
2620
2812
|
removedNodes = data.filter((item) => removedNodes.includes(item.id) && associated.includes(item.id)).map((item) => item.id);
|
|
2621
2813
|
}
|
|
2622
|
-
const parent = data.find((item) => item.id === removedItem.parentId);
|
|
2814
|
+
const parent = data.find((item) => item.id === (removedItem == null ? void 0 : removedItem.parentId));
|
|
2623
2815
|
const siblings = data.filter((item) => item.parentId === (parent == null ? void 0 : parent.id));
|
|
2624
2816
|
const parentEmpty = siblings.every((child) => removedNodes.includes(child.id) || !associated.includes(child.id));
|
|
2625
2817
|
if (parent && parentEmpty) {
|
|
2626
|
-
if ((_d = widget.options) == null ? void 0 : _d.hierarchyTraverse) {
|
|
2818
|
+
if ((_d = widget == null ? void 0 : widget.options) == null ? void 0 : _d.hierarchyTraverse) {
|
|
2627
2819
|
const parentDescendants = [];
|
|
2628
2820
|
getDescendants(siblings, parentDescendants);
|
|
2629
2821
|
const parentDeepEmpty = parentDescendants.every((descendant) => {
|
|
2630
2822
|
return removedNodes.includes(descendant) || !associated.includes(descendant);
|
|
2631
2823
|
});
|
|
2632
2824
|
if (parentDeepEmpty) {
|
|
2633
|
-
return
|
|
2825
|
+
return concat24(of32(removeMultivalueTag(__spreadProps(__spreadValues({}, action.payload), {
|
|
2634
2826
|
removedItem: { id: parent.id, value: null }
|
|
2635
2827
|
}))));
|
|
2636
2828
|
}
|
|
@@ -2640,51 +2832,58 @@ var removeMultivalueTagEpic = (action$, state$) => action$.pipe(filter46(removeM
|
|
|
2640
2832
|
}
|
|
2641
2833
|
}
|
|
2642
2834
|
}
|
|
2643
|
-
if ((_e = widget.options) == null ? void 0 : _e.hierarchyFull) {
|
|
2835
|
+
if ((_e = widget == null ? void 0 : widget.options) == null ? void 0 : _e.hierarchyFull) {
|
|
2644
2836
|
return of32(changeDataItem({
|
|
2645
2837
|
bcName,
|
|
2838
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2646
2839
|
cursor,
|
|
2647
2840
|
dataItem: { [associateFieldKey]: action.payload.dataItem.filter((item) => !removedNodes.includes(item.id)) }
|
|
2648
2841
|
}));
|
|
2649
2842
|
}
|
|
2650
|
-
if ((_f = widget.options) == null ? void 0 : _f.hierarchy) {
|
|
2651
|
-
|
|
2843
|
+
if ((_f = widget == null ? void 0 : widget.options) == null ? void 0 : _f.hierarchy) {
|
|
2844
|
+
const hierarchyBcName = (_j = (_i = (_h = (_g = widget == null ? void 0 : widget.options) == null ? void 0 : _g.hierarchy) == null ? void 0 : _h.find((hierarchyData) => {
|
|
2845
|
+
var _a2;
|
|
2846
|
+
return (_a2 = state.view.pendingDataChanges[hierarchyData.bcName]) == null ? void 0 : _a2[action.payload.removedItem.id];
|
|
2847
|
+
})) == null ? void 0 : _i.bcName) != null ? _j : bcName;
|
|
2848
|
+
return concat24(of32(changeDataItem({
|
|
2652
2849
|
/**
|
|
2653
2850
|
* This is incorrect and will break if different BC has records with
|
|
2654
2851
|
* identical ids.
|
|
2655
2852
|
*
|
|
2656
2853
|
* TODO: Record `level` should be mapped to hierarchyData index instead
|
|
2657
2854
|
*/
|
|
2658
|
-
bcName:
|
|
2659
|
-
|
|
2660
|
-
return (_a2 = state.view.pendingDataChanges[hierarchyData.bcName]) == null ? void 0 : _a2[action.payload.removedItem.id];
|
|
2661
|
-
})) == null ? void 0 : _i.bcName) != null ? _j : bcName,
|
|
2855
|
+
bcName: hierarchyBcName,
|
|
2856
|
+
bcUrl: buildBcUrl(hierarchyBcName, true, state),
|
|
2662
2857
|
cursor: action.payload.removedItem.id,
|
|
2663
2858
|
dataItem: __spreadProps(__spreadValues({}, action.payload.removedItem), { _associate: false })
|
|
2664
2859
|
})), of32(changeDataItem({
|
|
2665
2860
|
bcName,
|
|
2861
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2666
2862
|
cursor,
|
|
2667
2863
|
dataItem: { [associateFieldKey]: action.payload.dataItem }
|
|
2668
2864
|
})));
|
|
2669
2865
|
}
|
|
2670
|
-
return
|
|
2866
|
+
return concat24(of32(changeDataItem({
|
|
2671
2867
|
bcName: popupBcName,
|
|
2868
|
+
bcUrl: buildBcUrl(popupBcName, true, state),
|
|
2672
2869
|
cursor: action.payload.removedItem.id,
|
|
2673
2870
|
dataItem: __spreadProps(__spreadValues({}, action.payload.removedItem), { _associate: false })
|
|
2674
2871
|
})), of32(changeDataItem({
|
|
2675
2872
|
bcName,
|
|
2873
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2676
2874
|
cursor,
|
|
2677
2875
|
dataItem: { [associateFieldKey]: action.payload.dataItem }
|
|
2678
2876
|
})));
|
|
2679
2877
|
}));
|
|
2680
2878
|
// src/epics/data/bcFetchRowMetaRequestEpic.ts
|
|
2681
|
-
import { catchError as
|
|
2879
|
+
import { catchError as catchError14, concat as concat25, filter as filter47, map as map9, mergeMap as mergeMap32, of as of33, race as race3 } from "rxjs";
|
|
2682
2880
|
var bcFetchRowMetaRequestEpic = (action$, state$, { api }) => action$.pipe(filter47(bcFetchRowMeta.match), mergeMap32((action) => {
|
|
2881
|
+
var _a, _b;
|
|
2683
2882
|
const state = state$.value;
|
|
2684
2883
|
const screenName = state.screen.screenName;
|
|
2685
2884
|
const bcName = action.payload.bcName;
|
|
2686
|
-
const cursor = state.screen.bo.bc[bcName].cursor;
|
|
2687
|
-
const bcUrl = buildBcUrl(bcName, true);
|
|
2885
|
+
const cursor = (_a = state.screen.bo.bc[bcName].cursor) != null ? _a : "";
|
|
2886
|
+
const bcUrl = (_b = buildBcUrl(bcName, true, state)) != null ? _b : "";
|
|
2688
2887
|
const canceler = api.createCanceler();
|
|
2689
2888
|
const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName }));
|
|
2690
2889
|
const cancelByParentBc = cancelRequestEpic(action$, [bcSelectRecord], canceler.cancel, bcFetchRowMetaFail({ bcName }), (filteredAction) => {
|
|
@@ -2693,14 +2892,14 @@ var bcFetchRowMetaRequestEpic = (action$, state$, { api }) => action$.pipe(filte
|
|
|
2693
2892
|
});
|
|
2694
2893
|
const normalFlow = api.fetchRowMeta(screenName, bcUrl, void 0, canceler.cancelToken).pipe(map9((rowMeta) => {
|
|
2695
2894
|
return bcFetchRowMetaSuccess({ bcName, rowMeta, bcUrl, cursor });
|
|
2696
|
-
}),
|
|
2895
|
+
}), catchError14((error) => {
|
|
2697
2896
|
console.error(error);
|
|
2698
|
-
return of33(bcFetchRowMetaFail({ bcName }));
|
|
2897
|
+
return concat25(of33(bcFetchRowMetaFail({ bcName })), createApiErrorObservable(error));
|
|
2699
2898
|
}));
|
|
2700
2899
|
return race3(cancelFlow, cancelByParentBc, normalFlow);
|
|
2701
2900
|
}));
|
|
2702
2901
|
// src/epics/data/changeAssociationFullEpic.ts
|
|
2703
|
-
import { concat as
|
|
2902
|
+
import { concat as concat26, filter as filter48, mergeMap as mergeMap33, of as of34 } from "rxjs";
|
|
2704
2903
|
var changeAssociationFullEpic = (action$, state$) => action$.pipe(filter48(changeAssociationFull.match), mergeMap33((action) => {
|
|
2705
2904
|
var _a, _b, _c, _d, _e;
|
|
2706
2905
|
const state = state$.value;
|
|
@@ -2751,6 +2950,7 @@ var changeAssociationFullEpic = (action$, state$) => action$.pipe(filter48(chang
|
|
|
2751
2950
|
}
|
|
2752
2951
|
result.push(of34(changeDataItem({
|
|
2753
2952
|
bcName: action.payload.bcName,
|
|
2953
|
+
bcUrl: buildBcUrl(action.payload.bcName, true, state),
|
|
2754
2954
|
cursor: action.payload.dataItem.id,
|
|
2755
2955
|
dataItem: action.payload.dataItem
|
|
2756
2956
|
})));
|
|
@@ -2761,7 +2961,7 @@ var changeAssociationFullEpic = (action$, state$) => action$.pipe(filter48(chang
|
|
|
2761
2961
|
widgetName: action.payload.widgetName,
|
|
2762
2962
|
dataItem: __spreadProps(__spreadValues({}, parentItem), {
|
|
2763
2963
|
_associate: true,
|
|
2764
|
-
_value: parentItem[assocValueKey]
|
|
2964
|
+
_value: parentItem == null ? void 0 : parentItem[assocValueKey]
|
|
2765
2965
|
}),
|
|
2766
2966
|
assocValueKey
|
|
2767
2967
|
})));
|
|
@@ -2783,50 +2983,53 @@ var changeAssociationFullEpic = (action$, state$) => action$.pipe(filter48(chang
|
|
|
2783
2983
|
})));
|
|
2784
2984
|
}
|
|
2785
2985
|
}
|
|
2786
|
-
return
|
|
2986
|
+
return concat26(...result);
|
|
2787
2987
|
}));
|
|
2788
2988
|
// src/epics/data/saveAssociationsActiveEpic.ts
|
|
2789
|
-
import { catchError as
|
|
2989
|
+
import { catchError as catchError15, concat as concat27, EMPTY as EMPTY25, filter as filter49, mergeMap as mergeMap34, of as of35, switchMap as switchMap12 } from "rxjs";
|
|
2790
2990
|
var saveAssociationsActiveEpic = (action$, state$, { api }) => action$.pipe(filter49(saveAssociations.match), filter49((action) => {
|
|
2791
|
-
|
|
2991
|
+
var _a;
|
|
2992
|
+
return (_a = state$.value.view.popupData) == null ? void 0 : _a.active;
|
|
2792
2993
|
}), switchMap12((action) => {
|
|
2994
|
+
var _a, _b;
|
|
2793
2995
|
const state = state$.value;
|
|
2794
|
-
const calleeBCName = state.view.popupData.calleeBCName;
|
|
2795
|
-
const calleeWidgetName = state.view.popupData.calleeWidgetName;
|
|
2996
|
+
const calleeBCName = (_a = state.view.popupData) == null ? void 0 : _a.calleeBCName;
|
|
2997
|
+
const calleeWidgetName = (_b = state.view.popupData) == null ? void 0 : _b.calleeWidgetName;
|
|
2796
2998
|
const bcNames = action.payload.bcNames;
|
|
2797
|
-
const bcUrl = buildBcUrl(calleeBCName, true);
|
|
2999
|
+
const bcUrl = buildBcUrl(calleeBCName, true, state);
|
|
2798
3000
|
const pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {};
|
|
2799
3001
|
const params = bcNames.length ? { _bcName: bcNames[bcNames.length - 1] } : {};
|
|
2800
3002
|
return api.associate(state.screen.screenName, bcUrl, Object.values(pendingChanges).filter((i) => i._associate), params).pipe(mergeMap34((response) => {
|
|
2801
3003
|
const postInvoke = response.postActions[0];
|
|
2802
3004
|
const calleeWidget = state.view.widgets.find((widgetItem) => widgetItem.bcName === calleeBCName);
|
|
2803
|
-
return
|
|
2804
|
-
}),
|
|
3005
|
+
return concat27(postInvoke ? of35(processPostInvoke({ bcName: calleeBCName, postInvoke, widgetName: calleeWidget == null ? void 0 : calleeWidget.name })) : EMPTY25, of35(bcCancelPendingChanges({ bcNames })), of35(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName })));
|
|
3006
|
+
}), catchError15((err) => {
|
|
2805
3007
|
console.error(err);
|
|
2806
3008
|
return EMPTY25;
|
|
2807
3009
|
}));
|
|
2808
3010
|
}));
|
|
2809
3011
|
// src/epics/data/changeAssociationSameBcEpic.ts
|
|
2810
|
-
import { concat as
|
|
3012
|
+
import { concat as concat28, filter as filter50, mergeMap as mergeMap35, of as of36 } from "rxjs";
|
|
2811
3013
|
var changeAssociationSameBcEpic = (action$, state$) => action$.pipe(filter50(changeAssociationSameBc.match), mergeMap35((action) => {
|
|
2812
|
-
var _a, _b, _c, _d, _e;
|
|
3014
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3015
|
+
const state = state$.value;
|
|
2813
3016
|
const bcName = action.payload.bcName;
|
|
2814
3017
|
const result = [
|
|
2815
3018
|
of36(changeDataItem({
|
|
2816
3019
|
bcName,
|
|
3020
|
+
bcUrl: buildBcUrl(bcName, true, state),
|
|
2817
3021
|
cursor: action.payload.dataItem.id,
|
|
2818
3022
|
dataItem: action.payload.dataItem
|
|
2819
3023
|
}))
|
|
2820
3024
|
];
|
|
2821
|
-
const state = state$.value;
|
|
2822
3025
|
const selected = action.payload.dataItem._associate;
|
|
2823
3026
|
const depth = action.payload.depth || 1;
|
|
2824
3027
|
const parentDepth = depth - 1;
|
|
2825
3028
|
const widget = state.view.widgets.find((item) => item.name === action.payload.widgetName);
|
|
2826
3029
|
const hierarchyTraverse = (_a = widget.options) == null ? void 0 : _a.hierarchyTraverse;
|
|
2827
3030
|
const currentData = depth > 1 ? (_b = state.depthData[depth]) == null ? void 0 : _b[bcName] : state.data[bcName];
|
|
2828
|
-
const parentCursor = parentDepth ? parentDepth > 1 ? (_c = state.screen.bo.bc[bcName].depthBc[parentDepth]) == null ? void 0 :
|
|
2829
|
-
const parentItem = parentCursor ? parentDepth > 1 ? (
|
|
3031
|
+
const parentCursor = parentDepth ? parentDepth > 1 ? (_d = (_c = state.screen.bo.bc[bcName].depthBc) == null ? void 0 : _c[parentDepth]) == null ? void 0 : _d.cursor : state.screen.bo.bc[bcName].cursor : null;
|
|
3032
|
+
const parentItem = parentCursor ? parentDepth > 1 ? (_f = (_e = state.depthData[parentDepth]) == null ? void 0 : _e[bcName]) == null ? void 0 : _f.find((item) => item.id === parentCursor) : state.data[bcName].find((item) => item.id === parentCursor) : null;
|
|
2830
3033
|
if (parentDepth && hierarchyTraverse && selected) {
|
|
2831
3034
|
result.push(of36(changeAssociationSameBc({
|
|
2832
3035
|
bcName,
|
|
@@ -2834,7 +3037,7 @@ var changeAssociationSameBcEpic = (action$, state$) => action$.pipe(filter50(cha
|
|
|
2834
3037
|
widgetName: action.payload.widgetName,
|
|
2835
3038
|
dataItem: __spreadProps(__spreadValues({}, parentItem), {
|
|
2836
3039
|
_associate: true,
|
|
2837
|
-
_value: parentItem[action.payload.assocValueKey]
|
|
3040
|
+
_value: parentItem == null ? void 0 : parentItem[action.payload.assocValueKey]
|
|
2838
3041
|
}),
|
|
2839
3042
|
assocValueKey: action.payload.assocValueKey
|
|
2840
3043
|
})));
|
|
@@ -2851,18 +3054,19 @@ var changeAssociationSameBcEpic = (action$, state$) => action$.pipe(filter50(cha
|
|
|
2851
3054
|
})));
|
|
2852
3055
|
}
|
|
2853
3056
|
}
|
|
2854
|
-
return
|
|
3057
|
+
return concat28(...result);
|
|
2855
3058
|
}));
|
|
2856
3059
|
// src/epics/data/inlinePickListFetchDataEpic.ts
|
|
2857
|
-
import { catchError as
|
|
3060
|
+
import { catchError as catchError16, filter as filter51, mergeMap as mergeMap36, of as of37, race as race4 } from "rxjs";
|
|
2858
3061
|
var inlinePickListFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter51(inlinePickListFetchDataRequest.match), mergeMap36((action) => {
|
|
2859
3062
|
const { bcName, searchSpec, searchString } = action.payload;
|
|
2860
|
-
const
|
|
3063
|
+
const state = state$.value;
|
|
3064
|
+
const bcUrl = buildBcUrl(bcName, false, state);
|
|
2861
3065
|
const canceler = api.createCanceler();
|
|
2862
3066
|
const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }));
|
|
2863
3067
|
const normalFlow = api.fetchBcData(state$.value.screen.screenName, bcUrl, { [searchSpec + ".contains"]: searchString }, canceler.cancelToken).pipe(mergeMap36((data) => {
|
|
2864
3068
|
return of37(bcFetchDataSuccess({ bcName, data: data.data, bcUrl }));
|
|
2865
|
-
}),
|
|
3069
|
+
}), catchError16((error) => {
|
|
2866
3070
|
console.error(error);
|
|
2867
3071
|
return of37(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl }));
|
|
2868
3072
|
}));
|
|
@@ -2871,13 +3075,14 @@ var inlinePickListFetchDataEpic = (action$, state$, { api }) => action$.pipe(fil
|
|
|
2871
3075
|
// src/epics/data/saveAssociationsPassiveEpic.ts
|
|
2872
3076
|
import { filter as filter52, of as of38, switchMap as switchMap13 } from "rxjs";
|
|
2873
3077
|
var saveAssociationsPassiveEpic = (action$, state$) => action$.pipe(filter52(saveAssociations.match), filter52(() => {
|
|
2874
|
-
return !state$.value.view.popupData.active;
|
|
2875
|
-
}), switchMap13((action) => {
|
|
2876
3078
|
var _a;
|
|
3079
|
+
return !((_a = state$.value.view.popupData) == null ? void 0 : _a.active);
|
|
3080
|
+
}), switchMap13((action) => {
|
|
3081
|
+
var _a, _b;
|
|
2877
3082
|
const state = state$.value;
|
|
2878
|
-
const { calleeBCName = action.payload.calleeBcName, associateFieldKey = action.payload.associateFieldKey } = state.view.popupData;
|
|
3083
|
+
const { calleeBCName = action.payload.calleeBcName, associateFieldKey = action.payload.associateFieldKey } = (_a = state.view.popupData) != null ? _a : {};
|
|
2879
3084
|
const cursor = state.screen.bo.bc[calleeBCName].cursor;
|
|
2880
|
-
const recordPrevData = (
|
|
3085
|
+
const recordPrevData = (_b = state.data[calleeBCName].find((dataStateRecord) => dataStateRecord.id === cursor)[associateFieldKey]) != null ? _b : [];
|
|
2881
3086
|
const newValues = [];
|
|
2882
3087
|
action.payload.bcNames.forEach((pendingBc) => {
|
|
2883
3088
|
const pendingChanges = state.view.pendingDataChanges[pendingBc] || {};
|
|
@@ -2902,6 +3107,7 @@ var saveAssociationsPassiveEpic = (action$, state$) => action$.pipe(filter52(sav
|
|
|
2902
3107
|
}).concat(...addedItems);
|
|
2903
3108
|
return of38(changeDataItem({
|
|
2904
3109
|
bcName: calleeBCName,
|
|
3110
|
+
bcUrl: buildBcUrl(calleeBCName, true, state),
|
|
2905
3111
|
cursor,
|
|
2906
3112
|
dataItem: {
|
|
2907
3113
|
[associateFieldKey]: result
|
|
@@ -2938,7 +3144,7 @@ var changeChildrenAssociationsSameBcEpic = (action$, state$) => action$.pipe(fil
|
|
|
2938
3144
|
}));
|
|
2939
3145
|
}));
|
|
2940
3146
|
// src/epics/data/changeDescendantsAssociationsFullEpic.ts
|
|
2941
|
-
import { concat as
|
|
3147
|
+
import { concat as concat29, filter as filter55, mergeMap as mergeMap39, of as of41 } from "rxjs";
|
|
2942
3148
|
var changeDescendantsAssociationsFullEpic = (action$, state$) => action$.pipe(filter55(changeDescendantsAssociationsFull.match), mergeMap39((action) => {
|
|
2943
3149
|
const state = state$.value;
|
|
2944
3150
|
const depth = action.payload.depth;
|
|
@@ -2962,7 +3168,7 @@ var changeDescendantsAssociationsFullEpic = (action$, state$) => action$.pipe(fi
|
|
|
2962
3168
|
}))));
|
|
2963
3169
|
}
|
|
2964
3170
|
});
|
|
2965
|
-
return
|
|
3171
|
+
return concat29(...result);
|
|
2966
3172
|
}));
|
|
2967
3173
|
// src/api/ObservableApiWrapper.ts
|
|
2968
3174
|
import axios2 from "axios";
|
|
@@ -2990,7 +3196,7 @@ var ObservableApiWrapper = class {
|
|
|
2990
3196
|
}));
|
|
2991
3197
|
this.instance = instance;
|
|
2992
3198
|
}
|
|
2993
|
-
get(path, config
|
|
3199
|
+
get(path, config, callContext) {
|
|
2994
3200
|
return from(this.instance.get(path, config)).pipe(takeWhile(redirectOccurred), map10((response) => response.data));
|
|
2995
3201
|
}
|
|
2996
3202
|
put(path, data, callContext) {
|
|
@@ -3008,7 +3214,7 @@ import axios3 from "axios";
|
|
|
3008
3214
|
import { EMPTY as EMPTY26, expand, map as map11, reduce } from "rxjs";
|
|
3009
3215
|
var Api = class {
|
|
3010
3216
|
constructor(instance) {
|
|
3011
|
-
__publicField(this, "api$"
|
|
3217
|
+
__publicField(this, "api$");
|
|
3012
3218
|
this.api$ = new ObservableApiWrapper(instance);
|
|
3013
3219
|
}
|
|
3014
3220
|
routerRequest(path, params) {
|
|
@@ -3033,23 +3239,26 @@ var Api = class {
|
|
|
3033
3239
|
}
|
|
3034
3240
|
fetchRowMeta(screenName, bcUrl, params, cancelToken) {
|
|
3035
3241
|
const url = applyParams(buildUrl `row-meta/${screenName}/` + bcUrl, params);
|
|
3036
|
-
return this.api$.get(url, { cancelToken }).pipe(map11((response) =>
|
|
3242
|
+
return this.api$.get(url, { cancelToken }).pipe(map11((response) => {
|
|
3243
|
+
var _a;
|
|
3244
|
+
return (_a = response.data) == null ? void 0 : _a.row;
|
|
3245
|
+
}));
|
|
3037
3246
|
}
|
|
3038
3247
|
newBcData(screenName, bcUrl, context, params) {
|
|
3039
3248
|
const url = applyParams(buildUrl `row-meta-new/${screenName}/` + bcUrl, params);
|
|
3040
|
-
return this.api$.get(url,
|
|
3249
|
+
return this.api$.get(url, void 0, context).pipe(map11((response) => response.data));
|
|
3041
3250
|
}
|
|
3042
3251
|
saveBcData(screenName, bcUrl, data, context, params) {
|
|
3043
3252
|
const url = applyParams(buildUrl `data/${screenName}/` + bcUrl, params);
|
|
3044
3253
|
return this.api$.put(url, { data }, context).pipe(map11((response) => response.data));
|
|
3045
3254
|
}
|
|
3046
|
-
deleteBcData(screenName, bcUrl, context, params) {
|
|
3255
|
+
deleteBcData(screenName, bcUrl = "", context, params) {
|
|
3047
3256
|
const url = applyParams(buildUrl `data/${screenName}/` + bcUrl, params);
|
|
3048
3257
|
return this.api$.delete(url, context).pipe(map11((response) => response.data));
|
|
3049
3258
|
}
|
|
3050
3259
|
customAction(screenName, bcUrl, data, context, params) {
|
|
3051
3260
|
const url = applyParams(buildUrl `custom-action/${screenName}/` + bcUrl, params);
|
|
3052
|
-
return this.api$.post(url, { data: data || {} },
|
|
3261
|
+
return this.api$.post(url, { data: data || {} }, void 0, context).pipe(map11((response) => response.data));
|
|
3053
3262
|
}
|
|
3054
3263
|
associate(screenName, bcUrl, data, params) {
|
|
3055
3264
|
const processedData = Array.isArray(data) ? data.map((item) => ({
|
|
@@ -3061,9 +3270,23 @@ var Api = class {
|
|
|
3061
3270
|
return this.api$.post(url, processedData).pipe(map11((response) => response.data));
|
|
3062
3271
|
}
|
|
3063
3272
|
getRmByForceActive(screenName, bcUrl, data, params) {
|
|
3064
|
-
const url = applyParams(buildUrl `row-meta/${screenName}/` + bcUrl, params);
|
|
3273
|
+
const url = applyParams(buildUrl `row-meta/${screenName}/` + (bcUrl != null ? bcUrl : ""), params);
|
|
3065
3274
|
return this.api$.post(url, { data }).pipe(map11((response) => response.data.row));
|
|
3066
3275
|
}
|
|
3276
|
+
/**
|
|
3277
|
+
* Get Cxbox API file upload endpoint based on baseURL of axios instance
|
|
3278
|
+
*
|
|
3279
|
+
* Handles empty baseURL and trailing slash
|
|
3280
|
+
*
|
|
3281
|
+
* @returns File upload endpoint
|
|
3282
|
+
*/
|
|
3283
|
+
get fileUploadEndpoint() {
|
|
3284
|
+
const instance = this.api$.instance;
|
|
3285
|
+
if (!instance.defaults.baseURL) {
|
|
3286
|
+
return "/file";
|
|
3287
|
+
}
|
|
3288
|
+
return instance.defaults.baseURL.endsWith("/") ? `${instance.defaults.baseURL}file` : `${instance.defaults.baseURL}/file`;
|
|
3289
|
+
}
|
|
3067
3290
|
refreshMeta() {
|
|
3068
3291
|
return this.api$.get(buildUrl `bc-registry/refresh-meta`);
|
|
3069
3292
|
}
|
|
@@ -3081,5 +3304,239 @@ var Api = class {
|
|
|
3081
3304
|
};
|
|
3082
3305
|
}
|
|
3083
3306
|
};
|
|
3084
|
-
|
|
3307
|
+
// src/utils/autosave.ts
|
|
3308
|
+
function autosaveRoutine(action, store, next) {
|
|
3309
|
+
var _a, _b, _c;
|
|
3310
|
+
const state = store.getState();
|
|
3311
|
+
const dispatch = store.dispatch;
|
|
3312
|
+
const pendingDataChanges = state.view.pendingDataChanges;
|
|
3313
|
+
const bcList = Object.keys(pendingDataChanges);
|
|
3314
|
+
const baseBcNameIndex = ((_a = action.payload) == null ? void 0 : _a.bcName) && bcHasPendingAutosaveChanges(state, action.payload.bcName, (_b = state.screen.bo.bc[action.payload.bcName]) == null ? void 0 : _b.cursor) ? bcList.findIndex((bcName) => {
|
|
3315
|
+
var _a2;
|
|
3316
|
+
return bcName === ((_a2 = action.payload) == null ? void 0 : _a2.bcName);
|
|
3317
|
+
}) : bcList.findIndex((bcName) => {
|
|
3318
|
+
var _a2;
|
|
3319
|
+
return bcHasPendingAutosaveChanges(state, bcName, (_a2 = state.screen.bo.bc[bcName]) == null ? void 0 : _a2.cursor);
|
|
3320
|
+
});
|
|
3321
|
+
const baseBcName = bcList[baseBcNameIndex];
|
|
3322
|
+
if (baseBcNameIndex > -1) {
|
|
3323
|
+
bcList.splice(baseBcNameIndex, 1);
|
|
3324
|
+
}
|
|
3325
|
+
if (baseBcName) {
|
|
3326
|
+
bcList.forEach((bcName) => {
|
|
3327
|
+
var _a2, _b2;
|
|
3328
|
+
const widget = (_a2 = state.view.widgets) == null ? void 0 : _a2.find((v) => v.bcName === bcName);
|
|
3329
|
+
const cursor = (_b2 = state.screen.bo.bc[bcName]) == null ? void 0 : _b2.cursor;
|
|
3330
|
+
if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {
|
|
3331
|
+
dispatch(sendOperation({
|
|
3332
|
+
bcName,
|
|
3333
|
+
operationType: OperationTypeCrud.save,
|
|
3334
|
+
widgetName: widget == null ? void 0 : widget.name
|
|
3335
|
+
}));
|
|
3336
|
+
}
|
|
3337
|
+
});
|
|
3338
|
+
const baseWidget = (_c = state.view.widgets) == null ? void 0 : _c.find((v) => v.bcName === baseBcName);
|
|
3339
|
+
return next(sendOperation({
|
|
3340
|
+
bcName: baseBcName,
|
|
3341
|
+
operationType: OperationTypeCrud.save,
|
|
3342
|
+
widgetName: baseWidget == null ? void 0 : baseWidget.name,
|
|
3343
|
+
onSuccessAction: action
|
|
3344
|
+
}));
|
|
3345
|
+
}
|
|
3346
|
+
return next(action);
|
|
3347
|
+
}
|
|
3348
|
+
function bcHasPendingAutosaveChanges(store, bcName, cursor) {
|
|
3349
|
+
var _a;
|
|
3350
|
+
const pendingChanges = store.view.pendingDataChanges;
|
|
3351
|
+
const cursorChanges = (_a = pendingChanges[bcName]) == null ? void 0 : _a[cursor];
|
|
3352
|
+
const result = cursorChanges && !Object.keys(cursorChanges).includes("_associate") && Object.values(cursorChanges).length > 0;
|
|
3353
|
+
return result;
|
|
3354
|
+
}
|
|
3355
|
+
function checkUnsavedChangesOfBc(store, bcName) {
|
|
3356
|
+
var _a, _b;
|
|
3357
|
+
const pendingCursors = Object.keys((_b = (_a = store.view.pendingDataChanges) == null ? void 0 : _a[bcName]) != null ? _b : {});
|
|
3358
|
+
return pendingCursors.some((cursor) => bcHasPendingAutosaveChanges(store, bcName, cursor));
|
|
3359
|
+
}
|
|
3360
|
+
// src/middlewares/autosaveMiddleware.ts
|
|
3361
|
+
var saveFormMiddleware = ({ getState, dispatch }) => (next) => (action) => {
|
|
3362
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3363
|
+
const state = getState();
|
|
3364
|
+
const isSendOperation = sendOperation.match(action);
|
|
3365
|
+
const isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType);
|
|
3366
|
+
const isSelectTableCellInit = selectTableCellInit.match(action);
|
|
3367
|
+
const isSaveAction = isSendOperation && action.payload.operationType === OperationTypeCrud.save;
|
|
3368
|
+
const isNotSaveAction = !isSaveAction;
|
|
3369
|
+
const actionBcName = isSendOperation && action.payload.bcName;
|
|
3370
|
+
const hasAnotherUnsavedBc = Object.keys(state.view.pendingDataChanges).filter((key) => key !== actionBcName).filter((key) => checkUnsavedChangesOfBc(state, key)).length > 0;
|
|
3371
|
+
const isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc;
|
|
3372
|
+
const selectedCell = state.view.selectedCell;
|
|
3373
|
+
const isSelectTableCellInitOnAnotherRowOrWidget = selectedCell && isSelectTableCellInit && (selectedCell.widgetName !== action.payload.widgetName || selectedCell.rowId !== action.payload.rowId);
|
|
3374
|
+
const defaultSaveWidget = (_a = state.view.widgets) == null ? void 0 : _a.find((item) => {
|
|
3375
|
+
var _a2, _b2;
|
|
3376
|
+
return (_b2 = (_a2 = item == null ? void 0 : item.options) == null ? void 0 : _a2.actionGroups) == null ? void 0 : _b2.defaultSave;
|
|
3377
|
+
});
|
|
3378
|
+
const defaultCursor = (_c = (_b = state.screen.bo.bc) == null ? void 0 : _b[defaultSaveWidget == null ? void 0 : defaultSaveWidget.bcName]) == null ? void 0 : _c.cursor;
|
|
3379
|
+
const pendingData = (_f = (_e = (_d = state.view) == null ? void 0 : _d.pendingDataChanges) == null ? void 0 : _e[defaultSaveWidget == null ? void 0 : defaultSaveWidget.bcName]) == null ? void 0 : _f[defaultCursor];
|
|
3380
|
+
const isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0;
|
|
3381
|
+
if (isChangeLocation) {
|
|
3382
|
+
return next(sendOperation({
|
|
3383
|
+
bcName: defaultSaveWidget.bcName,
|
|
3384
|
+
operationType: ((_g = defaultSaveWidget.options) == null ? void 0 : _g.actionGroups).defaultSave,
|
|
3385
|
+
widgetName: defaultSaveWidget.name,
|
|
3386
|
+
onSuccessAction: action
|
|
3387
|
+
}));
|
|
3388
|
+
}
|
|
3389
|
+
const isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableCellInitOnAnotherRowOrWidget);
|
|
3390
|
+
if (isNeedSaveCondition) {
|
|
3391
|
+
return autosaveRoutine(action, { getState, dispatch }, next);
|
|
3392
|
+
}
|
|
3393
|
+
return next(action);
|
|
3394
|
+
};
|
|
3395
|
+
// src/middlewares/requiredFieldsMiddleware.ts
|
|
3396
|
+
var requiredFields = ({ getState, dispatch }) => (next) => (action) => {
|
|
3397
|
+
var _a, _b, _c, _d;
|
|
3398
|
+
const state = getState();
|
|
3399
|
+
if (sendOperation.match(action)) {
|
|
3400
|
+
const { bcName, operationType, widgetName } = action.payload;
|
|
3401
|
+
const cursor = (_a = state.screen.bo.bc[bcName]) == null ? void 0 : _a.cursor;
|
|
3402
|
+
if (cursor) {
|
|
3403
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
3404
|
+
const record = (_b = state.data[bcName]) == null ? void 0 : _b.find((item) => item.id === cursor);
|
|
3405
|
+
const rowMeta = bcUrl && ((_c = state.view.rowMeta[bcName]) == null ? void 0 : _c[bcUrl]);
|
|
3406
|
+
const pendingValues = (_d = state.view.pendingDataChanges[bcName]) == null ? void 0 : _d[cursor];
|
|
3407
|
+
const widget = state.view.widgets.find((item) => item.name === widgetName);
|
|
3408
|
+
if (operationRequiresAutosave(operationType, rowMeta == null ? void 0 : rowMeta.actions)) {
|
|
3409
|
+
const fieldsToCheck = {};
|
|
3410
|
+
state.view.widgets.filter((item) => item.bcName === (widget == null ? void 0 : widget.bcName)).forEach((item) => {
|
|
3411
|
+
const itemFieldsCalc = item.fields;
|
|
3412
|
+
if (item.fields) {
|
|
3413
|
+
item.fields.forEach((block) => {
|
|
3414
|
+
if (isWidgetFieldBlock(block)) {
|
|
3415
|
+
block.fields.forEach((field) => itemFieldsCalc.push(field));
|
|
3416
|
+
}
|
|
3417
|
+
});
|
|
3418
|
+
}
|
|
3419
|
+
itemFieldsCalc.forEach((widgetField) => {
|
|
3420
|
+
var _a2;
|
|
3421
|
+
const matchingRowMeta = (_a2 = rowMeta == null ? void 0 : rowMeta.fields) == null ? void 0 : _a2.find((rowMetaField) => rowMetaField.key === widgetField.key);
|
|
3422
|
+
if (!fieldsToCheck[widgetField.key] && matchingRowMeta && !matchingRowMeta.hidden) {
|
|
3423
|
+
fieldsToCheck[widgetField.key] = matchingRowMeta;
|
|
3424
|
+
}
|
|
3425
|
+
});
|
|
3426
|
+
});
|
|
3427
|
+
const dataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck));
|
|
3428
|
+
if (dataItem && TableLikeWidgetTypes.includes(widget == null ? void 0 : widget.type)) {
|
|
3429
|
+
dispatch(selectTableCellInit({ widgetName, rowId: cursor, fieldKey: Object.keys(dataItem)[0] }));
|
|
3430
|
+
}
|
|
3431
|
+
return dataItem ? next(changeDataItem({ bcName, bcUrl: buildBcUrl(bcName, true, state), cursor, dataItem })) : next(action);
|
|
3432
|
+
}
|
|
3433
|
+
if (hasPendingValidationFails(state, bcName)) {
|
|
3434
|
+
return addNotification({
|
|
3435
|
+
key: "requiredFieldsMissing",
|
|
3436
|
+
type: "buttonWarningNotification",
|
|
3437
|
+
message: "Required fields are missing",
|
|
3438
|
+
duration: 0,
|
|
3439
|
+
options: {
|
|
3440
|
+
buttonWarningNotificationOptions: {
|
|
3441
|
+
buttonText: "Cancel changes",
|
|
3442
|
+
actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
});
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
return next(action);
|
|
3450
|
+
};
|
|
3451
|
+
function operationRequiresAutosave(operationType, actions2) {
|
|
3452
|
+
let result = false;
|
|
3453
|
+
if (!actions2) {
|
|
3454
|
+
console.error('rowMeta is missing in the middle of "sendOperation" action');
|
|
3455
|
+
return result;
|
|
3456
|
+
}
|
|
3457
|
+
result = flattenOperations(actions2).some((action) => action.type === operationType && action.autoSaveBefore);
|
|
3458
|
+
return result;
|
|
3459
|
+
}
|
|
3460
|
+
function getRequiredFieldsMissing(record, pendingChanges, fieldsMeta) {
|
|
3461
|
+
const result = {};
|
|
3462
|
+
fieldsMeta.forEach((field) => {
|
|
3463
|
+
const value = record == null ? void 0 : record[field.key];
|
|
3464
|
+
const pendingValue = pendingChanges == null ? void 0 : pendingChanges[field.key];
|
|
3465
|
+
const effectiveValue = pendingValue !== void 0 ? pendingValue : value;
|
|
3466
|
+
let falsyValue = false;
|
|
3467
|
+
if (effectiveValue === null || effectiveValue === void 0 || effectiveValue === "") {
|
|
3468
|
+
falsyValue = true;
|
|
3469
|
+
}
|
|
3470
|
+
else if (Array.isArray(effectiveValue) && !effectiveValue.length) {
|
|
3471
|
+
falsyValue = true;
|
|
3472
|
+
}
|
|
3473
|
+
else if (effectiveValue && typeof effectiveValue === "object" && !Object.keys(effectiveValue).length) {
|
|
3474
|
+
falsyValue = true;
|
|
3475
|
+
}
|
|
3476
|
+
if (field.required && falsyValue) {
|
|
3477
|
+
result[field.key] = Array.isArray(effectiveValue) ? [] : null;
|
|
3478
|
+
}
|
|
3479
|
+
});
|
|
3480
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
3481
|
+
}
|
|
3482
|
+
function hasPendingValidationFails(store, bcName) {
|
|
3483
|
+
var _a;
|
|
3484
|
+
if (store.view.pendingValidationFailsFormat !== "target" /* target */ && store.view.pendingValidationFails && Object.keys(store.view.pendingValidationFails).length) {
|
|
3485
|
+
return true;
|
|
3486
|
+
}
|
|
3487
|
+
let checkResult = false;
|
|
3488
|
+
const bcPendingValidations = (_a = store.view.pendingValidationFails) == null ? void 0 : _a[bcName];
|
|
3489
|
+
const cursorsList = bcPendingValidations && Object.keys(bcPendingValidations);
|
|
3490
|
+
if (!cursorsList) {
|
|
3491
|
+
return false;
|
|
3492
|
+
}
|
|
3493
|
+
let i = 0;
|
|
3494
|
+
for (; i < cursorsList.length; i++) {
|
|
3495
|
+
if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {
|
|
3496
|
+
checkResult = true;
|
|
3497
|
+
break;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
return checkResult;
|
|
3501
|
+
}
|
|
3502
|
+
// src/middlewares/preInvokeMiddleware.ts
|
|
3503
|
+
var preInvokeAction = ({ getState }) => (next) => (action) => {
|
|
3504
|
+
var _a, _b, _c;
|
|
3505
|
+
if (sendOperation.match(action)) {
|
|
3506
|
+
const state = getState();
|
|
3507
|
+
const { operationType, widgetName, confirm } = action.payload;
|
|
3508
|
+
const bcName = (_a = state.view.widgets.find((widgetItem) => widgetItem.name === widgetName)) == null ? void 0 : _a.bcName;
|
|
3509
|
+
const bcUrl = buildBcUrl(bcName, true, state);
|
|
3510
|
+
const rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) == null ? void 0 : _b[bcUrl]);
|
|
3511
|
+
const actions2 = rowMeta && flattenOperations(rowMeta.actions);
|
|
3512
|
+
const preInvoke = (_c = actions2 == null ? void 0 : actions2.find((item) => item.type === operationType)) == null ? void 0 : _c.preInvoke;
|
|
3513
|
+
return preInvoke && !confirm ? next(processPreInvoke({
|
|
3514
|
+
bcName,
|
|
3515
|
+
operationType,
|
|
3516
|
+
widgetName,
|
|
3517
|
+
preInvoke
|
|
3518
|
+
})) : next(action);
|
|
3519
|
+
}
|
|
3520
|
+
return next(action);
|
|
3521
|
+
};
|
|
3522
|
+
// src/middlewares/popupMiddleware.ts
|
|
3523
|
+
var popupMiddleware = ({ getState }) => (next) => (action) => {
|
|
3524
|
+
var _a, _b, _c;
|
|
3525
|
+
if (showViewPopup.match(action)) {
|
|
3526
|
+
const state = getState();
|
|
3527
|
+
const bcName = action.payload.bcName;
|
|
3528
|
+
const widgetValueKey = (_b = (_a = state.view.widgets.find((item) => item.bcName === bcName)) == null ? void 0 : _a.options) == null ? void 0 : _b.displayedValueKey;
|
|
3529
|
+
const assocValueKey = (_c = action.payload.assocValueKey) != null ? _c : widgetValueKey;
|
|
3530
|
+
return widgetValueKey ? next(showViewPopup(__spreadProps(__spreadValues({}, action.payload), { assocValueKey }))) : next(action);
|
|
3531
|
+
}
|
|
3532
|
+
return next(action);
|
|
3533
|
+
};
|
|
3534
|
+
// src/middlewares/index.ts
|
|
3535
|
+
var middlewares = {
|
|
3536
|
+
autosave: saveFormMiddleware,
|
|
3537
|
+
requiredFields,
|
|
3538
|
+
preInvoke: preInvokeAction,
|
|
3539
|
+
popup: popupMiddleware
|
|
3540
|
+
};
|
|
3541
|
+
export { Api, actions_exports as actions, epics_exports as epics, interfaces_exports as interfaces, middlewares, reducers_exports as reducers, utils_exports as utils };
|
|
3085
3542
|
//# sourceMappingURL=cxbox-ui-core.modern.development.js.map
|