SB Sommar – Project Documentation

SB Sommar – Requirements: Add and Edit Forms

Add-activity and edit-activity forms: fields, validation, submit flows, time-gating, cookies, drafts, multi-day, delete, conflict warning, error visibility.

Part of the requirements index. Section IDs (02-§N.M) are stable and cited from code; they do not encode the file path.


6. Adding an Activity

Participants must be able to submit a new activity through the form at /lagg-till.html.

Required fields

Optional fields

Form UX

The form must help the user fill it in correctly. This is not about security — it is about reducing confusion and frustration.

Field controls

Submit feedback

Live validation



7. Editing and Removing Activities

Participants can edit their own active events (events whose date has not yet passed) through a session-cookie-based ownership mechanism. See §18 for the full specification.

Administrators with a valid admin token (§91) can edit or remove any activity through the same edit and delete flows available to participants.

A user may edit or delete an event if the event ID is present in their session cookie (ownership) or the user holds a valid admin token.



8. Locations

Participants cannot modify the location list.



9. Form Validation

When a participant submits an activity, the following must be verified:

Invalid submissions must be rejected with a clear, specific error message. Valid submissions must receive a confirmation immediately.



10. API Input Validation

The API server (app.js) receives submitted events and commits them to a YAML file on GitHub. Malformed input that reaches the YAML file can corrupt the file and break the entire site.

The server must therefore validate all input before touching GitHub:

This is separate from form UX validation. Form validation helps users. API validation protects the site’s data integrity.



19. Add-Activity Submit Flow

When validation passes and the user submits the add-activity form, the submission proceeds through a defined sequence: field locking → optional consent prompt → progress modal → result.

19.1 Field locking

19.3 Progress modal

19.4 Success state

19.5 Error state

19.6 Implementation constraints



20. Edit-Activity Submit Flow

When the user submits the edit-activity form, the submission proceeds through a defined sequence: field locking → progress modal → result. This mirrors the add-activity submit flow (§19) but without a consent step, and with success text and actions appropriate for an edit rather than a new submission.

20.1 Field locking

20.2 Progress modal

20.3 Success state

20.4 Error state

20.5 Implementation constraints



26. Form Time-Gating

The add-activity and edit-activity forms must only be usable during a defined period around the active camp. Outside this period, participants cannot create or edit activities.

26.1 Data model

The opens_for_editing field on each camps.yaml entry defines when the forms open. The submission period runs from opens_for_editing through end_date + 1 day (inclusive on both ends, compared as dates without timezone). See 05-DATA_CONTRACT.md §1 for the canonical field definition and the typical default (start_date − 7 days).

26.2 UI behaviour — before the period opens

26.3 UI behaviour — after the period closes

26.4 UI behaviour — edit form

26.5 API enforcement

26.6 Build-time data passing

26.7 Admin bypass before the camp opens

Context: administrators need to prepare the schedule via the website before opens_for_editing. Issues #335 and #336 asked for a way to add and edit activities during that preparation window without editing YAML by hand. The bypass is deliberately one-sided: admins can open the form before the camp opens, but the same forms remain locked for everyone — including admins — after the camp has ended, so finished camps cannot be altered retroactively through the website.



27. Past-Date Blocking

Events must not be created or edited with a date in the past. This rule applies to both the add-activity and edit-activity flows, at both the client and server layers.

27.1 Definition

27.2 Add-activity form (client)

27.3 Edit-activity form (client)

27.4 Add-event API endpoint (server)

27.5 Edit-event API endpoint (server)

27.6 Server validation location



Participants who have accepted the session cookie should get a smoother experience when adding and editing activities. The add form remembers the responsible person, and the edit page shows a list of owned events without requiring the user to navigate from the schedule.

48.1 Auto-fill responsible person on the add form

48.2 Dynamic intro text on the add form

48.6 Edit page with a specific event selected



53. Synchronous API Error Visibility and Deploy Safety

Background: the add-event and edit-event API endpoints respond with { success: true } before the GitHub write completes. If the GitHub operation fails (missing credentials, network error, invalid token), the user sees a success confirmation but the event is silently lost. This violates 02-§6.8 (“Submissions must not be silently lost”). Additionally, the deploy workflow’s .env backup can be lost if public_html is wiped before the backup step runs.

53.1 Synchronous GitHub commit (API requirements)

53.2 Progress feedback during submission (user requirements)

53.3 Persistent .env backup (site requirements)



54. Midnight-Crossing Events

Events at a summer camp can legitimately cross midnight (e.g. an evening party starting at 23:00 and ending at 01:00). The system must allow these while catching likely user mistakes (e.g. entering 16:00→14:00 when 16:00→17:00 was intended).

54.1 Midnight-crossing rule (event/data requirements)

54.2 User feedback (user requirements)

54.3 Edit form (site requirements)

54.4 Build-time lint (site requirements)



57. Markdown Toolbar for Description Field

The description textarea in the add-activity form (/lagg-till.html) and the edit-activity form (/redigera.html) must include a toolbar that helps users write Markdown without memorising syntax.

57.1 User requirements

57.2 Site requirements



58. Markdown Preview for Description Field

The description textarea in the add-activity form (/lagg-till.html) and the edit-activity form (/redigera.html) must include a live preview that shows the user how their Markdown will render.

58.1 User requirements

58.2 Site requirements

58.3 Design requirements



80. Multi-Day Selection and Batch Submission

Participants often run the same activity on multiple days at the same time and place. The add-activity form uses a day grid that is always multi-select — clicking days toggles them on/off. When more than one day is selected, the submission uses the batch endpoint. A confirmation modal is shown before every submission.

80.1 Day grid component (user requirements)

80.2 Multi-day info and validation (user requirements)

80.3 Batch API endpoint (API requirements)

80.4 Confirmation and submit flow (user requirements)

80.5 Edit form (site requirements)

80.6 Implementation constraints

80.7 Static multi-day hint (user requirements)



The add-activity form validates the optional link field on blur so that the user gets immediate feedback when the format is incorrect, without having to submit the form first.

81.1 Blur validation (user requirements)

81.2 Clearing errors (user requirements)

81.3 Error messages (user requirements)

81.4 Submit gating (site requirements)

81.5 Implementation constraints



82. Character counter on text input fields

The add-activity and edit-activity forms display a discreet character counter on text input fields so the user sees how much space remains before hitting the maximum length.

82.1 Affected fields and maximum lengths (site requirements)

82.2 Counter visibility (user requirements)

82.3 Counter format and placement (user requirements)

82.4 Counter updates (site requirements)

82.5 Both forms (site requirements)

82.6 Implementation constraints



85. Form Draft Cache (sessionStorage)

When filling in the add-activity form, all field values are saved to sessionStorage so that a page reload preserves the user’s input.

85.1 User requirements

85.2 Site requirements



89. Delete Activity

Participants who submitted an activity can delete it from the edit page. Deletion removes the event entirely from the camp’s YAML file.

89.1 Delete button on edit page (user requirements)

89.2 Delete submit flow (site requirements)

89.3 Server-side delete endpoint (site requirements)

89.4 Client-side session cleanup (site requirements)

89.5 Constraints



90.1 Context

The sb_session cookie tracks which events the current user has created, enabling the edit and delete flows. A bug in removeIdFromCookie (redigera.js) writes the cookie back without the Secure flag and without the Domain attribute, which can create duplicate cookies with the same name. Additionally, there is no way for users to inspect what is stored in the cookie or understand why editing may not work, making cookie problems difficult to diagnose.

90.3 Informational text about event cleanup (user requirements)

90.5 Bug fix — removeIdFromCookie attributes (site requirements)

90.6 Constraints



99. Conflict Warning in Add/Edit Forms and Activity Pages

99.1 Context

The Locale Overview page (§98) shows which locales are already booked, but a participant filling in the add- or edit-activity form is not automatically told when the values they have just entered collide with an existing booking. The server accepts conflicting bookings on purpose — clashes can be deliberate — so the warning must never prevent submission. Its job is to surface the clash early, while the participant is still choosing, and offer a quick path to the Locale Overview where free slots are visible.

The same warning is also useful on the per-event detail page at /schema/<slug>/: when someone opens an activity that is already in conflict with another activity, they should see it immediately alongside the booking details, not have to piece it together from the schedule. Issue #332 (Session 2).

99.2 Shared detection module

99.3 Add-activity form

99.4 Edit-activity form

99.5 Language and styling

99.6 Per-event activity pages