Merge branch 'hotfix/5.7.8'

This commit is contained in:
Yuri Kuznetsov
2019-12-04 15:09:26 +02:00
5 changed files with 27 additions and 22 deletions
@@ -84,6 +84,7 @@ class SumRelatedType extends \Espo\Core\Formula\Functions\Base
$foreignSelectManager = $this->getInjection('selectManagerFactory')->create($foreignEntityType);
$foreignLink = $entity->getRelationParam($link, 'foreign');
$foreignLinkAlias = $foreignLink . 'SumRelated';
if (empty($foreignLink)) {
throw new Error("No foreign link for link {$link}.");
@@ -95,29 +96,29 @@ class SumRelatedType extends \Espo\Core\Formula\Functions\Base
$foreignSelectManager->applyFilter($filter, $selectParams);
}
$selectParams['select'] = [[$foreignLink . '.id', 'foreignId'], 'SUM:' . $field];
$selectParams['select'] = [[$foreignLinkAlias . '.id', 'foreignId'], 'SUM:' . $field];
if ($entity->getRelationType($link) === 'hasChildren') {
$foreignSelectManager->addJoin([
$entity->getEntityType(),
$foreignLink,
$foreignLinkAlias,
[
$foreignLink . '.id:' => $foreignLink . 'Id',
$foreignLinkAlias . '.id:' => $foreignLink . 'Id',
'deleted' => false,
$foreignLink . '.id!=' => null,
$foreignLinkAlias . '.id!=' => null,
]
], $selectParams);
$selectParams['whereClause'][] = [$foreignLink . 'Type' => $entity->getEntityType()];
} else {
$foreignSelectManager->addJoin($foreignLink, $selectParams);
$foreignSelectManager->addJoin([$foreignLink, $foreignLinkAlias], $selectParams);
}
if (!empty($selectParams['distinct'])) {
$sqSelectParams = $selectParams;
$sqSelectParams['whereClause'][] = [
$foreignLink . '.id' => $entity->id
$foreignLinkAlias . '.id' => $entity->id
];
$sqSelectParams['select'] = ['id'];
@@ -133,11 +134,11 @@ class SumRelatedType extends \Espo\Core\Formula\Functions\Base
];
} else {
$selectParams['whereClause'][] = [
$foreignLink . '.id' => $entity->id
$foreignLinkAlias . '.id' => $entity->id
];
}
$selectParams['groupBy'] = [$foreignLink . '.id'];
$selectParams['groupBy'] = [$foreignLinkAlias . '.id'];
$entityManager->getRepository($foreignEntityType)->handleSelectParams($selectParams);
@@ -107,7 +107,7 @@
"View Users": "View Users"
},
"messages": {
"noSmtpSetup": "No SMTP setup. {link}.",
"noSmtpSetup": "SMTP is not configured: {link}",
"testEmailSent": "Test email has been sent",
"emailSent": "Email has been sent",
"savedAsDraft": "Saved as draft",
@@ -32,9 +32,18 @@ Espo.define('views/email/fields/compose-from-address', 'views/fields/base', func
editTemplate: 'email/fields/compose-from-address/edit',
data: function () {
var noSmtpMessage = this.translate('noSmtpSetup', 'messages', 'Email');
var linkHtml = '<a href="#EmailAccount">'+this.translate('EmailAccount', 'scopeNamesPlural')+'</a>';
if (!this.getAcl().check('EmailAccount')) {
linkHtml = '<a href="#Preferences">'+this.translate('Preferences')+'</a>';
}
noSmtpMessage = noSmtpMessage.replace('{link}', linkHtml);
return _.extend({
list: this.list,
noSmtpMessage: this.translate('noSmtpSetup', 'messages', 'Email').replace('{link}', '<a href="#Preferences">'+this.translate('Preferences')+'</a>')
noSmtpMessage: noSmtpMessage,
}, Dep.prototype.data.call(this));
},
@@ -58,9 +58,8 @@ define('views/fields/link-multiple-with-role', 'views/fields/link-multiple', fun
this.roleFieldScope = this.model.name;
}
if (this.roleType == 'enum') {
if (this.roleType == 'enum' && !this.forceRoles) {
this.roleList = this.getMetadata().get('entityDefs.' + this.roleFieldScope + '.fields.' + this.roleField + '.options');
if (!this.roleList) {
this.roleList = [];
this.skipRoles = true;
+6 -10
View File
@@ -26,10 +26,12 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/user/fields/teams', 'views/fields/link-multiple-with-role', function (Dep) {
define('views/user/fields/teams', 'views/fields/link-multiple-with-role', function (Dep) {
return Dep.extend({
forceRoles: true,
setup: function () {
Dep.prototype.setup.call(this);
@@ -43,7 +45,6 @@ Espo.define('views/user/fields/teams', 'views/fields/link-multiple-with-role', f
}
}, this);
this.listenTo(this.model, 'change:teamsIds', function () {
var toLoad = false;
this.ids.forEach(function (id) {
@@ -85,7 +86,6 @@ Espo.define('views/user/fields/teams', 'views/fields/link-multiple-with-role', f
teams.fetch();
}, this);
},
getDetailLinkHtml: function (id, name) {
@@ -94,6 +94,7 @@ Espo.define('views/user/fields/teams', 'views/fields/link-multiple-with-role', f
var role = (this.columns[id] || {})[this.columnName] || '';
var roleHtml = '';
if (role != '') {
role = this.getHelper().escapeString(role);
roleHtml = '<span class="text-muted small"> &#187; ' + role + '</span>';
}
var lineHtml = '<div>' + '<a href="#' + this.foreignScope + '/view/' + id + '">' + name + '</a> ' + roleHtml + '</div>';
@@ -101,21 +102,18 @@ Espo.define('views/user/fields/teams', 'views/fields/link-multiple-with-role', f
},
getJQSelect: function (id, roleValue) {
var roleList = Espo.Utils.clone((this.roleListMap[id] || []));
if (!roleList.length) {
return;
};
if (roleList.length || roleValue) {
$role = $('<select class="role form-control input-sm pull-right" data-id="'+id+'">');
roleList.unshift('');
roleList.forEach(function (role) {
var selectedHtml = (role == roleValue) ? 'selected': '';
role = this.getHelper().escapeString(role);
var label = role;
if (role == '') {
label = '--' + this.translate('None', 'labels') + '--';
@@ -127,8 +125,6 @@ Espo.define('views/user/fields/teams', 'views/fields/link-multiple-with-role', f
} else {
return $('<div class="small pull-right text-muted">').html(roleValue);
}
}
},
});
});