gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit3e3d5a553e3d5a55mission ST1: stall diagnosismre3e3d5a55/components/timelineedit.hl

7.1 KB

  1. // components/timelineedit.hl — `/timelines/:slug/edit` (tracker.worldapi.org#19, mission 066): the creator's editor of ONE
  2. // timeline — its franchise (a row of chips: None + every franchise; a tap attaches it), its titles in their in-world order
  3. // (↑ / ↓ move one place, ✕ removes), and "Add titles": our database as you type (search.hl's index), "Add" puts the title at
  4. // the end. Mobile first: one column, big tap targets. Only the creator (franchises.hl isEditorSession) sees the controls; every
  5. // face checks it again.
  6. //
  7. // HYBRIEL TRAPS (as components/search.hl, hybriel#121/#122): no member reads both the route param and `session` — the
  8. // timeline's data come from `slug` alone, the editor state from `session` alone; every list is replaced whole with the
  9. // face's answer, never appended to.
  10. parent './main.hl'
  11. import { appTitle } from '../project.hl'
  12. import { isEditorSession, editPageOf, addToTimeline, removeFromTimeline, moveInTimeline, setTimelineFranchise, editSearch } from '../lib/franchises.hl'
  13. import { warmReady, warmText } from '../lib/warm.hl'
  14. static editorOf = (&session) => { return isEditorSession(&session) }
  15. static startOf = (&slug) => { return editPageOf(slug) }
  16. slug = null
  17. session = null
  18. isEditor = editorOf(&session)
  19. notEditor = isEditor == false
  20. start = startOf(&slug)
  21. found = start.found
  22. notFound = start.found == false
  23. timelineId = start.id
  24. name = start.name
  25. viewHref = start.viewHref
  26. rows = start.rows
  27. hasRows = rows.length > 0
  28. noRows = rows.length == 0
  29. countText = rows.length == 1 ? '1 title' : rows.length + ' titles'
  30. chips = start.chips
  31. results = []
  32. hasResults = results.length > 0
  33. searchNote = ''
  34. hasSearchNote = searchNote != ''
  35. message = ''
  36. hasMessage = message != ''
  37. __title = found ? 'Edit ' + name + ' — ' + appTitle : appTitle
  38. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'
  39. // stage is there this page says so instead of showing half a map
  40. warming = !warmReady('all')
  41. warmNote = warming ? warmText() : ''
  42. View {
  43. timelineEditPage { "data-timeline" = timelineId
  44. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  45. if (notFound) {
  46. h1 { "Not found" }
  47. p { "This timeline doesn't exist." }
  48. }
  49. if (found) {
  50. franchisesHead {
  51. h1 { class = "typed" typeWord { class = "type-word type-timeline" "Timeline" } typeSep { "|" } typeName { name } }
  52. a { id = "timeline-view" class = "button" href = viewHref "View" }
  53. }
  54. if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }
  55. if (isEditor) {
  56. if (hasMessage) { p { id = "edit-message" class = "message" message } }
  57. editSection {
  58. h2 { class = "film-heading" "Franchise" }
  59. chipRow { id = "franchise-chips"
  60. for (c of chips) { button { type = "button" class = c.cls value = c.id c.name on click(e) { emit pickFranchise(c.id) } } }
  61. }
  62. a { class = "edit-new-franchise" href = "/franchises/edit" "New franchise …" }
  63. }
  64. editSection {
  65. h2 { class = "film-heading" "Titles in timeline order" }
  66. p { class = "muted list-count" countText }
  67. if (noRows) { p { class = "muted" "No titles yet — add some below." } }
  68. if (hasRows) {
  69. editRows { id = "edit-rows"
  70. for (row of rows) {
  71. editRow { "data-show" = row.id
  72. editPos { row.pos }
  73. img { class = "film-poster" src = row.posterUrl alt = "" }
  74. filmText {
  75. filmTitle { row.title }
  76. filmMeta { span { class = row.typeClass row.typeLabel } }
  77. }
  78. button { type = "button" class = row.upClass value = "up" title = "Move up" "aria-label" = "Move up" "↑" on click(e) { emit moveRow(row.id, -1) } }
  79. button { type = "button" class = row.downClass value = "down" title = "Move down" "aria-label" = "Move down" "↓" on click(e) { emit moveRow(row.id, 1) } }
  80. button { type = "button" class = "quiet mv rm" value = "remove" title = "Remove" "aria-label" = "Remove" "✕" on click(e) { emit removeRow(row.id) } }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. editSection {
  87. h2 { class = "film-heading" "Add titles" }
  88. input { id = "ted-search" type = "search" placeholder = "Search our movies and series" autocomplete = "off" "aria-label" = "Search titles" on input(e) { emit searchTyped(e) } }
  89. if (hasSearchNote) { p { id = "ted-note" class = "muted" searchNote } }
  90. if (hasResults) {
  91. editRows { id = "ted-results"
  92. for (r of results) {
  93. editRow { "data-show" = r.id
  94. img { class = "film-poster" src = r.posterUrl alt = "" }
  95. filmText {
  96. filmTitle { r.title }
  97. filmMeta { span { class = r.typeClass r.typeLabel } }
  98. }
  99. button { type = "button" class = "inverted add" value = r.id "Add" on click(e) { emit addRow(r.id) } }
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. on pickFranchise(franchiseId) {
  110. let r = emit server tedSetFranchise(timelineId, '' + franchiseId)
  111. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  112. message = ''
  113. chips = r.chips
  114. }
  115. on moveRow(showId, delta) {
  116. let r = emit server tedMove(timelineId, '' + showId, delta)
  117. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  118. message = ''
  119. rows = r.rows
  120. }
  121. on removeRow(showId) {
  122. let r = emit server tedRemove(timelineId, '' + showId)
  123. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  124. message = ''
  125. rows = r.rows
  126. }
  127. on addRow(showId) {
  128. let r = emit server tedAdd(timelineId, '' + showId)
  129. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  130. message = ''
  131. rows = r.rows
  132. // the added title leaves the results (it is in the timeline now)
  133. left = []
  134. for (x of results) { if (x.id != showId) { left.push(x) } }
  135. results = left
  136. }
  137. on searchTyped(e) {
  138. v = e.target.value
  139. let r = emit server tedSearch(timelineId, v)
  140. if (r == null || document.getElementById('ted-search').value != v) { return null }
  141. results = r.rows
  142. searchNote = v.trim() == '' ? '' : r.note
  143. }
  144. // ---- the faces (unique names; the trailing `session` is the server's) ----
  145. on server tedSetFranchise(timelineId, franchiseId, session) {
  146. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  147. return setTimelineFranchise(&timelineId, franchiseId)
  148. }
  149. on server tedMove(timelineId, showId, delta, session) {
  150. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  151. return moveInTimeline(&timelineId, &showId, &delta)
  152. }
  153. on server tedRemove(timelineId, showId, session) {
  154. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  155. return removeFromTimeline(&timelineId, &showId)
  156. }
  157. on server tedAdd(timelineId, showId, session) {
  158. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  159. return addToTimeline(&timelineId, &showId)
  160. }
  161. // the search is our public database (like /search) — no session
  162. on server tedSearch(timelineId, text) {
  163. return editSearch(&timelineId, text)
  164. }

Branches

Latest commits

  • 3e3d5a55mission ST1: stall diagnosismre
  • 9c3180eblog+status: RV28d measured after deploymre
  • fdf10b1alog: RV28d deployed on day38bmre
  • 320005e9log: RV28d merged, deploy runningmre
  • a8fef27dRV28d: reportmre
  • 2bae8373RV28d: re-vendor Hybriel set day38b (source 1e554d75, bin 5ff2a46d)mre
  • 16b3354aMerge branch 'main' into rv28cmre
  • 6f4f27d8log: RV28d started (day38b)mre
  • e6cf03ffmission RV28d: rv28c onto day38bmre
  • 3ccaee19status: live sweep freeze, waiting for Apollomre
  • 49f76ecblog: watch toggle slowness = session sweep freeze (tracker#50)mre
  • 3daf6eddlog: day37 live, still waiting for day39mre
  • 796ba672records: #277 slips to day39mre
  • a9eb9827records: mpackdb integrity clean, all 12 tablesmre
  • 6cf40dbdrecords: mpackdb integrity check, shows uncheckedmre
  • 1880f42arecords: day38 deploy may swap normallymre
  • 9d806e35records: mpackdb freeze until day38mre
  • a660239drecords: day37 lacks #277, wait for day38mre
  • b0abfdeaLOG: Anton hybriel#277 fix ready for day37mre
  • 7b5b2918Tracker: hybriel#277 fix comes in day37mre