mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-03 02:57: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 */
|
/** @var LinkMultiple */
|
||||||
return $this->getValueObject('users');
|
return $this->getValueObject('users');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 9.3.1
|
||||||
|
*/
|
||||||
|
public function getCalendars(): LinkMultiple
|
||||||
|
{
|
||||||
|
/** @var LinkMultiple */
|
||||||
|
return $this->getValueObject('calendars');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,13 @@
|
|||||||
{"name": "timeRanges"},
|
{"name": "timeRanges"},
|
||||||
false
|
false
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{"name": "users"},
|
||||||
|
false
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{"name": "calendars"},
|
{"name": "calendars"},
|
||||||
{"name": "users"}
|
false
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{"name": "description"}
|
{"name": "description"}
|
||||||
|
|||||||
@@ -13,9 +13,13 @@
|
|||||||
{"name": "timeRanges"},
|
{"name": "timeRanges"},
|
||||||
false
|
false
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{"name": "users"},
|
||||||
|
false
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{"name": "calendars"},
|
{"name": "calendars"},
|
||||||
{"name": "users"}
|
false
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{"name": "description"}
|
{"name": "description"}
|
||||||
|
|||||||
@@ -34,12 +34,20 @@
|
|||||||
},
|
},
|
||||||
"calendars": {
|
"calendars": {
|
||||||
"type": "linkMultiple",
|
"type": "linkMultiple",
|
||||||
"tooltip": true
|
"tooltip": true,
|
||||||
|
"validatorClassNameList": [
|
||||||
|
"Espo\\Classes\\FieldValidators\\WorkingTimeRange\\Calendars\\OnlyIfNoUsers",
|
||||||
|
"Espo\\Classes\\FieldValidators\\WorkingTimeRange\\Calendars\\RequiredIfNoUsers"
|
||||||
|
],
|
||||||
|
"autocompleteOnEmpty": true
|
||||||
},
|
},
|
||||||
"users": {
|
"users": {
|
||||||
"type": "linkMultiple",
|
"type": "linkMultiple",
|
||||||
"view": "views/working-time-range/fields/users",
|
"view": "views/working-time-range/fields/users",
|
||||||
"tooltip": true
|
"tooltip": true,
|
||||||
|
"validatorClassNameList": [
|
||||||
|
"Espo\\Classes\\FieldValidators\\WorkingTimeRange\\Users\\OnlyIfNoCalendars"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "datetime",
|
"type": "datetime",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"users": {
|
"calendars": {
|
||||||
"visible": {
|
"visible": {
|
||||||
"conditionGroup": [
|
"conditionGroup": [
|
||||||
{
|
{
|
||||||
@@ -19,8 +19,36 @@
|
|||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "isNotEmpty",
|
"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",
|
"type": "isNotEmpty",
|
||||||
"attribute": "usersIds"
|
"attribute": "usersIds"
|
||||||
|
|||||||
Reference in New Issue
Block a user