@nocobase/client 2.0.12 → 2.0.13

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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare const afterSuccess: import("@nocobase/flow-engine").ActionDefinition<import("@nocobase/flow-engine").FlowModel<import("@nocobase/flow-engine").DefaultStructure>, import("@nocobase/flow-engine").FlowContext>;
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ export * from './afterSuccess';
9
10
  export * from './confirm';
10
11
  export * from './dataScope';
11
12
  export * from './openView';
@@ -26,6 +26,7 @@ export declare class FilterFormGridModel extends GridModel {
26
26
  readonly loading: {
27
27
  value: boolean;
28
28
  };
29
+ private getAssociationFilterTargetKey;
29
30
  toggleFormFieldsCollapse(collapse: boolean, visibleRows: number): void;
30
31
  onModelCreated(subModel: FilterFormItemModel): Promise<void>;
31
32
  renderAddSubModelButton(): React.JSX.Element;
package/es/index.mjs CHANGED
@@ -3459,6 +3459,9 @@ const bp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3459
3459
  get actionSettingsItems() {
3460
3460
  return actionSettingsItems;
3461
3461
  },
3462
+ get afterSuccess() {
3463
+ return afterSuccess;
3464
+ },
3462
3465
  get allowAddNew() {
3463
3466
  return allowAddNew;
3464
3467
  },
@@ -9949,7 +9952,7 @@ function addAppVersion(e, t) {
9949
9952
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
9950
9953
  }), e;
9951
9954
  }
9952
- const name = "@nocobase/client", version = "2.0.12", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9955
+ const name = "@nocobase/client", version = "2.0.13", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9953
9956
  "@ahooksjs/use-url-state": "3.5.1",
9954
9957
  "@ant-design/cssinjs": "^1.11.1",
9955
9958
  "@ant-design/icons": "^5.6.1",
@@ -9972,10 +9975,10 @@ const name = "@nocobase/client", version = "2.0.12", license = "Apache-2.0", mai
9972
9975
  "@formily/reactive-react": "^2.2.27",
9973
9976
  "@formily/shared": "^2.2.27",
9974
9977
  "@formily/validator": "^2.2.27",
9975
- "@nocobase/evaluators": "2.0.12",
9976
- "@nocobase/flow-engine": "2.0.12",
9977
- "@nocobase/sdk": "2.0.12",
9978
- "@nocobase/utils": "2.0.12",
9978
+ "@nocobase/evaluators": "2.0.13",
9979
+ "@nocobase/flow-engine": "2.0.13",
9980
+ "@nocobase/sdk": "2.0.13",
9981
+ "@nocobase/utils": "2.0.13",
9979
9982
  "@tanstack/react-table": "^8.21.3",
9980
9983
  "@types/tabulator-tables": "^6.2.6",
9981
9984
  "acorn-jsx": "^5.3.2",
@@ -66418,7 +66421,98 @@ const BlockConfigsContext = createContext({
66418
66421
  }
66419
66422
  )
66420
66423
  ] });
66421
- }, confirm$1 = defineAction({
66424
+ }, afterSuccess = defineAction({
66425
+ name: "afterSuccess",
66426
+ title: tExpr("After successful submission"),
66427
+ uiSchema: {
66428
+ successMessage: {
66429
+ type: "string",
66430
+ title: tExpr("Popup message"),
66431
+ "x-decorator": "FormItem",
66432
+ "x-component": "Input.TextArea"
66433
+ },
66434
+ manualClose: {
66435
+ type: "boolean",
66436
+ title: tExpr("Message popup close method"),
66437
+ "x-decorator": "FormItem",
66438
+ "x-component": "Radio.Group",
66439
+ enum: [
66440
+ { label: tExpr("Automatic close"), value: !1 },
66441
+ { label: tExpr("Manually close"), value: !0 }
66442
+ ]
66443
+ },
66444
+ actionAfterSuccess: {
66445
+ type: "string",
66446
+ title: tExpr("Action after successful submission"),
66447
+ "x-decorator": "FormItem",
66448
+ "x-component": "Radio.Group",
66449
+ enum: [
66450
+ { label: tExpr("Stay on the current popup or page"), value: "stay" },
66451
+ { label: tExpr("Return to the previous popup or page"), value: "previous" },
66452
+ { label: tExpr("Close popup and redirect to"), value: "redirect" }
66453
+ ]
66454
+ },
66455
+ redirectTo: {
66456
+ type: "string",
66457
+ title: tExpr("Link"),
66458
+ "x-decorator": "FormItem",
66459
+ "x-component": TextAreaWithContextSelector,
66460
+ "x-reactions": {
66461
+ dependencies: ["actionAfterSuccess"],
66462
+ fulfill: {
66463
+ state: {
66464
+ visible: "{{$deps[0]==='redirect'}}"
66465
+ }
66466
+ }
66467
+ }
66468
+ }
66469
+ },
66470
+ defaultParams: {
66471
+ successMessage: tExpr("Saved successfully"),
66472
+ manualClose: !1,
66473
+ actionAfterSuccess: "previous"
66474
+ },
66475
+ handler(e, t) {
66476
+ return L(this, null, function* () {
66477
+ const { successMessage: o, manualClose: n = !1, actionAfterSuccess: r = "previous", redirectTo: i } = t;
66478
+ r === "previous" && e.view && e.view.close();
66479
+ const a = (c) => {
66480
+ if (e.engine) {
66481
+ let u = e.engine;
66482
+ for (; u.nextEngine; )
66483
+ u = u.nextEngine;
66484
+ const d = [];
66485
+ let p = u;
66486
+ for (; p; )
66487
+ d.push(p), p = p.previousEngine;
66488
+ for (const m of d)
66489
+ m.destroyView();
66490
+ }
66491
+ e.router.navigate(c);
66492
+ }, l = (c) => {
66493
+ if (isURL(c)) {
66494
+ window.location.href = c;
66495
+ return;
66496
+ }
66497
+ a(c);
66498
+ };
66499
+ if (o) {
66500
+ const c = e.t(o);
66501
+ if (n) {
66502
+ yield e.modal.success({
66503
+ title: c,
66504
+ onOk: () => L(this, null, function* () {
66505
+ r === "redirect" && i && l(i);
66506
+ })
66507
+ });
66508
+ return;
66509
+ } else
66510
+ e.message.success(c);
66511
+ }
66512
+ r === "redirect" && i && l(i);
66513
+ });
66514
+ }
66515
+ }), confirm$1 = defineAction({
66422
66516
  name: "confirm",
66423
66517
  title: tExpr("Confirmation"),
66424
66518
  uiSchema: {
@@ -73669,7 +73763,7 @@ const FlowRoute = () => {
73669
73763
  }
73670
73764
  };
73671
73765
  }
73672
- const m = yield a.loadOrCreateModel(p);
73766
+ const m = yield a.loadOrCreateModel(p, { skipSave: !a.context.flowSettingsEnabled });
73673
73767
  return m != null && m.uid && n && (m.context.addDelegate(l), m.removeParentDelegate(), n(m.uid, m)), m;
73674
73768
  }),
73675
73769
  {
@@ -73693,7 +73787,7 @@ const RemoteFlowModelRenderer = (e) => {
73693
73787
  function PageTabChildrenRenderer({ ctx: e, options: t }) {
73694
73788
  const { data: o, loading: n } = useRequest$1(
73695
73789
  () => L(this, null, function* () {
73696
- const i = yield e.engine.loadOrCreateModel(t);
73790
+ const i = yield e.engine.loadOrCreateModel(t, { skipSave: !e.flowSettingsEnabled });
73697
73791
  return i.context.addDelegate(e), i;
73698
73792
  }),
73699
73793
  {
@@ -75776,11 +75870,14 @@ function AssignFieldsEditor() {
75776
75870
  return useEffect(() => {
75777
75871
  let l = !1;
75778
75872
  return L(this, null, function* () {
75779
- const c = yield n.loadOrCreateModel({
75780
- parentId: o.uid,
75781
- subKey: "assignForm",
75782
- use: "AssignFormModel"
75783
- });
75873
+ const c = yield n.loadOrCreateModel(
75874
+ {
75875
+ parentId: o.uid,
75876
+ subKey: "assignForm",
75877
+ use: "AssignFormModel"
75878
+ },
75879
+ { skipSave: !e.context.flowSettingsEnabled }
75880
+ );
75784
75881
  l || (a(c), o.assignFormUid = (c == null ? void 0 : c.uid) || o.assignFormUid);
75785
75882
  }), () => {
75786
75883
  l = !0;
@@ -80590,6 +80687,19 @@ DetailsBlockModel.registerFlow({
80590
80687
  }
80591
80688
  }
80592
80689
  });
80690
+ DetailsBlockModel.registerFlow({
80691
+ key: "initialPaginationChangeRefresh",
80692
+ sort: 10001,
80693
+ steps: {
80694
+ refreshPaginationRelatedStates: {
80695
+ handler(e) {
80696
+ return L(this, null, function* () {
80697
+ e.model.hidden || !e.model.isMultiRecordResource() || (yield dispatchEventDeep(e.model, "paginationChange"));
80698
+ });
80699
+ }
80700
+ }
80701
+ }
80702
+ });
80593
80703
  DetailsBlockModel.define({
80594
80704
  label: tExpr("Details"),
80595
80705
  searchable: !0,
@@ -81155,7 +81265,11 @@ function markAssociationHydrationDone(e, t) {
81155
81265
  function RemoteModelRenderer$2({ options: e }) {
81156
81266
  const t = useFlowViewContext(), { data: o, loading: n } = useRequest$1(
81157
81267
  () => L(this, null, function* () {
81158
- return yield t.engine.loadOrCreateModel(e, { delegateToParent: !1, delegate: t });
81268
+ return yield t.engine.loadOrCreateModel(e, {
81269
+ delegateToParent: !1,
81270
+ delegate: t,
81271
+ skipSave: !t.flowSettingsEnabled
81272
+ });
81159
81273
  }),
81160
81274
  {
81161
81275
  refreshDeps: [t, e]
@@ -82846,7 +82960,11 @@ function injectRecordPickerPopupContext(e, t, o) {
82846
82960
  function RemoteModelRenderer$1({ options: e, fieldModel: t }) {
82847
82961
  const o = useFlowViewContext(), { data: n, loading: r } = useRequest$1(
82848
82962
  () => L(this, null, function* () {
82849
- const i = yield o.engine.loadOrCreateModel(e, { delegateToParent: !1, delegate: o });
82963
+ const i = yield o.engine.loadOrCreateModel(e, {
82964
+ delegateToParent: !1,
82965
+ delegate: o,
82966
+ skipSave: !o.flowSettingsEnabled
82967
+ });
82850
82968
  return injectRecordPickerPopupContext(i, o, t), i;
82851
82969
  }),
82852
82970
  {
@@ -85962,7 +86080,11 @@ function FieldWithoutPermissionPlaceholder({ targetModel: e, children: t }) {
85962
86080
  function RemoteModelRenderer({ options: e, fieldModel: t }) {
85963
86081
  const o = useFlowViewContext(), { data: n, loading: r } = useRequest$1(
85964
86082
  () => L(this, null, function* () {
85965
- const i = yield o.engine.loadOrCreateModel(e, { delegateToParent: !1, delegate: o });
86083
+ const i = yield o.engine.loadOrCreateModel(e, {
86084
+ delegateToParent: !1,
86085
+ delegate: o,
86086
+ skipSave: !o.flowSettingsEnabled
86087
+ });
85966
86088
  return i.context.defineProperty("associationModel", {
85967
86089
  value: t.context.associationModel
85968
86090
  }), i.actionName = e.scene, i;
@@ -89891,6 +90013,11 @@ class FilterFormGridModel extends GridModel {
89891
90013
  R(this, "hiddenRows", {});
89892
90014
  R(this, "loading", observable$1.ref(!1));
89893
90015
  }
90016
+ getAssociationFilterTargetKey(o) {
90017
+ var r;
90018
+ const n = (r = o == null ? void 0 : o.targetCollection) == null ? void 0 : r.filterTargetKey;
90019
+ return Array.isArray(n) ? n[0] || "id" : n || "id";
90020
+ }
89894
90021
  toggleFormFieldsCollapse(o, n) {
89895
90022
  const r = this.props.rows || {};
89896
90023
  if (o) {
@@ -89931,7 +90058,7 @@ class FilterFormGridModel extends GridModel {
89931
90058
  if (m || (m = (p = c.getField) == null ? void 0 : p.call(c, n)), m != null && m.target)
89932
90059
  return {
89933
90060
  targetId: l.uid,
89934
- filterPaths: [`${n}.${m.targetKey}`]
90061
+ filterPaths: [`${n}.${this.getAssociationFilterTargetKey(m)}`]
89935
90062
  };
89936
90063
  }
89937
90064
  return {
@@ -95343,7 +95470,11 @@ const models = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
95343
95470
  const o = e.inputArgs || {}, n = (w = (T = o.defineProperties) != null ? T : (M = ($ = e.model.context) == null ? void 0 : $.inputArgs) == null ? void 0 : M.defineProperties) != null ? w : void 0, r = (O = (j = o.defineMethods) != null ? j : (N = (B = e.model.context) == null ? void 0 : B.inputArgs) == null ? void 0 : N.defineMethods) != null ? O : void 0, i = ((z = (q = e.model) == null ? void 0 : q.getInputArgs) == null ? void 0 : z.call(q)) || {}, a = (o == null ? void 0 : o.defaultInputKeys) || [], l = (re) => {
95344
95471
  const ie = typeof (o == null ? void 0 : o[re]) != "undefined", ne = a.includes(re);
95345
95472
  return ie && !ne ? o[re] : typeof (t == null ? void 0 : t[re]) != "undefined" ? t[re] : ie ? o[re] : i == null ? void 0 : i[re];
95346
- }, c = l("filterByTk"), u = l("sourceId"), d = typeof (o == null ? void 0 : o.dataSourceKey) != "undefined" ? o.dataSourceKey : t == null ? void 0 : t.dataSourceKey, p = typeof (o == null ? void 0 : o.collectionName) != "undefined" ? o.collectionName : t == null ? void 0 : t.collectionName, m = typeof (o == null ? void 0 : o.associationName) != "undefined" ? o.associationName : t == null ? void 0 : t.associationName, h = typeof o.tabUid != "undefined" ? o.tabUid : t.tabUid, g = (V = e.inputArgs) != null && V.isMobileLayout ? "embed" : ((U = e.inputArgs) == null ? void 0 : U.mode) || t.mode || "drawer";
95473
+ }, c = (() => {
95474
+ var ie;
95475
+ const re = l("filterByTk");
95476
+ return Array.isArray((ie = e.collection) == null ? void 0 : ie.filterTargetKey) && e.collection.filterTargetKey.length === 1 && re != null && typeof re != "object" ? { [e.collection.filterTargetKey[0]]: re } : re;
95477
+ })(), u = l("sourceId"), d = typeof (o == null ? void 0 : o.dataSourceKey) != "undefined" ? o.dataSourceKey : t == null ? void 0 : t.dataSourceKey, p = typeof (o == null ? void 0 : o.collectionName) != "undefined" ? o.collectionName : t == null ? void 0 : t.collectionName, m = typeof (o == null ? void 0 : o.associationName) != "undefined" ? o.associationName : t == null ? void 0 : t.associationName, h = typeof o.tabUid != "undefined" ? o.tabUid : t.tabUid, g = (V = e.inputArgs) != null && V.isMobileLayout ? "embed" : ((U = e.inputArgs) == null ? void 0 : U.mode) || t.mode || "drawer";
95347
95478
  let f = typeof o.navigation != "undefined" ? o.navigation : t.navigation;
95348
95479
  if ((n || r) && (f = !1), f !== !1 && e.isNavigationEnabled !== !1 && !e.inputArgs.navigation && (K = e.view) != null && K.navigation) {
95349
95480
  const re = g, ie = A(x({}, e.inputArgs), {
@@ -95399,13 +95530,16 @@ const models = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
95399
95530
  }, b = e.inputArgs.pageModelClass || t.pageModelClass || "ChildPageModel", S = e.inputArgs.size || t.size || "medium";
95400
95531
  let C = null, P = null, F = e.model.uid;
95401
95532
  if (t.subModelKey) {
95402
- const re = yield e.engine.loadOrCreateModel({
95403
- async: !0,
95404
- parentId: e.model.uid,
95405
- subKey: t.subModelKey,
95406
- subType: "object",
95407
- use: "FlowModel"
95408
- });
95533
+ const re = yield e.engine.loadOrCreateModel(
95534
+ {
95535
+ async: !0,
95536
+ parentId: e.model.uid,
95537
+ subKey: t.subModelKey,
95538
+ subType: "object",
95539
+ use: "FlowModel"
95540
+ },
95541
+ { skipSave: !e.flowSettingsEnabled }
95542
+ );
95409
95543
  re != null && re.uid && (F = re.uid);
95410
95544
  }
95411
95545
  const v = !!((Z = e.inputArgs) != null && Z.navigation), k = ((W = (ee = e.view) == null ? void 0 : ee.inputArgs) == null ? void 0 : W.openerUids) || o.openerUids || [], I = v ? o.openerUids || k : [...k, ((oe = (Y = e.model.context) == null ? void 0 : Y.inputArgs) == null ? void 0 : oe.viewUid) || e.model.uid], D = typeof o.preventClose != "undefined" ? !!o.preventClose : !!t.preventClose, E = A(x(x({
@@ -100062,6 +100196,7 @@ const overflowMode = defineAction({
100062
100196
  aclCheck,
100063
100197
  aclCheckRefresh,
100064
100198
  actionLinkageRules,
100199
+ afterSuccess,
100065
100200
  blockHeight,
100066
100201
  blockLinkageRules,
100067
100202
  confirm: confirm$1,
@@ -107936,6 +108071,7 @@ export {
107936
108071
  actionLinkageRules,
107937
108072
  actionSettings,
107938
108073
  actionSettingsItems,
108074
+ afterSuccess,
107939
108075
  allowAddNew,
107940
108076
  appendQueryStringToUrl,
107941
108077
  applyMobilePaginationProps,