gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite0db0d1be0db0d1bHM60 report: tracker#60 packed short-ID ownersmree0db0d1b/components/franchiseedit.hl

4.3 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. found = []
  19. hasFound = found.length > 0
  20. __title = 'Edit franchises — ' + appTitle
  21. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'
  22. // stage is there this page says so instead of showing half a map
  23. warming = !warmReady('all')
  24. warmNote = warming ? warmText() : ''
  25. View {
  26. franchiseEditPage {
  27. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  28. h1 { "Edit franchises" }
  29. if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }
  30. if (isEditor) {
  31. if (hasMessage) { p { id = "edit-message" class = "message" message } }
  32. editSection {
  33. h2 { class = "film-heading" "New franchise" }
  34. input { id = "fe-name" type = "text" placeholder = "Name, e.g. Star Trek" autocomplete = "off" "aria-label" = "Franchise name" }
  35. textarea { id = "fe-summary" rows = "3" placeholder = "A few words about it (optional)" "aria-label" = "Franchise summary" }
  36. button { id = "fe-create" type = "button" class = "primary" "Create franchise" on click(e) { emit newFranchise(e) } }
  37. }
  38. editSection {
  39. h2 { class = "film-heading" "New timeline" }
  40. input { id = "te-name" type = "text" placeholder = "Name, e.g. Star Trek — Prime" autocomplete = "off" "aria-label" = "Timeline name" }
  41. button { id = "te-create" type = "button" class = "primary" "Create timeline" on click(e) { emit newTimeline(e) } }
  42. }
  43. editSection {
  44. h2 { class = "film-heading" "Edit a timeline" }
  45. input { id = "tl-find" type = "search" placeholder = "Timeline name" autocomplete = "off" "aria-label" = "Find a timeline" on input(e) { emit findTyped(e) } }
  46. if (hasFound) {
  47. timelineList { id = "tl-found"
  48. for (t of found) {
  49. a { class = "timeline-link" href = t.href
  50. timelineLinkName { t.name }
  51. timelineLinkCount { t.countText }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. on newFranchise(e) {
  61. r = emit server fedCreateFranchise(document.getElementById('fe-name').value, document.getElementById('fe-summary').value)
  62. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not create it.' return null }
  63. navigate('/franchises/' + r.slug)
  64. }
  65. on newTimeline(e) {
  66. r = emit server fedCreateTimeline(document.getElementById('te-name').value)
  67. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not create it.' return null }
  68. navigate('/timelines/' + r.slug + '/edit')
  69. }
  70. on findTyped(e) {
  71. v = e.target.value
  72. r = emit server fedFindTimelines(v)
  73. if (r == null || document.getElementById('tl-find').value != v) { return null }
  74. found = r.rows
  75. }
  76. // ---- the faces (unique names: hl:web dispatches by name across all files; the trailing `session` is the server's) ----
  77. on server fedCreateFranchise(name, summary, session) {
  78. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  79. return createFranchise(name, summary)
  80. }
  81. on server fedCreateTimeline(name, session) {
  82. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  83. return createTimeline(&name)
  84. }
  85. // timeline names are public (/franchises lists them all) — no session needed
  86. on server fedFindTimelines(text) {
  87. return { rows = findTimelines(&text) }
  88. }

Branches

Latest commits

  • e0db0d1bHM60 report: tracker#60 packed short-ID ownersmre
  • e822524bstatus wordingmre
  • 1c7f0480log: HM60/HM61 startedmre
  • 2841d215missions HM60 HM61mre
  • 289c6ce4HM1 report: heap object breakdownmre
  • 2e7d6257log: HM1 startedmre
  • 2f790465mission HM1: heap object breakdownmre
  • a18957falog: evening re-measure after CBmre
  • aac9a98dlog: evening re-measure startmre
  • 45163bd4log: person/tmdb error hypothesismre
  • cb38de2blog: swap 503 causemre
  • fd10c3d5log: CB livemre
  • 7557c025log: CB deploy try 2mre
  • 06a7534aMerge branch 'cb'mre
  • 2f8030d6log: CB gates greenmre
  • 498bf644log: CB gates startmre
  • f59c2847gc1: bound the five request caches (shows.hl cacheLimit)mre
  • 6ea2c6d6log: morning re-measure 11-04mre
  • 446290f0log: GC1 livemre
  • 8e6aa91dlog: GC1 deploy retrymre