Fix 3.1.4 (#551)

* renderCustomizedFormArea

* enh: readonlyw

* enh:readonlyw

* enh: PTOKEN

* fix: operatingContext.getBeforeRecord on update
This commit is contained in:
RB 2022-12-12 13:50:06 +08:00 committed by GitHub
parent e7cc4db358
commit 1916c04108
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 35 deletions

View file

@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<!-- UNCOMMENT USE TOMCAT -->

View file

@ -67,11 +67,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* 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

View file

@ -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("::");

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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 {

View file

@ -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;
}

View file

@ -613,6 +613,10 @@ class EditableForm extends RbForm {
renderDetailForm() {
return null
}
renderCustomizedFormArea() {
return null
}
}
const STATE_NAMES = {

View file

@ -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 && <input type="file" className="hide" accept="image/*" ref={(c) => (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"
/>
<span className={'zmdi zmdi-close clean ' + (this.state.value ? '' : 'hide')} onClick={() => 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)}
/>
<span className={`zmdi zmdi-close clean ${this.state.value ? '' : 'hide'}`} onClick={() => this.handleClear()} title={$L('清除')} />