mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
* feat(vacay): support half vacation days (#552) Log a vacation day as a half day (0.5) as well as a full day and count it as such against the entitlement. A "Half day" mode joins the calendar toolbar on desktop and mobile; half days render as a diagonal half-fill in the day cell, and the used/remaining totals carry the fraction. Closes #552 * refactor(vacay): half-day as a per-person toggle with a corner badge The diagonal half-fill collided with the two-person split — one person's half day looked like two people off. Drop the diagonal: the cell fill keeps showing who is off, a half day gets a small corner ½ badge, and a hover tooltip lists who is off on that date and how much (only when a half day is present). Logging moves from a third mode to a Half-day toggle that applies to the selected person, on desktop and mobile. * feat(vacay): mark half days with an orange corner dot Swap the ½ badge for a small orange dot in the bottom-right corner, mirroring the blue trip dot — quieter in the grid, and the hover tooltip still spells out who is on a half day. * fix(vacay): make the fraction migration idempotent The crosswalk test replays the migration tail (rewind + re-run), which expects every later migration to be idempotent. Guard the vacay_entries ADD COLUMN behind a pragma_table_info check so the second run is a no-op. Also only set dayVisual's `half` flag when true, so full days keep their exact { background, numColor } shape for the mobile day-model unit test. * style(vacay): nudge the mobile day dots slightly inward The blue trip dot and orange half-day dot sat right in the cell corner on mobile; move both a touch toward the centre so they read cleaner.
This commit is contained in:
@@ -241,6 +241,20 @@ export default function MVacay() {
|
||||
{t('vacay.modeCompany')}
|
||||
</button>
|
||||
)}
|
||||
{/* Divider — the half-day switch modifies the selected person's logging, it isn't a mode. */}
|
||||
<span className="mx-[1px] h-5 w-px self-center bg-[color:var(--m-shbr)]" aria-hidden />
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => v.setHalfDay(h => !h)}
|
||||
aria-pressed={v.halfDay}
|
||||
aria-label={t('vacay.modeHalf')}
|
||||
title={t('vacay.modeHalfHint')}
|
||||
className={`flex h-9 w-9 flex-none items-center justify-center rounded-full text-[0.9375rem] font-extrabold leading-none ${
|
||||
v.halfDay ? 'bg-m-act text-m-actfg' : 'bg-[color:var(--m-ic)] text-m-muted'
|
||||
}`}
|
||||
>
|
||||
½
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -49,11 +49,20 @@ export default function MVacayMonth({
|
||||
<span
|
||||
aria-hidden
|
||||
className={`absolute rounded-full ${
|
||||
mini ? 'right-[1px] top-[1px] h-[3px] w-[3px]' : 'right-[2px] top-[2px] h-[5px] w-[5px]'
|
||||
mini ? 'right-[2px] top-[2px] h-[3px] w-[3px]' : 'right-[4px] top-[4px] h-[5px] w-[5px]'
|
||||
}`}
|
||||
style={{ background: tripDotColor }}
|
||||
/>
|
||||
)}
|
||||
{visual.half && (
|
||||
<span
|
||||
aria-hidden
|
||||
className={`absolute rounded-full ${
|
||||
mini ? 'right-[2px] bottom-[2px] h-[3px] w-[3px]' : 'right-[4px] bottom-[4px] h-[5px] w-[5px]'
|
||||
}`}
|
||||
style={{ background: '#f97316' }}
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -37,6 +37,8 @@ export function useMVacay() {
|
||||
const [view, setView] = useState<MVacayView>('grid')
|
||||
const [month, setMonth] = useState(() => new Date().getMonth())
|
||||
const [mode, setMode] = useState<MVacayMode>('vacation')
|
||||
// Half-day modifier: when on, taps log the selected person's day as 0.5 (#552).
|
||||
const [halfDay, setHalfDay] = useState(false)
|
||||
const [sheet, setSheet] = useState<MVacaySheet>(null)
|
||||
const [tripDates, setTripDates] = useState<Set<string>>(new Set())
|
||||
|
||||
@@ -130,8 +132,8 @@ export function useMVacay() {
|
||||
}
|
||||
if (blockWeekends && isWeekend(dateStr, weekendDays)) return
|
||||
if (companyHolidaysEnabled && companyHolidaySet.has(dateStr)) return
|
||||
await toggleEntry(dateStr, selectedUserId || undefined)
|
||||
}, [view, mode, companyHolidaysEnabled, blockWeekends, weekendDays, companyHolidaySet, toggleEntry, toggleCompanyHoliday, selectedUserId])
|
||||
await toggleEntry(dateStr, selectedUserId || undefined, halfDay ? 0.5 : 1)
|
||||
}, [view, mode, halfDay, companyHolidaysEnabled, blockWeekends, weekendDays, companyHolidaySet, toggleEntry, toggleCompanyHoliday, selectedUserId])
|
||||
|
||||
// Entitlement stepper: never below what is already used this year
|
||||
// (carried-over days cover the difference when used > entitlement).
|
||||
@@ -172,7 +174,7 @@ export function useMVacay() {
|
||||
loading, plan, selectedYear,
|
||||
users, isFused, currentUser,
|
||||
incomingInvites, acceptInvite, declineInvite,
|
||||
view, month, mode, sheet, setSheet, setMode, setMonth,
|
||||
view, month, mode, halfDay, setHalfDay, sheet, setSheet, setMode, setMonth,
|
||||
tripDates, tripDotColor,
|
||||
blockWeekends, companyHolidaysEnabled, holidaysEnabled, weekStart, weekendDays,
|
||||
dayCtx, monthNamesShort, monthNameLong,
|
||||
|
||||
@@ -8,6 +8,8 @@ export interface DayVisual {
|
||||
background: string
|
||||
numColor: string
|
||||
boxShadow?: string
|
||||
// At least one person logged this day as a half day (#552) — the cell shows a ½ badge.
|
||||
half?: boolean
|
||||
}
|
||||
|
||||
export interface DayVisualContext {
|
||||
@@ -88,7 +90,12 @@ export function dayVisual(dateStr: string, dayOfWeek: number, ctx: DayVisualCont
|
||||
const entries = ctx.entryMap[dateStr]
|
||||
if (entries && entries.length > 0) {
|
||||
const tints = entries.map(e => personTint(e.person_color || FALLBACK_PERSON_COLOR))
|
||||
return { background: tints.length === 1 ? tints[0] : splitBackground(tints), numColor: '#101013' }
|
||||
// The fill still shows WHO is off; half days (#552) keep it and add a corner
|
||||
// dot, so a half day never looks like a two-person split. Only set `half` when
|
||||
// true so full days keep their exact { background, numColor } shape.
|
||||
const visual: DayVisual = { background: tints.length === 1 ? tints[0] : splitBackground(tints), numColor: '#101013' }
|
||||
if (entries.some(e => (e.fraction ?? 1) === 0.5)) visual.half = true
|
||||
return visual
|
||||
}
|
||||
const holiday = ctx.holidays[dateStr]
|
||||
if (holiday) {
|
||||
|
||||
Reference in New Issue
Block a user