Skip to content

Commit

Permalink
feat:easyfilter (#856)
Browse files Browse the repository at this point in the history
* style

* fix: 列表排序加AUTOID

* enh: 实体索引

* feat: easyfilter
  • Loading branch information
getrebuild authored Jan 9, 2025
1 parent 89dd151 commit 3695a5f
Show file tree
Hide file tree
Showing 19 changed files with 339 additions and 99 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from cb281b to 401838
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ else if (viewMode) {
// v3.7
model.set("hadSop", true);

model.remove("id"); // Clean form's ID of config
model.set("layoutId", model.getID("id"));
model.remove("id");
return model.toJSON();
}

Expand Down Expand Up @@ -392,45 +393,51 @@ protected void buildModelElements(JSONArray elements, Entity entity, Record reco
// v2.2 高级控制
// v3.8.4 视图下也有效(单字段编辑也算编辑)
if (useAdvControl) {
Object displayOnCreate = el.remove("displayOnCreate");
Object displayOnUpdate = el.remove("displayOnUpdate");
Object hiddenOnCreate = el.remove("hiddenOnCreate");
Object hiddenOnUpdate = el.remove("hiddenOnUpdate");
if (hiddenOnCreate == null) {
Object displayOnCreate39 = el.remove("displayOnCreate");
Object displayOnUpdate39 = el.remove("displayOnUpdate");
if (displayOnCreate39 != null && !(Boolean) displayOnCreate39) hiddenOnCreate = true;
if (displayOnUpdate39 != null && !(Boolean) displayOnUpdate39) hiddenOnUpdate = true;
}
final Object requiredOnCreate = el.remove("requiredOnCreate");
final Object requiredOnUpdate = el.remove("requiredOnUpdate");
final Object readonlyOnCreate = el.remove("readonlyOnCreate");
final Object readonlyOnUpdate = el.remove("readonlyOnUpdate");
// fix v3.3.4 跟随主记录新建/更新
boolean isNew2 = isNew;
boolean isNewState = isNew;
if (entity.getMainEntity() != null) {
ID fromMain = FormsBuilderContextHolder.getMainIdOfDetail(false);
isNew2 = EntityHelper.isUnsavedId(fromMain);
isNewState = EntityHelper.isUnsavedId(fromMain);
}

// 视图下忽略此选项
if (viewModel) {
displayOnCreate = true;
displayOnUpdate = true;
hiddenOnCreate = false;
hiddenOnUpdate = false;
}
// 显示
if (displayOnCreate != null && !(Boolean) displayOnCreate && isNew2) {
// 隐藏 v4.0
if (hiddenOnCreate != null && (Boolean) hiddenOnCreate && isNewState) {
iter.remove();
continue;
}
if (displayOnUpdate != null && !(Boolean) displayOnUpdate && !isNew2) {
if (hiddenOnUpdate != null && (Boolean) hiddenOnUpdate && !isNewState) {
iter.remove();
continue;
}
// 必填
if (requiredOnCreate != null && (Boolean) requiredOnCreate && isNew2) {
if (requiredOnCreate != null && (Boolean) requiredOnCreate && isNewState) {
el.put("nullable", false);
}
if (requiredOnUpdate != null && (Boolean) requiredOnUpdate && !isNew2) {
if (requiredOnUpdate != null && (Boolean) requiredOnUpdate && !isNewState) {
el.put("nullable", false);
}
// 只读 v3.6
if (readonlyOnCreate != null && (Boolean) readonlyOnCreate && isNew2) {
if (readonlyOnCreate != null && (Boolean) readonlyOnCreate && isNewState) {
el.put("readonly", true);
}
if (readonlyOnUpdate != null && (Boolean) readonlyOnUpdate && !isNew2) {
if (readonlyOnUpdate != null && (Boolean) readonlyOnUpdate && !isNewState) {
el.put("readonly", true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
* 创建实体
*
Expand Down Expand Up @@ -271,7 +274,9 @@ private Field createBuiltinField(Entity entity, String fieldName, String fieldLa
*/
private boolean schema2Database(Entity entity) {
Dialect dialect = Application.getPersistManagerFactory().getDialect();
Table table = new Table40(entity, dialect);
List<String> ixs = Arrays.asList(
EntityHelper.QuickCode, EntityHelper.OwningUser, EntityHelper.OwningDept, EntityHelper.CreatedOn, EntityHelper.ModifiedOn);
Table table = new Table40(entity, dialect, ixs);
String[] ddls = table.generateDDL(false, false, false);

try {
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/rebuild/core/metadata/impl/Table40.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.dialect.Dialect;
import cn.devezhao.persist4j.util.XmlHelper;
import cn.devezhao.persist4j.util.support.Table;
import org.dom4j.Element;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -23,11 +26,23 @@
public class Table40 extends Table {

public Table40(Entity entity, Dialect dialect) {
super(entity, dialect);
this(entity, dialect, null);
}

public Table40(Entity entity, Dialect dialect, List<?> indexList) {
super(entity, dialect, indexList);
public Table40(Entity entity, Dialect dialect, List<String> indexFields) {
super(entity, dialect, buildIndexList(indexFields));
}

private static List<Element> buildIndexList(List<String> indexFields) {
if (indexFields == null || indexFields.isEmpty()) return null;

List<Element> ixs = new ArrayList<>();
for (String indexField : indexFields) {
Element ix = XmlHelper.createDom4jElement("index");
ix.addAttribute("field-list", indexField);
ixs.add(ix);
}
return ixs;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class ParseHelper {
* @param token
* @return
*/
protected static String convetOperation(String token) {
public static String convetOperation(String token) {
if (EQ.equalsIgnoreCase(token)) {
return "=";
} else if (NEQ.equalsIgnoreCase(token)) {
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/rebuild/core/support/general/QueryParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,28 @@ private void doParseIfNeed() {
if (StringUtils.isNotBlank(where)) wheres.add(where);
}

final String sqlWhere = wheres.isEmpty() ? "1=1" : StringUtils.join(wheres.iterator(), " and ");
fullSql.append(" where ").append(sqlWhere);
final String whereClause = wheres.isEmpty() ? "1=1" : StringUtils.join(wheres.iterator(), " and ");
fullSql.append(" where ").append(whereClause);

// 排序

String sortNode = queryExpr.getString("sort");
String sortSql = null;
String sortClause = null;
if (StringUtils.isNotBlank(sortNode)) {
sortSql = parseSort(sortNode);
sortClause = parseSort(sortNode);
} else if (entity.containsField(EntityHelper.ModifiedOn)) {
sortSql = EntityHelper.ModifiedOn + " desc";
sortClause = EntityHelper.ModifiedOn + " desc";
} else if (entity.containsField(EntityHelper.CreatedOn)) {
sortSql = EntityHelper.CreatedOn + " desc";
sortClause = EntityHelper.CreatedOn + " desc";
}
if (StringUtils.isNotBlank(sortClause)) {
fullSql.append(" order by ").append(sortClause);
// v3.9.1
if (!sortClause.contains(" autoId") && entity.containsField(EntityHelper.AutoId)) fullSql.append(", autoId");
}
if (StringUtils.isNotBlank(sortSql)) fullSql.append(" order by ").append(sortSql);

this.sql = fullSql.toString();
this.countSql = this.buildCountSql(pkName) + sqlWhere;
this.countSql = this.buildCountSql(pkName) + whereClause;

int pageNo = NumberUtils.toInt(queryExpr.getString("pageNo"), 1);
int pageSize = NumberUtils.toInt(queryExpr.getString("pageSize"), 40);
Expand Down
53 changes: 24 additions & 29 deletions src/main/resources/web/admin/bizuser/role-privileges.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,33 @@
padding: 10px 0 5px;
text-align: right;
}
.table.table-priv td > a.cp {
.table.table-priv td > a.cp,
.name > span > a {
position: absolute;
left: 50%;
margin-left: 15px;
margin-top: 1px;
font-size: 16px;
margin-top: 2px;
font-size: 15px;
color: #999;
display: none;
}
.table.table-priv tr:hover > td > a.cp,
.table.table-priv td > a.cp.active {
.table.table-priv td > a.cp.active,
.name > span > a.active,
.table.table-priv tr:hover .name > span > a {
display: inline-block;
}
.table.table-priv td > a.cp.active,
.table.table-priv td > a.cp:hover {
color: #4285f4;
.table.table-priv td > a.cp:hover,
.name > span > a.active,
.name > span > a:hover {
color: #4285f4 !important;
}
.name > span > a {
font-size: 16px;
left: unset;
margin-left: 10px;
margin-top: -2px;
}

.nav-tabs li {
Expand All @@ -99,22 +110,6 @@
font-weight: normal;
line-height: 1.2;
}

.name > span > a {
font-size: 18px;
position: absolute;
margin-left: 6px;
margin-top: -3px;
display: none;
}
.name > span > a.active,
.name > span > a:hover {
color: #4285f4 !important;
}
.name > span > a.active,
.table.table-priv tr:hover .name > span > a {
display: inline-block;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -178,30 +173,30 @@
<tr th:each="entity : ${Entities}">
<td class="name">
<a th:data-entity="${entity[1]}" th:data-name="${entity[0]}" th:title="${bundle.L('批量选择')}">[[${entity[2]}]]</a>
<span class="bosskey-show">
<a th:data-entity="${entity[1]}" th:title="${bundle.L('字段权限')}"><i class="mdi mdi-playlist-edit"></i></a>
<span>
<a th:data-entity="${entity[1]}" th:title="${bundle.L('字段权限')}"><i class="mdi mdi-filter-variant-remove"></i></a>
</span>
</td>
<td><i data-action="C" class="priv R0"></i><a></a></td>
<td>
<i data-action="R" class="priv R0"></i>
<a data-action="R9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter"></i></a>
<a data-action="R9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter-cog-outline"></i></a>
</td>
<td>
<i data-action="U" class="priv R0"></i>
<a data-action="U9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter"></i></a>
<a data-action="U9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter-cog-outline"></i></a>
</td>
<td>
<i data-action="D" class="priv R0"></i>
<a data-action="D9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter"></i></a>
<a data-action="D9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter-cog-outline"></i></a>
</td>
<td>
<i data-action="A" class="priv R0"></i>
<a data-action="A9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter"></i></a>
<a data-action="A9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter-cog-outline"></i></a>
</td>
<td>
<i data-action="S" class="priv R0"></i>
<a data-action="S9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter"></i></a>
<a data-action="S9" class="cp" th:title="${bundle.L('自定义权限')}"><i class="mdi mdi-filter-cog-outline"></i></a>
</td>
</tr>
</tbody>
Expand Down
10 changes: 7 additions & 3 deletions src/main/resources/web/admin/metadata/form-design.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<thead>
<tr>
<th>[[${bundle.L('字段')}]]</th>
<th>[[${bundle.L('显示')}]]</th>
<th>[[${bundle.L('隐藏')}]]</th>
<th>
<span class="d-inline-block">[[${bundle.L('必填')}]] <i class="zmdi zmdi-help zicon up-2" data-toggle="tooltip" th:title="${bundle.L('本选项仅针对表单有效')}"></i></span>
</th>
Expand All @@ -101,13 +101,14 @@
<td>TEMPLATE</td>
<td>
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline">
<input class="custom-control-input" type="checkbox" name="displayOnCreate" checked />
<input class="custom-control-input" type="checkbox" name="hiddenOnCreate" />
<span class="custom-control-label">[[${bundle.L('新建时')}]]</span>
</label>
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline">
<input class="custom-control-input" type="checkbox" name="displayOnUpdate" checked />
<input class="custom-control-input" type="checkbox" name="hiddenOnUpdate" />
<span class="custom-control-label">[[${bundle.L('编辑时')}]]</span>
</label>
<a class="easy-control" data-type="hidden"><i class="icon mdi mdi-filter-cog-outline"></i></a>
</td>
<td>
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline">
Expand All @@ -118,6 +119,7 @@
<input class="custom-control-input" type="checkbox" name="requiredOnUpdate" />
<span class="custom-control-label">[[${bundle.L('编辑时')}]]</span>
</label>
<a class="easy-control" data-type="required"><i class="icon mdi mdi-filter-cog-outline"></i></a>
</td>
<td>
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline">
Expand All @@ -128,6 +130,7 @@
<input class="custom-control-input" type="checkbox" name="readonlyOnUpdate" />
<span class="custom-control-label">[[${bundle.L('编辑时')}]]</span>
</label>
<a class="easy-control" data-type="readonly"><i class="icon mdi mdi-filter-cog-outline"></i></a>
</td>
</tr>
</tbody>
Expand All @@ -152,6 +155,7 @@
</script>
<script th:src="@{/assets/js/metadata/entity-switch.js}" type="text/babel"></script>
<script th:src="@{/assets/js/general/rb-advfilter.js}" type="text/babel"></script>
<script th:src="@{/assets/js/general/rb-easyfilter.js}" type="text/babel"></script>
<script th:src="@{/assets/js/metadata/field-type.js}" type="text/babel"></script>
<script th:src="@{/assets/js/metadata/field-new2.js}" type="text/babel"></script>
<script th:src="@{/assets/js/metadata/form-design.js}" type="text/babel"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/admin/robot/trigger-design.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
</form>
</div>
</li>
<li class="timeline-item">
<li class="timeline-item exec">
<div class="timeline-date"><span>[[${bundle.L('就执行操作')}]]</span></div>
<div class="timeline-content">
<form class="simple">
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/web/assets/css/approvals.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ See LICENSE and COMMERCIAL in the project root for license information.
padding: 4px 20px;
}

#config-side .adv-filter-wrap .alert.alert-warning {
padding: 0;
margin-bottom: 20px;
}

#config-side .footer,
#config-side .adv-filter-option .btn-footer {
position: absolute;
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/web/assets/css/form-design.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,24 @@ form.field-attr label > span {
.table.table-p .custom-control {
padding-left: 1.9377rem;
margin-right: 1.385rem;
padding-left: 22px;
margin-right: 12px;
}

.table.table-p a.easy-control {
font-size: 15px;
color: #999;
display: none;
}

.table.table-p tr:hover a.easy-control {
display: inline-block;
}

.table.table-p a.easy-control:hover,
.table.table-p a.easy-control.active {
color: #4285f4;
display: inline-block;
}

.type-list .dd-handle {
Expand Down
Loading

0 comments on commit 3695a5f

Please sign in to comment.