From 456a563f49abc7e34cae63d52bfe818d953d2124 Mon Sep 17 00:00:00 2001
From: RB
Date: Wed, 17 Aug 2022 16:04:57 +0800
Subject: [PATCH] better meta new
---
@rbv | 2 +-
.../core/metadata/impl/Entity2Schema.java | 1 +
src/main/resources/i18n/lang.zh_CN.json | 5 +-
.../web/admin/metadata/entities.html | 22 +-
.../web/admin/metadata/entity-new.html | 13 +-
.../web/admin/metadata/field-new.html | 35 +-
.../web/admin/metadata/form-design.html | 1 +
.../resources/web/assets/css/form-design.css | 21 +-
.../web/assets/js/metadata/entity-new.js | 2 +-
.../web/assets/js/metadata/field-new.js | 11 +-
.../web/assets/js/metadata/field-type.js | 35 +
.../web/assets/js/metadata/form-design.js | 50 +-
.../web/assets/lib/mdi7/preview.html | 8223 +++++++++++++++--
13 files changed, 7774 insertions(+), 647 deletions(-)
create mode 100644 src/main/resources/web/assets/js/metadata/field-type.js
diff --git a/@rbv b/@rbv
index 449a2a31c..60919b027 160000
--- a/@rbv
+++ b/@rbv
@@ -1 +1 @@
-Subproject commit 449a2a31c91ed2c189885db49cbfc4bee3436675
+Subproject commit 60919b027a9fec806028e161180a35889821300b
diff --git a/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java b/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java
index e20400090..57572d849 100644
--- a/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java
+++ b/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java
@@ -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);
diff --git a/src/main/resources/i18n/lang.zh_CN.json b/src/main/resources/i18n/lang.zh_CN.json
index 8cd25557e..87e8c3ff6 100644
--- a/src/main/resources/i18n/lang.zh_CN.json
+++ b/src/main/resources/i18n/lang.zh_CN.json
@@ -2279,5 +2279,8 @@
"部分功能可能需要商业版才能正常运行":"部分功能可能需要商业版才能正常运行",
"默认大小":"默认大小",
"在线查看":"在线查看",
- "提交人撤回":"提交人撤回"
+ "提交人撤回":"提交人撤回",
+ "添加一个名称字段":"添加一个名称字段",
+ "这是明细实体":"这是明细实体",
+ "添加一个自动编号字段":"添加一个自动编号字段"
}
diff --git a/src/main/resources/web/admin/metadata/entities.html b/src/main/resources/web/admin/metadata/entities.html
index b237bd55a..9af898636 100644
--- a/src/main/resources/web/admin/metadata/entities.html
+++ b/src/main/resources/web/admin/metadata/entities.html
@@ -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;
+ }
@@ -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) $(`${$L('内置')}`).appendTo($t.find('a.card'))
if (!!item.detailEntity) $(`${$L('明细')}`).appendTo($t.find('a.card'))
return $t
diff --git a/src/main/resources/web/admin/metadata/entity-new.html b/src/main/resources/web/admin/metadata/entity-new.html
index 9248e26a4..d4e8852cd 100644
--- a/src/main/resources/web/admin/metadata/entity-new.html
+++ b/src/main/resources/web/admin/metadata/entity-new.html
@@ -48,7 +48,16 @@
+
+
+
@@ -58,7 +67,7 @@
diff --git a/src/main/resources/web/admin/metadata/field-new.html b/src/main/resources/web/admin/metadata/field-new.html
index 82df21b0c..fc23c877a 100644
--- a/src/main/resources/web/admin/metadata/field-new.html
+++ b/src/main/resources/web/admin/metadata/field-new.html
@@ -3,6 +3,11 @@
[[${bundle.L('添加字段')}]]
+
@@ -16,34 +21,7 @@
@@ -88,6 +66,7 @@
+
diff --git a/src/main/resources/web/admin/metadata/form-design.html b/src/main/resources/web/admin/metadata/form-design.html
index a02a38be3..5b1388c59 100644
--- a/src/main/resources/web/admin/metadata/form-design.html
+++ b/src/main/resources/web/admin/metadata/form-design.html
@@ -128,6 +128,7 @@
isSuperAdmin: '[[${isSuperAdmin}]]' === 'true',
}
+
+
-
Usage
<span class="mdi mdi-name"></span>
-
- Click the icon, hex codepoint, or name below to copy the value to your clipboard.
-
+ Click the icon, hex codepoint, or name below to copy the value to your clipboard.
New Icons -
@@ -409,309 +408,7395 @@
Deprecated Icons -
-
- Deprecated icons will be removed in a future major release.
-
+ Deprecated icons will be removed in a future major release.
-
- Size
+ Size
-
-
-
-
-
+
Rotate
+
+
+
+
-
-
-
-
- mdi-rotate-45
-
+
mdi-rotate-45
+
+
+
+
+
-
-
-
-
- mdi-rotate-90
-
+
mdi-rotate-90
+
+
+
+
+
-
-
-
-
- mdi-rotate-135
-
+
mdi-rotate-135
+
+
+
+
+
-
-
-
-
- mdi-rotate-180
-
+
mdi-rotate-180
+
+
+
+
+
-
-
-
-
- mdi-rotate-225
-
+
mdi-rotate-225
+
+
+
+
+
-
-
-
-
- mdi-rotate-270
-
+
mdi-rotate-270
+
+
+
+
+
-
-
-
-
- mdi-rotate-315
-
+
mdi-rotate-315
+
Flip
+
+
+
+
-
-
-
-
- mdi-flip-h
-
+
mdi-flip-h
+
+
+
+
+
-
-
-
-
- mdi-flip-v
-
+
mdi-flip-v
+
-
Note: We do not include the ability to use mdi-flip-*
and
- mdi-rotate-*
at the same time.
+
Note: We do not include the ability to use mdi-flip-*
and mdi-rotate-*
at the same time.
Spin
+
-
-
-
-
- mdi-spin
-
+
mdi-spin
+
+
Color
-
-
-
-
-
- mdi-light
-
+
+
+
-
-
-
-
- mdi-light mdi-inactive
-
+
mdi-light
+
+
+
+
+
-
-
-
-
- mdi-dark
-
+
mdi-light mdi-inactive
+
+
+
+
+
-
-
-
-
- mdi-dark mdi-inactive
-
+
mdi-dark
+
+
+
+
+
+
+ mdi-dark mdi-inactive
+
+
-
-
-
+
diff --git a/src/main/resources/web/assets/css/form-design.css b/src/main/resources/web/assets/css/form-design.css
index 174362393..bc757532b 100644
--- a/src/main/resources/web/assets/css/form-design.css
+++ b/src/main/resources/web/assets/css/form-design.css
@@ -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;
+}
diff --git a/src/main/resources/web/assets/js/metadata/entity-new.js b/src/main/resources/web/assets/js/metadata/entity-new.js
index cdc834d65..52f279c9d 100644
--- a/src/main/resources/web/assets/js/metadata/entity-new.js
+++ b/src/main/resources/web/assets/js/metadata/entity-new.js
@@ -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)
})
diff --git a/src/main/resources/web/assets/js/metadata/field-new.js b/src/main/resources/web/assets/js/metadata/field-new.js
index 91a7babe1..293b66aea 100644
--- a/src/main/resources/web/assets/js/metadata/field-new.js
+++ b/src/main/resources/web/assets/js/metadata/field-new.js
@@ -4,6 +4,7 @@ Copyright (c) REBUILD 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 = $(``).appendTo('#type')
+ if (t[2]) $o.addClass('bosskey-show')
+ }
+
+ // $('#type, #refEntity').select2({})
+
let referenceLoaded = false
let classificationLoaded = false
$('#type').on('change', function () {
diff --git a/src/main/resources/web/assets/js/metadata/field-type.js b/src/main/resources/web/assets/js/metadata/field-type.js
new file mode 100644
index 000000000..a47200317
--- /dev/null
+++ b/src/main/resources/web/assets/js/metadata/field-type.js
@@ -0,0 +1,35 @@
+/*!
+Copyright (c) REBUILD 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],
+}
diff --git a/src/main/resources/web/assets/js/metadata/form-design.js b/src/main/resources/web/assets/js/metadata/form-design.js
index 7c9e4adf1..2dc0c87fc 100644
--- a/src/main/resources/web/assets/js/metadata/form-design.js
+++ b/src/main/resources/web/assets/js/metadata/form-design.js
@@ -4,6 +4,7 @@ Copyright (c) REBUILD 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 = $('
').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) {
$(``)
.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) {
$(``)
.appendTo($action)
- .click(function () {
+ .on('click', function () {
render_unset(data)
$item.remove()
})
@@ -264,7 +244,7 @@ const render_item = function (data) {
$item.addClass('divider')
$(``)
.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) {
$(``)
.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 = $(`
${$L(fieldType.label)}
`).appendTo('.type-list')
- $item.click(function () {
+ const $item = $(`
${$L(fieldType.label)}
`).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('仅超级管理员可添加字段'))
})
diff --git a/src/main/resources/web/assets/lib/mdi7/preview.html b/src/main/resources/web/assets/lib/mdi7/preview.html
index d36d1a0a5..d5bb3c0ca 100644
--- a/src/main/resources/web/assets/lib/mdi7/preview.html
+++ b/src/main/resources/web/assets/lib/mdi7/preview.html
@@ -1,406 +1,405 @@
-
+
-
-
+
-
+
Material Design Icons
-
+
-