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

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.
@@ -163,7 +163,7 @@ var bcFetchRowMetaSuccess = createAction("bcFetchRowMetaSuccess");
163
163
  var bcFetchRowMetaFail = createAction("bcFetchRowMetaFail");
164
164
  var bcNewData = createAction("bcNewData");
165
165
  var bcNewDataSuccess = createAction("bcNewDataSuccess");
166
- var bcNewDataFail = createAction("bcNewDataSuccess");
166
+ var bcNewDataFail = createAction("bcNewDataFail");
167
167
  var bcDeleteDataFail = createAction("bcDeleteDataFail");
168
168
  var forceActiveChangeFail = createAction("forceActiveChangeFail");
169
169
  var sendOperation = createAction("sendOperation");
@@ -544,9 +544,8 @@ function getTemplate(literals, ...placeholders) {
544
544
  result += literals[literals.length - 1];
545
545
  return result;
546
546
  }
547
- function buildBcUrl(bcName, includeSelf = false, store) {
548
- const storeInstance = store;
549
- const bcMap = storeInstance.screen.bo.bc;
547
+ function buildBcUrl(bcName, includeSelf = false, state) {
548
+ const bcMap = state.screen.bo.bc;
550
549
  const bc = bcMap[bcName];
551
550
  if (!bc) {
552
551
  return null;
@@ -724,7 +723,7 @@ function getSorters(sorters) {
724
723
  }
725
724
  function parseFilters(defaultFilters) {
726
725
  const result = [];
727
- const urlParams = new URL(defaultFilters).searchParams;
726
+ const urlParams = new URL(defaultFilters, window.location.origin).searchParams;
728
727
  urlParams.forEach((param) => {
729
728
  const [fieldName, type] = param.split(".");
730
729
  if (fieldName && type && urlParams.get(param)) {
@@ -754,7 +753,7 @@ function parseSorters(sorters) {
754
753
  return null;
755
754
  }
756
755
  const result = [];
757
- const dictionary = new URL(sorters).searchParams;
756
+ const dictionary = new URL(sorters, window.location.origin).searchParams;
758
757
  Object.entries(dictionary).map(([sort, fieldKey]) => {
759
758
  const [order, direction] = sort.split(".").slice(1);
760
759
  return { fieldName: fieldKey, order: Number.parseInt(order, 10), direction };
@@ -1194,7 +1193,9 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
1194
1193
  state.metaInProgress[action.payload.bcName] = true;
1195
1194
  }
1196
1195
  }).addCase(bcFetchRowMetaSuccess, (state, action) => {
1197
- state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1196
+ if (state.rowMeta[action.payload.bcName]) {
1197
+ state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta;
1198
+ }
1198
1199
  state.metaInProgress[action.payload.bcName] = false;
1199
1200
  }).addCase(bcNewDataSuccess, (state, action) => {
1200
1201
  state.selectedCell = initialViewState.selectedCell;
@@ -1232,7 +1233,7 @@ var createViewReducerBuilderManager = (initialState) => new ReducerBuilderManage
1232
1233
  const prevCursor = prevBc[action.payload.cursor] || {};
1233
1234
  const prevPending = prevCursor || {};
1234
1235
  const nextPending = __spreadValues(__spreadValues({}, prevPending), action.payload.dataItem);
1235
- const bcUrl = buildBcUrl(actionBcName, true);
1236
+ const bcUrl = action.payload.bcUrl;
1236
1237
  const rowMeta = (_a = state.rowMeta[actionBcName]) == null ? void 0 : _a[bcUrl];
1237
1238
  const nextValidationFails = {};
1238
1239
  const isTargetFormatPVF = state.pendingValidationFailsFormat === "target" /* target */;
@@ -1501,7 +1502,7 @@ var sendOperationEpic = (action$, state$, { api }) => action$.pipe(filter(sendOp
1501
1502
  const screenName = state.screen.screenName;
1502
1503
  const { bcName, operationType, widgetName } = action.payload;
1503
1504
  const confirm = ((_a = action.payload.confirmOperation) == null ? void 0 : _a.type) || action.payload.confirm;
1504
- const bcUrl = buildBcUrl(bcName, true);
1505
+ const bcUrl = buildBcUrl(bcName, true, state);
1505
1506
  const bc = state.screen.bo.bc[bcName];
1506
1507
  const rowMeta = bcUrl && ((_b = state.view.rowMeta[bcName]) == null ? void 0 : _b[bcUrl]);
1507
1508
  const fields = rowMeta == null ? void 0 : rowMeta.fields;
@@ -1592,7 +1593,7 @@ var fileUploadConfirmEpic = (action$, state$, { api }) => action$.pipe(filter3(b
1592
1593
  var _a;
1593
1594
  const state = state$.value;
1594
1595
  const bcName = state.view.popupData.bcName;
1595
- const bcUrl = buildBcUrl(bcName, true);
1596
+ const bcUrl = buildBcUrl(bcName, true, state);
1596
1597
  const widgetName = (_a = state.view.widgets.find((item) => item.bcName === bcName)) == null ? void 0 : _a.name;
1597
1598
  const data = {
1598
1599
  bulkIds: action.payload.fileIds
@@ -1660,7 +1661,7 @@ var getRowMetaByForceActiveEpic = (action$, state$, { api }) => action$.pipe(fil
1660
1661
  var _a2;
1661
1662
  return item.name === ((_a2 = state.view.popupData) == null ? void 0 : _a2.widgetName) && [WidgetTypes4.PickListPopup, WidgetTypes4.FlatTreePopup].includes(item.type);
1662
1663
  });
1663
- const bcUrl = buildBcUrl(bcName, true);
1664
+ const bcUrl = buildBcUrl(bcName, true, state);
1664
1665
  const pendingChanges = state.view.pendingDataChanges[bcName][cursor];
1665
1666
  const handledForceActive = ((_a = state.view.handledForceActive[bcName]) == null ? void 0 : _a[cursor]) || {};
1666
1667
  const currentRecordData = (_b = state.data[bcName]) == null ? void 0 : _b.find((record) => record.id === cursor);
@@ -1703,6 +1704,7 @@ var getRowMetaByForceActiveEpic = (action$, state$, { api }) => action$.pipe(fil
1703
1704
  }
1704
1705
  return concat5(of7(removePendingRequest({ requestId })), state.view.url === initUrl ? concat5(of7(changeDataItem({
1705
1706
  bcName,
1707
+ bcUrl: buildBcUrl(bcName, true, state),
1706
1708
  cursor,
1707
1709
  dataItem: { [changedFiledKey]: currentRecordData[changedFiledKey] },
1708
1710
  disableRetry: true
@@ -1799,7 +1801,7 @@ import { catchError as catchError4, concat as concat7, EMPTY as EMPTY8, filter a
1799
1801
  var userDrillDownEpic = (action$, state$, { api }) => action$.pipe(filter15(userDrillDown.match), switchMap6((action) => {
1800
1802
  const state = state$.value;
1801
1803
  const { bcName, fieldKey, cursor } = action.payload;
1802
- const bcUrl = buildBcUrl(bcName, true);
1804
+ const bcUrl = buildBcUrl(bcName, true, state);
1803
1805
  return api.fetchRowMeta(state.screen.screenName, bcUrl).pipe(mergeMap10((rowMeta) => {
1804
1806
  var _a, _b, _c, _d;
1805
1807
  const drillDownField = rowMeta.fields.find((field) => field.key === fieldKey);
@@ -2148,7 +2150,7 @@ import { OperationTypeCrud as OperationTypeCrud8 } from "@cxbox-ui/schema";
2148
2150
  var bcNewDataEpic = (action$, state$, { api }) => action$.pipe(filter35(sendOperation.match), filter35((action) => matchOperationRole(OperationTypeCrud8.create, action.payload, state$.value)), mergeMap20((action) => {
2149
2151
  const state = state$.value;
2150
2152
  const bcName = action.payload.bcName;
2151
- const bcUrl = buildBcUrl(bcName);
2153
+ const bcUrl = buildBcUrl(bcName, false, state);
2152
2154
  const context = { widgetName: action.payload.widgetName };
2153
2155
  const params = { _action: action.payload.operationType };
2154
2156
  return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe(mergeMap20((data) => {
@@ -2160,7 +2162,8 @@ var bcNewDataEpic = (action$, state$, { api }) => action$.pipe(filter35(sendOper
2160
2162
  const postInvoke = data.postActions[0];
2161
2163
  const cursor = dataItem.id;
2162
2164
  return concat13(of22(bcNewDataSuccess({ bcName, dataItem, bcUrl })), of22(bcFetchRowMetaSuccess({ bcName, bcUrl: `${bcUrl}/${cursor}`, rowMeta, cursor })), of22(changeDataItem({
2163
- bcName: action.payload.bcName,
2165
+ bcName,
2166
+ bcUrl: buildBcUrl(bcName, true, state),
2164
2167
  cursor,
2165
2168
  dataItem: {
2166
2169
  id: cursor
@@ -2194,7 +2197,7 @@ var bcLoadMoreEpic = (action$, state$, { api }) => action$.pipe(filter37(bcLoadM
2194
2197
  const { cursor, page } = bc;
2195
2198
  const limit = ((_a = state.view.widgets.find((i) => i.bcName === bcName)) == null ? void 0 : _a.limit) || bc.limit;
2196
2199
  const limitBySelfCursor = (_b = state.router.bcPath) == null ? void 0 : _b.includes(`${bcName}/${cursor}`);
2197
- const bcUrl = buildBcUrl(bcName, limitBySelfCursor);
2200
+ const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
2198
2201
  const filters = state.screen.filters[bcName] || [];
2199
2202
  const sorters = state.screen.sorters[bcName];
2200
2203
  const fetchParams = __spreadValues(__spreadValues({
@@ -2225,7 +2228,7 @@ var bcSaveDataEpic = (action$, state$, { api }) => action$.pipe(filter38(sendOpe
2225
2228
  var _a, _b, _c;
2226
2229
  const state = state$.value;
2227
2230
  const bcName = action.payload.bcName;
2228
- const bcUrl = buildBcUrl(bcName, true);
2231
+ const bcUrl = buildBcUrl(bcName, true, state);
2229
2232
  const widgetName = action.payload.widgetName;
2230
2233
  const cursor = state.screen.bo.bc[bcName].cursor;
2231
2234
  const dataItem = state.data[bcName].find((item) => item.id === cursor);
@@ -2377,7 +2380,7 @@ var bcFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter40(isAnyO
2377
2380
  return item.bcName === widget.bcName && item.type === WidgetTypes5.AssocListPopup && ((_a2 = item.options) == null ? void 0 : _a2.hierarchyFull);
2378
2381
  });
2379
2382
  const limitBySelfCursor = (_c = state.router.bcPath) == null ? void 0 : _c.includes(`${bcName}/${cursor}`);
2380
- const bcUrl = buildBcUrl(bcName, limitBySelfCursor);
2383
+ const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state);
2381
2384
  const fetchParams = __spreadValues(__spreadValues({
2382
2385
  _page: page,
2383
2386
  _limit: limit
@@ -2458,7 +2461,7 @@ var bcDeleteDataEpic = (action$, store$, { api }) => action$.pipe(filter41(sendO
2458
2461
  const state = store$.value;
2459
2462
  const bcName = action.payload.bcName;
2460
2463
  const cursor = state.screen.bo.bc[bcName].cursor;
2461
- const bcUrl = buildBcUrl(bcName, true);
2464
+ const bcUrl = buildBcUrl(bcName, true, state);
2462
2465
  const context = { widgetName: action.payload.widgetName };
2463
2466
  const isTargetFormatPVF = state.view.pendingValidationFailsFormat === "target" /* target */;
2464
2467
  return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe(mergeMap26((data) => {
@@ -2492,9 +2495,11 @@ var changeAssociationEpic = (action$, state$) => action$.pipe(filter43(changeAss
2492
2495
  var _a, _b, _c, _d, _e;
2493
2496
  const state = state$.value;
2494
2497
  const selected = action.payload.dataItem._associate;
2498
+ const bcName = action.payload.bcName;
2495
2499
  const result = [
2496
2500
  of29(changeDataItem({
2497
- bcName: action.payload.bcName,
2501
+ bcName,
2502
+ bcUrl: buildBcUrl(bcName, true, state),
2498
2503
  cursor: action.payload.dataItem.id,
2499
2504
  dataItem: action.payload.dataItem
2500
2505
  }))
@@ -2567,7 +2572,7 @@ var bcCancelCreateDataEpic = (action$, state$, { api }) => action$.pipe(filter44
2567
2572
  const state = state$.value;
2568
2573
  const screenName = state.screen.screenName;
2569
2574
  const bcName = action.payload.bcName;
2570
- const bcUrl = buildBcUrl(bcName, true);
2575
+ const bcUrl = buildBcUrl(bcName, true, state);
2571
2576
  const bc = state.screen.bo.bc[bcName];
2572
2577
  const cursor = bc == null ? void 0 : bc.cursor;
2573
2578
  const context = { widgetName: action.payload.widgetName };
@@ -2645,11 +2650,16 @@ var removeMultivalueTagEpic = (action$, state$) => action$.pipe(filter46(removeM
2645
2650
  if ((_e = widget.options) == null ? void 0 : _e.hierarchyFull) {
2646
2651
  return of32(changeDataItem({
2647
2652
  bcName,
2653
+ bcUrl: buildBcUrl(bcName, true, state),
2648
2654
  cursor,
2649
2655
  dataItem: { [associateFieldKey]: action.payload.dataItem.filter((item) => !removedNodes.includes(item.id)) }
2650
2656
  }));
2651
2657
  }
2652
2658
  if ((_f = widget.options) == null ? void 0 : _f.hierarchy) {
2659
+ const hierarchyBcName = (_j = (_i = (_h = (_g = widget.options) == null ? void 0 : _g.hierarchy) == null ? void 0 : _h.find((hierarchyData) => {
2660
+ var _a2;
2661
+ return (_a2 = state.view.pendingDataChanges[hierarchyData.bcName]) == null ? void 0 : _a2[action.payload.removedItem.id];
2662
+ })) == null ? void 0 : _i.bcName) != null ? _j : bcName;
2653
2663
  return concat21(of32(changeDataItem({
2654
2664
  /**
2655
2665
  * This is incorrect and will break if different BC has records with
@@ -2657,24 +2667,25 @@ var removeMultivalueTagEpic = (action$, state$) => action$.pipe(filter46(removeM
2657
2667
  *
2658
2668
  * TODO: Record `level` should be mapped to hierarchyData index instead
2659
2669
  */
2660
- bcName: (_j = (_i = (_h = (_g = widget.options) == null ? void 0 : _g.hierarchy) == null ? void 0 : _h.find((hierarchyData) => {
2661
- var _a2;
2662
- return (_a2 = state.view.pendingDataChanges[hierarchyData.bcName]) == null ? void 0 : _a2[action.payload.removedItem.id];
2663
- })) == null ? void 0 : _i.bcName) != null ? _j : bcName,
2670
+ bcName: hierarchyBcName,
2671
+ bcUrl: buildBcUrl(hierarchyBcName, true, state),
2664
2672
  cursor: action.payload.removedItem.id,
2665
2673
  dataItem: __spreadProps(__spreadValues({}, action.payload.removedItem), { _associate: false })
2666
2674
  })), of32(changeDataItem({
2667
2675
  bcName,
2676
+ bcUrl: buildBcUrl(bcName, true, state),
2668
2677
  cursor,
2669
2678
  dataItem: { [associateFieldKey]: action.payload.dataItem }
2670
2679
  })));
2671
2680
  }
2672
2681
  return concat21(of32(changeDataItem({
2673
2682
  bcName: popupBcName,
2683
+ bcUrl: buildBcUrl(popupBcName, true, state),
2674
2684
  cursor: action.payload.removedItem.id,
2675
2685
  dataItem: __spreadProps(__spreadValues({}, action.payload.removedItem), { _associate: false })
2676
2686
  })), of32(changeDataItem({
2677
2687
  bcName,
2688
+ bcUrl: buildBcUrl(bcName, true, state),
2678
2689
  cursor,
2679
2690
  dataItem: { [associateFieldKey]: action.payload.dataItem }
2680
2691
  })));
@@ -2686,7 +2697,7 @@ var bcFetchRowMetaRequestEpic = (action$, state$, { api }) => action$.pipe(filte
2686
2697
  const screenName = state.screen.screenName;
2687
2698
  const bcName = action.payload.bcName;
2688
2699
  const cursor = state.screen.bo.bc[bcName].cursor;
2689
- const bcUrl = buildBcUrl(bcName, true);
2700
+ const bcUrl = buildBcUrl(bcName, true, state);
2690
2701
  const canceler = api.createCanceler();
2691
2702
  const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName }));
2692
2703
  const cancelByParentBc = cancelRequestEpic(action$, [bcSelectRecord], canceler.cancel, bcFetchRowMetaFail({ bcName }), (filteredAction) => {
@@ -2753,6 +2764,7 @@ var changeAssociationFullEpic = (action$, state$) => action$.pipe(filter48(chang
2753
2764
  }
2754
2765
  result.push(of34(changeDataItem({
2755
2766
  bcName: action.payload.bcName,
2767
+ bcUrl: buildBcUrl(action.payload.bcName, true, state),
2756
2768
  cursor: action.payload.dataItem.id,
2757
2769
  dataItem: action.payload.dataItem
2758
2770
  })));
@@ -2796,7 +2808,7 @@ var saveAssociationsActiveEpic = (action$, state$, { api }) => action$.pipe(filt
2796
2808
  const calleeBCName = state.view.popupData.calleeBCName;
2797
2809
  const calleeWidgetName = state.view.popupData.calleeWidgetName;
2798
2810
  const bcNames = action.payload.bcNames;
2799
- const bcUrl = buildBcUrl(calleeBCName, true);
2811
+ const bcUrl = buildBcUrl(calleeBCName, true, state);
2800
2812
  const pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {};
2801
2813
  const params = bcNames.length ? { _bcName: bcNames[bcNames.length - 1] } : {};
2802
2814
  return api.associate(state.screen.screenName, bcUrl, Object.values(pendingChanges).filter((i) => i._associate), params).pipe(mergeMap34((response) => {
@@ -2812,15 +2824,16 @@ var saveAssociationsActiveEpic = (action$, state$, { api }) => action$.pipe(filt
2812
2824
  import { concat as concat24, filter as filter50, mergeMap as mergeMap35, of as of36 } from "rxjs";
2813
2825
  var changeAssociationSameBcEpic = (action$, state$) => action$.pipe(filter50(changeAssociationSameBc.match), mergeMap35((action) => {
2814
2826
  var _a, _b, _c, _d, _e;
2827
+ const state = state$.value;
2815
2828
  const bcName = action.payload.bcName;
2816
2829
  const result = [
2817
2830
  of36(changeDataItem({
2818
2831
  bcName,
2832
+ bcUrl: buildBcUrl(bcName, true, state),
2819
2833
  cursor: action.payload.dataItem.id,
2820
2834
  dataItem: action.payload.dataItem
2821
2835
  }))
2822
2836
  ];
2823
- const state = state$.value;
2824
2837
  const selected = action.payload.dataItem._associate;
2825
2838
  const depth = action.payload.depth || 1;
2826
2839
  const parentDepth = depth - 1;
@@ -2859,7 +2872,8 @@ var changeAssociationSameBcEpic = (action$, state$) => action$.pipe(filter50(cha
2859
2872
  import { catchError as catchError15, filter as filter51, mergeMap as mergeMap36, of as of37, race as race4 } from "rxjs";
2860
2873
  var inlinePickListFetchDataEpic = (action$, state$, { api }) => action$.pipe(filter51(inlinePickListFetchDataRequest.match), mergeMap36((action) => {
2861
2874
  const { bcName, searchSpec, searchString } = action.payload;
2862
- const bcUrl = buildBcUrl(bcName, false);
2875
+ const state = state$.value;
2876
+ const bcUrl = buildBcUrl(bcName, false, state);
2863
2877
  const canceler = api.createCanceler();
2864
2878
  const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }));
2865
2879
  const normalFlow = api.fetchBcData(state$.value.screen.screenName, bcUrl, { [searchSpec + ".contains"]: searchString }, canceler.cancelToken).pipe(mergeMap36((data) => {
@@ -2904,6 +2918,7 @@ var saveAssociationsPassiveEpic = (action$, state$) => action$.pipe(filter52(sav
2904
2918
  }).concat(...addedItems);
2905
2919
  return of38(changeDataItem({
2906
2920
  bcName: calleeBCName,
2921
+ bcUrl: buildBcUrl(calleeBCName, true, state),
2907
2922
  cursor,
2908
2923
  dataItem: {
2909
2924
  [associateFieldKey]: result