diff --git a/application/Espo/Classes/FieldProcessing/WorkingTimeCalendar/IsDefaultLoader.php b/application/Espo/Classes/FieldProcessing/WorkingTimeCalendar/IsDefaultLoader.php new file mode 100644 index 0000000000..0d1b11e8a9 --- /dev/null +++ b/application/Espo/Classes/FieldProcessing/WorkingTimeCalendar/IsDefaultLoader.php @@ -0,0 +1,53 @@ +. + * + * 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\FieldProcessing\WorkingTimeCalendar; + +use Espo\Core\FieldProcessing\Loader; +use Espo\Core\FieldProcessing\Loader\Params; +use Espo\Core\Utils\Config; +use Espo\Entities\WorkingTimeCalendar; +use Espo\ORM\Entity; + +/** + * @implements Loader + */ +class IsDefaultLoader implements Loader +{ + public function __construct( + private Config $config, + ) {} + + public function process(Entity $entity, Params $params): void + { + $isDefault = $entity->getId() === $this->config->get('workingTimeCalendarId'); + + $entity->set('isDefault', $isDefault); + } +} diff --git a/application/Espo/Resources/i18n/en_US/WorkingTimeCalendar.json b/application/Espo/Resources/i18n/en_US/WorkingTimeCalendar.json index 960e132ecf..3df8bbc930 100644 --- a/application/Espo/Resources/i18n/en_US/WorkingTimeCalendar.json +++ b/application/Espo/Resources/i18n/en_US/WorkingTimeCalendar.json @@ -18,9 +18,14 @@ "weekday3TimeRanges": "Wed Schedule", "weekday4TimeRanges": "Thu Schedule", "weekday5TimeRanges": "Fri Schedule", - "weekday6TimeRanges": "Sat Schedule" + "weekday6TimeRanges": "Sat Schedule", + "isDefault": "Is Default" }, "links": { + "users": "Users", "ranges": "Exceptions" + }, + "tooltips": { + "isDefault": "Indicates whether this calendar is the system default. The default working time calendar can be configured in: Administration > Settings > Working Time Calendar." } } diff --git a/application/Espo/Resources/layouts/WorkingTimeCalendar/defaultSidePanel.json b/application/Espo/Resources/layouts/WorkingTimeCalendar/defaultSidePanel.json index fe51488c70..e641ce2505 100644 --- a/application/Espo/Resources/layouts/WorkingTimeCalendar/defaultSidePanel.json +++ b/application/Espo/Resources/layouts/WorkingTimeCalendar/defaultSidePanel.json @@ -1 +1,3 @@ -[] +[ + "isDefault" +] diff --git a/application/Espo/Resources/layouts/WorkingTimeCalendar/list.json b/application/Espo/Resources/layouts/WorkingTimeCalendar/list.json index ac1822864f..602f42bfbf 100644 --- a/application/Espo/Resources/layouts/WorkingTimeCalendar/list.json +++ b/application/Espo/Resources/layouts/WorkingTimeCalendar/list.json @@ -2,5 +2,9 @@ { "name": "name", "link": true + }, + { + "name": "isDefault", + "width": 14 } ] diff --git a/application/Espo/Resources/layouts/WorkingTimeCalendar/relationships.json b/application/Espo/Resources/layouts/WorkingTimeCalendar/relationships.json index 4cbbe81f7c..cdca22c0cd 100644 --- a/application/Espo/Resources/layouts/WorkingTimeCalendar/relationships.json +++ b/application/Espo/Resources/layouts/WorkingTimeCalendar/relationships.json @@ -1,3 +1,5 @@ [ - "ranges" + "ranges", + "users", + "teams" ] diff --git a/application/Espo/Resources/metadata/clientDefs/WorkingTimeCalendar.json b/application/Espo/Resources/metadata/clientDefs/WorkingTimeCalendar.json index d9eb0151e8..b03566d01c 100644 --- a/application/Espo/Resources/metadata/clientDefs/WorkingTimeCalendar.json +++ b/application/Espo/Resources/metadata/clientDefs/WorkingTimeCalendar.json @@ -15,5 +15,17 @@ } ] } + }, + "relationshipPanels": { + "teams": { + "createDisabled": true, + "editDisabled": true, + "removeDisabled": true + }, + "users": { + "createDisabled": true, + "editDisabled": true, + "removeDisabled": true + } } } diff --git a/application/Espo/Resources/metadata/entityDefs/WorkingTimeCalendar.json b/application/Espo/Resources/metadata/entityDefs/WorkingTimeCalendar.json index ab4a0f2562..7bcaf4e570 100644 --- a/application/Espo/Resources/metadata/entityDefs/WorkingTimeCalendar.json +++ b/application/Espo/Resources/metadata/entityDefs/WorkingTimeCalendar.json @@ -83,6 +83,14 @@ "default": null, "view": "views/working-time-calendar/fields/time-ranges" }, + "isDefault": { + "type": "bool", + "readOnly": true, + "notStorable": true, + "orderDisabled": true, + "loaderClassName": "Espo\\Classes\\FieldProcessing\\WorkingTimeCalendar\\IsDefaultLoader", + "tooltip": true + }, "teams": { "type": "linkMultiple", "readOnly": true @@ -110,6 +118,12 @@ "foreign": "calendars", "entity": "WorkingTimeRange" }, + "users": { + "type": "hasMany", + "foreign": "workingTimeCalendar", + "entity": "User", + "readOnly": true + }, "teams": { "type": "hasMany", "foreign": "workingTimeCalendar", diff --git a/application/Espo/Resources/metadata/logicDefs/WorkingTimeCalendar.json b/application/Espo/Resources/metadata/logicDefs/WorkingTimeCalendar.json index fdccd8ba44..fa5894b0a8 100644 --- a/application/Espo/Resources/metadata/logicDefs/WorkingTimeCalendar.json +++ b/application/Espo/Resources/metadata/logicDefs/WorkingTimeCalendar.json @@ -79,6 +79,16 @@ } ] } + }, + "isDefault": { + "visible": { + "conditionGroup": [ + { + "type": "isNotEmpty", + "attribute": "id" + } + ] + } } } }