Skip to content

Commit

Permalink
Fix 3.5.0 beta2b (#685)
Browse files Browse the repository at this point in the history
* feat: MobileAppPath

* fix: quick-filter

* fix: 位置自动定位

* fix: 详情页引用编辑错误; 顶部显示二级字段

* uoload app

* be: 父级字段多个子级问题

* be: _autoLocation

* beta2
  • Loading branch information
getrebuild authored Nov 28, 2023
1 parent 45d5c8f commit 6ddfd6e
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 64 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.5.0-beta1</version>
<version>3.5.0-beta2</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<!-- UNCOMMENT USE TOMCAT -->
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/core/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "3.5.0-beta1";
public static final String VER = "3.5.0-beta2";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 3050000;
public static final int BUILD = 3050002;

static {
// Driver for DB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,27 @@ public JSONArray getFillinValue(Field field, ID sourceId) {
String cascadingField = easyField.getExtraAttr(EasyFieldConfigProps.REFERENCE_CASCADINGFIELD);
if (StringUtils.isNotBlank(cascadingField)) {
String[] ts = cascadingField.split(MetadataHelper.SPLITER_RE);
ConfigBean fake = new ConfigBean()
.set("target", ts[0])
.set("source", ts[1])
.set("whenCreate", true)
.set("whenUpdate", true)
.set("fillinForce", true);

// 移除冲突的表单回填配置
for (Iterator<ConfigBean> iter = config.iterator(); iter.hasNext(); ) {
ConfigBean cb = iter.next();
if (StringUtils.equals(cb.getString("source"), fake.getString("source"))
&& StringUtils.equals(cb.getString("target"), fake.getString("target"))) {
iter.remove();
break;
// v35 父级的忽略
if (!ts[0].contains(".")) {
ConfigBean fake = new ConfigBean()
.set("target", ts[0])
.set("source", ts[1])
.set("whenCreate", true)
.set("whenUpdate", true)
.set("fillinForce", true);

// 移除冲突的表单回填配置
for (Iterator<ConfigBean> iter = config.iterator(); iter.hasNext(); ) {
ConfigBean cb = iter.next();
if (StringUtils.equals(cb.getString("source"), fake.getString("source"))
&& StringUtils.equals(cb.getString("target"), fake.getString("target"))) {
iter.remove();
break;
}
}
}

config.add(fake);
config.add(fake);
}
}

if (config.isEmpty()) return JSONUtils.EMPTY_ARRAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ public Set<String> getListFilterPaneFields(ID user, String entity) {

for (String s : quickFields) {
if (s.startsWith("&")) s = s.substring(1);
paneFields.add(s);

if (entityMeta.containsField(s)) {
paneFields.add(s);
} else {
// 不支持二级
if (!s.contains(".")) log.warn("No field in filter pane : {}#{}", entity, s);
}
}
}

Expand Down
18 changes: 6 additions & 12 deletions src/main/java/com/rebuild/core/metadata/EntityRecordCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public boolean onSetFieldValueWarn(Field field, String value, Record record) {

final boolean isNew = record.getPrimary() == null;

// 明细关联主记录
if (isNew && isDtmField(field)) return true;
// 明细关联主记录 + 位置定位
if (isNew && isForceCreateable(field)) return true;

// 公共字段前台可能会布局出来
// 此处忽略检查没问题,因为最后还会复写,即 EntityHelper#bindCommonsFieldsValue
Expand Down Expand Up @@ -182,20 +182,14 @@ public void verify(Record record) {
keepFieldValueSafe(record);
}

// 明细关联主记录字段
private boolean isDtmField(Field field) {
// 强制可新建的字段
private boolean isForceCreateable(Field field) {
// DTF 字段(明细关联主记录字段)
if (field.getType() == FieldType.REFERENCE && entity.getMainEntity() != null) {
return field.equals(MetadataHelper.getDetailToMainField(entity));
}
return false;
}

// 强制可新建的字段
private boolean isForceCreateable(Field field) {
// DTF 字段
if (isDtmField(field)) return true;

// 自动定位的
// 启用自动定位的
EasyField easyField = EasyMetaFactory.valueOf(field);
if (easyField.getDisplayType() == DisplayType.LOCATION) {
return BooleanUtils.toBoolean(easyField.getExtraAttr(EasyFieldConfigProps.LOCATION_AUTOLOCATION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,14 @@ else if (dt == DisplayType.BARCODE) {
}

JSONObject extraAttrs = JSON.parseObject(fieldElement.valueOf("@extra-attrs"));
if (extraAttrs.containsKey("_cascadingFieldChild") && extraAttrs.getString("_cascadingFieldChild").contains(".")) {
// 优先明细>主实体
String _cascadingFieldChild = extraAttrs.getString("_cascadingFieldChild");
if (_cascadingFieldChild != null && _cascadingFieldChild.contains(".")) {
// 优先使用明细>主实体
} else {
extraAttrs.put("_cascadingFieldChild", fs[2] + SPLITER + fs[3]);
fieldElement.addAttribute("extra-attrs", extraAttrs.toJSONString());
}
// FIXME v35 多个子级(使用 ; 分割)
}

if (log.isDebugEnabled()) XmlHelper.dump(rootElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.util.Set;

/**
* FIXME 异步发送可能失败,日志表未记录
*
* @author devezhao [email protected]
* @since 2019/05/25
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public String parseRef(String content, String cascadingValue) {
// 可能同时存在父子级
String cascadingFieldParent = field.getExtraAttrs().getString("_cascadingFieldParent");
String cascadingFieldChild = field.getExtraAttrs().getString("_cascadingFieldChild");
// v35 多个使用第一个
if (cascadingFieldChild != null) cascadingFieldChild = cascadingFieldChild.split(";")[0];

ID cascadingValueId = ID.valueOf(cascadingValue);
List<String> parentAndChind = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ private void doParseIfNeed() {

// append: QuickQuery
JSONObject quickFilter = queryExpr.getJSONObject("filter");
if (ParseHelper.validAdvFilter(quickFilter)) {
if (quickFilter != null) {
String where = new AdvFilterParser(quickFilter, entity).toSqlWhere();
if (StringUtils.isNotBlank(where)) wheres.add(where);
}
// v3.3
JSONObject quickFilterAnd = queryExpr.getJSONObject("filterAnd");
if (ParseHelper.validAdvFilter(quickFilterAnd)) {
if (quickFilterAnd != null) {
String where = new AdvFilterParser(quickFilterAnd, entity).toSqlWhere();
if (StringUtils.isNotBlank(where)) wheres.add(where);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rebuild/web/admin/ConfigCommons.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static Object[][] queryListOfConfig(String sql, String belongEntity, Stri
Object[][] array = Application.createQuery(sql).setLimit(500).array();
for (Object[] o : array) {
o[2] = EasyMetaFactory.getLabel(MetadataHelper.getEntity((String) o[2]));
o[5] = I18nUtils.formatDate((Date) o[5]);
if (o[5] instanceof Date) o[5] = I18nUtils.formatDate((Date) o[5]);
}
return array;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public ModelAndView pageList(@PathVariable String entity, HttpServletRequest req
paneFields.add(EasyMetaFactory.valueOf(listEntity.getField(field)).toJSON());
}
}
mv.getModel().put("paneFields", paneFields);

if (!paneFields.isEmpty()) mv.getModel().put("paneFields", paneFields);
}

// 查询页签 v3.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void redirect(@IdParam ID anyId, HttpServletRequest request, HttpServletR

} else if (MetadataHelper.isBusinessEntity(entity)) {
if ("dock".equalsIgnoreCase(type)) {
url = String.format("entity/view/{%s", anyId);
url = String.format("entity/view?id=%s", anyId);
} else if ("newtab".equalsIgnoreCase(type)) {
url = String.format("%s/view/%s", entity.getName(), anyId);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/admin/system-cfg.html
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ <h5>[[${bundle.L('其他')}]]</h5>
</tr>
</tbody>
</table>
<input type="file" class="hide file_4image" accept="image/*" data-maxsize="10485760" data-local="true" data-noname="true" />
<input type="file" class="hide file_4image" accept="image/*" data-maxsize="104857600" data-local="true" data-noname="true" />
<input type="file" class="hide file_MobileAppPath" accept=".apk,.ipa" />
<div class="edit-footer">
<button class="btn btn-link" type="button">[[${bundle.L('取消')}]]</button>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/web/assets/css/rb-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,8 @@ a.link.link-icon::after {
margin-right: -1px !important;
}

.type-DECIMAL em.vflag {
.type-DECIMAL em.vflag,
.type-LOCATION em.vflag {
position: absolute;
right: 10px;
top: 10px;
Expand Down Expand Up @@ -3136,6 +3137,7 @@ form {
margin-left: 10px;
font-weight: bold;
line-height: 20px;
text-transform: none;
}

.page-head-title .sub-title::before {
Expand Down
45 changes: 28 additions & 17 deletions src/main/resources/web/assets/js/admin/syscfg-g.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,42 @@ useEditComp = function (name) {
)
} else if ('MobileAppPath' === name) {
setTimeout(() => {
$initUploader($('.file_MobileAppPath'), null, (res) => {
$('#_MobileAppPath a').text($fileCutName(res.key))
changeValue({ target: { name: 'MobileAppPath', value: res.key } })
})
$initUploader(
$('.file_MobileAppPath'),
(res) => {
let $span = $('.btn_MobileAppPath span')
if (!$span[0]) $span = $('<span></span>').appendTo('.btn_MobileAppPath')
$span.text(` (${res.percent.toFixed(0)}%)`)
},
(res) => {
$('#_MobileAppPath a:eq(0)').text($fileCutName(res.key))
changeValue({ target: { name: 'MobileAppPath', value: res.key } })
setTimeout(() => $('.btn_MobileAppPath span').remove(), 1000)
}
)
}, 1000)

return (
<RF>
<button className="btn btn-light btn-sm btn_MobileAppPath" type="button" onClick={() => $('.file_MobileAppPath')[0].click()}>
<i className="icon zmdi zmdi-upload"></i> {$L('上传')}
</button>
<a className="ml-1" href={`${rb.baseUrl}/h5app-download`} target="_blank">
{val_MobileAppPath ? $fileCutName(val_MobileAppPath) : null}
</a>
{val_MobileAppPath && (
<a
title={$L('移除')}
className="ml-1"
onClick={() => {
$('#_MobileAppPath a').text('')
changeValue({ target: { name: 'MobileAppPath', value: null } })
}}>
<i className="mdi mdi-close" />
<span className="d-inline-block down-2">
<a className="ml-1" href={`${rb.baseUrl}/h5app-download`} target="_blank">
{val_MobileAppPath ? $fileCutName(val_MobileAppPath) : null}
</a>
)}
{val_MobileAppPath && (
<a
title={$L('移除')}
className="ml-1"
onClick={() => {
$('#_MobileAppPath a').text('')
changeValue({ target: { name: 'MobileAppPath', value: null } })
}}>
<i className="mdi mdi-close" />
</a>
)}
</span>
</RF>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/js/rb-datalist.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ const CellRenders = {
} else if (parent && parent.RbViewModal) {
parent.RbViewModal.create({ id: v.id, entity: v.entity }, wpc.forceSubView)
} else {
window.open(`${rb.baseUrl}/app/redirect?id=${v.id}`)
window.open(`${rb.baseUrl}/app/redirect?id=${v.id}&type=newtab`)
}
e && $stopEvent(e, true)
return false
Expand Down
26 changes: 22 additions & 4 deletions src/main/resources/web/assets/js/rb-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2472,9 +2472,25 @@ class RbFormAvatar extends RbFormElement {
}

class RbFormLocation extends RbFormElement {
constructor(props) {
super(props)
this._autoLocation = props.locationAutoLocation && props.$$$parent.isNew && !props.value
}

renderElement() {
const lnglat = this._parseLnglat(this.state.value)
if (this.props.readonly) return super.renderElement(lnglat ? lnglat.text : null)
if (this.props.readonly) {
return (
<RF>
{super.renderElement(lnglat ? lnglat.text : null)}
{this._autoLocation && (
<em className="vflag">
<i className="zmdi zmdi-pin-drop flash infinite slow fs-14" ref={(c) => (this._$icon = c)} />
</em>
)}
</RF>
)
}

return (
<div className="input-group has-append">
Expand All @@ -2489,6 +2505,7 @@ class RbFormLocation extends RbFormElement {
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('清除')} />
<div className="input-group-append">
<button className="btn btn-secondary" type="button" onClick={() => this._showMap(lnglat)}>
Expand Down Expand Up @@ -2570,14 +2587,15 @@ class RbFormLocation extends RbFormElement {
componentDidMount() {
super.componentDidMount()

const props = this.props
if (props.locationAutoLocation && props.$$$parent.isNew && !props.value) {
if (this._autoLocation) {
$(this._$icon).addClass('animated')
// eslint-disable-next-line no-undef
$autoLocation((v) => {
$(this._$icon).removeClass('animated')
v = v && v.text ? `${v.text}$$$$${v.lng},${v.lat}` : null
v && this.handleChange({ target: { value: v } }, true)

if (this.props.readonly) $(this._$icon).remove()
else $(this._$icon).removeClass('animated')
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/general/reference-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
if (parent && parent.RbViewModal && parent.RbViewModal.mode === 1) {
parent.RbViewModal.create({ id: v.id, entity: v.entity })
} else {
const openUrl = `${rb.baseUrl}/app/redirect?id=${v.id}&type=dock`
const openUrl = `${rb.baseUrl}/app/redirect?id=${v.id}&type=newtab`
window.open(openUrl, '_blank')
}
e && $stopEvent(e)
Expand Down

0 comments on commit 6ddfd6e

Please sign in to comment.