Skip to content

Commit

Permalink
feat: no bg color for forbidden drop days
Browse files Browse the repository at this point in the history
  • Loading branch information
krantheman committed Jun 12, 2024
1 parent 3cf536f commit 98d8ebf
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions roster/src/components/MonthViewTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
dropCell.employee === employee.name &&
dropCell.date === day.date &&
!(
events.data?.[employee.name]?.[day.date]?.holiday ||
events.data?.[employee.name]?.[day.date]?.leave
isHolidayOrLeave(employee.name, day.date) ||
hasSameShift(employee.name, day.date)
),
}"
@mouseenter="
Expand All @@ -94,14 +94,8 @@
() => {
if (
!(
events.data?.[employee.name]?.[day.date]?.holiday ||
events.data?.[employee.name]?.[day.date]?.leave ||
(Array.isArray(events.data?.[employee.name]?.[day.date]) &&
events.data?.[employee.name]?.[day.date].some(
(shift: Shift) =>
shift.shift_type === hoveredCell.shift_type &&
shift.status === hoveredCell.shift_status,
))
isHolidayOrLeave(employee.name, day.date) ||
hasSameShift(employee.name, day.date)
)
)
swapShift.submit();
Expand Down Expand Up @@ -159,11 +153,7 @@
dropCell.employee === employee.name &&
dropCell.date === day.date &&
dropCell.shift === shift.name &&
!events.data?.[employee.name]?.[day.date].some(
(shift: Shift) =>
shift.shift_type === hoveredCell.shift_type &&
shift.status === hoveredCell.shift_status,
) &&
!hasSameShift(employee.name, day.date) &&
'scale-105',
]"
:style="{
Expand Down Expand Up @@ -322,6 +312,17 @@ watch(
() => events.fetch(),
);
const isHolidayOrLeave = (employee: string, day: string) =>
events.data?.[employee]?.[day]?.holiday || events.data?.[employee]?.[day]?.leave;
const hasSameShift = (employee: string, day: string) =>
Array.isArray(events.data?.[employee]?.[day]) &&
events.data?.[employee]?.[day].some(
(shift: Shift) =>
shift.shift_type === hoveredCell.value.shift_type &&
shift.status === hoveredCell.value.shift_status,
);
// RESOURCES
const events = createResource({
Expand Down

0 comments on commit 98d8ebf

Please sign in to comment.