mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-03 00:27:01 +00:00
workking time exception ux impr
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user