better meta new

This commit is contained in:
RB 2022-08-17 16:04:57 +08:00
parent e514865f9f
commit 456a563f49
13 changed files with 7774 additions and 647 deletions

2
@rbv

@ -1 +1 @@
Subproject commit 449a2a31c91ed2c189885db49cbfc4bee3436675
Subproject commit 60919b027a9fec806028e161180a35889821300b

View file

@ -53,6 +53,7 @@ public class Entity2Schema extends Field2Schema {
* @param mainEntity
* @param haveNameField
* @return
* @see #createEntity(String, String, String, String, boolean)
*/
public String createEntity(String entityLabel, String comments, String mainEntity, boolean haveNameField) {
return createEntity(null, entityLabel, comments, mainEntity, haveNameField);

View file

@ -2279,5 +2279,8 @@
"部分功能可能需要商业版才能正常运行":"部分功能可能需要商业版才能正常运行",
"默认大小":"默认大小",
"在线查看":"在线查看",
"提交人撤回":"提交人撤回"
"提交人撤回":"提交人撤回",
"添加一个名称字段":"添加一个名称字段",
"这是明细实体":"这是明细实体",
"添加一个自动编号字段":"添加一个自动编号字段"
}

View file

@ -58,6 +58,20 @@
padding: 0;
color: #777;
}
.new-entity .card.entity .card-body {
padding: 7px;
}
.new-entity .card.entity .card-body .float-left,
.new-entity .card.entity .card-body .ml-7 {
display: block;
width: 100%;
clear: both;
margin: 0 !important;
text-align: center;
}
.new-entity .card.entity .card-body .ml-7 .text-muted {
display: none;
}
</style>
</head>
<body>
@ -129,9 +143,9 @@
const $new = render_entity({
icon: 'plus',
entityLabel: $L('添加实体'),
comments: $L('添加一个新的实体'),
})
$new
.addClass('new-entity')
.find('a.card')
.attr('href', 'javascript:;')
.click(function () {
@ -153,10 +167,14 @@
const render_entity = function (item) {
const $t = $($('#entity-tmpl').html()).appendTo('#entityList')
$t.find('a.card').attr('href', `entity/${item.entityName}/base`)
$t.find('a.card').attr({
href: `entity/${item.entityName}/base`,
title: item.comments || null,
})
$t.find('.icon').addClass(`zmdi-${item.icon}`)
$t.find('span').text(item.entityLabel)
$t.find('p').text(item.comments || '-')
if (item.builtin) $(`<i class="badge badge-pill badge-secondary font-weight-light">${$L('内置')}</i>`).appendTo($t.find('a.card'))
if (!!item.detailEntity) $(`<i class="badge badge-pill badge-secondary font-weight-light">${$L('明细')}</i>`).appendTo($t.find('a.card'))
return $t

View file

@ -48,7 +48,16 @@
<div class="col-sm-7">
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
<input class="custom-control-input" type="checkbox" id="nameField" />
<span class="custom-control-label">[[${bundle.L('添加名称字段')}]]</span>
<span class="custom-control-label">[[${bundle.L('添加一个名称字段')}]]</span>
</label>
</div>
</div>
<div class="form-group row pt-0 hide">
<label class="col-sm-3 col-form-label text-sm-right"></label>
<div class="col-sm-7">
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
<input class="custom-control-input" type="checkbox" id="seriesField" />
<span class="custom-control-label">[[${bundle.L('添加一个自动编号字段')}]]</span>
</label>
</div>
</div>
@ -58,7 +67,7 @@
<label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
<input class="custom-control-input" type="checkbox" id="isDetail" />
<span class="custom-control-label">
[[${bundle.L('这是一个明细实体')}]]
[[${bundle.L('这是明细实体')}]]
<i class="zmdi zmdi-help zicon" data-toggle="tooltip" th:title="${bundle.L('通过明细实体可以更好的组织业务关系。例如订单明细通常依附于订单,而非独立存在')}"></i>
</span>
</label>

View file

@ -3,6 +3,11 @@
<head>
<th:block th:replace="~{/_include/header}" />
<title>[[${bundle.L('添加字段')}]]</title>
<style>
.select2-container--default .select2-results > .select2-results__options {
max-height: 151px;
}
</style>
</head>
<body class="dialog">
<div class="main-content">
@ -16,34 +21,7 @@
<div class="form-group row">
<label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('字段类型')}]]</label>
<div class="col-sm-7">
<select class="form-control form-control-sm" id="type">
<option value="TEXT">[[${bundle.L('文本')}]]</option>
<option value="NTEXT">[[${bundle.L('多行文本')}]]</option>
<option value="PHONE">[[${bundle.L('电话')}]]</option>
<option value="EMAIL">[[${bundle.L('邮箱')}]]</option>
<option value="URL">[[${bundle.L('链接')}]]</option>
<option value="NUMBER">[[${bundle.L('整数')}]]</option>
<option value="DECIMAL">[[${bundle.L('小数')}]]</option>
<option value="SERIES">[[${bundle.L('自动编号')}]]</option>
<option value="DATE">[[${bundle.L('日期')}]]</option>
<option value="DATETIME">[[${bundle.L('日期时间')}]]</option>
<option value="TIME">[[${bundle.L('时间')}]]</option>
<option value="PICKLIST">[[${bundle.L('下拉列表')}]]</option>
<option value="CLASSIFICATION">[[${bundle.L('分类')}]]</option>
<option value="MULTISELECT">[[${bundle.L('多选')}]]</option>
<option value="REFERENCE">[[${bundle.L('引用')}]]</option>
<option value="N2NREFERENCE">[[${bundle.L('多引用')}]]</option>
<option value="FILE">[[${bundle.L('文件')}]]</option>
<option value="IMAGE">[[${bundle.L('图片')}]]</option>
<option value="AVATAR">[[${bundle.L('头像')}]]</option>
<option value="BARCODE">[[${bundle.L('二维码')}]]</option>
<option value="LOCATION">[[${bundle.L('位置')}]]</option>
<option value="SIGN">[[${bundle.L('签名')}]]</option>
<option value="BOOL">[[${bundle.L('布尔')}]]</option>
<optgroup th:label="${bundle.L('保留类型')}" class="bosskey-show">
<option value="STATE">[[${bundle.L('状态')}]]</option>
</optgroup>
</select>
<select class="form-control form-control-sm" id="type"></select>
</div>
</div>
<div class="form-group row hide J_dt-REFERENCE J_dt-N2NREFERENCE">
@ -88,6 +66,7 @@
</form>
</div>
<th:block th:replace="~{/_include/footer}" />
<script th:src="@{/assets/js/metadata/field-type.js}" type="text/babel"></script>
<script th:src="@{/assets/js/metadata/field-new.js}" type="text/babel"></script>
</body>
</html>

View file

@ -128,6 +128,7 @@
isSuperAdmin: '[[${isSuperAdmin}]]' === 'true',
}
</script>
<script th:src="@{/assets/js/metadata/field-type.js}" type="text/babel"></script>
<script th:src="@{/assets/js/metadata/form-design.js}" type="text/babel"></script>
<script th:src="@{/assets/js/metadata/entity-switch.js}" type="text/babel"></script>
</body>

View file

@ -227,7 +227,8 @@ See LICENSE and COMMERCIAL in the project root for license information.
color: #999;
}
.field-list .dd-item:hover .dd-handle::before {
.field-list .dd-item:hover .dd-handle::before,
.type-list .dd-item:hover .dd-handle::before {
color: #fff;
}
@ -235,12 +236,6 @@ See LICENSE and COMMERCIAL in the project root for license information.
right: 32px;
}
.type-list .dd-item .dd-handle:hover,
.type-list .dd-item .dd-handle:hover::before {
background-color: transparent;
color: #4285f4;
}
form.field-attr {
width: 500px;
max-width: 400px;
@ -311,3 +306,15 @@ form.field-attr label > span {
.field-aside .nav.nav-tabs {
margin-top: 7px;
}
.type-list .dd-handle {
padding-left: 38px !important;
}
.type-list .dd-handle .icon.mdi {
font-size: 1.4rem;
width: 20px;
position: absolute;
left: 13px;
margin-top: -1px;
}

View file

@ -23,7 +23,7 @@ $(document).ready(function () {
}
$new.button('loading')
$.post(`/admin/entity/entity-new?nameField=${$val('#nameField')}`, JSON.stringify(data), (res) => {
$.post(`/admin/entity/entity-new?nameField=${$val('#nameField')}&seriesField=${$val('#seriesField')}`, JSON.stringify(data), (res) => {
if (res.error_code === 0) parent.location.href = `${rb.baseUrl}/admin/entity/${res.data}/base`
else RbHighbar.error(res.error_msg)
})

View file

@ -4,6 +4,7 @@ Copyright (c) REBUILD <https://getrebuild.com/> and/or its owners. All rights re
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/
/* global FIELD_TYPES */
$(document).ready(function () {
const entity = $urlp('entity')
@ -44,7 +45,7 @@ $(document).ready(function () {
if ($val('#saveAndNew')) {
RbHighbar.success($L('字段已添加'))
$('#fieldLabel, #comments').val('')
$('#type').val('TEXT').trigger('change')
// $('#type').val('TEXT').trigger('change')
$('#fieldLabel').focus()
// @see `field-new.html`
@ -60,6 +61,14 @@ $(document).ready(function () {
})
})
for (let k in FIELD_TYPES) {
const t = FIELD_TYPES[k]
const $o = $(`<option value="${k}">${t[0]}</option>`).appendTo('#type')
if (t[2]) $o.addClass('bosskey-show')
}
// $('#type, #refEntity').select2({})
let referenceLoaded = false
let classificationLoaded = false
$('#type').on('change', function () {

View file

@ -0,0 +1,35 @@
/*!
Copyright (c) REBUILD <https://getrebuild.com/> and/or its owners. All rights reserved.
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/
// 字段类型
// eslint-disable-next-line no-unused-vars
const FIELD_TYPES = {
'TEXT': [$L('文本'), 'mdi-form-textbox'],
'NTEXT': [$L('多行文本'), 'mdi-form-textarea'],
'PHONE': [$L('电话'), 'mdi-phone-classic'],
'EMAIL': [$L('邮箱'), 'mdi-email'],
'URL': [$L('链接'), 'mdi-link'],
'NUMBER': [$L('整数'), 'mdi-numeric'],
'DECIMAL': [$L('小数'), 'mdi-numeric'],
'SERIES': [$L('自动编号'), 'mdi-alphabetical'],
'DATE': [$L('日期'), 'mdi-calendar-multiselect-outline'],
'DATETIME': [$L('日期时间'), 'mdi-calendar-multiselect-outline'],
'TIME': [$L('时间'), 'mdi-clock-time-seven-outline'],
'PICKLIST': [$L('下拉列表'), 'mdi-form-select'],
'CLASSIFICATION': [$L('分类'), 'mdi-form-dropdown'],
'MULTISELECT': [$L('多选'), 'mdi-format-list-checks'],
'REFERENCE': [$L('引用'), 'mdi-feature-search-outline'],
'N2NREFERENCE': [$L('多引用'), 'mdi-text-box-search-outline'],
'FILE': [$L('附件'), 'mdi-attachment'],
'IMAGE': [$L('图片'), 'mdi-image'],
'AVATAR': [$L('头像'), 'mdi-account-box-outline'],
'BARCODE': [$L('二维码'), 'mdi-qrcode'],
'LOCATION': [$L('位置'), 'mdi-map-marker'],
'SIGN': [$L('签名'), 'mdi-file-sign'],
'BOOL': [$L('布尔'), 'mdi-toggle-switch-off-outline'],
'STATE': [$L('状态'), 'mdi-language-java', true],
}

View file

@ -4,6 +4,7 @@ Copyright (c) REBUILD <https://getrebuild.com/> and/or its owners. All rights re
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/
/* global FIELD_TYPES */
const wpc = window.__PageConfig
const DIVIDER_LINE = '$DIVIDER$'
@ -48,7 +49,7 @@ $(document).ready(function () {
'.form-preview'
)
const $action = $('<div class="dd-action"><a><i class="zmdi zmdi-close"></i></a></div>').appendTo($item.find('.dd-handle'))
$action.find('a').click(function () {
$action.find('a').on('click', function () {
$item.remove()
})
} else {
@ -66,38 +67,17 @@ $(document).ready(function () {
.disableSelection()
})
$('.J_add-divider').click(function () {
$('.J_add-divider').on('click', function () {
$('.nav-tabs-classic a[href="#form-design"]').tab('show')
render_item({ fieldName: DIVIDER_LINE, fieldLabel: '', colspan: 4 })
})
// @see field-new.html
const FIELD_TYPES = {
'TEXT': $L('文本'),
'NTEXT': $L('多行文本'),
'PHONE': $L('电话'),
'EMAIL': $L('邮箱'),
'URL': $L('链接'),
'NUMBER': $L('整数'),
'DECIMAL': $L('小数'),
'SERIES': $L('自动编号'),
'DATE': $L('日期'),
'DATETIME': $L('日期时间'),
'TIME': $L('时间'),
'PICKLIST': $L('下拉列表'),
'CLASSIFICATION': $L('分类'),
'MULTISELECT': $L('多选'),
'REFERENCE': $L('引用'),
'N2NREFERENCE': $L('多引用'),
'FILE': $L('附件'),
'IMAGE': $L('图片'),
'AVATAR': $L('头像'),
'BARCODE': $L('二维码'),
'LOCATION': $L('位置'),
'SIGN': $L('签名'),
'BOOL': $L('布尔'),
// @see field-type.js
for (let k in FIELD_TYPES) {
const ft = FIELD_TYPES[k]
if (!ft[2]) render_type({ name: k, label: ft[0], icon: ft[1] })
}
for (let k in FIELD_TYPES) render_type({ name: k, label: FIELD_TYPES[k] })
// SAVE
@ -119,7 +99,7 @@ $(document).ready(function () {
})
}
$('.J_save').click(function () {
$('.J_save').on('click', function () {
const formElements = []
$('.form-preview .J_field').each(function () {
const $this = $(this)
@ -222,7 +202,7 @@ const render_item = function (data) {
$(`<a title="${$L('修改')}"><i class="zmdi zmdi-edit"></i></a>`)
.appendTo($action)
.click(function () {
.on('click', function () {
const _onConfirm = function (nv) {
// 字段名
if (nv.fieldLabel) $item.find('.dd-handle>span').text(nv.fieldLabel)
@ -254,7 +234,7 @@ const render_item = function (data) {
$(`<a title="${$L('移除')}"><i class="zmdi zmdi-close"></i></a>`)
.appendTo($action)
.click(function () {
.on('click', function () {
render_unset(data)
$item.remove()
})
@ -264,7 +244,7 @@ const render_item = function (data) {
$item.addClass('divider')
$(`<a title="${$L('修改')}"><i class="zmdi zmdi-edit"></i></a>`)
.appendTo($action)
.click(function () {
.on('click', function () {
const _onConfirm = function (nv) {
$item.find('.dd-handle span').text(nv.dividerName || '')
}
@ -275,7 +255,7 @@ const render_item = function (data) {
$(`<a title="${$L('移除')}"><i class="zmdi zmdi-close"></i></a>`)
.appendTo($action)
.click(function () {
.on('click', function () {
$item.remove()
})
}
@ -287,7 +267,7 @@ const render_unset = function (data) {
if (data.creatable === false) $item.find('.dd-handle').addClass('readonly')
else if (data.nullable === false) $item.find('.dd-handle').addClass('not-nullable')
$item.click(function () {
$item.on('click', function () {
$('.nav-tabs-classic a[href="#form-design"]').tab('show')
render_item(data)
$item.remove()
@ -296,8 +276,8 @@ const render_unset = function (data) {
}
const render_type = function (fieldType) {
const $item = $(`<li class="dd-item"><div class="dd-handle">${$L(fieldType.label)}</div></li>`).appendTo('.type-list')
$item.click(function () {
const $item = $(`<li class="dd-item"><div class="dd-handle"><i class="icon mdi ${fieldType.icon || 'mdi-form-textbox'}"></i> ${$L(fieldType.label)}</div></li>`).appendTo('.type-list')
$item.on('click', function () {
if (wpc.isSuperAdmin) RbModal.create(`/p/admin/metadata/field-new?entity=${wpc.entityName}&type=${fieldType.name}`, $L('添加字段'), { disposeOnHide: true })
else RbHighbar.error($L('仅超级管理员可添加字段'))
})

File diff suppressed because one or more lines are too long