gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit78ee6b5678ee6b56Move remaining component styles into Style blocksmre78ee6b56/components/franchiseedit.hl

4.6 KB

  1. // components/franchiseedit.hl — `/franchises/edit` (tracker.worldapi.org#19, mission 066): the creator's editor, step 1 —
  2. // a new franchise (name + summary → its index), a new timeline (name → its own editor, /timelines/<slug>/edit, where titles
  3. // are added and ordered and the franchise is attached), and a finder for the timelines that exist (by name → their editor).
  4. // Only the creator (franchises.hl isEditorSession: ident id az5b2, TRACKER_EDITORS) sees the forms; every face checks it again.
  5. //
  6. // HYBRIEL TRAPS (as components/search.hl): no member reads both a route param and `session`; every list is replaced whole.
  7. parent './main.hl'
  8. import { navigate } from 'hl:web'
  9. import { appTitle } from '../project.hl'
  10. import { isEditorSession, createFranchise, createTimeline, findTimelines } from '../lib/franchises.hl'
  11. import { warmReady, warmText } from '../lib/warm.hl'
  12. static editorOf = (&session) => { return isEditorSession(&session) }
  13. session = null
  14. isEditor = editorOf(&session)
  15. notEditor = isEditor == false
  16. message = ''
  17. hasMessage = message != ''
  18. franchiseName = ''
  19. franchiseSummary = ''
  20. timelineName = ''
  21. findText = ''
  22. found = []
  23. hasFound = found.length > 0
  24. __title = 'Edit franchises — ' + appTitle
  25. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'
  26. // stage is there this page says so instead of showing half a map
  27. warming = !warmReady('all')
  28. warmNote = warming ? warmText() : ''
  29. // Component styles use the shared theme variables.
  30. Style {
  31. franchiseEditPage {
  32. display = 'block'
  33. }
  34. }
  35. View {
  36. franchiseEditPage {
  37. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  38. h1 { "Edit franchises" }
  39. if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }
  40. if (isEditor) {
  41. if (hasMessage) { p { id = "edit-message" class = "message" message } }
  42. editSection {
  43. h2 { class = "film-heading" "New franchise" }
  44. input { id = "fe-name" value = franchiseName on input(e) { franchiseName = e.target.value } type = "text" placeholder = "Name, e.g. Star Trek" autocomplete = "off" "aria-label" = "Franchise name" }
  45. textarea { id = "fe-summary" value = franchiseSummary on input(e) { franchiseSummary = e.target.value } rows = "3" placeholder = "A few words about it (optional)" "aria-label" = "Franchise summary" }
  46. button { id = "fe-create" type = "button" class = "primary" "Create franchise" on click(e) { emit newFranchise(e) } }
  47. }
  48. editSection {
  49. h2 { class = "film-heading" "New timeline" }
  50. input { id = "te-name" value = timelineName on input(e) { timelineName = e.target.value } type = "text" placeholder = "Name, e.g. Star Trek — Prime" autocomplete = "off" "aria-label" = "Timeline name" }
  51. button { id = "te-create" type = "button" class = "primary" "Create timeline" on click(e) { emit newTimeline(e) } }
  52. }
  53. editSection {
  54. h2 { class = "film-heading" "Edit a timeline" }
  55. input { id = "tl-find" value = findText type = "search" placeholder = "Timeline name" autocomplete = "off" "aria-label" = "Find a timeline" on input(e) { emit findTyped(e) } }
  56. if (hasFound) {
  57. timelineList { id = "tl-found"
  58. for (t of found) {
  59. a { class = "timeline-link" href = t.href
  60. timelineLinkName { t.name }
  61. timelineLinkCount { t.countText }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. on newFranchise(e) {
  71. r = emit server fedCreateFranchise(franchiseName, franchiseSummary)
  72. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not create it.' return null }
  73. navigate('/franchises/' + r.slug)
  74. }
  75. on newTimeline(e) {
  76. r = emit server fedCreateTimeline(timelineName)
  77. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not create it.' return null }
  78. navigate('/timelines/' + r.slug + '/edit')
  79. }
  80. on findTyped(e) {
  81. v = e.target.value
  82. findText = v
  83. r = emit server fedFindTimelines(v)
  84. if (r == null || findText != v) { return null }
  85. found = r.rows
  86. }
  87. // ---- the faces (unique names: hl:web dispatches by name across all files; the trailing `session` is the server's) ----
  88. on server fedCreateFranchise(name, summary, session) {
  89. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  90. return createFranchise(name, summary)
  91. }
  92. on server fedCreateTimeline(name, session) {
  93. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  94. return createTimeline(&name)
  95. }
  96. // timeline names are public (/franchises lists them all) — no session needed
  97. on server fedFindTimelines(text) {
  98. return { rows = findTimelines(&text) }
  99. }

Branches

Latest commits

  • 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
  • 975d06d1log: #36 live, DP66 startedmre
  • d6d03fa3mission: T36Bmre
  • e7512d00status: #36 rolled back, retry askedmre
  • c98e2043log: T36A rollbackmre
  • ae905f15Merge t36a: tracker#36 apply rechecks, reportmre
  • 796bfaceT36A: report validated fixes, failed live SSH check and verified rollbackmre
  • 55257852log: #53 live, #56 mergedmre
  • 78b39f1bMerge hm56-rows: tracker#56 list builders insert oncemre
  • 7aea52batmdb fix: protect owners without slugs and record passing gatesmre
  • 9b3c2559tmdb fix: revalidate planned identities and reserve target idsmre