From 1916c04108fb222623bed7e2715749b493ecd438 Mon Sep 17 00:00:00 2001 From: RB <42044143+getrebuild@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:50:06 +0800 Subject: [PATCH] Fix 3.1.4 (#551) * renderCustomizedFormArea * enh: readonlyw * enh:readonlyw * enh: PTOKEN * fix: operatingContext.getBeforeRecord on update --- pom.xml | 2 +- .../java/com/rebuild/core/Application.java | 4 +-- .../core/configuration/NavBuilder.java | 13 +++++---- .../configuration/general/FormsBuilder.java | 16 ++++++++--- .../trigger/impl/FieldAggregation.java | 3 +- .../trigger/impl/GroupAggregation.java | 3 +- .../resources/web/assets/css/triggers.css | 13 ++++----- .../resources/web/assets/js/rb-approval.js | 4 +++ src/main/resources/web/assets/js/rb-forms.js | 28 +++++++++---------- 9 files changed, 51 insertions(+), 35 deletions(-) diff --git a/pom.xml b/pom.xml index 4b19c4920..65f0fc894 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.rebuild rebuild - 3.1.3 + 3.1.4 rebuild Building your business-systems freely! diff --git a/src/main/java/com/rebuild/core/Application.java b/src/main/java/com/rebuild/core/Application.java index e7fca3266..4aafc3673 100644 --- a/src/main/java/com/rebuild/core/Application.java +++ b/src/main/java/com/rebuild/core/Application.java @@ -67,11 +67,11 @@ public class Application implements ApplicationListener /** * Rebuild Version */ - public static final String VER = "3.1.3"; + public static final String VER = "3.1.4"; /** * Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2} */ - public static final int BUILD = 3010311; + public static final int BUILD = 3010411; static { // Driver for DB diff --git a/src/main/java/com/rebuild/core/configuration/NavBuilder.java b/src/main/java/com/rebuild/core/configuration/NavBuilder.java index 6d2d8ddd0..245a3eb33 100644 --- a/src/main/java/com/rebuild/core/configuration/NavBuilder.java +++ b/src/main/java/com/rebuild/core/configuration/NavBuilder.java @@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSONObject; import com.rebuild.api.user.PageTokenVerify; import com.rebuild.core.Application; import com.rebuild.core.UserContextHolder; +import com.rebuild.core.cache.CommonsCache; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.metadata.RecordBuilder; @@ -141,14 +142,16 @@ public class NavBuilder extends NavManager { } else if ("URL".equals(type)) { - // 替换 RBTOKEN + // 替换 RBTOKEN https://juejin.cn/post/7045494433797652511 // https://getrebuild.com/docs/rbv/openapi/page-token-verify if (value.contains("$RBTOKEN$") || value.contains("%24RBTOKEN%24")) { - String ptoken = PTOKEN_IFNEED.get(); + + final String key = "PTOKEN:" + user; + String ptoken = Application.getCommonsCache().get(key); if (ptoken == null) { - ptoken = PageTokenVerify.generate(UserContextHolder.getUser()); - PTOKEN_IFNEED.set(ptoken); + ptoken = PageTokenVerify.generate(user); + Application.getCommonsCache().put(key, ptoken, CommonsCache.TS_HOUR / 2); } if (value.contains("$RBTOKEN$")) value = value.replace("$RBTOKEN$", ptoken); @@ -157,7 +160,7 @@ public class NavBuilder extends NavManager { item.put("value", value); } - // URL 绑定实体权限 + // URL 绑定实体权限 https://juejin.cn/post/7045494433797652511 // 如 https://www.baidu.com/::ENTITY_NAME String[] ss = value.split("::"); diff --git a/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java b/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java index 404e0c640..3a3bff4e0 100644 --- a/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java +++ b/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java @@ -62,6 +62,11 @@ public class FormsBuilder extends FormsManager { // 引用记录 public static final String DV_REFERENCE_PREFIX = "&"; + // 自动只读 + private static final int READONLYW_RO = 2; + // 自动只读-表单回填 + private static final int READONLYW_RW = 3; + /** * 表单-编辑 * @@ -188,7 +193,9 @@ public class FormsBuilder extends FormsManager { // 前端可收集值 if (roAutosWithout == null) roAutosWithout = AutoFillinManager.instance.getAutoReadonlyFields(entity); if (roAutosWithout.contains(field.getString("field"))) { - field.put("readonlyw", true); + field.put("readonlyw", READONLYW_RW); + } else { + field.put("readonlyw", READONLYW_RO); } } } @@ -424,7 +431,7 @@ public class FormsBuilder extends FormsManager { // 默认值 if (el.get("value") == null) { if (dt == DisplayType.SERIES) { - el.put("value", Language.L("自动值")); + el.put("readonlyw", READONLYW_RO); } else { Object defaultValue = easyField.exprDefaultValue(); if (defaultValue != null) { @@ -433,7 +440,7 @@ public class FormsBuilder extends FormsManager { } } - // 触发器自动值 + // 自动值 if (roViaAuto && el.get("value") == null) { if (dt == DisplayType.EMAIL || dt == DisplayType.PHONE @@ -445,7 +452,8 @@ public class FormsBuilder extends FormsManager { || dt == DisplayType.SERIES || dt == DisplayType.TEXT || dt == DisplayType.NTEXT) { - el.put("value", Language.L("自动值")); + Integer s = el.getInteger("readonlyw"); + if (s == null) el.put("readonlyw", READONLYW_RO); } } diff --git a/src/main/java/com/rebuild/core/service/trigger/impl/FieldAggregation.java b/src/main/java/com/rebuild/core/service/trigger/impl/FieldAggregation.java index 3d0e6d282..967e16c20 100644 --- a/src/main/java/com/rebuild/core/service/trigger/impl/FieldAggregation.java +++ b/src/main/java/com/rebuild/core/service/trigger/impl/FieldAggregation.java @@ -267,7 +267,8 @@ public class FieldAggregation extends TriggerAction { // fix: v3.1.3 清空字段值以后无法找到记录 if (o != null && targetRecordId == null && operatingContext.getAction() == BizzPermission.UPDATE && this.getClass() == FieldAggregation.class) { - ID beforeValue = operatingContext.getBeforeRecord().getID(followSourceField); + ID beforeValue = operatingContext.getBeforeRecord() == null + ? null : operatingContext.getBeforeRecord().getID(followSourceField); ID afterValue = operatingContext.getAfterRecord().getID(followSourceField); if (beforeValue != null && afterValue == null) { targetRecordId = beforeValue; diff --git a/src/main/java/com/rebuild/core/service/trigger/impl/GroupAggregation.java b/src/main/java/com/rebuild/core/service/trigger/impl/GroupAggregation.java index 8237bd1a8..905dcb50b 100644 --- a/src/main/java/com/rebuild/core/service/trigger/impl/GroupAggregation.java +++ b/src/main/java/com/rebuild/core/service/trigger/impl/GroupAggregation.java @@ -133,7 +133,8 @@ public class GroupAggregation extends FieldAggregation { String targetField = e.getValue(); if (isGroupUpdate) { - Object beforeValue = operatingContext.getBeforeRecord().getObjectValue(sourceField); + Object beforeValue = operatingContext.getBeforeRecord() == null + ? null : operatingContext.getBeforeRecord().getObjectValue(sourceField); Object afterValue = operatingContext.getAfterRecord().getObjectValue(sourceField); if (NullValue.isNull(beforeValue) && NullValue.isNull(afterValue)) { } else { diff --git a/src/main/resources/web/assets/css/triggers.css b/src/main/resources/web/assets/css/triggers.css index 3386b8190..c13c02146 100644 --- a/src/main/resources/web/assets/css/triggers.css +++ b/src/main/resources/web/assets/css/triggers.css @@ -21,6 +21,11 @@ See LICENSE and COMMERCIAL in the project root for license information. max-width: 180px; } +.timeline.spare form.simple input.form-control-sm, +.timeline.spare form.simple select.form-control-sm { + max-width: 485px; +} + .timeline.spare .timeline-content { padding: 0; } @@ -376,8 +381,7 @@ textarea.formula-code { } .on-timers { - padding: 15px 26px; - padding-bottom: 20px; + padding: 15px 26px 20px; border-radius: 2px; border: 1px solid #eee; font-size: 1rem; @@ -507,11 +511,6 @@ textarea.formula-code { } } -input.form-control-sm, -select.form-control-sm { - max-width: 485px; -} - .alert-mb-0 > .alert { margin-bottom: 0; } diff --git a/src/main/resources/web/assets/js/rb-approval.js b/src/main/resources/web/assets/js/rb-approval.js index 4ffffe74c..4e30d1795 100644 --- a/src/main/resources/web/assets/js/rb-approval.js +++ b/src/main/resources/web/assets/js/rb-approval.js @@ -613,6 +613,10 @@ class EditableForm extends RbForm { renderDetailForm() { return null } + + renderCustomizedFormArea() { + return null + } } const STATE_NAMES = { diff --git a/src/main/resources/web/assets/js/rb-forms.js b/src/main/resources/web/assets/js/rb-forms.js index 035773f10..bf2df46cc 100644 --- a/src/main/resources/web/assets/js/rb-forms.js +++ b/src/main/resources/web/assets/js/rb-forms.js @@ -437,18 +437,18 @@ class RbForm extends React.Component { // 新纪录初始值 if (this.isNew) { this.props.children.map((child) => { - let val = child.props.value - if (val && (child.props.readonly !== true || child.props.readonlyw === true)) { - if (typeof val === 'object') { - if ($.isArray(val)) { + let iv = child.props.value + if (iv && (!this.props.readonly || (this.props.readonly && this.props.readonlyw === 3))) { + if (typeof iv === 'object') { + if ($.isArray(iv)) { // eg. [file1, file2, image1] } else { // eg. {id:xxx, text:xxx} - val = val.id + iv = iv.id } } - this.setFieldValue(child.props.field, val) + this.setFieldValue(child.props.field, iv) } }) } @@ -708,7 +708,9 @@ class RbFormElement extends React.Component { const props = this.props if (!props.onView) { // 必填字段 - if (!props.nullable && $empty(props.value)) props.$$$parent.setFieldValue(props.field, null, $L('%s 不能为空', props.label)) + if (!props.nullable && $empty(props.value) && props.readonlyw !== 2) { + props.$$$parent.setFieldValue(props.field, null, $L('%s 不能为空', props.label)) + } // props.tip && $(this._fieldLabel).find('i.zmdi').tooltip({ placement: 'right' }) this.onEditModeChanged() @@ -735,6 +737,7 @@ class RbFormElement extends React.Component { onChange={(e) => this.handleChange(e, this.props.readonly ? false : true)} // onBlur={this.props.readonly ? null : () => this.checkValue()} readOnly={this.props.readonly} + placeholder={this.props.readonlyw > 0 ? $L('自动值') : null} maxLength={this.props.maxLength || 200} /> ) @@ -866,13 +869,6 @@ class RbFormText extends RbFormElement { constructor(props) { super(props) } - - getValue() { - const v = super.getValue() - // fix: 3.1.1 - if (v && v === $L('自动值')) return null - else return v - } } class RbFormUrl extends RbFormText { @@ -978,6 +974,7 @@ class RbFormNumber extends RbFormText { onChange={(e) => this.handleChange(e, this.props.readonly ? false : true)} // onBlur={this.props.readonly ? null : () => this.checkValue()} readOnly={this.props.readonly} + placeholder={this.props.readonlyw > 0 ? $L('自动值') : null} maxLength="29" /> ) @@ -1092,6 +1089,7 @@ class RbFormTextarea extends RbFormElement { onChange={(e) => this.handleChange(e, this.props.readonly ? false : true)} // onBlur={this.props.readonly ? null : () => this.checkValue()} readOnly={this.props.readonly} + placeholder={this.props.readonlyw > 0 ? $L('自动值') : null} maxLength="6000" /> {this.props.useMdedit && !this.props.readonly && (this._fieldValue__upload = c)} />} @@ -1211,6 +1209,7 @@ class RbFormDateTime extends RbFormElement { value={this.state.value || ''} onChange={(e) => this.handleChange(e, this.props.readonly ? false : true)} // onBlur={this.props.readonly ? null : () => this.checkValue()} + placeholder={this.props.readonlyw > 0 ? $L('自动值') : null} maxLength="20" /> this.handleClear()} /> @@ -2202,6 +2201,7 @@ class RbFormLocation extends RbFormElement { value={lnglat ? lnglat.text || '' : ''} onChange={(e) => this.handleChange(e)} readOnly + placeholder={this.props.readonlyw > 0 ? $L('自动值') : null} onClick={() => this._showMap(lnglat)} /> this.handleClear()} title={$L('清除')} />