mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
TSK-745: Do not allow changing previous months events (Requests and public holidays) (#2796)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
cfda41bb66
commit
41f60e1011
@ -16,7 +16,7 @@
|
|||||||
import { Employee } from '@hcengineering/contact'
|
import { Employee } from '@hcengineering/contact'
|
||||||
import { EmployeePresenter } from '@hcengineering/contact-resources'
|
import { EmployeePresenter } from '@hcengineering/contact-resources'
|
||||||
import contact from '@hcengineering/contact-resources/src/plugin'
|
import contact from '@hcengineering/contact-resources/src/plugin'
|
||||||
import { Ref } from '@hcengineering/core'
|
import { AccountRole, getCurrentAccount, Ref } from '@hcengineering/core'
|
||||||
import type { Department, Request, RequestType, Staff } from '@hcengineering/hr'
|
import type { Department, Request, RequestType, Staff } from '@hcengineering/hr'
|
||||||
import {
|
import {
|
||||||
areDatesEqual,
|
areDatesEqual,
|
||||||
@ -75,8 +75,16 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isFutureDate () {
|
||||||
|
const today = new Date(Date.now())
|
||||||
|
return (
|
||||||
|
currentDate >= today ||
|
||||||
|
(currentDate.getMonth() === today.getMonth() && currentDate.getFullYear() === today.getFullYear())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function isEditable (employee: Staff): boolean {
|
function isEditable (employee: Staff): boolean {
|
||||||
return editableList.includes(employee._id)
|
return editableList.includes(employee._id) && (isFutureDate() || getCurrentAccount().role === AccountRole.Owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
const noWeekendHolidayType: Ref<RequestType>[] = [hr.ids.PTO, hr.ids.PTO2, hr.ids.Vacation]
|
const noWeekendHolidayType: Ref<RequestType>[] = [hr.ids.PTO, hr.ids.PTO2, hr.ids.Vacation]
|
||||||
@ -158,7 +166,7 @@
|
|||||||
on:mouseleave={() => {
|
on:mouseleave={() => {
|
||||||
hoveredIndex = -1
|
hoveredIndex = -1
|
||||||
}}
|
}}
|
||||||
on:click={() => setPublicHoliday(day)}
|
on:click={() => isFutureDate() && setPublicHoliday(day)}
|
||||||
>
|
>
|
||||||
{getWeekDayName(day, 'short')}
|
{getWeekDayName(day, 'short')}
|
||||||
<span>{day.getDate()}</span>
|
<span>{day.getDate()}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user