Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e31f49

Browse files
authoredNov 2, 2024··
Fix 3.8.4 (#824)
* fix: * fix:引用明细实体禁止快速新建 * enh:列表模版排序 * be:style * .startup * brk:高级控制视图下也有效 * 3.8.4
1 parent b0d02d7 commit 5e31f49

File tree

14 files changed

+74
-21
lines changed

14 files changed

+74
-21
lines changed
 

‎@rbv‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit fee47408a07d130bf3791095b77dbe5a54786421
1+
Subproject commit 49ccf618ee3871d85ee4c3bac3dc9350bc87cfc8

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.rebuild</groupId>
1212
<artifactId>rebuild</artifactId>
13-
<version>3.8.3</version>
13+
<version>3.8.4</version>
1414
<name>rebuild</name>
1515
<description>Building your business-systems freely!</description>
1616
<url>https://getrebuild.com/</url>

‎src/main/java/com/rebuild/core/Application.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
7474
/**
7575
* Rebuild Version
7676
*/
77-
public static final String VER = "3.8.3";
77+
public static final String VER = "3.8.4";
7878
/**
7979
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
8080
*/
81-
public static final int BUILD = 3080308;
81+
public static final int BUILD = 3080408;
8282

8383
static {
8484
// Driver for DB

‎src/main/java/com/rebuild/core/ServerStatus.java‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
import cn.devezhao.commons.CodecUtils;
1212
import cn.devezhao.commons.ThrowableUtils;
1313
import com.rebuild.core.cache.CommonsCache;
14+
import com.rebuild.core.support.RebuildConfiguration;
1415
import com.rebuild.core.support.setup.Installer;
1516
import lombok.extern.slf4j.Slf4j;
1617
import org.apache.commons.io.FileUtils;
1718
import org.apache.commons.io.IOUtils;
1819
import org.apache.commons.lang.StringUtils;
1920

2021
import java.io.File;
22+
import java.io.IOException;
2123
import java.io.RandomAccessFile;
24+
import java.nio.charset.StandardCharsets;
2225
import java.sql.Connection;
2326
import java.sql.DriverManager;
2427
import java.util.ArrayList;
@@ -42,7 +45,7 @@ public final class ServerStatus {
4245
/**
4346
* 启动实例标识
4447
*/
45-
public static final String STARTUP_ONCE = CodecUtils.randomCode(40);
48+
public static final String STARTUP_ONCE = genStartupOnce();
4649

4750
private static long LastCheckTime = 0;
4851
private static final List<Status> LAST_STATUS = new ArrayList<>();
@@ -164,6 +167,23 @@ static Status checkCacheService() {
164167
return Status.success(name);
165168
}
166169

170+
private static String genStartupOnce() {
171+
File once = RebuildConfiguration.getFileOfTemp(".startup");
172+
String onceToken;
173+
try {
174+
if (once.exists()) {
175+
onceToken = FileUtils.readFileToString(once, StandardCharsets.UTF_8);
176+
} else {
177+
onceToken = CodecUtils.randomCode(32);
178+
FileUtils.writeStringToFile(once, onceToken, StandardCharsets.UTF_8);
179+
}
180+
} catch (Exception ignored) {
181+
onceToken = CodecUtils.randomCode(32);
182+
}
183+
// 32+8
184+
return onceToken + CodecUtils.randomCode(8);
185+
}
186+
167187
// 状态
168188
public static class Status {
169189
final public String name;

‎src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ else if (viewMode) {
241241
}
242242
}
243243

244-
buildModelElements(elements, entityMeta, recordData, user, viewMode, !viewMode);
244+
buildModelElements(elements, entityMeta, recordData, user, viewMode, true);
245245

246246
if (elements.isEmpty()) {
247247
return formatModelError(Language.L("此表单布局尚未配置,请配置后使用"));
@@ -343,8 +343,8 @@ private ApprovalState getHadApproval(Entity entity, ID recordId) {
343343
* @param entity
344344
* @param recordData
345345
* @param user
346-
* @param viewModel
347-
* @param useAdvControl
346+
* @param viewModel 是否视图
347+
* @param useAdvControl 是否使用表单高级控制
348348
*/
349349
protected void buildModelElements(JSONArray elements, Entity entity, Record recordData, ID user, boolean viewModel, boolean useAdvControl) {
350350
final User formUser = Application.getUserStore().getUser(user);
@@ -385,22 +385,26 @@ protected void buildModelElements(JSONArray elements, Entity entity, Record reco
385385
}
386386

387387
// v2.2 高级控制
388-
if (viewModel) useAdvControl = false;
388+
// v3.8.4 视图下也有效(单字段编辑也算编辑)
389389
if (useAdvControl) {
390-
final Object displayOnCreate = el.remove("displayOnCreate");
391-
final Object displayOnUpdate = el.remove("displayOnUpdate");
390+
Object displayOnCreate = el.remove("displayOnCreate");
391+
Object displayOnUpdate = el.remove("displayOnUpdate");
392392
final Object requiredOnCreate = el.remove("requiredOnCreate");
393393
final Object requiredOnUpdate = el.remove("requiredOnUpdate");
394394
final Object readonlyOnCreate = el.remove("readonlyOnCreate");
395395
final Object readonlyOnUpdate = el.remove("readonlyOnUpdate");
396-
397396
// fix v3.3.4 跟随主记录新建/更新
398397
boolean isNew2 = isNew;
399398
if (entity.getMainEntity() != null) {
400399
ID fromMain = FormsBuilderContextHolder.getMainIdOfDetail(false);
401400
isNew2 = EntityHelper.isUnsavedId(fromMain);
402401
}
403402

403+
// 视图下忽略此选项
404+
if (viewModel) {
405+
displayOnCreate = true;
406+
displayOnUpdate = true;
407+
}
404408
// 显示
405409
if (displayOnCreate != null && !(Boolean) displayOnCreate && isNew2) {
406410
iter.remove();
@@ -410,15 +414,13 @@ protected void buildModelElements(JSONArray elements, Entity entity, Record reco
410414
iter.remove();
411415
continue;
412416
}
413-
414417
// 必填
415418
if (requiredOnCreate != null && (Boolean) requiredOnCreate && isNew2) {
416419
el.put("nullable", false);
417420
}
418421
if (requiredOnUpdate != null && (Boolean) requiredOnUpdate && !isNew2) {
419422
el.put("nullable", false);
420423
}
421-
422424
// 只读 v3.6
423425
if (readonlyOnCreate != null && (Boolean) readonlyOnCreate && isNew2) {
424426
el.put("readonly", true);

‎src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ protected Map<String, Object> buildData(Record record, Map<String, String> varsM
381381
// Keep Type
382382
} else if (dt == DisplayType.DECIMAL) {
383383
String format = easyField.getExtraAttr(EasyFieldConfigProps.DECIMAL_FORMAT);
384-
int scale = StringUtils.isBlank(format) ? 2 : format.split("\\.")[1].length();
384+
int scale = format.split("\\.").length == 1 ? 0
385+
: StringUtils.isBlank(format) ? 2 : format.split("\\.")[1].length();
385386
// Keep Type
386387
fieldValue = ((BigDecimal) fieldValue).setScale(scale, RoundingMode.HALF_UP);
387388
} else {

‎src/main/java/com/rebuild/core/service/datareport/EasyExcelListGenerator.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ protected Map<String, List<Map<String, Object>>> buildData() {
7474
if (validFields.isEmpty()) return Collections.emptyMap();
7575

7676
queryData.put("fields", validFields); // 使用模板字段
77+
// v3.8.4 优先使用模版中指定的排序
78+
if (varsExtractor.getListTypeSortFields() != null) queryData.put("sort", varsExtractor.getListTypeSortFields());
7779

7880
QueryParser queryParser = new QueryParser(queryData);
7981
int[] limits = queryParser.getSqlLimit();

‎src/main/java/com/rebuild/core/service/datareport/TemplateExtractor.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class TemplateExtractor {
6161
final protected File templateFile;
6262
final private boolean isListType;
6363

64+
private Set<String> listTypeSortFields = new LinkedHashSet<>();
65+
6466
/**
6567
* @param template
6668
*/
@@ -99,6 +101,17 @@ public Map<String, String> transformVars(Entity entity) {
99101
if (thatName.startsWith(NROW_PREFIX)) {
100102
String listField = thatName.substring(1);
101103

104+
// v3.8.4
105+
if (isListType) {
106+
if (listField.endsWith(TemplateExtractor33.SORT_ASC)) {
107+
listTypeSortFields.add(listField);
108+
listField = listField.substring(0, listField.length() - 4);
109+
} else if (listField.endsWith(TemplateExtractor33.SORT_DESC)) {
110+
listTypeSortFields.add(listField);
111+
listField = listField.substring(0, listField.length() - 5);
112+
}
113+
}
114+
102115
// 审批流程
103116
if (!this.isListType && thatName.startsWith(APPROVAL_PREFIX)) {
104117
String stepNodeField = listField.substring(APPROVAL_PREFIX.length());
@@ -206,4 +219,13 @@ private Field findFieldByLabel(Entity entity, String fieldLabel) {
206219
}
207220
return null;
208221
}
222+
223+
/**
224+
* 列表模版指定排序
225+
*
226+
* @return
227+
*/
228+
protected String getListTypeSortFields() {
229+
return listTypeSortFields.isEmpty() ? null : StringUtils.join(listTypeSortFields, ";");
230+
}
209231
}

‎src/main/java/com/rebuild/core/service/datareport/TemplateExtractor33.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public class TemplateExtractor33 extends TemplateExtractor {
4242
public static final String DETAIL_PREFIX2 = NROW_PREFIX2 + "detail";
4343
public static final String APPROVAL_PREFIX2 = NROW_PREFIX2 + "approval";
4444
// 排序
45-
private static final String SORT_ASC = ":asc";
46-
private static final String SORT_DESC = ":desc";
45+
protected static final String SORT_ASC = ":asc";
46+
protected static final String SORT_DESC = ":desc";
4747

4848
private Map<String, String> sortFields = new HashMap<>();
4949
private Set<String> inShapeVars = new HashSet<>();

‎src/main/java/com/rebuild/web/admin/metadata/MetaFieldController.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public ModelAndView pageEntityField(@PathVariable String entity, @PathVariable S
143143
Entity refEntity = fieldMeta.getReferenceEntity();
144144
mv.getModel().put("fieldRefentity", refEntity.getName());
145145
mv.getModel().put("fieldRefentityLabel", EasyMetaFactory.getLabel(refEntity));
146+
mv.getModel().put("fieldRefentityIsDetail", refEntity.getMainEntity() != null);
146147
}
147148

148149
if (ft == FieldType.REFERENCE && !easyField.isBuiltin()) {

‎src/main/resources/web/admin/metadata/field-edit.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right pt-1">[[${bundle.L('启用快速新建')}]]</label>
107107
<div class="col-md-12 col-xl-6 col-lg-8">
108108
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
109-
<input class="custom-control-input" type="checkbox" id="referenceQuickNew" />
109+
<input class="custom-control-input" type="checkbox" id="referenceQuickNew" th:disabled="${fieldRefentityIsDetail}" />
110110
<span class="custom-control-label">[[${bundle.L('是')}]]</span>
111111
</label>
112112
</div>

‎src/main/resources/web/assets/js/general/rb-forms.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,9 +2603,9 @@ class RbFormBarcode extends RbFormElement {
26032603
title={this.state.value}
26042604
onClick={() => {
26052605
RbAlert.create(
2606-
<div className="mb-4">
2606+
<div className="mb-3 text-center">
26072607
<img src={`${codeUrl}&w=${isbar ? 64 * 2 : 80 * 3}`} alt={this.state.value} style={{ maxWidth: '100%' }} />
2608-
{!isbar && <div className="text-muted mt-3 mb-1 text-break">{this.state.value}</div>}
2608+
{!isbar && <div className="text-muted mt-2 mb-1 text-break text-bold">{this.state.value}</div>}
26092609
</div>,
26102610
{
26112611
type: 'clear',

‎src/main/resources/web/assets/js/metadata/field-edit.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ $(document).ready(function () {
6262
$('#fileSuffix').val($(this).data('suff'))
6363
})
6464
}
65+
// fix:v3.8.4
66+
if ($('#referenceQuickNew').attr('disabled')) {
67+
console.log($('#referenceQuickNew').attr('disabled'))
68+
$('#referenceQuickNew')[0].checked = false
69+
}
6570

6671
const $btn = $('.J_save').on('click', function () {
6772
if (!wpc.metaId) return

‎src/main/resources/web/assets/js/rb-components.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class RbAlert extends React.Component {
267267
<span className="zmdi zmdi-close" />
268268
</button>
269269
</div>
270-
<div className="modal-body">{this.renderContent()}</div>
270+
<div className="modal-body">{this.props.type === 'clear' ? this.props.message : this.renderContent()}</div>
271271
</div>
272272
</div>
273273
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.