ProSchedulerSign in

Timeline · Use cases

Subtask checklist inside events

Each job carries its checklist; ticking a step updates the job in your state. The checkboxes stop the drag so they stay checkboxes.

Live demo

Tick off a step · Drag a job by its title

Fullscreen
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { priorityColors, technicians, workOrders, type WorkOrder } from "./data/operations"
import { useEvents } from "./kit"

export function SubtaskChecklistDemo() {
  const { events, setEvents, handlers } = useEvents(workOrders)

  const toggle = (id: string, index: number) =>
    setEvents((list) =>
      list.map((order) => {
        if (order.id !== id) return order
        const checklist = order.checklist.map((item, i) => (i === index ? { ...item, done: !item.done } : item))
        const progress = Math.round((checklist.filter((i) => i.done).length / checklist.length) * 100)
        return { ...order, checklist, progress }
      })
    )

  return (
    <ProScheduler
      data={events}
      resources={technicians}
      view={{ timeline: { type: "week", resolutionHorizontal: "day" } }}
      styleConfig={{ laneHeight: 128, minRowHeight: 140, unitWidthPx: 150, fitToWidth: false }}
      showDefaultEditor={false}
      renderTimelineEvent={({ original }) => {
        const order = original as WorkOrder
        return (
          <div
            className="flex h-full flex-col gap-1 overflow-hidden rounded-md border-l-4 bg-card p-1.5 text-[11px] shadow-xs ring-1 ring-border"
            style={{ borderLeftColor: priorityColors[order.priority] }}
          >
            <strong className="truncate text-foreground">{order.title}</strong>
            {order.checklist.map((item, i) => (
              <label
                key={item.label}
                className="flex items-center gap-1.5 text-muted-foreground"
                // Keep the checkbox a checkbox: don't start a drag or a click on the bar.
                onPointerDown={(e) => e.stopPropagation()}
                onClick={(e) => e.stopPropagation()}
              >
                <input type="checkbox" checked={item.done} onChange={() => toggle(order.id, i)} />
                <span className={item.done ? "line-through" : undefined}>{item.label}</span>
              </label>
            ))}
          </div>
        )
      }}
      height={620}
      {...handlers}
    />
  )
}

About this demo

Each job carries its checklist; ticking a step updates the job in your state. The checkboxes stop the drag so they stay checkboxes.

Things to try

  • Tick off a step
  • Drag a job by its title

The props behind it are explained in Custom rendering.

Use ProScheduler in your project