Skip to content

Patterns

The planning editor

A planning view in Meadowstack, a rota, a machine plan or a booking grid, is an editor: people drag to move, hold Alt to copy, add in an empty cell and watch the totals change as they go, and the keyboard does the same. The kit's component handles the dragging, the keyboard and the announcements, while the page decides what a move means and refuses a bad one before the drop, in words, with the same rule the api uses.

By Bohuslav PoláčekChecked

apps/demo/src/modules/shifts/pages/rota.tsx
const planning: RotaPlanning | undefined =
  canPlan && view
    ? {
        refuseDrop: (drop) => refusal(view, drop, nameOf),
        restFor: (personId, date, kind) => restReason(plannedOf(view), { personId, date, kind }),
        onDrop: (drop) => {
          if (drop.type === "source") {
            const role = shiftRolesOf(drop.to.row)[0];
            if (!role || !isKind(drop.source.id)) return;
            const input = { personId: drop.to.row, branchId, date: drop.to.column, kind: drop.source.id, role };
            void add(input, tx("Směna přidána", "Shift added"));
            return;
          }
          const input = { ...inputOf(drop.item), personId: drop.to.row, date: drop.to.column };
          if (drop.copy) void add(input, tx("Směna zkopírována", "Shift copied"));
          else void change(drop.item, input, tx("Směna přesunuta", "Shift moved"));
        },
        onRefuse: (reason) => toast.error(reason),
        onOpen: (shift) => setDialog({ mode: "edit", shift }),
        onQuickAdd: (input) => void add({ ...input, branchId }, tx("Směna přidána", "Shift added")),
        onMore: (personId, date) =>
          setDialog({ mode: "add", values: { personId, date, role: shiftRolesOf(personId)[0] } }),
      }
    : undefined;
The rota in the demo's restaurant: a planner gets the grid's handlers, everyone else gets none and the same grid reads only. Each handler says what a drop means, and the refusal comes from the rule the api uses. Read from the repository when the site was built.

Open it in the live demo

The flow, step by step

A branch manager plans next week in the demo's restaurant rota:

  1. Open the week. The rota shows the branch's week by person and day. Above it sits what the week still lacks, such as a missing cook for an afternoon, and below it who changed what.
  2. Drag a shift to another day or person. While it is in the hand, a cell that cannot take it turns grey and says why under the pointer: time off, another shift that day, a role the person does not work, or a break of the rest rules (11 hours between shifts, 35 in the week). Letting go there sends the shift home with a short shake, and a toast repeats the reason.
  3. Copy and add. Alt (Option) drags a copy. A template from the strip drops in as a new shift, and the plus in an empty cell adds one in a click. "Add shift" opens the dialog, which greys out the same people for the same reasons.
  4. Watch the totals. The gaps, the coverage and the hours against the 48-hour week follow every move in the same frame, because they are derived from the week on screen. Whoever may see money also gets each day's labour cost against the expected takings, quiet while the share stays inside 25 to 35 %.
  5. Undo. Every change shows at once, writes a history entry and offers Undo. "Copy last week" fills the week from the one before, leaving out whoever is away, and is undone as a whole.
  6. From the keyboard. Space picks a shift up, the arrows choose a cell, Space drops it, Alt with Space drops a copy and Escape cancels. Every step is announced in a live region, a refusal with its reason. The plus in an empty cell is a pointer shortcut kept out of the tab order; from the keyboard a template or "Add shift" does the same.
  7. Publish. The week stays a draft until "Publish rota". The staff read the last published week, the same grid with no handlers, and publishing tells the people whose shifts changed.
  8. On a phone the week becomes a list by day, edited through the dialog.

The rules and where each one is enforced

docs/recipes/planning-view.md picks the component by the question the view answers, from "who works which day?" (ScheduleGrid) to "what waits for what?" (GanttChart).

What AI coding tools build instead

  • A drag library wired into the page. It works with a mouse and nothing else: no keyboard, no announcements, no refusal while dragging. The kit's components carry the keyboard, the announcements and the motion, so no app rebuilds them.
  • Telling the person after the drop. The shift lands, the save fails, and a toast says the cook was on leave. Here the cell refuses while the shift is still in the hand.
  • The rule in the page and again in the api. They drift, and the dialog offers someone the api then refuses. One function in domain/, imported by both.
  • Totals computed on save. The manager plans blind and learns about the overtime afterwards. Here the hours follow every move.
  • A move with no history and no Undo. Planning changes are the ones people regret.
  • A grid squeezed onto a phone. Drag and fine placement are not for a thumb; the editor becomes a list.
  • A conflict hidden by quietly moving the other block. Show the conflict and let the person decide.

Where to see it

Example apps with a resource timeline

Which example apps and modules render the kit's ResourceTimeline, the planning editor for machines, vehicles and courts by the hour, computed from the demo's code when the site was built.Read from the demo's source when the site was built: 4 of 9 example apps render <ResourceTimeline>, in the modules named here as each app's sidebar names them.

Questions

How do I make a drag and drop schedule work from the keyboard?

Use a component that has it built in. On the rota, Space picks a shift up, the arrows choose a cell, Space drops it, Alt with Space drops a copy and Escape cancels, and every step is announced in a live region. Rebuilding that for every app is why apps on the framework never import a drag library.

Should a scheduling conflict show before or after the drop?

Before. While the shift is in the hand, a cell that cannot take it turns grey and says why under the pointer. Letting go there sends the shift home with a short shake and the same reason in a toast.

How do the totals stay right while people drag?

They are derived from the week held on screen instead of computed on save, so the gaps, the coverage and the hours follow every move in the same frame.

Can people who only read the plan use the same screen?

Yes. They get the same grid without handlers: nothing moves, and the frame still scrolls from the keyboard. On the demo's rota the staff read the last published week while the manager edits a draft.

What happens to a planning view on a phone?

It becomes a list, by day on the rota, edited through a dialog. Drag and fine placement are not for a thumb.

Two ways

Build it yourself, or have it built

  • Build it yourself

    Build your app on the framework

    Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.

    One payment, lifetime updates

    Get the framework
  • Have it built

    Have us build your app

    Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.

    After launch, Care keeps it improving, from €99 a month.

    from €1,990

    Describe your app