mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
fix(calendar): prevent adding timeblocks outside of working hours
This commit is contained in:
1 parent
128d53788e
commit
af6dcfe0b8
1 file changed
+16
@@ -282,6 +282,21 @@ export default {
|
||||
},
|
||||
|
||||
onCellClick(DOMEvent, split) {
|
||||
const allNonWorkingHoursEvents =
|
||||
DOMEvent.target.querySelectorAll('.non-working-event');
|
||||
|
||||
const calendarHeight = DOMEvent.target.offsetHeight;
|
||||
|
||||
const morningNonWorkingHoursEventHeight =
|
||||
allNonWorkingHoursEvents?.[0]?.offsetHeight || 950;
|
||||
const afternoonNonWorkingHoursEventHeight =
|
||||
allNonWorkingHoursEvents?.[1]?.offsetHeight || 1700;
|
||||
|
||||
if (
|
||||
// Check if the click is not in the non-working hours events
|
||||
DOMEvent.offsetY > morningNonWorkingHoursEventHeight &&
|
||||
DOMEvent.offsetY < calendarHeight - afternoonNonWorkingHoursEventHeight
|
||||
) {
|
||||
const dateFrom = split.date;
|
||||
dateFrom.setHours(Math.floor(DOMEvent.offsetY / 100), 0, 0, 0);
|
||||
const dateTo = new Date(dateFrom);
|
||||
@@ -307,6 +322,7 @@ export default {
|
||||
end: tmUtils.formatDateTimeForBackend(dateTo),
|
||||
});
|
||||
}, 150);
|
||||
}
|
||||
|
||||
if (!this.isDOMElementAnEvent(DOMEvent.target)) this.selectCell(DOMEvent);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user