gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd1a91be9d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmred1a91be9/components/timelineedit.hl

8.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. searchText = ''
  32. results = []
  33. hasResults = results.length > 0
  34. searchNote = ''
  35. hasSearchNote = searchNote != ''
  36. message = ''
  37. hasMessage = message != ''
  38. __title = found ? 'Edit ' + name + ' — ' + appTitle : appTitle
  39. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'
  40. // stage is there this page says so instead of showing half a map
  41. warming = !warmReady('all')
  42. warmNote = warming ? warmText() : ''
  43. // Component styles use the shared theme variables.
  44. Style {
  45. timelineEditPage {
  46. display = 'block'
  47. }
  48. chipRow {
  49. display = 'flex'
  50. flexWrap = 'wrap'
  51. gap = '.4rem'
  52. }
  53. 'button.chip' {
  54. padding = '.3rem .8rem'
  55. fontSize = '.9rem'
  56. color = 'var(--color-text)'
  57. background = 'var(--color-surface)'
  58. }
  59. 'button.chip.on' {
  60. color = 'var(--color-accent-text)'
  61. background = 'var(--color-accent)'
  62. }
  63. aEditNewFranchise {
  64. display = 'block'
  65. padding = '.8rem 0'
  66. fontSize = '.9rem'
  67. }
  68. editRows {
  69. display = 'block'
  70. }
  71. editRow {
  72. display = 'flex'
  73. alignItems = 'center'
  74. gap = '.5rem'
  75. padding = '.4rem 0'
  76. }
  77. editPos {
  78. flex = 'none'
  79. width = '1.6rem'
  80. color = 'var(--color-text-muted)'
  81. fontVariantNumeric = 'tabular-nums'
  82. textAlign = 'right'
  83. }
  84. buttonMv {
  85. flex = 'none'
  86. width = '2.75rem'
  87. height = '2.75rem'
  88. padding = '0'
  89. fontSize = '1.1rem'
  90. }
  91. 'button.mv.off' {
  92. opacity = '.3'
  93. pointerEvents = 'none'
  94. }
  95. 'button.mv.rm' {
  96. color = 'var(--color-danger)'
  97. }
  98. }
  99. View {
  100. timelineEditPage { "data-timeline" = timelineId
  101. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  102. if (notFound) {
  103. h1 { "Not found" }
  104. p { "This timeline doesn't exist." }
  105. }
  106. if (found) {
  107. franchisesHead {
  108. h1 { class = "typed" typeWord { class = "type-word type-timeline" "Timeline" } typeSep { "|" } typeName { name } }
  109. a { id = "timeline-view" class = "button" href = viewHref "View" }
  110. }
  111. if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }
  112. if (isEditor) {
  113. if (hasMessage) { p { id = "edit-message" class = "message" message } }
  114. editSection {
  115. h2 { class = "film-heading" "Franchise" }
  116. chipRow { id = "franchise-chips"
  117. for (c of chips) { button { type = "button" class = c.cls value = c.id c.name on click(e) { emit pickFranchise(c.id) } } }
  118. }
  119. a { Style.aEditNewFranchise href = "/franchises/edit" "New franchise …" }
  120. }
  121. editSection {
  122. h2 { class = "film-heading" "Titles in timeline order" }
  123. p { class = "muted list-count" countText }
  124. if (noRows) { p { class = "muted" "No titles yet — add some below." } }
  125. if (hasRows) {
  126. editRows { id = "edit-rows"
  127. for (row of rows) {
  128. editRow { "data-show" = row.id
  129. editPos { row.pos }
  130. img { class = "film-poster" src = row.posterUrl alt = "" }
  131. filmText {
  132. filmTitle { row.title }
  133. filmMeta { span { class = row.typeClass row.typeLabel } }
  134. }
  135. button { type = "button" class = row.upClass value = "up" title = "Move up" "aria-label" = "Move up" "↑" on click(e) { emit moveRow(row.id, -1) } }
  136. button { type = "button" class = row.downClass value = "down" title = "Move down" "aria-label" = "Move down" "↓" on click(e) { emit moveRow(row.id, 1) } }
  137. button { type = "button" Style.buttonMv class = "quiet rm" value = "remove" title = "Remove" "aria-label" = "Remove" "✕" on click(e) { emit removeRow(row.id) } }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. editSection {
  144. h2 { class = "film-heading" "Add titles" }
  145. 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) } }
  146. if (hasSearchNote) { p { id = "ted-note" class = "muted" searchNote } }
  147. if (hasResults) {
  148. editRows { id = "ted-results"
  149. for (r of results) {
  150. editRow { "data-show" = r.id
  151. img { class = "film-poster" src = r.posterUrl alt = "" }
  152. filmText {
  153. filmTitle { r.title }
  154. filmMeta { span { class = r.typeClass r.typeLabel } }
  155. }
  156. button { type = "button" class = "inverted add" value = r.id "Add" on click(e) { emit addRow(r.id) } }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. on pickFranchise(franchiseId) {
  167. r = emit server tedSetFranchise(timelineId, '' + franchiseId)
  168. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  169. message = ''
  170. chips = r.chips
  171. }
  172. on moveRow(showId, delta) {
  173. r = emit server tedMove(timelineId, '' + showId, delta)
  174. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  175. message = ''
  176. rows = r.rows
  177. }
  178. on removeRow(showId) {
  179. r = emit server tedRemove(timelineId, '' + showId)
  180. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  181. message = ''
  182. rows = r.rows
  183. }
  184. on addRow(showId) {
  185. r = emit server tedAdd(timelineId, '' + showId)
  186. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  187. message = ''
  188. rows = r.rows
  189. // the added title leaves the results (it is in the timeline now)
  190. left = []
  191. for (x of results) { if (x.id != showId) { left.push(x) } }
  192. results = left
  193. }
  194. on searchTyped(e) {
  195. v = e.target.value
  196. searchText = v
  197. r = emit server tedSearch(timelineId, v)
  198. if (r == null || searchText != v) { return null }
  199. results = r.rows
  200. searchNote = v.trim() == '' ? '' : r.note
  201. }
  202. // ---- the faces (unique names; the trailing `session` is the server's) ----
  203. on server tedSetFranchise(timelineId, franchiseId, session) {
  204. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  205. return setTimelineFranchise(&timelineId, franchiseId)
  206. }
  207. on server tedMove(timelineId, showId, delta, session) {
  208. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  209. return moveInTimeline(&timelineId, &showId, &delta)
  210. }
  211. on server tedRemove(timelineId, showId, session) {
  212. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  213. return removeFromTimeline(&timelineId, &showId)
  214. }
  215. on server tedAdd(timelineId, showId, session) {
  216. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  217. return addToTimeline(&timelineId, &showId)
  218. }
  219. // the search is our public database (like /search) — no session
  220. on server tedSearch(timelineId, text) {
  221. return editSearch(&timelineId, text)
  222. }

Branches

Latest commits

  • d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmre
  • a404ed75Report HM57 audit, gates and integration notesmre
  • 1dcb87a7Use plain declarations for unchanged bindingsmre
  • b90395e3log: HM51 mergedmre
  • 9888d076Merge hm51-classes: tracker#51 views use Style referencesmre
  • 4399bc2fReference remaining component-owned root Style rulesmre
  • 9edcc2dflog: #58 live, HM57 startedmre
  • 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
  • aed12917Reference owned Style rules in genres and searchmre
  • 14195720log: HM49B done, HM51 startedmre
  • 78ee6b56Move remaining component styles into Style blocksmre
  • 7f04de33log: HM49Bmre
  • 00616cf3log: #49 batch merged, DP67 startedmre
  • d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
  • 079f376dMove seven components' styles into Style blocksmre
  • 17d66feelog: #58 mergedmre
  • 69a6640bMerge hm58-map: tracker#58 project.hl only the mapmre
  • a85f7900Move route logic out of the project mapmre
  • 13dea5belog: #56 live, HM49 and HM58 startedmre
  • a31c8f2fdocs: tracker#36 remaining listmre