referenceDataFilter

This commit is contained in:
oahzeved 2020-05-25 17:26:34 +08:00
parent 50214412eb
commit 4107c2f213
4 changed files with 58 additions and 12 deletions

View file

@ -68,7 +68,7 @@ a#entityIcon:hover{opacity:0.8}
<div class="card bosskey-show">
<div class="card-header">导出${entityLabel}实体</div>
<div class="card-body">
<p>将实体的元数据导出,方便与其他实例间共享。你也可以将导出文件发布到 <a class="link" href="https://github.com/getrebuild/rebuild-datas" target="_blank">元数据市场</a>。</p>
<p>将实体的元数据导出,方便与其他实例间共享。你也可以将导出文件发布到 <a class="link" href="https://github.com/getrebuild/rebuild-datas" target="_blank">RB 仓库</a>。</p>
<div class="mb-1">
<a href="../entity-export?id=${entityMetaId}" target="_blank" class="btn btn-primary"><i class="zmdi zmdi-cloud-download icon"></i> 导出</a>
</div>

View file

@ -170,7 +170,16 @@
<div class="form-group row J_for-REFERENCE hide pt-0 pb-0">
<label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right">引用实体</label>
<div class="col-md-12 col-xl-6 col-lg-8">
<div class="form-control-plaintext"><a href="../../${fieldRefentity}/base">${fieldRefentityLabel} (${fieldRefentity})</a></div>
<div class="form-control-plaintext">
<a class="J_referenceEntity" data-refentity="${fieldRefentity}" href="../../${fieldRefentity}/base">${fieldRefentityLabel} (${fieldRefentity})</a>
</div>
</div>
</div>
<div class="form-group row J_for-REFERENCE hide pt-0 pb-1">
<label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right">附加过滤条件</label>
<div class="col-md-12 col-xl-6 col-lg-8">
<a class="btn btn-sm btn-link pl-0 text-left down-2" id="referenceDataFilter">点击设置</a>
<p class="form-text mb-0 mt-0">符合过滤条件的数据才能被选择或使用</p>
</div>
</div>
<div class="form-group row J_for-DATE hide">
@ -326,6 +335,7 @@ window.__PageConfig = {
isSlaveToMasterField: ${isSlaveToMasterField}
}
</script>
<script src="${baseUrl}/assets/js/rb-advfilter.jsx" type="text/babel"></script>
<script src="${baseUrl}/assets/js/entityhub/field-edit.jsx" type="text/babel"></script>
</body>
</html>

View file

@ -1,6 +1,6 @@
.rb-right-sidebar {
width: 420px;
right: -420px;
width: 480px;
right: -480px;
}
.rb-right-sidebar .sb-content,
@ -45,7 +45,7 @@
#config-side .header>input {
background-color: rgba(255, 255, 255, .6);
border-radius: 3px;
border-radius: 0;
padding: 0 5px;
}

View file

@ -6,6 +6,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
*/
const wpc = window.__PageConfig
const __gExtConfig = {}
$(document).ready(function () {
const dt = wpc.fieldType
@ -31,12 +32,10 @@ $(document).ready(function () {
else _data.defaultValue = dv
} else if (dv === '') _data.defaultValue = dv
const extConfig = {}
const extConfig = { ...__gExtConfig }
$(`.J_for-${dt} .form-control, .J_for-${dt} .custom-control-input`).each(function () {
const k = $(this).attr('id')
if ('defaultValue' !== k) {
extConfig[k] = $val(this)
}
if ('defaultValue' !== k) extConfig[k] = $val(this)
})
if (!$same(extConfig, extConfigOld)) {
_data['extConfig'] = JSON.stringify(extConfig)
@ -77,7 +76,12 @@ $(document).ready(function () {
}
}
if (dt === 'PICKLIST' || dt === 'MULTISELECT') {
// -
if (wpc.fieldName === 'approvalState' || wpc.fieldName === 'approvalId') {
$('.J_for-STATE, .J_for-REFERENCE').remove()
}
// &
else if (dt === 'PICKLIST' || dt === 'MULTISELECT') {
$.get(`/admin/field/picklist-gets?entity=${wpc.entityName}&field=${wpc.fieldName}&isAll=false`, function (res) {
if (res.data.length === 0) { $('#picklist-items li').text('请添加选项'); return }
$('#picklist-items').empty()
@ -87,6 +91,7 @@ $(document).ready(function () {
$('.J_picklist-edit').click(() =>
RbModal.create(`${rb.baseUrl}/admin/p/entityhub/picklist-editor?entity=${wpc.entityName}&field=${wpc.fieldName}&multi=${dt === 'MULTISELECT'}`, '配置选项'))
}
//
else if (dt === 'SERIES') {
$('#defaultValue').parents('.form-group').remove()
$('#fieldNullable, #fieldUpdatable, #fieldRepeatable').attr('disabled', true)
@ -103,6 +108,7 @@ $(document).ready(function () {
})
})
}
//
else if (dt === 'DATE' || dt === 'DATETIME') {
$('#defaultValue').datetimepicker({
componentIcon: 'zmdi zmdi-calendar',
@ -122,6 +128,7 @@ $(document).ready(function () {
})
$('#defaultValue').next().removeClass('hide').find('button').click(() => renderRbcomp(<AdvDateDefaultValue type={dt} />))
}
// &
else if (dt === 'FILE' || dt === 'IMAGE') {
let uploadNumber = [0, 9]
if (extConfigOld['uploadNumber']) {
@ -142,13 +149,15 @@ $(document).ready(function () {
})
$('#fieldNullable').attr('disabled', true)
}
//
else if (dt === 'CLASSIFICATION') {
$.get(`/admin/entityhub/classification/info?id=${extConfigOld.classification}`, function (res) {
$('#useClassification a').attr({ href: `${rb.baseUrl}/admin/entityhub/classification/${extConfigOld.classification}` }).text(res.data.name)
})
}
else if (wpc.fieldName === 'approvalState' || wpc.fieldName === 'approvalId') {
$('.J_for-STATE, .J_for-REFERENCE').remove()
//
else if (dt === 'REFERENCE') {
_handleReference()
}
//
@ -270,4 +279,31 @@ class AdvDateDefaultValue extends RbAlert {
$('#defaultValue').val('{' + expr + '}')
this.hide()
}
}
//
const _handleReference = function () {
const referenceEntity = $('.J_referenceEntity').data('refentity')
let dataFilter = (wpc.extConfig || {}).referenceDataFilter
const saveFilter = function (res) {
if (res && res.items && res.items.length > 0) {
$('#referenceDataFilter').text(`已设置条件 (${res.items.length})`)
dataFilter = res
} else {
$('#referenceDataFilter').text('点击设置')
dataFilter = null
}
__gExtConfig.referenceDataFilter = dataFilter
}
dataFilter && saveFilter(dataFilter)
let advFilter
$('#referenceDataFilter').click(() => {
if (advFilter) advFilter.show()
else renderRbcomp(<AdvFilter title="附加过滤条件" inModal={true} canNoFilters={true}
entity={referenceEntity}
filter={dataFilter}
confirm={saveFilter} />, null, function () { advFilter = this })
})
}