Merge branch 'fix'

This commit is contained in:
Yuri Kuznetsov
2025-06-02 09:49:10 +03:00
7 changed files with 131 additions and 18 deletions

View File

@@ -58,6 +58,9 @@ class DataBuilder
public function __construct(private MetadataProvider $metadataProvider, private FieldUtil $fieldUtil)
{}
/**
* @return stdClass&object{table: stdClass, fieldTable: stdClass}
*/
public function build(Table $table): stdClass
{
$data = (object) [

View File

@@ -128,6 +128,7 @@ class ItemGeneralConverter implements ItemConverter
case 'columnLike':
case 'columnIn':
case 'columnNotIn':
case 'columnIsNull':
case 'columnIsNotNull':
case 'columnEquals':
case 'columnNotEquals':

View File

@@ -0,0 +1,91 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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.
************************************************************************/
namespace Espo\Core\Utils\Client;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Module;
use Espo\Core\Utils\Util;
/**
* Allows bundled extensions to work when the system is in the developer mode.
*/
class DevModeExtensionInitJsFileListProvider
{
public function __construct(
private Module $module,
private FileManager $fileManager,
private Config $config,
) {}
/**
* @return string[]
*/
public function get(): array
{
$developedModule = $this->config->get('developedModule');
if (!$developedModule) {
return [];
}
$output = [];
foreach ($this->getBundledModuleList() as $module) {
if ($module === $developedModule) {
continue;
}
$file = "client/custom/modules/$module/lib/init.js";
if ($this->fileManager->exists($file)) {
$output[] = $file;
}
}
return $output;
}
/**
* @return string[]
*/
private function getBundledModuleList(): array
{
$modules = array_values(array_filter(
$this->module->getList(),
fn ($item) => $this->module->get([$item, 'bundled'])
));
return array_map(
fn ($item) => Util::fromCamelCase($item, '-'),
$modules
);
}
}

View File

@@ -31,6 +31,7 @@ namespace Espo\Core\Utils;
use Espo\Core\Api\Response;
use Espo\Core\Api\ResponseWrapper;
use Espo\Core\Utils\Client\DevModeExtensionInitJsFileListProvider;
use Espo\Core\Utils\Client\DevModeJsFileListProvider;
use Espo\Core\Utils\Client\LoaderParamsProvider;
use Espo\Core\Utils\Client\RenderParams;
@@ -67,6 +68,7 @@ class ClientManager
private Metadata $metadata,
private FileManager $fileManager,
private DevModeJsFileListProvider $devModeJsFileListProvider,
private DevModeExtensionInitJsFileListProvider $devModeExtensionInitJsFileListProvider,
private Module $module,
private LoaderParamsProvider $loaderParamsProvider,
private SystemConfig $systemConfig,
@@ -304,6 +306,7 @@ class ClientManager
return array_merge(
$this->metadata->get(['app', 'client', 'developerModeScriptList']) ?? [],
$this->getDeveloperModeBundleLibFileList(),
$this->devModeExtensionInitJsFileListProvider->get(),
);
}

View File

@@ -93,6 +93,8 @@ class Autocomplete {
const $modalBody = this.$element.closest('.modal-body');
const isModal = !!$modalBody.length;
this.$element.autocomplete({
beforeRender: $container => {
if (options.beforeRender) {
@@ -110,6 +112,13 @@ class Autocomplete {
setTimeout(() => this.$element.autocomplete('hide'), 30);
}
}
if (isModal) {
// Fixes dropdown dissapearing when clicking scrollbar.
$container.on('mousedown', e => {
e.preventDefault();
});
}
},
lookup: lookup,
minChars: options.minChars || 0,

View File

@@ -29,7 +29,7 @@
import BaseFieldView from 'views/fields/base';
/**
* Important. Used in extensions.
* Important. Extended in extensions.
*/
export default class extends BaseFieldView {
@@ -46,25 +46,23 @@ export default class extends BaseFieldView {
setup() {
this.addActionHandler('editConditions', () => this.edit());
this.conditionGroup = Espo.Utils.cloneDeep((this.model.get(this.name) || {}).conditionGroup || []);
this.scope = this.params.scope || this.options.scope;
this.createStringView();
}
createStringView() {
this.createView('conditionGroup', 'views/admin/dynamic-logic/conditions-string/group-base', {
async prepare() {
this.conditionGroup = Espo.Utils.cloneDeep((this.model.attributes[this.name] || {}).conditionGroup || []);
return this.createStringView();
}
async createStringView() {
return this.createView('conditionGroup', 'views/admin/dynamic-logic/conditions-string/group-base', {
selector: '.top-group-string-container',
itemData: {
value: this.conditionGroup
},
operator: 'and',
scope: this.scope,
}, view => {
if (this.isRendered()) {
view.render();
}
});
}
@@ -75,12 +73,13 @@ export default class extends BaseFieldView {
}, view => {
view.render();
this.listenTo(view, 'apply', conditionGroup => {
this.listenTo(view, 'apply', async conditionGroup => {
this.conditionGroup = conditionGroup;
this.trigger('change');
this.createStringView();
await this.createStringView();
await this.reRender();
});
});
}

View File

@@ -52,9 +52,9 @@ export default class extends EditRecordView {
const entityType = this.model.get('entityType');
if (!entityType) {
this.model.set('header', '');
this.model.set('body', '');
this.model.set('footer', '');
this.model.set('header', null);
this.model.set('body', null);
this.model.set('footer', null);
this.hideField('variables');
@@ -67,6 +67,7 @@ export default class extends EditRecordView {
this.model.set('header', storedData[entityType].header);
this.model.set('body', storedData[entityType].body);
this.model.set('footer', storedData[entityType].footer);
this.model.set('style', storedData[entityType].style);
return;
}
@@ -74,6 +75,7 @@ export default class extends EditRecordView {
let header, body, footer;
let sourceType = null;
let style = null;
if (
this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', entityType])
@@ -102,15 +104,18 @@ export default class extends EditRecordView {
footer = this.getMetadata().get(
['entityDefs', 'Template', 'defaultTemplates', sourceType, 'footer']
);
style = this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', sourceType, 'style']);
}
body = body || '';
body = body || null;
header = header || null;
footer = footer || null;
this.model.set('body', body);
this.model.set('header', header);
this.model.set('footer', footer);
this.model.set('style', style);
});
this.listenTo(this.model, 'change', (e, o) => {
@@ -121,7 +126,8 @@ export default class extends EditRecordView {
if (
!this.model.hasChanged('header') &&
!this.model.hasChanged('body') &&
!this.model.hasChanged('footer')
!this.model.hasChanged('footer') &&
!this.model.hasChanged('style')
) {
return;
}
@@ -136,6 +142,7 @@ export default class extends EditRecordView {
header: this.model.get('header'),
body: this.model.get('body'),
footer: this.model.get('footer'),
style: this.model.get('style'),
};
});
}