Skip to content

Attach events to the periods they are about - #2

Open
alex-andreyev wants to merge 1 commit into
MarketKernel:mainfrom
alex-andreyev:attach-events-to-periods
Open

alex-andreyev wants to merge 1 commit into
MarketKernel:mainfrom
alex-andreyev:attach-events-to-periods

Conversation

@alex-andreyev

Copy link
Copy Markdown

An event can now name the periods it is about: a life, a reign, a war, as many as it takes. The first flight (17 Dec 1903) belongs both to the Wright brothers' lives and to the age of powered flight.

What changes

  • The event's window gets a "Periods" list with a checkbox for each period whose dates take in the event's date.
    • The list follows the date as it is typed.
    • If the date leaves a ticked period, a warning says so, and the period is ticked again when the date comes back.
  • Details. An event links to its periods. A period lists its events, each a step to it. In edit mode a period also offers "Add an event to it", which starts a new event already attached.
  • Links stay true. If a period's new dates leave an event out, or the period is deleted, the event is detached from that period only, in the same command, so one undo brings it back. A toast says how many events were let go.

File format

periods on an event is a list of period ids; see docs/format.md. It is read and checked like the other fields:

  • dropped with a warning: an id that is not a period of the file, a value that is not a list, an entry that is not an id;
  • an id named twice is kept once;
  • an empty list is not written.

Older versions keep the field in extra when they save.

Tests

  • tests/model.mjs covers parsing, warnings, the round trip, periodHolds, periodsAt, eventsOf and detachFrom. For periodHolds, a date's own span has to meet the period's: "1957" is in "Oct 1957 – 1975".
  • tests/app.mjs covers:
    • the window's list following the date;
    • ticking two periods;
    • the links in the details;
    • "Add an event to it";
    • new dates and deletion detaching the event from one period, and undo;
    • the saved file keeping the list.

npm run check passes: all unit tests, 206 browser checks and 22 PWA checks. The suite was run with TZ=UTC; see #1 for the two date tests that fail in America/Los_Angeles on main.

Russian translations are included.

A follow-up PR adds a list of periods to hide and show them; it builds on this one.

🤖 Generated with Claude Code

An event can now name the periods it is about: a life, a reign, a war, as
many as it takes. The first flight is in both brothers' lives and in the age
of powered flight. The file keeps them as `periods`, a list of period ids on
the event.

- The event's window ticks any of the periods its date falls within. The
  list follows the date as it is typed, and a tick is kept while the date
  moves out of a period and back.
- An event's details link to its periods. A period's details list its
  events and, in edit mode, offer to add one already attached.
- New dates that leave an event out of a period, or deleting the period,
  detach the event from that period alone, in the same command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant