gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite982c26de982c26dlog: HM65 mergedmree982c26d/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 '../lib/app.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

  • 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
  • 05448a98Merge cb69-imports: appTitle in a dependency-free topicmre
  • e55b379dKeep shared app title independent of the route import graphmre
  • 9a99659blog: hybriel#334, batch waits for day48mre
  • 85fa6c9blog: CB68 result, CB69 startedmre
  • 2f07c1b7log: DP68 boot gate failed, CB68mre