Merge branch 'fix'

This commit is contained in:
Yuri Kuznetsov
2022-05-23 17:29:48 +03:00
18 changed files with 329 additions and 98 deletions
@@ -48,6 +48,10 @@ class SetAttributeType extends Base
throw new Error("SetAttribute: First argument is not string.");
}
if ($name === 'id') {
throw new Error("Formula set-attribute: Not allowed to set `id` attribute.");
}
$value = $this->evaluate($item->value[1]);
$this->getEntity()->set($name, $value);
+51 -2
View File
@@ -38,6 +38,17 @@ return [
'password' => '',
],
'useCache' => true,
/** Max number of jobs per one execution. */
'jobMaxPortion' => 15,
/** Jobs will be executed in parallel processes. */
'jobRunInParallel' => false,
/** Max number of processes run simultaneously. */
'jobPoolConcurrencyNumber' => 8,
/** Max number of CRON processes run simultaneously. */
'daemonMaxProcessNumber' => 5,
/** Interval between process runs in seconds. */
'daemonInterval' => 10,
'daemonProcessTimeout' => 36000,
'recordsPerPage' => 20,
'recordsPerPageSmall' => 5,
'recordsPerPageSelect' => 10,
@@ -78,8 +89,35 @@ return [
'Lead',
'Opportunity',
],
'tabList' => ["Account", "Contact", "Lead", "Opportunity", "Case", "Email", "Calendar", "Meeting", "Call", "Task", "_delimiter_", "Document", "Campaign", "KnowledgeBaseArticle", "Stream", "User"],
'quickCreateList' => ["Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case", "Email"],
'tabList' => [
"Account",
"Contact",
"Lead",
"Opportunity",
"Case",
"Email",
"Calendar",
"Meeting",
"Call",
"Task",
"_delimiter_",
"Document",
"Campaign",
"KnowledgeBaseArticle",
"Stream",
"User"
],
'quickCreateList' => [
"Account",
"Contact",
"Lead",
"Opportunity",
"Meeting",
"Call",
"Task",
"Case",
"Email"
],
'exportDisabled' => false,
'adminNotifications' => true,
'adminNotificationsNewVersion' => true,
@@ -163,5 +201,16 @@ return [
'pdfEngine' => 'Tcpdf',
'smsProvider' => null,
'defaultFileStorage' => 'EspoUploadDir',
'ldapUserNameAttribute' => 'sAMAccountName',
'ldapUserFirstNameAttribute' => 'givenName',
'ldapUserLastNameAttribute' => 'sn',
'ldapUserTitleAttribute' => 'title',
'ldapUserEmailAddressAttribute' => 'mail',
'ldapUserPhoneNumberAttribute' => 'telephoneNumber',
'ldapUserObjectClass' => 'person',
'ldapPortalUserLdapAuth' => false,
'passwordGenerateLength' => 10,
'massActionIdleCountThreshold' => 100,
'exportIdleCountThreshold' => 1000,
'isInstalled' => false,
];
@@ -34,28 +34,6 @@ return [
'user' => '',
'group' => '',
],
/** Max number of jobs per one execution. */
'jobMaxPortion' => 15,
/** Max execution time (in seconds) allocated for a single job. If exceeded then set to Failed.*/
'jobPeriod' => 7800,
/**
* Max execution time (in seconds) allocated for a single job with active process.
* If exceeded then set to Failed.
*/
'jobPeriodForActiveProcess' => 36000,
/** Number of attempts to re-run failed jobs. */
'jobRerunAttemptNumber' => 1,
/** Jobs will be executed in parallel processes. */
'jobRunInParallel' => false,
/** Max number of processes run simultaneously. */
'jobPoolConcurrencyNumber' => 8,
/** Min interval (in seconds) between two CRON runs. */
'cronMinInterval' => 2,
/** Max number of CRON processes run simultaneously. */
'daemonMaxProcessNumber' => 5,
/** Interval between process runs in seconds. */
'daemonInterval' => 10,
'daemonProcessTimeout' => 36000,
'crud' => [
'get' => 'read',
'post' => 'create',
@@ -253,13 +231,6 @@ return [
'aclAllowDeleteCreated',
],
'isInstalled' => false,
'ldapUserNameAttribute' => 'sAMAccountName',
'ldapUserFirstNameAttribute' => 'givenName',
'ldapUserLastNameAttribute' => 'sn',
'ldapUserTitleAttribute' => 'title',
'ldapUserEmailAddressAttribute' => 'mail',
'ldapUserPhoneNumberAttribute' => 'telephoneNumber',
'ldapUserObjectClass' => 'person',
'requiredPhpVersion' => '7.4.0',
'requiredPhpLibs' => [
'json',
@@ -287,8 +258,13 @@ return [
'recommendedMysqlParams' => [],
'requiredMariadbVersion' => '10.1.0',
'recommendedMariadbParams' => [],
'ldapPortalUserLdapAuth' => false,
'passwordGenerateLength' => 10,
'massActionIdleCountThreshold' => 100,
'exportIdleCountThreshold' => 1000,
/** Max execution time (in seconds) allocated for a single job. If exceeded then set to Failed.*/
'jobPeriod' => 7800,
/** Max execution time (in seconds) allocated for a single job with active process.
* If exceeded then set to Failed. */
'jobPeriodForActiveProcess' => 36000,
/** Number of attempts to re-run failed jobs. */
'jobRerunAttemptNumber' => 1,
/** Min interval (in seconds) between two CRON runs. */
'cronMinInterval' => 2,
];
@@ -1,6 +1,7 @@
{
"createHookClassNameList": [
"Espo\\Tools\\EntityManager\\Link\\Hooks\\TargetListCreate"
"Espo\\Tools\\EntityManager\\Link\\Hooks\\TargetListCreate",
"Espo\\Tools\\EntityManager\\Link\\Hooks\\AssignedUsersCreate"
],
"deleteHookClassNameList": [
"Espo\\Tools\\EntityManager\\Link\\Hooks\\TargetListDelete",
@@ -0,0 +1,101 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii 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.
************************************************************************/
namespace Espo\Tools\EntityManager\Link\Hooks;
use Espo\Tools\EntityManager\Link\CreateHook;
use Espo\Tools\EntityManager\Link\Params;
use Espo\Tools\EntityManager\Link\Type;
use Espo\Core\Utils\Metadata;
use Espo\Entities\User;
class AssignedUsersCreate implements CreateHook
{
private const LINK_NAME = 'assignedUsers';
private Metadata $metadata;
public function __construct(Metadata $metadata)
{
$this->metadata = $metadata;
}
public function process(Params $params): void
{
if ($params->getType() !== Type::MANY_TO_MANY) {
return;
}
$foreignEntityType = $params->getForeignEntityType();
$entityType = $params->getEntityType();
if (!$foreignEntityType || !$entityType) {
return;
}
if (
$params->getEntityType() === User::ENTITY_TYPE &&
$params->getForeignLink() === self::LINK_NAME
) {
$this->processInternal($foreignEntityType);
return;
}
if (
$params->getForeignEntityType() === User::ENTITY_TYPE &&
$params->getLink() === self::LINK_NAME
) {
$this->processInternal($entityType);
return;
}
}
private function processInternal(string $entityType): void
{
$fieldType = $this->metadata->get(['entityDefs', $entityType, 'fields', self::LINK_NAME, 'type']);
if ($fieldType !== 'linkMultiple') {
return;
}
$this->metadata->set('entityDefs', $entityType, [
'fields' => [
self::LINK_NAME => [
'view' => 'views/fields/assigned-users',
],
]
]);
$this->metadata->save();
}
}
+5 -8
View File
@@ -7,14 +7,11 @@
</div>
{{/if}}
{{#unless rowList.length}}
{{#if createDisabled}}
{{#unless showRoot}}
<div class="no-data">{{translate 'No Data'}}</div>
{{/unless}}
{{/if}}
{{/unless}}
<div class="list list-expanded list-tree">
{{#if noData}}
<div class="no-data">{{translate 'No Data'}}</div>
{{/if}}
<div class="list list-expanded list-tree{{#if noData}} hidden{{/if}}">
{{#if showRootMenu}}
<div class="btn-group pull-right">
<a href="javascript:" class="small dropdown-toggle btn-link" data-toggle="dropdown">
@@ -557,6 +557,8 @@ define('views/admin/entity-manager/edit', ['view', 'model'], function (Dep, Mode
}
}
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
Espo.Ajax
.postRequest(url, data)
.then(() => {
@@ -41,6 +41,7 @@ define('views/admin/formula/fields/attribute', 'views/fields/multi-enum', functi
var attributeList = this.getFieldManager()
.getEntityTypeAttributeList(this.options.scope)
.concat(['id'])
.sort();
var links = this.getMetadata().get(['entityDefs', this.options.scope, 'links']) || {};
+24 -6
View File
@@ -46,36 +46,53 @@ define('views/fields/bool', 'views/fields/base', function (Dep) {
data: function () {
var data = Dep.prototype.data.call(this);
data.valueIsSet = this.model.has(this.name);
return data;
},
afterRender: function () {
Dep.prototype.afterRender.call(this);
if (this.mode == 'search') {
this.$element.on('change', function () {
if (this.mode === 'search') {
this.$element.on('change', () => {
this.trigger('change');
}.bind(this));
});
}
},
fetch: function () {
var value = this.$element.get(0).checked;
var data = {};
data[this.name] = value;
return data;
},
fetchSearch: function () {
var type = this.$element.val();
if (!type) return;
if (!type) {
return;
}
if (type === 'any') {
return {
type: 'in',
value: [true, false],
type: 'or',
value: [
{
type: 'isTrue',
attribute: this.name,
},
{
type: 'isFalse',
attribute: this.name,
},
],
data: {
type: type,
},
@@ -88,6 +105,7 @@ define('views/fields/bool', 'views/fields/base', function (Dep) {
type: type,
},
};
return data;
},
+1
View File
@@ -349,6 +349,7 @@ define('views/fields/formula', 'views/fields/text', function (Dep) {
var attributeList = this.getFieldManager()
.getEntityTypeAttributeList(this.targetEntityType)
.concat(['id'])
.sort();
var links = this.getMetadata().get(['entityDefs', this.targetEntityType, 'links']) || {};
+19 -10
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/fields/range-currency', 'views/fields/range-float', function (Dep, Float) {
define('views/fields/range-currency', 'views/fields/range-float', function (Dep, Float) {
return Dep.extend({
@@ -37,7 +37,8 @@ Espo.define('views/fields/range-currency', 'views/fields/range-float', function
data: function () {
return _.extend({
currencyField: this.currencyField,
currencyValue: this.model.get(this.fromCurrencyField) || this.getPreferences().get('defaultCurrency') || this.getConfig().get('defaultCurrency'),
currencyValue: this.model.get(this.fromCurrencyField) ||
this.getPreferences().get('defaultCurrency') || this.getConfig().get('defaultCurrency'),
currencyOptions: this.currencyOptions,
currencyList: this.currencyList
}, Dep.prototype.data.call(this));
@@ -57,7 +58,8 @@ Espo.define('views/fields/range-currency', 'views/fields/range-float', function
afterRender: function () {
Dep.prototype.afterRender.call(this);
if (this.mode == 'edit') {
if (this.mode === 'edit') {
this.$currency = this.$el.find('[data-name="' + this.currencyField + '"]');
}
},
@@ -69,15 +71,19 @@ Espo.define('views/fields/range-currency', 'views/fields/range-float', function
var fromValue = isNaN(fromValue) ? null : fromValue;
var toValue = isNaN(toValue) ? null : toValue;
var currencyValue = this.model.get(this.fromCurrencyField) || this.model.get(this.toCurrencyField) ;
var currencyValue = this.model.get(this.fromCurrencyField) || this.model.get(this.toCurrencyField);
if (fromValue !== null && toValue !== null) {
return this.formatNumber(fromValue) + ' &#8211 ' + this.formatNumber(toValue) + ' '+currencyValue+'';
} else if (fromValue) {
return this.formatNumber(fromValue) + ' &#8211 ' +
this.formatNumber(toValue) + ' ' + currencyValue + '';
}
else if (fromValue) {
return '&#62;&#61; ' + this.formatNumber(fromValue) + ' '+currencyValue+'';
} else if (toValue) {
}
else if (toValue) {
return '&#60;&#61; ' + this.formatNumber(toValue) + ' '+currencyValue+'';
} else {
}
else {
return this.translate('None');
}
},
@@ -90,12 +96,15 @@ Espo.define('views/fields/range-currency', 'views/fields/range-float', function
if (data[this.fromField] !== null) {
data[this.fromCurrencyField] = currencyValue;
} else {
}
else {
data[this.fromCurrencyField] = null;
}
if (data[this.toField] !== null) {
data[this.toCurrencyField] = currencyValue;
} else {
}
else {
data[this.toCurrencyField] = null;
}
+17 -4
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/fields/range-float', ['views/fields/range-int', 'views/fields/float'], function (Dep, Float) {
define('views/fields/range-float', ['views/fields/range-int', 'views/fields/float'], function (Dep, Float) {
return Dep.extend({
@@ -35,17 +35,22 @@ Espo.define('views/fields/range-float', ['views/fields/range-int', 'views/fields
validations: ['required', 'float', 'range', 'order'],
validateFloat: function () {
var validate = function (name) {
var validate = (name) => {
if (isNaN(this.model.get(name))) {
var msg = this.translate('fieldShouldBeFloat', 'messages').replace('{field}', this.getLabelText());
var msg = this.translate('fieldShouldBeFloat', 'messages')
.replace('{field}', this.getLabelText());
this.showValidationMessage(msg, '[data-name="'+name+'"]');
return true;
}
}.bind(this);
};
var result = false;
result = validate(this.fromField) || result;
result = validate(this.toField) || result;
return result;
},
@@ -57,6 +62,14 @@ Espo.define('views/fields/range-float', ['views/fields/range-int', 'views/fields
return Float.prototype.formatNumber.call(this, value);
},
formatNumberDetail: function (value) {
return Float.prototype.formatNumberDetail.call(this, value);
},
formatNumberEdit: function (value) {
return Float.prototype.formatNumberEdit.call(this, value);
},
});
});
+64 -31
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'], function (Dep, Int) {
define('views/fields/range-int', ['views/fields/base', 'views/fields/int'], function (Dep, Int) {
return Dep.extend({
@@ -42,16 +42,20 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
data: function () {
var data = Dep.prototype.data.call(this);
data.ucName = Espo.Utils.upperCaseFirst(this.name);
data.fromValue = this.model.get(this.fromField);
data.toValue = this.model.get(this.toField);
return data;
},
init: function () {
var ucName = Espo.Utils.upperCaseFirst(this.options.defs.name);
this.fromField = 'from' + ucName;
this.toField = 'to' + ucName;
Dep.prototype.init.call(this);
},
@@ -64,11 +68,14 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
if (fromValue !== null && toValue !== null) {
return this.formatNumber(fromValue) + ' &#8211 ' + this.formatNumber(toValue);
} else if (fromValue) {
}
else if (fromValue) {
return '&#62;&#61; ' + this.formatNumber(fromValue);
} else if (toValue) {
}
else if (toValue) {
return '&#60;&#61; ' + this.formatNumber(toValue);
} else {
}
else {
return this.translate('None');
}
},
@@ -76,14 +83,17 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
setup: function () {
if (this.getPreferences().has('decimalMark')) {
this.decimalMark = this.getPreferences().get('decimalMark');
} else {
}
else {
if (this.getConfig().has('decimalMark')) {
this.decimalMark = this.getConfig().get('decimalMark');
}
}
if (this.getPreferences().has('thousandSeparator')) {
this.thousandSeparator = this.getPreferences().get('thousandSeparator');
} else {
}
else {
if (this.getConfig().has('thousandSeparator')) {
this.thousandSeparator = this.getConfig().get('thousandSeparator');
}
@@ -92,53 +102,63 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
afterRender: function () {
Dep.prototype.afterRender.call(this);
if (this.mode == 'edit') {
if (this.mode === 'edit') {
this.$from = this.$el.find('[data-name="' + this.fromField + '"]');
this.$to = this.$el.find('[data-name="' + this.toField + '"]');
this.$from.on('change', function () {
this.$from.on('change', () => {
this.trigger('change');
}.bind(this));
this.$to.on('change', function () {
});
this.$to.on('change', () => {
this.trigger('change');
}.bind(this));
});
}
},
validateRequired: function () {
var validate = function (name) {
var validate = (name) => {
if (this.model.isRequired(name)) {
if (this.model.get(name) === null) {
var msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
this.showValidationMessage(msg, '[data-name="'+name+'"]');
return true;
}
}
}.bind(this);
};
var result = false;
result = validate(this.fromField) || result;
result = validate(this.toField) || result;
return result;
},
validateInt: function () {
var validate = function (name) {
var validate = (name) => {
if (isNaN(this.model.get(name))) {
var msg = this.translate('fieldShouldBeInt', 'messages').replace('{field}', this.getLabelText());
this.showValidationMessage(msg, '[data-name="'+name+'"]');
return true;
}
}.bind(this);
};
var result = false;
result = validate(this.fromField) || result;
result = validate(this.toField) || result;
return result;
},
validateRange: function () {
var validate = function (name) {
var validate = (name) => {
var value = this.model.get(name);
if (value === null) {
@@ -150,34 +170,45 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
if (minValue !== null && maxValue !== null) {
if (value < minValue || value > maxValue ) {
var msg = this.translate('fieldShouldBeBetween', 'messages').replace('{field}', this.translate(name, 'fields', this.model.name))
.replace('{min}', minValue)
.replace('{max}', maxValue);
var msg = this.translate('fieldShouldBeBetween', 'messages')
.replace('{field}', this.translate(name, 'fields', this.model.name))
.replace('{min}', minValue)
.replace('{max}', maxValue);
this.showValidationMessage(msg, '[data-name="'+name+'"]');
return true;
}
} else {
if (minValue !== null) {
if (value < minValue) {
var msg = this.translate('fieldShouldBeLess', 'messages').replace('{field}', this.translate(name, 'fields', this.model.name))
.replace('{value}', minValue);
var msg = this.translate('fieldShouldBeLess', 'messages')
.replace('{field}', this.translate(name, 'fields', this.model.name))
.replace('{value}', minValue);
this.showValidationMessage(msg, '[data-name="'+name+'"]');
return true;
}
} else if (maxValue !== null) {
if (value > maxValue) {
var msg = this.translate('fieldShouldBeGreater', 'messages').replace('{field}', this.translate(name, 'fields', this.model.name))
.replace('{value}', maxValue);
var msg = this.translate('fieldShouldBeGreater', 'messages')
.replace('{field}', this.translate(name, 'fields', this.model.name))
.replace('{value}', maxValue);
this.showValidationMessage(msg, '[data-name="'+name+'"]');
return true;
}
}
}
}.bind(this);
};
var result = false;
result = validate(this.fromField) || result;
result = validate(this.toField) || result;
return result;
},
@@ -187,10 +218,12 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
if (fromValue !== null && toValue !== null) {
if (fromValue > toValue) {
var msg = this.translate('fieldShouldBeGreater', 'messages').replace('{field}', this.translate(this.toField, 'fields', this.model.name))
.replace('{value}', this.translate(this.fromField, 'fields', this.model.name));
var msg = this.translate('fieldShouldBeGreater', 'messages')
.replace('{field}', this.translate(this.toField, 'fields', this.model.name))
.replace('{value}', this.translate(this.fromField, 'fields', this.model.name));
this.showValidationMessage(msg, '[data-name="'+this.fromField+'"]');
return true;
}
}
@@ -198,7 +231,7 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
isRequired: function () {
return this.model.getFieldParam(this.fromField, 'required') ||
this.model.getFieldParam(this.toField, 'required');
this.model.getFieldParam(this.toField, 'required');
},
parse: function (value) {
@@ -207,16 +240,16 @@ Espo.define('views/fields/range-int', ['views/fields/base', 'views/fields/int'],
formatNumber: function (value) {
return value;
return Int.prototype.formatNumber.call(this, value);
//return Int.prototype.formatNumber.call(this, value);
},
fetch: function (form) {
var data = {};
data[this.fromField] = this.parse(this.$from.val().trim());
data[this.toField] = this.parse(this.$to.val().trim());
return data;
}
return data;
},
});
});
+24
View File
@@ -119,6 +119,30 @@ define('views/modals/related-list', ['views/modal', 'search-manager'], function
this.collection.fetch();
});
// Sync changing models.
this.listenTo(this.panelCollection, 'change', (m, o) => {
// Prevent change after save.
if (o.xhr || !m.id) {
return;
}
let model = this.collection.get(m.id);
if (!model) {
return;
}
let attributes = {};
for (let name in m.attributes) {
if (m.hasChanged(name)) {
attributes[name] = m.attributes[name];
}
}
model.set(attributes);
});
if (this.model) {
this.listenTo(this.model, 'after:unrelate', () => {
this.panelCollection.fetch({
+2
View File
@@ -95,6 +95,8 @@ define('views/record/list-tree', 'views/record/list', function (Dep) {
data.showRootMenu = false;
}
data.noData = data.createDisabled && !data.rowList.length && !data.showRoot;
return data;
},
+1 -1
View File
@@ -5,7 +5,7 @@
"homepage": "https://github.com/espocrm/espocrm.git",
"license": "GPL-3.0-only",
"require": {
"php": ">=7.4.0",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"ext-pdo_mysql": "*",
"ext-openssl": "*",
"ext-json": "*",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "7.1.5",
"version": "7.1.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "7.1.5",
"version": "7.1.6",
"description": "Open-source CRM.",
"repository": {
"type": "git",