From 6e736c2ecc0e25e92b7b77eb2fe0e0e7cd0bb8a6 Mon Sep 17 00:00:00 2001 From: joshua_cm Date: Tue, 22 Jul 2025 16:14:53 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dadd=20a=20limit=20to=20th?= =?UTF-8?q?e=20Long=20Text=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/dataFields/ABFieldLongText.js | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js b/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js index bfa0f4f9..6408f311 100644 --- a/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js +++ b/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js @@ -16,6 +16,7 @@ export default function (AB) { super(`${ibase}_longtext`, { default: "", defaultCheckbox: "", + maxLength: "", // <-- 新增 ID }); } @@ -61,6 +62,32 @@ export default function (AB) { }, ], }, + { + view: "layout", + cols: [ + { + view: "label", + label: L("Max Length:"), + align: "right", + width: 100, + }, + { + id: ids.maxLength, + view: "counter", + name: "maxLength", + min: 1, + max: 10000, + step: 1, + labelWidth: uiConfig.labelWidthXLarge, + placeholder: L("Optional limit"), + on: { + onAfterRender: function () { + ABField.CYPRESS_REF(this); + }, + }, + }, + ], + }, { view: "checkbox", name: "supportMultilingual", @@ -77,25 +104,31 @@ export default function (AB) { ]); } - /** - * @method FieldClass() - * Call our Parent's _FieldClass() helper with the proper key to return - * the ABFieldXXX class represented by this Property Editor. - * @return {ABFieldXXX Class} - */ FieldClass() { return super._FieldClass("LongText"); } populate(field) { super.populate(field); + const value = field.settings.default === "" ? 0 : 1; $$(this.ids.defaultCheckbox).setValue(value); + $$(this.ids.default).setValue(field.settings.default || ""); + + // 新增:设置 maxLength 值 + if (field.settings.maxLength) { + $$(this.ids.maxLength).setValue(field.settings.maxLength); + } } show() { super.show(); $$(this.ids.defaultCheckbox).setValue(0); + $$(this.ids.default).setValue(""); + $$(this.ids.default).disable(); + + // 新增:清空 maxLength + $$(this.ids.maxLength).setValue(""); } checkboxDefaultValue(state) { @@ -106,6 +139,19 @@ export default function (AB) { $$(this.ids.default).enable(); } } + + values() { + const values = super.values(); + + values.default = $$(this.ids.defaultCheckbox).getValue() + ? $$(this.ids.default).getValue() + : ""; + + // 加入 maxLength 保存 + values.maxLength = parseInt($$(this.ids.maxLength).getValue()) || null; + + return values; + } } return ABFieldLongText; From 51e0f7e49823d45eeaf764adf476cb416bcb7c82 Mon Sep 17 00:00:00 2001 From: joshua_cm Date: Wed, 23 Jul 2025 16:39:50 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dadd=20a=20limit=20to=20th?= =?UTF-8?q?e=20Long=20Text=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Designer/properties/dataFields/ABFieldLongText.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js b/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js index 6408f311..268cbb70 100644 --- a/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js +++ b/src/rootPages/Designer/properties/dataFields/ABFieldLongText.js @@ -104,6 +104,12 @@ export default function (AB) { ]); } + /** + * @method FieldClass() + * Call our Parent's _FieldClass() helper with the proper key to return + * the ABFieldXXX class represented by this Property Editor. + * @return {ABFieldXXX Class} + */ FieldClass() { return super._FieldClass("LongText"); }