Merge branch 'fix'

This commit is contained in:
Yurii
2026-02-14 16:25:52 +02:00
27 changed files with 584 additions and 56 deletions
@@ -0,0 +1,55 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* 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.
************************************************************************/
namespace Espo\Classes\FieldValidators\WorkingTimeRange\Calendars;
use Espo\Core\FieldValidation\Validator;
use Espo\Core\FieldValidation\Validator\Data;
use Espo\Core\FieldValidation\Validator\Failure;
use Espo\Entities\WorkingTimeRange;
use Espo\ORM\Entity;
/**
* @implements Validator<WorkingTimeRange>
*/
class OnlyIfNoUsers implements Validator
{
public function validate(Entity $entity, string $field, Data $data): ?Failure
{
if ($entity->getCalendars()->getCount() === 0) {
return null;
}
if ($entity->getUsers()->getCount() === 0) {
return null;
}
return Failure::create();
}
}
@@ -0,0 +1,52 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* 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.
************************************************************************/
namespace Espo\Classes\FieldValidators\WorkingTimeRange\Calendars;
use Espo\Core\FieldValidation\Validator;
use Espo\Core\FieldValidation\Validator\Data;
use Espo\Core\FieldValidation\Validator\Failure;
use Espo\Entities\WorkingTimeRange;
use Espo\ORM\Entity;
/**
* @implements Validator<WorkingTimeRange>
*/
class RequiredIfNoUsers implements Validator
{
public function validate(Entity $entity, string $field, Data $data): ?Failure
{
if ($entity->getCalendars()->getCount() !== 0 || $entity->getUsers()->getCount() !== 0) {
return null;
}
return Failure::create();
}
}
@@ -0,0 +1,55 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* 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.
************************************************************************/
namespace Espo\Classes\FieldValidators\WorkingTimeRange\Users;
use Espo\Core\FieldValidation\Validator;
use Espo\Core\FieldValidation\Validator\Data;
use Espo\Core\FieldValidation\Validator\Failure;
use Espo\Entities\WorkingTimeRange;
use Espo\ORM\Entity;
/**
* @implements Validator<WorkingTimeRange>
*/
class OnlyIfNoCalendars implements Validator
{
public function validate(Entity $entity, string $field, Data $data): ?Failure
{
if ($entity->getUsers()->getCount() === 0) {
return null;
}
if ($entity->getCalendars()->getCount() === 0) {
return null;
}
return Failure::create();
}
}
@@ -65,7 +65,11 @@ class ListLoader implements LoaderInterface
foreach ($this->getFieldList($entityType) as $field) {
if (
!in_array($field . 'Ids', $select) &&
!in_array($field . 'Names', $select)
!in_array($field . 'Names', $select) &&
(
!$entity->hasAttribute($field . 'Columns') ||
!in_array($field . 'Columns', $select)
)
) {
continue;
}
@@ -128,4 +128,13 @@ class WorkingTimeRange extends Entity
/** @var LinkMultiple */
return $this->getValueObject('users');
}
/**
* @since 9.3.1
*/
public function getCalendars(): LinkMultiple
{
/** @var LinkMultiple */
return $this->getValueObject('calendars');
}
}
+6 -2
View File
@@ -267,8 +267,12 @@ class Image implements EntryPoint
}
}
if ($targetWidth < 1 || $targetHeight < 1) {
throw new RuntimeException("No width or height.");
if ($targetWidth < 1) {
$targetWidth = 1;
}
if ($targetHeight < 1) {
$targetHeight = 1;
}
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
@@ -1,5 +1,6 @@
{
"labels": {
"Create ApiUser": "Create API User"
"Create ApiUser": "Create API User",
"OpenAPI spec": "OpenAPI spec"
}
}
@@ -13,9 +13,13 @@
{"name": "timeRanges"},
false
],
[
{"name": "users"},
false
],
[
{"name": "calendars"},
{"name": "users"}
false
],
[
{"name": "description"}
@@ -13,9 +13,13 @@
{"name": "timeRanges"},
false
],
[
{"name": "users"},
false
],
[
{"name": "calendars"},
{"name": "users"}
false
],
[
{"name": "description"}
@@ -30,5 +30,18 @@
},
"filterList": [
],
"boolFilterList": []
"boolFilterList": [],
"menu": {
"list": {
"dropdown": [
{
"name": "openApiSpec",
"label": "OpenAPI spec",
"link": "api/v1/OpenApi",
"handler": "handlers/api-user/open-api-spec-action",
"actionFunction": "process"
}
]
}
}
}
@@ -23,7 +23,7 @@
"type": "decimal",
"decimalPlaces": 6,
"min": 0.0001,
"precision": 15,
"precision": 20,
"scale": 8,
"required": true,
"audited": true,
@@ -119,7 +119,8 @@
},
"fontFace": {
"type": "enum",
"view": "views/template/fields/font-face"
"view": "views/template/fields/font-face",
"isSorted": true
},
"title": {
"type": "varchar"
@@ -34,12 +34,20 @@
},
"calendars": {
"type": "linkMultiple",
"tooltip": true
"tooltip": true,
"validatorClassNameList": [
"Espo\\Classes\\FieldValidators\\WorkingTimeRange\\Calendars\\OnlyIfNoUsers",
"Espo\\Classes\\FieldValidators\\WorkingTimeRange\\Calendars\\RequiredIfNoUsers"
],
"autocompleteOnEmpty": true
},
"users": {
"type": "linkMultiple",
"view": "views/working-time-range/fields/users",
"tooltip": true
"tooltip": true,
"validatorClassNameList": [
"Espo\\Classes\\FieldValidators\\WorkingTimeRange\\Users\\OnlyIfNoCalendars"
]
},
"createdAt": {
"type": "datetime",
@@ -11,7 +11,7 @@
]
}
},
"users": {
"calendars": {
"visible": {
"conditionGroup": [
{
@@ -19,8 +19,36 @@
"value": [
{
"type": "isNotEmpty",
"attribute": "id"
"attribute": "calendarsIds"
},
{
"type": "isEmpty",
"attribute": "usersIds"
}
]
}
]
}
},
"users": {
"required": {
"conditionGroup": [
{
"type": "or",
"value": [
{
"type": "isEmpty",
"attribute": "calendarsIds"
}
]
}
]
},
"visible": {
"conditionGroup": [
{
"type": "or",
"value": [
{
"type": "isNotEmpty",
"attribute": "usersIds"
@@ -724,6 +724,7 @@ class EntityManager
'collection.order',
'collection.textFilterFields',
'collection.fullTextSearch',
'collection.countDisabled',
]);
foreach ($this->getAdditionalParamLocationMap($name) as $it) {
@@ -84,6 +84,7 @@ class Service
$this->entityManager->saveEntity($entity);
$service->loadAdditionalFields($entity);
$service->prepareEntityForOutput($entity);
return $entity;
@@ -108,6 +109,7 @@ class Service
$this->entityManager->saveEntity($entity);
$service->loadAdditionalFields($entity);
$service->prepareEntityForOutput($entity);
return $entity;
@@ -472,12 +472,15 @@ class RecordService
private function prepareSetFields(Notification $entity): void
{
if ($entity->getRelated() && $entity->getData()?->relatedName) {
$entity->set('relatedName', $entity->getData()->relatedName);
$relatedName = $entity->getData()->relatedName ?? null;
$createdByName = $entity->getData()->createdByName ?? null;
if ($entity->getRelated() && $relatedName !== null) {
$entity->set('relatedName', $relatedName);
}
if ($entity->getCreatedBy() && $entity->getData()?->createdByName) {
$entity->set('createdByName', $entity->getData()->createdByName);
if ($entity->getCreatedBy() && $createdByName !== null) {
$entity->set('createdByName', $createdByName);
}
}
}
@@ -30,33 +30,61 @@
namespace Espo\Tools\Pdf\Dompdf;
use Dompdf\Dompdf;
use Dompdf\FontMetrics;
use Dompdf\Options;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Metadata;
use Espo\Tools\Pdf\Params;
use Espo\Tools\Pdf\Template;
class DompdfInitializer
{
private string $defaultFontFace = 'DejaVu Sans';
private string $cacheDir = 'data/cache/application/dompdf';
private string $pdfaCacheDir = 'data/cache/application/pdfa-dompdf';
private const PT = 2.83465;
/** @var array<string, string> */
private array $standardFontMapping = [
'courier' => 'DejaVu Sans Mono',
'fixed' => 'DejaVu Sans Mono',
'helvetica' => 'DejaVu Sans',
'monospace' => 'DejaVu Sans Mono',
'sans-serif' => 'DejaVu Sans',
'serif' => 'DejaVu Serif',
'times' => 'DejaVu Serif',
'times-roman' => 'DejaVu Serif',
];
public function __construct(
private Config $config,
private Metadata $metadata,
private FileManager $fileManager,
) {}
public function initialize(Template $template, Params $params): Dompdf
{
$options = new Options();
$options->setIsPdfAEnabled($params->isPdfA());
$options->setDefaultFont($this->getFontFace($template));
$options
->setIsPdfAEnabled($params->isPdfA())
->setDefaultFont($this->getFontFace($template))
->setIsJavascriptEnabled(false);
$dir = $params->isPdfA() ? $this->pdfaCacheDir : $this->cacheDir;
$options->setFontDir($dir);
$options->setFontCache($dir);
if (!$this->fileManager->isDir($dir)) {
$this->fileManager->mkdir($dir);
}
$pdf = new Dompdf($options);
if ($params->isPdfA()) {
$this->mapFonts($pdf);
}
$this->mapFonts($pdf, $params->isPdfA(), $dir);
$size = $template->getPageFormat() === Template::PAGE_FORMAT_CUSTOM ?
[0.0, 0.0, $template->getPageWidth() * self::PT, $template->getPageHeight() * self::PT] :
@@ -79,18 +107,36 @@ class DompdfInitializer
$this->defaultFontFace;
}
private function mapFonts(Dompdf $pdf): void
private function mapFonts(Dompdf $pdf, bool $isPdfA, string $dir): void
{
// Fonts are included in PDF/A. Map standard fonts to open source analogues.
$file = $dir . '/' . FontMetrics::USER_FONTS_FILE;
if ($this->fileManager->exists($file)) {
return;
}
// When fonts are included in PDF/A, we need to map standard fonts to open source analogues.
// Also need to support popular fonts specified in CSS styles.
$fontMetrics = $pdf->getFontMetrics();
$fontMetrics->setFontFamily('courier', $fontMetrics->getFamily('DejaVu Sans Mono'));
$fontMetrics->setFontFamily('fixed', $fontMetrics->getFamily('DejaVu Sans Mono'));
$fontMetrics->setFontFamily('helvetica', $fontMetrics->getFamily('DejaVu Sans'));
$fontMetrics->setFontFamily('monospace', $fontMetrics->getFamily('DejaVu Sans Mono'));
$fontMetrics->setFontFamily('sans-serif', $fontMetrics->getFamily('DejaVu Sans'));
$fontMetrics->setFontFamily('serif', $fontMetrics->getFamily('DejaVu Serif'));
$fontMetrics->setFontFamily('times', $fontMetrics->getFamily('DejaVu Serif'));
$fontMetrics->setFontFamily('times-roman', $fontMetrics->getFamily('DejaVu Serif'));
if ($isPdfA) {
foreach ($this->standardFontMapping as $key => $value) {
$fontMetrics->setFontFamily($key, $fontMetrics->getFamily($value));
}
return;
}
/** @var string[] $fontList */
$fontList = $this->metadata->get('app.pdfEngines.Dompdf.fontFaceList') ?? [];
$fontList = array_map(fn ($it) => strtolower($it), $fontList);
foreach ($this->standardFontMapping as $key => $value) {
if (in_array(strtolower($key), $fontList)) {
continue;
}
$fontMetrics->setFontFamily($key, $fontMetrics->getFamily($value));
}
}
}
@@ -0,0 +1,46 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* 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 ActionHandler from 'action-handler';
import {inject} from 'di';
import Router from 'router';
// noinspection JSUnusedGlobalSymbols
export default class extends ActionHandler {
/**
* @type {Router}
* @private
*/
@inject(Router)
router
process() {
window.open('api/v1/OpenApi', '_blank');
}
}
+112
View File
@@ -0,0 +1,112 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* 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.
************************************************************************/
/**
* @since 9.3.1
*/
export default class LinkFieldIconHelper {
/**
* @param {import('views/fields/link').default} view
* @param {{
* iconClass: string,
* getIconClass: function(): string|null,
* getColor: function(): string,
* }} options
*/
constructor(view, options) {
this.view = view;
this.options = options;
view.listenTo(view, 'after:render', () => {
if (view.isEditMode()) {
this.control();
}
});
view.addHandler('keydown', `input[data-name="${view.nameName}"]`, (/** KeyboardEvent */e, target) => {
if (e.code === 'Enter') {
return;
}
target.classList.add('being-typed');
});
view.addHandler('change', `input[data-name="${view.nameName}"]`, (e, target) => {
setTimeout(() => target.classList.remove('being-typed'), 200);
});
view.addHandler('blur', `input[data-name="${view.nameName}"]`, (e, target) => {
target.classList.remove('being-typed');
});
view.on('change', () => {
if (!view.isEditMode()) {
return;
}
const span = view.element.querySelector('span.icon-in-input');
if (span) {
span.parentNode.removeChild(span);
}
setTimeout(() => this.control(), 0);
});
}
/**
* @private
*/
control() {
const view = this.view;
const nameElement = view.element.querySelector(`input[data-name="${view.nameName}"]`);
nameElement.classList.remove('being-typed');
const icon = document.createElement('span');
icon.className = 'icon-in-input ' + this.options.iconClass;
icon.style.color = this.options.getColor();
const iconClass = this.options.getIconClass();
if (!iconClass) {
return;
}
icon.className += ' ' + iconClass;
const input = view.element.querySelector('.input-group > input');
if (!input) {
return;
}
input.after(icon);
}
}
+10
View File
@@ -118,6 +118,16 @@ class LayoutFiltersView extends LayoutRowsView {
return false;
}
/** @type {string[]|null} */
const layoutList = model.getFieldParam(name, 'layoutAvailabilityList');
if (
layoutList &&
!layoutList.includes(this.type)
) {
return false;
}
return !model.getFieldParam(name, 'disabled') &&
!model.getFieldParam(name, 'utility') &&
!model.getFieldParam(name, 'layoutFiltersDisabled');
@@ -108,8 +108,14 @@ class ExpandedLayoutDashletFieldView extends BaseFieldView {
this.addActionHandler('editItem', (event, target) => this.editItem(target.dataset.name));
this.targetEntityType = this.model.get('entityType') ||
this.targetEntityType = this.model.attributes.entityType ??
this.getMetadata().get(['dashlets', this.dataObject.dashletName, 'entityType']);
this.listenTo(this.model, 'change:entityType', () => {
if (this.model.attributes.entityType) {
this.targetEntityType = this.model.attributes.entityType;
}
});
}
/**
+24 -4
View File
@@ -223,8 +223,7 @@ class DetailModalView extends ModalView {
return;
}
this.model = this.sourceModel.clone();
this.model.collection = this.sourceModel.collection.clone();
this.cloneSourceModel();
this.setupAfterModelCreated();
@@ -259,6 +258,23 @@ class DetailModalView extends ModalView {
}
}
/**
* @private
*/
cloneSourceModel() {
this.model = this.sourceModel.clone();
const sourceCollection = this.sourceModel.collection;
if (!sourceCollection) {
return;
}
this.model.collection = sourceCollection.clone();
this.listenTo(this.model.collection, 'update-source', () => sourceCollection.fetch())
}
/**
* Additional setup with the model ready.
*
@@ -512,6 +528,7 @@ class DetailModalView extends ModalView {
}
const previousModel = this.model;
const previousCollection = this.model.collection;
this.sourceModel = this.model.collection.at(indexOfRecord);
@@ -524,12 +541,15 @@ class DetailModalView extends ModalView {
this.id = this.sourceModel.id;
this.scope = this.sourceModel.entityType;
this.model = this.sourceModel.clone();
this.model.collection = this.sourceModel.collection.clone();
this.cloneSourceModel();
this.stopListening(previousModel, 'change');
this.stopListening(previousModel, 'sync');
if (previousCollection) {
this.stopListening(previousCollection, 'update-source');
}
this.listenTo(this.model, 'change', () => {
this.sourceModel.set(this.model.getClonedAttributes());
});
+2 -1
View File
@@ -846,7 +846,8 @@ class DetailRecordView extends BaseRecordView {
if (this.duplicateAction) {
if (
this.getAcl().check(this.entityType, 'create') &&
!this.getMetadata().get(['clientDefs', this.scope, 'duplicateDisabled'])
!this.getMetadata().get(['clientDefs', this.scope, 'duplicateDisabled']) &&
!this.getMetadata().get(['clientDefs', this.scope, 'createDisabled'])
) {
this.addDropdownItem({
label: 'Duplicate',
+22 -5
View File
@@ -2364,24 +2364,41 @@ td.cell {
}
}
div:has(.avatar-in-input):not(:has(.being-typed)) {
div:has(.avatar-in-input),
div:has(.icon-in-input) {
&:not(:has(.being-typed)) {
> .input-group > input {
padding-left: var(--33px);
}
&:has(.color-icon) {
> .input-group > input {
padding-left: var(--21px);
}
}
> .icon-in-input,
> .avatar-in-input {
display: inline-block;
position: absolute;
top: var(--9px);
left: var(--10px);
z-index: 3;
user-select: none;
pointer-events: none;
}
}
div:has(.avatar-in-input) {
> .avatar-in-input {
top: var(--9px);
left: var(--10px);
}
> .icon-in-input {
top: var(--11px);
left: var(--10px);
}
}
> .avatar-in-input,
> .icon-in-input {
display: none;
}
}
+5
View File
@@ -33,6 +33,11 @@
}
]
}
},
"additionalParams": {
"type": "object",
"additionalProperties": true,
"description": "Additional engine-wise parameters."
}
}
}
+21
View File
@@ -433,6 +433,27 @@
}
}
},
{
"if": {
"properties": {
"type": {
"anyOf": [
{"const": "enum"},
{"const": "multiEnum"},
{"const": "checklist"}
]
}
}
},
"then": {
"properties": {
"isSorted": {
"type": "boolean",
"description": "Sort the dropdown options alphabetically."
}
}
}
},
{
"if": {
"properties": {