feat: update shift display logic and styles for ended shifts
Enhanced the user interface to visually indicate when shifts have ended, including graying out past shifts and adding labels for clarity. Updated styles for both the public and admin views to reflect these changes, ensuring a consistent experience. Adjusted the logic to keep ended shifts visible until midnight in their respective time zones, improving user understanding of shift availability.
This commit is contained in:
1 parent
b039eef5ae
commit
208f08753e
6 files changed
+108
-15
No files matched your search
+1
-1
@@ -1251,7 +1251,7 @@ function ShiftList(props: { config: AppConfig; event: AdminEvent; csrf: string;
|
||||
<details class="help-tip">
|
||||
<summary aria-label="About upcoming shifts">?</summary>
|
||||
<p>
|
||||
Shifts show on the public list when this event is public, the shift is not cancelled, and it has not ended. Repeating shifts add dates for the next three months. Add weekly shifts fills those dates. Shifts already on the schedule stay as they are, including cancelled ones.
|
||||
Shifts show on the public list when this event is public and the shift is not cancelled. A shift that has already ended stays on today's card, grayed out, until midnight. Then that day leaves the list. Repeating shifts add dates for the next three months. Add weekly shifts fills those dates. Shifts already on the schedule stay as they are, including cancelled ones.
|
||||
</p>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
+11
-4
@@ -673,16 +673,20 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {
|
||||
const closed = shift.full || shift.cancelled || shift.ended;
|
||||
const action = closed ? 'View shift' : 'Sign up';
|
||||
return (
|
||||
<section class="shift-pane">
|
||||
<section class={shift.ended ? 'shift-pane is-ended' : 'shift-pane'}>
|
||||
<div class="shift-pane-body">
|
||||
<h3>{shift.role}</h3>
|
||||
<ShiftWhen shift={shift} />
|
||||
{shift.inProgress ? <p class="status">In progress</p> : null}
|
||||
<p class="status">{shift.inProgress ? 'In progress' : ''}</p>
|
||||
<Spots shift={shift} />
|
||||
<h4 class="roster-label">Volunteers</h4>
|
||||
<RosterNames config={props.config} shiftId={shift.id} names={shift.volunteers} />
|
||||
</div>
|
||||
{shift.full ? (
|
||||
{shift.ended ? (
|
||||
<p class="btn-card is-static">
|
||||
<span class="shift-full-label">Ended</span>
|
||||
</p>
|
||||
) : shift.full ? (
|
||||
<p class="btn-card is-static">
|
||||
<span class="shift-full-label">Full</span>
|
||||
<span>Not accepting more signups</span>
|
||||
@@ -860,14 +864,16 @@ function CalendarShift(props: { config: AppConfig; shift: PublicShift }) {
|
||||
const closed = shift.full || shift.cancelled || shift.ended;
|
||||
const action = closed ? 'View shift' : 'Sign up';
|
||||
return (
|
||||
<a class="cal-shift" href={appPath(props.config, `/s/${shift.id}`)} data-signup={closed ? undefined : ''}>
|
||||
<a class={shift.ended ? 'cal-shift is-ended' : 'cal-shift'} href={appPath(props.config, `/s/${shift.id}`)} data-signup={closed ? undefined : ''}>
|
||||
<span class="cal-line">
|
||||
{shift.when.startLabel} {shift.role}
|
||||
{shift.ended ? ' · Ended' : ''}
|
||||
</span>
|
||||
<span class="sr-only">
|
||||
{'. '}
|
||||
{action} for {shift.role} on {shift.when.dateLabel}, {shift.when.startLabel} to {shift.when.endLabel}{' '}
|
||||
{shift.when.abbreviation}. {spotsSentence(shift)}
|
||||
{shift.ended ? ' Ended.' : ''}
|
||||
{shift.inProgress ? ' In progress.' : ''}
|
||||
{shift.volunteers.length > 0 ? ` Volunteers: ${shift.volunteers.join(', ')}.` : ' No one signed up yet.'}
|
||||
</span>
|
||||
@@ -880,6 +886,7 @@ function CalendarShift(props: { config: AppConfig; shift: PublicShift }) {
|
||||
{shift.when.sameDay ? null : <time dateTime={shift.endsAtUtc}>{shift.when.endDateLabel} </time>}
|
||||
<time dateTime={shift.endsAtUtc}>{shift.when.endLabel}</time> {shift.when.abbreviation}
|
||||
</span>
|
||||
{shift.ended ? <span class="status">Ended</span> : null}
|
||||
{shift.inProgress ? <span class="status">In progress</span> : null}
|
||||
<Spots shift={shift} />
|
||||
<span class="cal-names">{shift.volunteers.length > 0 ? shift.volunteers.join(', ') : 'No one signed up yet.'}</span>
|
||||
|
||||
+5
-3
@@ -1,7 +1,7 @@
|
||||
import { Temporal } from '@js-temporal/polyfill';
|
||||
import type Database from 'better-sqlite3';
|
||||
import { isWithinSignupWindow } from './signup-window.js';
|
||||
import { formatInstantInZone, todayInZone } from './time.js';
|
||||
import { formatInstantInZone, localToUtc, todayInZone } from './time.js';
|
||||
|
||||
/** Weekday 0 is Sunday, matching the zoned clock. The public sign-up cards use Wednesday. */
|
||||
export const WEDNESDAY = 3;
|
||||
@@ -110,15 +110,17 @@ export function getPublishedEvent(db: Database.Database, slug: string, now: stri
|
||||
}
|
||||
| undefined;
|
||||
if (!event || event.published !== 1) return null;
|
||||
// A shift that already ended stays through the rest of its local day, then leaves at midnight.
|
||||
const todayStart = localToUtc(todayInZone(event.tz, Temporal.Instant.from(now)), '00:00', event.tz);
|
||||
const rows = db
|
||||
.prepare(
|
||||
`SELECT ${SHIFT_COLUMNS}
|
||||
${SHIFT_FROM}
|
||||
WHERE e.id = ? AND s.cancelled = 0 AND s.ends_at_utc > ?
|
||||
WHERE e.id = ? AND s.cancelled = 0 AND (s.ends_at_utc > ? OR s.starts_at_utc >= ?)
|
||||
GROUP BY s.id
|
||||
ORDER BY s.starts_at_utc, s.role, s.id`,
|
||||
)
|
||||
.all(event.id, now) as ShiftRow[];
|
||||
.all(event.id, now, todayStart) as ShiftRow[];
|
||||
const names = volunteerNamesByShift(db, rows.map((row) => row.id));
|
||||
return {
|
||||
id: event.id,
|
||||
|
||||
Reference in new issue
Block a user