comples created modified fields

This commit is contained in:
Yuri Kuznetsov
2020-03-11 14:38:15 +02:00
parent 04444aa03a
commit e93860101c
6 changed files with 135 additions and 61 deletions
@@ -1,44 +0,0 @@
{{#if fieldList.length}}
<div class="row">
{{#each fieldList}}
<div class="cell form-group col-sm-6 col-md-12{{#if hidden}} hidden-cell{{/if}}" data-name="{{name}}">
<label class="control-label{{#if hidden}} hidden{{/if}}" data-name="{{name}}"><span class="label-text">{{translate name scope=../model.name category='fields'}}</span></label>
<div class="field{{#if hidden}} hidden{{/if}}" data-name="{{name}}">
{{{var viewKey ../this}}}
</div>
</div>
{{/each}}
</div>
{{/if}}
{{#unless complexDateFieldsDisabled}}
<div class="row">
{{#if hasComplexCreated}}
<div class="cell form-group col-sm-6 col-md-12" data-name="complexCreated">
<label class="control-label" data-name="complexCreated"><span class="label-text">{{translate 'Created'}}</span></label>
<div class="field" data-name="complexCreated">
<span data-name="createdAt" class="field">{{{createdAtField}}}</span> <span class="text-muted">&raquo;</span> <span data-name="createdBy" class="field">{{{createdByField}}}</span>
</div>
</div>
{{/if}}
{{#if hasComplexModified}}
<div class="cell form-group col-sm-6 col-md-12" data-name="complexModified">
<label class="control-label" data-name="complexModified"><span class="label-text">{{translate 'Modified'}}</span></label>
<div class="field" data-name="complexModified">
<span data-name="modifiedAt" class="field">{{{modifiedAtField}}}</span> <span class="text-muted">&raquo;</span> <span data-name="modifiedBy" class="field">{{{modifiedByField}}}</span>
</div>
</div>
{{/if}}
</div>
{{/unless}}
{{#if followersField}}
<div class="row">
<div class="cell form-group col-sm-6 col-md-12" data-name="followers">
<label class="control-label" data-name="followers"><span class="label-text">{{translate 'Followers'}}</span></label>
<div class="field" data-name="followers">
{{{followersField}}}
</div>
</div>
</div>
{{/if}}
+1 -1
View File
@@ -2,7 +2,7 @@
<div class="row">
{{#each fieldList}}
<div class="cell form-group col-sm-6 col-md-12{{#if hidden}} hidden-cell{{/if}}" data-name="{{name}}">
<label class="control-label{{#if hidden}} hidden{{/if}}" data-name="{{name}}"><span class="label-text">{{translate name scope=../model.name category='fields'}}</span></label>
<label class="control-label{{#if hidden}} hidden{{/if}}" data-name="{{name}}"><span class="label-text">{{#if labelText}}{{labelText}}{{else}}{{translate label scope=../../model.name category='fields'}}{{/if}}</span></label>
<div class="field{{#if hidden}} hidden{{/if}}" data-name="{{name}}">
{{{var viewKey ../this}}}
</div>
@@ -0,0 +1,84 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM 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.
*
* EspoCRM 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 EspoCRM. If not, see http://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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/fields/complex-created', 'views/fields/base', function (Dep) {
return Dep.extend({
detailTemplateContent:
`<span data-name="{{baseName}}At" class="field">{{{atField}}}</span> `+
`<span class="text-muted">&raquo;</span> `+
`<span data-name="{{baseName}}By" class="field">{{{byField}}}</span>`,
baseName: 'created',
getAttributeList: function () {
return [this.fieldAt, this.fieldBy];
},
setup: function () {
Dep.prototype.setup.call(this);
this.baseName = this.options.baseName || this.baseName;
this.fieldAt = this.baseName + 'At';
this.fieldBy = this.baseName + 'By';
this.createField('at');
this.createField('by');
},
data: function () {
return _.extend({
baseName: this.baseName,
}, Dep.prototype.data.call(this));
},
createField: function (part) {
var field = this.baseName + Espo.Utils.upperCaseFirst(part);
var type = this.model.getFieldType(field) || 'base';
var viewName = this.model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type);
this.createView(part + 'Field', viewName, {
name: field,
model: this.model,
mode: 'detail',
readOnly: true,
readOnlyLocked: true,
el: this.getSelector() + ' [data-name="'+field+'"]',
});
},
fetch: function () {
return {};
},
});
});
+2 -1
View File
@@ -102,6 +102,7 @@ Espo.define('views/record/panels/bottom', 'view', function (Dep) {
}
item = Espo.Utils.clone(item);
item.viewKey = item.name + 'Field';
item.label = item.label || item.name;
if (this.recordHelper.getFieldStateParam(item.name, 'hidden') !== null) {
item.hidden = this.recordHelper.getFieldStateParam(item.name, 'hidden');
@@ -143,7 +144,7 @@ Espo.define('views/record/panels/bottom', 'view', function (Dep) {
},
getFields: function () {
return this.getFields();
return this.getFieldViews();
},
getFieldList: function () {
+35 -10
View File
@@ -26,12 +26,10 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/record/panels/default-side', 'views/record/panels/side', function (Dep) {
define('views/record/panels/default-side', 'views/record/panels/side', function (Dep) {
return Dep.extend({
template: 'record/panels/default-side',
data: function () {
var data = Dep.prototype.data.call(this);
if (this.complexCreatedDisabled && this.complexModifiedDisabled || (!this.hasComplexCreated && !this.hasComplexModified)) {
@@ -43,7 +41,7 @@ Espo.define('views/record/panels/default-side', 'views/record/panels/side', func
},
setup: function () {
Dep.prototype.setup.call(this);
this.fieldList = Espo.Utils.cloneDeep(this.fieldList);
this.hasComplexCreated =
!!this.getMetadata().get(['entityDefs', this.model.name, 'fields', 'createdAt'])
@@ -55,10 +53,22 @@ Espo.define('views/record/panels/default-side', 'views/record/panels/side', func
&&
!!this.getMetadata().get(['entityDefs', this.model.name, 'fields', 'modifiedBy']);
Dep.prototype.setup.call(this);
},
setupFields: function () {
Dep.prototype.setupFields.call(this);
if (!this.complexCreatedDisabled) {
if (this.hasComplexCreated) {
this.createField('createdBy', null, null, null, true);
this.createField('createdAt', null, null, null, true);
this.fieldList.push({
name: 'complexCreated',
labelText: this.translate('Created'),
isAdditional: true,
view: 'views/fields/complex-created',
readOnly: true,
});
if (!this.model.get('createdById')) {
this.recordViewObject.hideField('complexCreated');
}
@@ -69,8 +79,16 @@ Espo.define('views/record/panels/default-side', 'views/record/panels/side', func
if (!this.complexModifiedDisabled) {
if (this.hasComplexModified) {
this.createField('modifiedBy', null, null, null, true);
this.createField('modifiedAt', null, null, null, true);
this.fieldList.push({
name: 'complexModified',
labelText: this.translate('Modified'),
isAdditional: true,
view: 'views/fields/complex-created',
readOnly: true,
options: {
baseName: 'modified',
},
});
}
if (!this.model.get('modifiedById')) {
this.recordViewObject.hideField('complexModified');
@@ -93,7 +111,13 @@ Espo.define('views/record/panels/default-side', 'views/record/panels/side', func
}
if (this.getMetadata().get(['scopes', this.model.name ,'stream']) && !this.getUser().isPortal()) {
this.createField('followers', 'views/fields/followers', null, null, true);
this.fieldList.push({
name: 'followers',
labelText: this.translate('Followers'),
isAdditional: true,
view: 'views/fields/followers',
readOnly: true,
});
this.controlFollowersField();
this.listenTo(this.model, 'change:followersIds', this.controlFollowersField, this);
}
@@ -105,6 +129,7 @@ Espo.define('views/record/panels/default-side', 'views/record/panels/side', func
} else {
this.recordViewObject.hideField('followers');
}
}
},
});
});
+13 -5
View File
@@ -102,6 +102,7 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
}
item = Espo.Utils.clone(item);
item.viewKey = item.name + 'Field';
item.label = item.label || item.name;
if (this.recordHelper.getFieldStateParam(item.name, 'hidden') !== null) {
item.hidden = this.recordHelper.getFieldStateParam(item.name, 'hidden');
@@ -113,7 +114,10 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
this.fieldList = this.fieldList.filter(function (item) {
if (!item.name) return;
if (!(item.name in (((this.model.defs || {}).fields) || {}))) return;
if (!item.isAdditional) {
if (!(item.name in (((this.model.defs || {}).fields) || {}))) return;
}
return true;
}, this);
@@ -208,16 +212,20 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
} else {
field = item;
}
if (!(field in this.model.defs.fields)) {
return;
if (!item.isAdditional) {
if (!(field in this.model.defs.fields)) {
return;
}
}
this.createField(field, view, null, null, readOnly);
this.createField(field, view, null, null, readOnly, item.options);
}, this);
},
getFields: function () {
return this.getFields();
return this.getFieldViews();
},
getFieldViews: function () {