Always Allow Owner to edit/Create Public holidays (#4528)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2024-02-05 23:09:19 +05:00 committed by GitHub
parent 722ae8a0f5
commit 02758613d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -37,9 +37,9 @@
}
}
function saveHoliday () {
async function saveHoliday () {
if (existingHoliday !== undefined) {
client.updateDoc(hr.class.PublicHoliday, core.space.Space, existingHoliday._id, {
await client.updateDoc(hr.class.PublicHoliday, core.space.Space, existingHoliday._id, {
title,
description
})
@ -50,7 +50,7 @@
date: toTzDate(date),
department
}
client.createDoc(hr.class.PublicHoliday, core.space.Space, holiday)
await client.createDoc(hr.class.PublicHoliday, core.space.Space, holiday)
}
}
findHoliday()

View File

@ -172,6 +172,7 @@
eventToHTMLElement(e)
)
}
const me = getCurrentAccount()
function isFutureDate () {
const today = new Date(Date.now())
@ -182,7 +183,7 @@
}
function isEditable (employee: Staff): boolean {
return editableList.includes(employee._id) && (isFutureDate() || getCurrentAccount().role === AccountRole.Owner)
return editableList.includes(employee._id) && (isFutureDate() || me.role === AccountRole.Owner)
}
function getTooltip (requests: Request[], day: Date, staff: Staff): LabelAndProps | undefined {
@ -305,7 +306,7 @@
class="timeline-cell timeline-day-header flex-col-center justify-center"
style={getCellStyle()}
on:click={() => {
if (isFutureDate()) {
if (isFutureDate() || me.role === AccountRole.Owner) {
setPublicHoliday(day)
}
}}