This commit is contained in:
devezhao 2019-03-28 18:18:00 +08:00
parent 8c59532537
commit 2ec7567336
32 changed files with 204 additions and 27 deletions

View file

@ -241,7 +241,7 @@ public abstract class ChartData {
DisplayType axisType = axisField.getDisplayType();
String label = null;
if (axisType == DisplayType.PICKLIST) {
if (axisType == DisplayType.PICKLIST) { // TODO CLASSIFICATION
label = PickListManager.getLabel((ID) value);
} else if (axisType == DisplayType.REFERENCE) {
label = FieldValueWrapper.getLabel((ID) value);

View file

@ -203,7 +203,7 @@ public class DataImporter extends BulkTask {
return cell.asDouble();
} else if (dt == DisplayType.DATE || dt == DisplayType.DATETIME) {
return checkoutDateValue(field, cell);
} else if (dt == DisplayType.PICKLIST) {
} else if (dt == DisplayType.PICKLIST) { // TODO CLASSIFICATION
return checkoutPickListValue(field, cell);
} else if (dt == DisplayType.REFERENCE) {
return checkoutReferenceValue(field, cell);

View file

@ -211,6 +211,8 @@ public class Field2Schema {
if (displayType == DisplayType.PICKLIST) {
refEntity = "PickList";
} else if (displayType == DisplayType.CLASSIFICATION) {
refEntity = "ClassificationData";
}
if (StringUtils.isNotBlank(refEntity)) {
record.setString("refEntity", refEntity);

View file

@ -0,0 +1,29 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.portals;
/**
* TODO
*
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/28
*/
public class ClassificationManager implements PortalsManager {
}

View file

@ -204,7 +204,7 @@ public class FormsManager extends BaseLayoutManager {
int dateLength = -1;
if (dt == DisplayType.PICKLIST) {
if (dt == DisplayType.PICKLIST) { // TODO CLASSIFICATION
JSONArray options = PickListManager.getPickList(fieldMeta);
el.put("options", options);
}
@ -342,7 +342,7 @@ public class FormsManager extends BaseLayoutManager {
if (data.hasValue(fieldName)) {
Object value = data.getObjectValue(fieldName);
DisplayType dt = field.getDisplayType();
if (dt == DisplayType.PICKLIST) {
if (dt == DisplayType.PICKLIST) { // TODO CLASSIFICATION
ID pickValue = (ID) value;
return onView ? pickValue.getLabel() : pickValue.toLiteral();
}

View file

@ -138,7 +138,7 @@ public class JSONQueryParser {
StringBuffer sqlBase = new StringBuffer("select ");
for (Field field : fieldList) {
if (EasyMeta.getDisplayType(field) == DisplayType.PICKLIST) {
if (EasyMeta.getDisplayType(field) == DisplayType.PICKLIST) { // TODO CLASSIFICATION
sqlBase.append('&');
}
sqlBase.append(field.getName()).append(',');

View file

@ -77,7 +77,7 @@ public class FieldValueWrapper {
return wrapDecimal(value, field);
} else if (dt == DisplayType.REFERENCE) {
return wrapReference(value, field);
} else if (dt == DisplayType.PICKLIST || dt == DisplayType.IMAGE || dt == DisplayType.FILE || dt == DisplayType.LOCATION) {
} else if (dt == DisplayType.PICKLIST || dt == DisplayType.IMAGE || dt == DisplayType.FILE || dt == DisplayType.LOCATION) { // TODO CLASSIFICATION
// 无需处理
return value;
} else if (dt == DisplayType.BOOL) {

View file

@ -130,7 +130,7 @@ public class QuickCodeReindexTask extends BulkTask {
String nameVal = null;
if (dt == DisplayType.TEXT) {
nameVal = record.getString(nameField.getName());
} else if (dt == DisplayType.PICKLIST) {
} else if (dt == DisplayType.PICKLIST) { // TODO CLASSIFICATION
ID plid = record.getID(nameField.getName());
nameVal = PickListManager.getLabel(plid);
}

View file

@ -183,7 +183,7 @@ public class AdvFilterParser {
}
DisplayType fieldType = EasyMeta.getDisplayType(fieldMeta);
if (fieldType == DisplayType.PICKLIST || hasAndFlag) {
if (fieldType == DisplayType.PICKLIST || hasAndFlag) { // TODO CLASSIFICATION
field = "&" + field;
}
@ -379,7 +379,7 @@ public class AdvFilterParser {
Field nameField = rootEntity.getNameField();
DisplayType dt = EasyMeta.getDisplayType(nameField);
if (dt == DisplayType.PICKLIST || dt == DisplayType.REFERENCE) {
if (dt == DisplayType.PICKLIST || dt == DisplayType.REFERENCE) { // TODO CLASSIFICATION
fields.add("&" + nameField.getName());
} else if (dt == DisplayType.TEXT || dt == DisplayType.EMAIL || dt == DisplayType.URL || dt == DisplayType.PHONE || dt == DisplayType.SERIES) {
fields.add(nameField.getName());

View file

@ -23,9 +23,11 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.rebuild.server.Application;
import com.rebuild.web.BasePageControll;
/**
@ -35,11 +37,22 @@ import com.rebuild.web.BasePageControll;
* @since 2019/03/27
*/
@Controller
@RequestMapping("/admin/")
@RequestMapping("/admin/entityhub/")
public class ClassificationControll extends BasePageControll {
@RequestMapping("classifications")
public ModelAndView pageIndex(HttpServletRequest request) throws IOException {
return createModelAndView("/admin/classification/index.jsp");
Object[][] array = Application.createQuery(
"select dataId,name,description from Classification order by name")
.array();
request.setAttribute("classifications", array);
return createModelAndView("/admin/entityhub/classification/list.jsp");
}
@RequestMapping("classification/{id}")
public ModelAndView pageData(@PathVariable String id,
HttpServletRequest request) throws IOException {
return createModelAndView("/admin/entityhub/classification/editor.jsp");
}
}

View file

@ -50,7 +50,7 @@ public class FormDesignControll extends BasePageControll implements PortalsConfi
@RequestMapping("{entity}/form-design")
public ModelAndView pageFormDesign(@PathVariable String entity, HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/form-design.jsp");
ModelAndView mv = createModelAndView("/admin/entityhub/form-design.jsp");
MetaEntityControll.setEntityBase(mv, entity);
JSON cfg = FormsManager.getFormLayout(entity, getRequestUser(request));
if (cfg != null) {

View file

@ -62,14 +62,14 @@ public class MetaEntityControll extends BasePageControll {
@RequestMapping("entities")
public ModelAndView pageList(HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/entity-grid.jsp");
ModelAndView mv = createModelAndView("/admin/entityhub/entity-grid.jsp");
mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
return mv;
}
@RequestMapping("entity/{entity}/base")
public ModelAndView pageEntityBase(@PathVariable String entity, HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/entity-edit.jsp");
ModelAndView mv = createModelAndView("/admin/entityhub/entity-edit.jsp");
setEntityBase(mv, entity);
Entity entityMeta = MetadataHelper.getEntity(entity);
@ -87,7 +87,7 @@ public class MetaEntityControll extends BasePageControll {
}
@RequestMapping("entity/{entity}/advanced")
public ModelAndView pageEntityDanger(@PathVariable String entity, HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/entity-advanced.jsp");
ModelAndView mv = createModelAndView("/admin/entityhub/entity-advanced.jsp");
mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
setEntityBase(mv, entity);
return mv;

View file

@ -63,7 +63,7 @@ public class MetaFieldControll extends BasePageControll {
@RequestMapping("{entity}/fields")
public ModelAndView pageEntityFields(@PathVariable String entity, HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/fields.jsp");
ModelAndView mv = createModelAndView("/admin/entityhub/fields.jsp");
MetaEntityControll.setEntityBase(mv, entity);
String nameField = MetadataHelper.getNameField(entity).getName();
mv.getModel().put("nameField", nameField);
@ -101,7 +101,7 @@ public class MetaFieldControll extends BasePageControll {
@RequestMapping("{entity}/field/{field}")
public ModelAndView pageEntityField(@PathVariable String entity, @PathVariable String field, HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/field-edit.jsp");
ModelAndView mv = createModelAndView("/admin/entityhub/field-edit.jsp");
EasyMeta easyMeta = MetaEntityControll.setEntityBase(mv, entity);
Field fieldMeta = ((Entity) easyMeta.getBaseMeta()).getField(field);

View file

@ -145,6 +145,7 @@
<field name="dataId" type="primary" />
<field name="name" type="string" max-length="100" nullable="false" />
<field name="description" type="string" max-length="600" />
<field name="isDisabled" type="bool" default-value="F" />
</entity>
<entity name="ClassificationData" type-code="019" name-field="name" description="分类明细数据">
@ -152,8 +153,9 @@
<field name="dataId" type="reference" ref-entity="Classification" nullable="false" cascade="delete" />
<field name="code" type="string" max-length="50" />
<field name="name" type="string" max-length="100" nullable="false" />
<field name="fullName" type="string" max-length="200" nullable="false" description="父级fullName+fullName" />
<field name="parent" type="reference" ref-entity="ClassificationData" />
<index field-list="parent,name,code"/>
<index field-list="dataId,parent,name,fullName"/>
</entity>
<entity name="ShareAccess" type-code="020" description="记录共享">

View file

@ -27,7 +27,7 @@
</li>
<li class="divider">业务/实体</li>
<li class="${param['activeNav'] == 'entities' ? 'active' : ''}"><a href="${baseUrl}/admin/entities"><i class="icon zmdi zmdi-widgets"></i><span>实体管理</span></a></li>
<li class="${param['activeNav'] == 'classifications' ? 'active' : ''}"><a href="${baseUrl}/admin/classifications"><i class="icon zmdi zmdi-layers"></i><span>分类数据</span></a></li>
<li class="${param['activeNav'] == 'classifications' ? 'active' : ''}"><a href="${baseUrl}/admin/entityhub/classifications"><i class="icon x21 zmdi zmdi-layers"></i><span>分类数据</span></a></li>
<li class="${param['activeNav'] == 'audit-logging' ? 'active' : ''} hide"><a href="${baseUrl}/admin/audit-logging"><i class="icon zmdi zmdi-assignment-check"></i><span>数据审计</span></a></li>
<li class="${param['activeNav'] == 'data-importer' ? 'active' : ''}"><a href="${baseUrl}/admin/dataio/importer"><i class="icon zmdi zmdi-cloud-upload"></i><span>数据导入</span></a></li>
<li class="divider">用户</li>

View file

@ -0,0 +1,52 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/_include/Head.jsp"%>
<title>分类数据编辑</title>
<style type="text/css">
.level-box .col-md-3>ol {
border:2px solid #eee;
padding: 0 5px;
margin-bottom: 15px;
}
</style>
</head>
<body>
<div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-color-header">
<jsp:include page="/_include/NavTop.jsp">
<jsp:param value="审计日志" name="pageTitle"/>
</jsp:include>
<jsp:include page="/_include/NavLeftAdmin.jsp">
<jsp:param value="classifications" name="activeNav"/>
</jsp:include>
<div class="rb-content">
<div class="page-head">
<div class="page-head-title">分类数据编辑</div>
</div>
<div class="main-content container-fluid pt-1">
<div class="card">
<div class="card-body">
<div class="row level-box">
<div class="col-md-3">
<h5>一级分类</h5>
<ol class="dd-list unset-list">
</ol>
<form>
<div class="input-group input-group-sm">
<input class="form-control J_name" type="text" maxlength="40">
<div class="input-group-append"><button class="btn btn-secondary J_confirm" type="submit">添加</button></div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<%@ include file="/_include/Foot.jsp"%>
<script src="${baseUrl}/assets/js/sortable.js"></script>
<script src="${baseUrl}/assets/js/entity/classification-editor.jsx" type="text/babel"></script>
</body>
</html>

View file

@ -1,9 +1,10 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/_include/Head.jsp"%>
<title>审计日志</title>
<title>分类数据</title>
<style type="text/css">
</style>
</head>
@ -16,13 +17,20 @@
<jsp:param value="classifications" name="activeNav"/>
</jsp:include>
<div class="rb-content">
<div class="page-head">
<div class="page-head-title">分类数据</div>
</div>
<div class="main-content container-fluid">
<h3 class="text-center">暂未支持</h3>
<button class="J_add">添加</button>
<div>
<c:forEach items="${classifications}" var="item">
<a href="classification/${item[0]}"><strong>${item[1]}</strong><p>${item[2]}</p></a>
</c:forEach>
</div>
</div>
</div>
</div>
<%@ include file="/_include/Foot.jsp"%>
<script type="text/babel">
</script>
<script src="${baseUrl}/assets/js/entity/classification.jsx" type="text/babel"></script>
</body>
</html>

View file

@ -1438,4 +1438,9 @@ form.dropzone .note {
form.simple {
max-width: 888px;
}
.rb-left-sidebar .sidebar-elements>li>a .icon.x21,
.rb-left-sidebar .sidebar-elements .sub-menu li>a .icon.x21 {
font-size: 21px;
}

View file

@ -0,0 +1,26 @@
$(document).ready(function () {
let boxTmpl = $('.level-box>.col-md-3')
init_levelbox(boxTmpl)
})
var init_levelbox = function (box) {
box.find('.dd-list').sortable({
placeholder: 'dd-placeholder',
handle: '.dd-handle',
axis: 'y',
}).disableSelection()
box.find('.J_confirm').click(() => {
let name = box.find('.J_name').val()
if (name) {
render_unset([$random(), name], box.find('.dd-list'))
box.find('.J_name').val('')
}
return false
})
}
// Over sortable.js
render_unset_after = function (item, data) {
item.off('click')
}

View file

@ -0,0 +1,38 @@
$(document).ready(function () {
$('.J_add').click(() => {
renderRbcomp(<DlgAddOne />)
})
})
class DlgAddOne extends RbFormHandler {
constructor(props) {
super(props)
}
render() {
return (<RbModal title="添加分类数据" ref="dlg">
<form>
<div className="form-group row">
<label className="col-sm-3 col-form-label text-sm-right">名称</label>
<div className="col-sm-7">
<input className="form-control form-control-sm" value={this.state.name || ''} data-id="name" onChange={this.handleChange} maxLength="40" />
</div>
</div>
<div className="form-group row footer">
<div className="col-sm-7 offset-sm-3">
<button className="btn btn-primary" type="button" onClick={() => this.save()}>确定</button>
</div>
</div>
</form>
</RbModal>)
}
save() {
if (!this.state.name) { rb.highbar('请输入名称'); return }
let _data = { name: this.state.name }
_data.metadata = { entity: 'Classification' }
$.post(rb.baseUrl + '/app/entity/record-save', JSON.stringify(_data), (res) => {
if (res.error_code === 0) {
location.href = 'classification/' + res.data.id
} else rb.hberror(res.error_msg)
})
}
}

View file

@ -7,8 +7,8 @@ $(document).ready(function () {
}).disableSelection()
})
const render_unset = function (data) {
let item = $('<li class="dd-item" data-key="' + data[0] + '"><div class="dd-handle">' + data[1] + '</div></li>').appendTo('.unset-list')
const render_unset = function (data, target) {
let item = $('<li class="dd-item" data-key="' + data[0] + '"><div class="dd-handle">' + data[1] + '</div></li>').appendTo(target || '.unset-list')
item.click(function () {
render_item(data)
item.remove()
@ -20,8 +20,8 @@ let render_unset_after = function (item, data) {
// 更多实现
}
const render_item = function (data) {
let item = $('<li class="dd-item dd3-item" data-key="' + data[0] + '"><div class="dd-handle dd3-handle"></div><div class="dd3-content">' + data[1] + '</div></li>').appendTo('.J_config')
const render_item = function (data, target) {
let item = $('<li class="dd-item dd3-item" data-key="' + data[0] + '"><div class="dd-handle dd3-handle"></div><div class="dd3-content">' + data[1] + '</div></li>').appendTo(target || '.J_config')
let del = $('<div class="dd3-action"><a href="javascript:;">[移除]</a></div>').appendTo(item)
del.find('a').click(function () {
data[1] = item.find('.dd3-content').text()

View file

@ -89,5 +89,7 @@ public class TestSupport {
new Field2Schema(UserService.ADMIN_USER).create(testEntity, "FILE", DisplayType.FILE, null, null);
new Field2Schema(UserService.ADMIN_USER).create(testEntity, "PICKLIST", DisplayType.PICKLIST, null, null);
new Field2Schema(UserService.ADMIN_USER).create(testEntity, "REFERENCE", DisplayType.REFERENCE, null, entityName);
new Field2Schema(UserService.ADMIN_USER).create(testEntity, "AVATAR", DisplayType.AVATAR, null, entityName);
new Field2Schema(UserService.ADMIN_USER).create(testEntity, "CLASSIFICATION", DisplayType.CLASSIFICATION, null, entityName);
}
}