entity manager show primary filters
This commit is contained in:
@@ -46,7 +46,8 @@
|
||||
"layout": "Layout",
|
||||
"author": "Author",
|
||||
"module": "Module",
|
||||
"version": "Version"
|
||||
"version": "Version",
|
||||
"primaryFilters": "Primary Filters"
|
||||
},
|
||||
"options": {
|
||||
"type": {
|
||||
|
||||
@@ -26,43 +26,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="record record-container">{{{record}}}</div>
|
||||
<div class="record">
|
||||
<div class="record-grid">
|
||||
<div class="left">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body panel-body-form">
|
||||
<div class="row">
|
||||
<div class="cell col-sm-6 form-group">
|
||||
<label
|
||||
class="control-label"
|
||||
>{{translate 'name' scope='EntityManager' category='fields'}}</label>
|
||||
<div class="field">
|
||||
{{scope}}
|
||||
</div>
|
||||
</div>
|
||||
{{#if type}}
|
||||
<div class="cell col-sm-6 form-group">
|
||||
<label
|
||||
class="control-label"
|
||||
>{{translate 'type' scope='EntityManager' category='fields'}}</label>
|
||||
<div class="field">
|
||||
{{type}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="cell col-sm-6 form-group">
|
||||
<label
|
||||
class="control-label"
|
||||
>{{translate 'label' scope='EntityManager' category='fields'}}</label>
|
||||
<div class="field">
|
||||
{{label}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body panel-body-form">
|
||||
<div class="row">
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
import ArrayFieldView from 'views/fields/array';
|
||||
|
||||
class EntityManagerPrimaryFiltersFieldView extends ArrayFieldView {
|
||||
|
||||
// language=Handlebars
|
||||
detailTemplateContent = `
|
||||
{{#unless isEmpty}}
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
{{#each dateList}}
|
||||
<tr>
|
||||
<td style="width: 50%">{{name}}</td>
|
||||
<td style="width: 50%">{{label}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
{{#if valueIsSet}}
|
||||
<span class="none-value">{{translate 'None'}}</span>
|
||||
{{else}}
|
||||
<span class="loading-value"></span>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
`
|
||||
|
||||
// noinspection JSCheckFunctionSignatures
|
||||
data() {
|
||||
// noinspection JSValidateTypes
|
||||
return {
|
||||
...super.data(),
|
||||
dateList: this.getValuesItems(),
|
||||
};
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.targetEntityType = options.targetEntityType;
|
||||
}
|
||||
|
||||
getValuesItems() {
|
||||
return (this.model.get(this.name) || []).map(/** string */item => {
|
||||
return {
|
||||
name: item,
|
||||
label: this.translate(item, 'presetFilters', this.targetEntityType),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default EntityManagerPrimaryFiltersFieldView;
|
||||
@@ -27,6 +27,9 @@
|
||||
************************************************************************/
|
||||
|
||||
import View from 'view';
|
||||
import DetailRecordView from 'views/record/detail';
|
||||
import Model from 'model';
|
||||
import EntityManagerPrimaryFiltersFieldView from 'views/admin/entity-manager/fields/primary-filters';
|
||||
|
||||
class EntityManagerScopeView extends View {
|
||||
|
||||
@@ -68,6 +71,84 @@ class EntityManagerScopeView extends View {
|
||||
this.scope = this.options.scope;
|
||||
|
||||
this.setupScopeData();
|
||||
|
||||
this.model = new Model({
|
||||
name: this.scope,
|
||||
type: this.type,
|
||||
label: this.label,
|
||||
primaryFilters: this.getPrimaryFilters(),
|
||||
});
|
||||
|
||||
this.model.setDefs({
|
||||
fields: {
|
||||
name: {
|
||||
type: 'varchar',
|
||||
},
|
||||
type: {
|
||||
type: 'varchar',
|
||||
},
|
||||
label: {
|
||||
type: 'varchar',
|
||||
},
|
||||
primaryFilters: {
|
||||
type: 'array',
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
this.recordView = new DetailRecordView({
|
||||
model: this.model,
|
||||
inlineEditDisabled: true,
|
||||
buttonsDisabled: true,
|
||||
readOnly: true,
|
||||
detailLayout: [
|
||||
{
|
||||
tabBreak: true,
|
||||
tabLabel: this.translate('General', 'labels', 'Settings'),
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
name: 'name',
|
||||
labelText: this.translate('name', 'fields', 'EntityManager'),
|
||||
},
|
||||
{
|
||||
name: 'type',
|
||||
labelText: this.translate('type', 'fields', 'EntityManager'),
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'label',
|
||||
labelText: this.translate('label', 'fields', 'EntityManager'),
|
||||
},
|
||||
false
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
tabBreak: true,
|
||||
tabLabel: this.translate('Details'),
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
view: new EntityManagerPrimaryFiltersFieldView({
|
||||
name: 'primaryFilters',
|
||||
labelText: this.translate('primaryFilters', 'fields', 'EntityManager'),
|
||||
targetEntityType: this.scope,
|
||||
}),
|
||||
},
|
||||
false
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
this.assignView('record', this.recordView, '.record-container');
|
||||
|
||||
if (!this.type) {
|
||||
this.recordView.hideField('type');
|
||||
}
|
||||
}
|
||||
|
||||
setupScopeData() {
|
||||
@@ -182,6 +263,19 @@ class EntityManagerScopeView extends View {
|
||||
this.getHelper().broadcastChannel.postMessage('update:metadata');
|
||||
this.getHelper().broadcastChannel.postMessage('update:settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string[]}
|
||||
*/
|
||||
getPrimaryFilters() {
|
||||
return this.getMetadata().get(`clientDefs.${this.scope}.filterList`, []).map(item => {
|
||||
if (typeof item === 'object' && item.name) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
return item.toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default EntityManagerScopeView;
|
||||
|
||||
Reference in New Issue
Block a user