tracker
All repositories: gitoria
8.1 KB
// components/timelineedit.hl — `/timelines/:slug/edit` (tracker.worldapi.org#19, mission 066): the creator's editor of ONE// timeline — its franchise (a row of chips: None + every franchise; a tap attaches it), its titles in their in-world order// (↑ / ↓ move one place, ✕ removes), and "Add titles": our database as you type (search.hl's index), "Add" puts the title at// the end. Mobile first: one column, big tap targets. Only the creator (franchises.hl isEditorSession) sees the controls; every// face checks it again.//// HYBRIEL TRAPS (as components/search.hl, hybriel#121/#122): no member reads both the route param and `session` — the// timeline's data come from `slug` alone, the editor state from `session` alone; every list is replaced whole with the// face's answer, never appended to.parent './main.hl'import { appTitle } from '../lib/app.hl'import { isEditorSession, editPageOf, addToTimeline, removeFromTimeline, moveInTimeline, setTimelineFranchise, editSearch } from '../lib/franchises.hl'import { warmReady, warmText } from '../lib/warm.hl'static editorOf = (&session) => { return isEditorSession(&session) }static startOf = (&slug) => { return editPageOf(slug) }slug = nullsession = nullisEditor = editorOf(&session)notEditor = isEditor == falsestart = startOf(&slug)found = start.foundnotFound = start.found == falsetimelineId = start.idname = start.nameviewHref = start.viewHrefrows = start.rowshasRows = rows.length > 0noRows = rows.length == 0countText = rows.length == 1 ? '1 title' : rows.length + ' titles'chips = start.chipssearchText = ''results = []hasResults = results.length > 0searchNote = ''hasSearchNote = searchNote != ''message = ''hasMessage = message != ''__title = found ? 'Edit ' + name + ' — ' + appTitle : appTitle// mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'// stage is there this page says so instead of showing half a mapwarming = !warmReady('all')warmNote = warming ? warmText() : ''// Component styles use the shared theme variables.Style {timelineEditPage {display = 'block'}chipRow {display = 'flex'flexWrap = 'wrap'gap = '.4rem'}'button.chip' {padding = '.3rem .8rem'fontSize = '.9rem'color = 'var(--color-text)'background = 'var(--color-surface)'}'button.chip.on' {color = 'var(--color-accent-text)'background = 'var(--color-accent)'}aEditNewFranchise {display = 'block'padding = '.8rem 0'fontSize = '.9rem'}editRows {display = 'block'}editRow {display = 'flex'alignItems = 'center'gap = '.5rem'padding = '.4rem 0'}editPos {flex = 'none'width = '1.6rem'color = 'var(--color-text-muted)'fontVariantNumeric = 'tabular-nums'textAlign = 'right'}buttonMv {flex = 'none'width = '2.75rem'height = '2.75rem'padding = '0'fontSize = '1.1rem'}'button.mv.off' {opacity = '.3'pointerEvents = 'none'}'button.mv.rm' {color = 'var(--color-danger)'}}View {timelineEditPage { "data-timeline" = timelineIdif (warming) { p { id = "warming" class = "message banner" warmNote } }if (notFound) {h1 { "Not found" }p { "This timeline doesn't exist." }}if (found) {franchisesHead {h1 { class = "typed" typeWord { class = "type-word type-timeline" "Timeline" } typeSep { "|" } typeName { name } }a { id = "timeline-view" class = "button" href = viewHref "View" }}if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }if (isEditor) {if (hasMessage) { p { id = "edit-message" class = "message" message } }editSection {h2 { class = "film-heading" "Franchise" }chipRow { id = "franchise-chips"for (c of chips) { button { type = "button" class = c.cls value = c.id c.name on click(e) { emit pickFranchise(c.id) } } }}a { Style.aEditNewFranchise href = "/franchises/edit" "New franchise …" }}editSection {h2 { class = "film-heading" "Titles in timeline order" }p { class = "muted list-count" countText }if (noRows) { p { class = "muted" "No titles yet — add some below." } }if (hasRows) {editRows { id = "edit-rows"for (row of rows) {editRow { "data-show" = row.ideditPos { row.pos }img { class = "film-poster" src = row.posterUrl alt = "" }filmText {filmTitle { row.title }filmMeta { span { class = row.typeClass row.typeLabel } }}button { type = "button" class = row.upClass value = "up" title = "Move up" "aria-label" = "Move up" "↑" on click(e) { emit moveRow(row.id, -1) } }button { type = "button" class = row.downClass value = "down" title = "Move down" "aria-label" = "Move down" "↓" on click(e) { emit moveRow(row.id, 1) } }button { type = "button" Style.buttonMv class = "quiet rm" value = "remove" title = "Remove" "aria-label" = "Remove" "✕" on click(e) { emit removeRow(row.id) } }}}}}}editSection {h2 { class = "film-heading" "Add titles" }input { id = "ted-search" value = searchText type = "search" placeholder = "Search our movies and series" autocomplete = "off" "aria-label" = "Search titles" on input(e) { emit searchTyped(e) } }if (hasSearchNote) { p { id = "ted-note" class = "muted" searchNote } }if (hasResults) {editRows { id = "ted-results"for (r of results) {editRow { "data-show" = r.idimg { class = "film-poster" src = r.posterUrl alt = "" }filmText {filmTitle { r.title }filmMeta { span { class = r.typeClass r.typeLabel } }}button { type = "button" class = "inverted add" value = r.id "Add" on click(e) { emit addRow(r.id) } }}}}}}}}}}on pickFranchise(franchiseId) {r = emit server tedSetFranchise(timelineId, '' + franchiseId)if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }message = ''chips = r.chips}on moveRow(showId, delta) {r = emit server tedMove(timelineId, '' + showId, delta)if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }message = ''rows = r.rows}on removeRow(showId) {r = emit server tedRemove(timelineId, '' + showId)if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }message = ''rows = r.rows}on addRow(showId) {r = emit server tedAdd(timelineId, '' + showId)if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }message = ''rows = r.rows// the added title leaves the results (it is in the timeline now)left = []for (x of results) { if (x.id != showId) { left.push(x) } }results = left}on searchTyped(e) {v = e.target.valuesearchText = vr = emit server tedSearch(timelineId, v)if (r == null || searchText != v) { return null }results = r.rowssearchNote = v.trim() == '' ? '' : r.note}// ---- the faces (unique names; the trailing `session` is the server's) ----on server tedSetFranchise(timelineId, franchiseId, session) {if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }return setTimelineFranchise(&timelineId, franchiseId)}on server tedMove(timelineId, showId, delta, session) {if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }return moveInTimeline(&timelineId, &showId, &delta)}on server tedRemove(timelineId, showId, session) {if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }return removeFromTimeline(&timelineId, &showId)}on server tedAdd(timelineId, showId, session) {if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }return addToTimeline(&timelineId, &showId)}// the search is our public database (like /search) — no sessionon server tedSearch(timelineId, text) {return editSearch(&timelineId, text)}
Branches
Latest commits
- b32b8440Merge hm66-catalogindex: packed catalog indexmre
- 2db0f7adReport HM66 heap measurements and validationmre
- 6ce15623Pack catalog lists and membership maps in UTF-8 bytesmre
- 71134e21HM66 briefmre
- ed4cbab2status timemre
- e982c26dlog: HM65 mergedmre
- 6e72f9d1Merge hm65-fields: episode boot scan reads three fieldsmre
- 07a5c883HM65 report measured field projection and complete validationmre
- 0eab858fRead only catalog date fields during the episode boot scanmre
- d3179273log: HM65 hl:heap vendoringmre
- cb78a1a0HM65 report missing heap diagnostic package with repromre
- 89606a5cHM65 briefmre
- 096ce0d4log: DP69 live on day48mre
- b3d8a80bDP69 brief, RV48 mergedmre
- ce6d7d32Merge rv48: Hybriel day48mre
- 3da2ea86RV48: report day48 cold starts, gates and cleanupmre
- 8d9ecdfeRV48: re-vendor Hybriel set day48 (source b6a8f429, bin 660a9524)mre
- 4a802ae7status: RV48 runningmre
- 0a5412b6RV48 brief, day48 outmre
- 56665efelog: CB69 mergedmre