@nocobase/client 2.0.36 → 2.0.37
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/es/flow/models/blocks/form/submitValues.d.ts +13 -0
- package/es/index.mjs +78 -26
- package/lib/index.js +4 -4
- package/package.json +6 -6
|
@@ -15,6 +15,19 @@ import type { FormBlockModel } from './FormBlockModel';
|
|
|
15
15
|
* - 返回 null 表示无法安全推断,调用方应回退到 `validateFields()` 全量校验。
|
|
16
16
|
*/
|
|
17
17
|
export declare function getValidationNamePathsExcludingHiddenModels(blockModel: FormBlockModel): NamePath[] | null;
|
|
18
|
+
export declare function shouldSkipSubmitValidation(model: {
|
|
19
|
+
getStepParams?: (flowKey: string, stepKey: string) => {
|
|
20
|
+
skipValidator?: boolean;
|
|
21
|
+
} | undefined;
|
|
22
|
+
} | null | undefined): boolean;
|
|
23
|
+
export declare function validateSubmitForm(options: {
|
|
24
|
+
form?: {
|
|
25
|
+
validateFields?: (nameList?: any) => Promise<any>;
|
|
26
|
+
} | null;
|
|
27
|
+
blockModel?: FormBlockModel | null;
|
|
28
|
+
flowSettingsEnabled?: boolean;
|
|
29
|
+
skipValidator?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
18
31
|
/**
|
|
19
32
|
* 提交前过滤:移除当前表单 block 中被「联动规则隐藏」的字段值(`model.hidden === true`)。
|
|
20
33
|
*
|
package/es/index.mjs
CHANGED
|
@@ -9976,7 +9976,7 @@ function addAppVersion(e, t) {
|
|
|
9976
9976
|
addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
|
|
9977
9977
|
}), e;
|
|
9978
9978
|
}
|
|
9979
|
-
const name = "@nocobase/client", version = "2.0.
|
|
9979
|
+
const name = "@nocobase/client", version = "2.0.37", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
|
|
9980
9980
|
"@ahooksjs/use-url-state": "3.5.1",
|
|
9981
9981
|
"@ant-design/cssinjs": "^1.11.1",
|
|
9982
9982
|
"@ant-design/icons": "^5.6.1",
|
|
@@ -9999,10 +9999,10 @@ const name = "@nocobase/client", version = "2.0.36", license = "Apache-2.0", mai
|
|
|
9999
9999
|
"@formily/reactive-react": "^2.2.27",
|
|
10000
10000
|
"@formily/shared": "^2.2.27",
|
|
10001
10001
|
"@formily/validator": "^2.2.27",
|
|
10002
|
-
"@nocobase/evaluators": "2.0.
|
|
10003
|
-
"@nocobase/flow-engine": "2.0.
|
|
10004
|
-
"@nocobase/sdk": "2.0.
|
|
10005
|
-
"@nocobase/utils": "2.0.
|
|
10002
|
+
"@nocobase/evaluators": "2.0.37",
|
|
10003
|
+
"@nocobase/flow-engine": "2.0.37",
|
|
10004
|
+
"@nocobase/sdk": "2.0.37",
|
|
10005
|
+
"@nocobase/utils": "2.0.37",
|
|
10006
10006
|
"@tanstack/react-table": "^8.21.3",
|
|
10007
10007
|
"@types/tabulator-tables": "^6.2.6",
|
|
10008
10008
|
"acorn-jsx": "^5.3.2",
|
|
@@ -79806,6 +79806,23 @@ function getValidationNamePathsExcludingHiddenModels(e) {
|
|
|
79806
79806
|
const i = collectHiddenModelNamePaths(e);
|
|
79807
79807
|
return i.length ? n.filter((a) => !i.some((l) => isNamePathPrefix(l, a))) : n;
|
|
79808
79808
|
}
|
|
79809
|
+
function shouldSkipSubmitValidation(e) {
|
|
79810
|
+
var t, o;
|
|
79811
|
+
return ((o = (t = e == null ? void 0 : e.getStepParams) == null ? void 0 : t.call(e, "submitSettings", "skipRequiredValidation")) == null ? void 0 : o.skipValidator) === !0;
|
|
79812
|
+
}
|
|
79813
|
+
function validateSubmitForm(e) {
|
|
79814
|
+
return L(this, null, function* () {
|
|
79815
|
+
const { form: t, blockModel: o, flowSettingsEnabled: n, skipValidator: r } = e;
|
|
79816
|
+
if (r || !t || typeof t.validateFields != "function")
|
|
79817
|
+
return;
|
|
79818
|
+
const i = n && o ? getValidationNamePathsExcludingHiddenModels(o) : null;
|
|
79819
|
+
if (Array.isArray(i)) {
|
|
79820
|
+
i.length && (yield t.validateFields(i));
|
|
79821
|
+
return;
|
|
79822
|
+
}
|
|
79823
|
+
yield t.validateFields();
|
|
79824
|
+
});
|
|
79825
|
+
}
|
|
79809
79826
|
function omitHiddenModelValuesFromSubmit(e, t) {
|
|
79810
79827
|
if (!e || typeof e != "object")
|
|
79811
79828
|
return e;
|
|
@@ -79819,24 +79836,29 @@ function omitHiddenModelValuesFromSubmit(e, t) {
|
|
|
79819
79836
|
}
|
|
79820
79837
|
function submitHandler(e, t, o) {
|
|
79821
79838
|
return L(this, null, function* () {
|
|
79822
|
-
var c, u
|
|
79823
|
-
const n = e.resource, r = e.blockModel
|
|
79824
|
-
|
|
79825
|
-
|
|
79839
|
+
var l, c, u;
|
|
79840
|
+
const n = e.resource, r = e.blockModel;
|
|
79841
|
+
yield validateSubmitForm({
|
|
79842
|
+
form: r == null ? void 0 : r.form,
|
|
79843
|
+
blockModel: r,
|
|
79844
|
+
flowSettingsEnabled: e == null ? void 0 : e.flowSettingsEnabled,
|
|
79845
|
+
skipValidator: shouldSkipSubmitValidation(e == null ? void 0 : e.model)
|
|
79846
|
+
});
|
|
79847
|
+
const i = r.form.getFieldsValue(!0), a = omitHiddenModelValuesFromSubmit(i, r);
|
|
79826
79848
|
if (n instanceof SingleRecordResource) {
|
|
79827
79849
|
if (r instanceof EditFormModel) {
|
|
79828
|
-
const
|
|
79829
|
-
|
|
79850
|
+
const p = n.getMeta("currentFilterByTk");
|
|
79851
|
+
p ? n.setFilterByTk(p) : n.isNewRecord = !0;
|
|
79830
79852
|
}
|
|
79831
|
-
const
|
|
79832
|
-
r instanceof EditFormModel ? (n.isNewRecord = !1, (
|
|
79853
|
+
const d = o ? yield o(a) : yield n.save(a, t.requestConfig);
|
|
79854
|
+
r instanceof EditFormModel ? (n.isNewRecord = !1, (l = r.resetUserModifiedFields) == null || l.call(r), yield n.refresh()) : (r.form.resetFields(), r.emitter.emit("onFieldReset"), (c = r.resetUserModifiedFields) == null || c.call(r), e.view.inputArgs.collectionName === r.collection.name && e.view.inputArgs.onChange && e.view.inputArgs.onChange(d == null ? void 0 : d.data));
|
|
79833
79855
|
} else if (n instanceof MultiRecordResource) {
|
|
79834
|
-
const
|
|
79835
|
-
if (!
|
|
79856
|
+
const d = n.getMeta("currentFilterByTk");
|
|
79857
|
+
if (!d) {
|
|
79836
79858
|
e.message.error(e.t("No filterByTk found for multi-record resource."));
|
|
79837
79859
|
return;
|
|
79838
79860
|
}
|
|
79839
|
-
(yield o) ? yield o(
|
|
79861
|
+
(yield o) ? yield o(a, d) : yield n.update(d, a, t.requestConfig), (u = r.resetUserModifiedFields) == null || u.call(r);
|
|
79840
79862
|
}
|
|
79841
79863
|
});
|
|
79842
79864
|
}
|
|
@@ -82470,8 +82492,12 @@ FormSubmitActionModel.registerFlow({
|
|
|
82470
82492
|
return L(this, null, function* () {
|
|
82471
82493
|
if (t.enable)
|
|
82472
82494
|
try {
|
|
82473
|
-
|
|
82474
|
-
|
|
82495
|
+
yield validateSubmitForm({
|
|
82496
|
+
form: e.form,
|
|
82497
|
+
blockModel: e.blockModel,
|
|
82498
|
+
flowSettingsEnabled: e == null ? void 0 : e.flowSettingsEnabled,
|
|
82499
|
+
skipValidator: shouldSkipSubmitValidation(e == null ? void 0 : e.model)
|
|
82500
|
+
}), (yield e.modal.confirm({
|
|
82475
82501
|
title: e.t(t.title, { ns: "lm-flow-engine" }),
|
|
82476
82502
|
content: e.t(t.content, { ns: "lm-flow-engine" }),
|
|
82477
82503
|
okText: e.t("Confirm"),
|
|
@@ -82483,6 +82509,15 @@ FormSubmitActionModel.registerFlow({
|
|
|
82483
82509
|
});
|
|
82484
82510
|
}
|
|
82485
82511
|
},
|
|
82512
|
+
skipRequiredValidation: {
|
|
82513
|
+
title: tExpr("Skip required validation"),
|
|
82514
|
+
uiMode: { type: "switch", key: "skipValidator" },
|
|
82515
|
+
defaultParams: {
|
|
82516
|
+
skipValidator: !1
|
|
82517
|
+
},
|
|
82518
|
+
handler() {
|
|
82519
|
+
}
|
|
82520
|
+
},
|
|
82486
82521
|
saveResource: {
|
|
82487
82522
|
handler(e, t) {
|
|
82488
82523
|
return L(this, null, function* () {
|
|
@@ -87953,8 +87988,12 @@ PopupSubTableFormSubmitActionModel.registerFlow({
|
|
|
87953
87988
|
return L(this, null, function* () {
|
|
87954
87989
|
if (t.enable)
|
|
87955
87990
|
try {
|
|
87956
|
-
|
|
87957
|
-
|
|
87991
|
+
yield validateSubmitForm({
|
|
87992
|
+
form: e.form,
|
|
87993
|
+
blockModel: e.blockModel,
|
|
87994
|
+
flowSettingsEnabled: e == null ? void 0 : e.flowSettingsEnabled,
|
|
87995
|
+
skipValidator: shouldSkipSubmitValidation(e == null ? void 0 : e.model)
|
|
87996
|
+
}), (yield e.modal.confirm({
|
|
87958
87997
|
title: e.t(t.title, { ns: "lm-flow-engine" }),
|
|
87959
87998
|
content: e.t(t.content, { ns: "lm-flow-engine" }),
|
|
87960
87999
|
okText: e.t("Confirm"),
|
|
@@ -87966,20 +88005,33 @@ PopupSubTableFormSubmitActionModel.registerFlow({
|
|
|
87966
88005
|
});
|
|
87967
88006
|
}
|
|
87968
88007
|
},
|
|
88008
|
+
skipRequiredValidation: {
|
|
88009
|
+
title: tExpr("Skip required validation"),
|
|
88010
|
+
uiMode: { type: "switch", key: "skipValidator" },
|
|
88011
|
+
defaultParams: {
|
|
88012
|
+
skipValidator: !1
|
|
88013
|
+
},
|
|
88014
|
+
handler() {
|
|
88015
|
+
}
|
|
88016
|
+
},
|
|
87969
88017
|
save: {
|
|
87970
88018
|
handler(e, t) {
|
|
87971
88019
|
return L(this, null, function* () {
|
|
87972
88020
|
var d;
|
|
87973
88021
|
const o = e.blockModel, n = o.context.associationModel, r = n.context.resource, a = o.resource.getUpdateAssociationValues(), l = n.context.collectionField.name, c = r.getUpdateAssociationValues(), u = matchPath(c, l);
|
|
87974
88022
|
try {
|
|
87975
|
-
|
|
87976
|
-
|
|
87977
|
-
|
|
88023
|
+
yield validateSubmitForm({
|
|
88024
|
+
form: o == null ? void 0 : o.form,
|
|
88025
|
+
blockModel: o,
|
|
88026
|
+
flowSettingsEnabled: e == null ? void 0 : e.flowSettingsEnabled,
|
|
88027
|
+
skipValidator: shouldSkipSubmitValidation(e == null ? void 0 : e.model)
|
|
88028
|
+
});
|
|
88029
|
+
const p = o.form.getFieldsValue(!0), m = omitHiddenModelValuesFromSubmit(p, o);
|
|
87978
88030
|
n.dispatchEvent("updateRow", {
|
|
87979
|
-
updatedRecord:
|
|
88031
|
+
updatedRecord: m
|
|
87980
88032
|
});
|
|
87981
|
-
const
|
|
87982
|
-
r.addUpdateAssociationValues(
|
|
88033
|
+
const h = a.map((g) => `${u}.${g}`);
|
|
88034
|
+
r.addUpdateAssociationValues(h), (d = o.resetUserModifiedFields) == null || d.call(o);
|
|
87983
88035
|
} catch (p) {
|
|
87984
88036
|
return;
|
|
87985
88037
|
}
|