diff --git a/plugins/hr-assets/lang/en.json b/plugins/hr-assets/lang/en.json index 8b8e503442..66039f8374 100644 --- a/plugins/hr-assets/lang/en.json +++ b/plugins/hr-assets/lang/en.json @@ -36,6 +36,7 @@ "ChooseNewType": "Choose new type:", "UnchangeableType": "This type cannot be changed", "Request": "Request", + "ExistingRequests": "There are already existing requests for set dates", "Staff": "Worker", "Member": "Member", "Members": "Members", diff --git a/plugins/hr-assets/lang/ru.json b/plugins/hr-assets/lang/ru.json index 8f1b4b81eb..a6893aafd5 100644 --- a/plugins/hr-assets/lang/ru.json +++ b/plugins/hr-assets/lang/ru.json @@ -36,6 +36,7 @@ "ChooseNewType": "Выберите новый тип:", "UnchangeableType": "Этот тип нельзя поменять", "Request": "Запрос", + "ExistingRequests": "На данные даты уже существуют запросы", "Staff": "Работник", "Member": "Сотрудник", "Members": "Сотрудники", diff --git a/plugins/hr-resources/src/components/CreateRequest.svelte b/plugins/hr-resources/src/components/CreateRequest.svelte index 40c10f0347..926b8c9812 100644 --- a/plugins/hr-resources/src/components/CreateRequest.svelte +++ b/plugins/hr-resources/src/components/CreateRequest.svelte @@ -21,14 +21,16 @@ import { translate } from '@hcengineering/platform' import { Card, createQuery, getClient } from '@hcengineering/presentation' import { EmployeeBox } from '@hcengineering/contact-resources' - import ui, { Button, DateRangePresenter, DropdownLabelsIntl, IconAttachment } from '@hcengineering/ui' + import ui, { Button, DateRangePresenter, DropdownLabelsIntl, IconAttachment, Label } from '@hcengineering/ui' import { createEventDispatcher } from 'svelte' import hr from '../plugin' + import { getRequests } from '../utils' export let staff: Staff export let date: Date export let readonly: boolean export let docQuery: DocumentQuery | undefined + export let employeeRequests: Map, Request[]> let description: string = '' let employee: Ref = staff._id @@ -77,13 +79,33 @@ function typeSelected (_id: Ref): void { type = types.find((p) => p._id === _id) } + + function moreThanLimit ( + employeeRequests: Map, Request[]>, + staff: Staff, + startDate: Date, + endDate: Date, + type: RequestType | undefined + ): boolean { + if (employeeRequests === undefined) return true + if (type === undefined) return true + const requests = getRequests(employeeRequests, startDate, endDate, staff._id) + return requests.length > 0 + } + $: notLimit = moreThanLimit( + employeeRequests, + staff, + new Date(value), + new Date(new Date(dueDate).setHours(23, 59, 59, 999)), + type + ) { dispatch('close') }} @@ -138,4 +160,9 @@ }} /> + + {#if notLimit} + diff --git a/plugins/hr-resources/src/components/schedule/MonthView.svelte b/plugins/hr-resources/src/components/schedule/MonthView.svelte index e9147bd253..a2d456c016 100644 --- a/plugins/hr-resources/src/components/schedule/MonthView.svelte +++ b/plugins/hr-resources/src/components/schedule/MonthView.svelte @@ -69,6 +69,7 @@ staff, date, readonly, + employeeRequests, docQuery: { active: true, $search: editableList.join(' | ') } }, eventToHTMLElement(e) @@ -236,6 +237,7 @@
0} class="h-full w-full"> {#if requests.length}