gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit08e5525508e55255log: HM56 done, T36A startedmre08e55255/components/franchiseedit.hl

4.5 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. View {
  30. franchiseEditPage {
  31. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  32. h1 { "Edit franchises" }
  33. if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }
  34. if (isEditor) {
  35. if (hasMessage) { p { id = "edit-message" class = "message" message } }
  36. editSection {
  37. h2 { class = "film-heading" "New franchise" }
  38. 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" }
  39. 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" }
  40. button { id = "fe-create" type = "button" class = "primary" "Create franchise" on click(e) { emit newFranchise(e) } }
  41. }
  42. editSection {
  43. h2 { class = "film-heading" "New timeline" }
  44. 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" }
  45. button { id = "te-create" type = "button" class = "primary" "Create timeline" on click(e) { emit newTimeline(e) } }
  46. }
  47. editSection {
  48. h2 { class = "film-heading" "Edit a timeline" }
  49. input { id = "tl-find" value = findText type = "search" placeholder = "Timeline name" autocomplete = "off" "aria-label" = "Find a timeline" on input(e) { emit findTyped(e) } }
  50. if (hasFound) {
  51. timelineList { id = "tl-found"
  52. for (t of found) {
  53. a { class = "timeline-link" href = t.href
  54. timelineLinkName { t.name }
  55. timelineLinkCount { t.countText }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
  64. on newFranchise(e) {
  65. r = emit server fedCreateFranchise(franchiseName, franchiseSummary)
  66. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not create it.' return null }
  67. navigate('/franchises/' + r.slug)
  68. }
  69. on newTimeline(e) {
  70. r = emit server fedCreateTimeline(timelineName)
  71. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not create it.' return null }
  72. navigate('/timelines/' + r.slug + '/edit')
  73. }
  74. on findTyped(e) {
  75. v = e.target.value
  76. findText = v
  77. r = emit server fedFindTimelines(v)
  78. if (r == null || findText != v) { return null }
  79. found = r.rows
  80. }
  81. // ---- the faces (unique names: hl:web dispatches by name across all files; the trailing `session` is the server's) ----
  82. on server fedCreateFranchise(name, summary, session) {
  83. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  84. return createFranchise(name, summary)
  85. }
  86. on server fedCreateTimeline(name, session) {
  87. if (!isEditorSession(&session)) { return { error = 'only the creator can do that' } }
  88. return createTimeline(&name)
  89. }
  90. // timeline names are public (/franchises lists them all) — no session needed
  91. on server fedFindTimelines(text) {
  92. return { rows = findTimelines(&text) }
  93. }

Branches

Latest commits

  • 08e55255log: HM56 done, T36A startedmre
  • 5fd2ac75status: #36 GOmre
  • 0d253b45mission: T36Amre
  • 2aa22d23log: #36 GOmre
  • 833aee2flog: #50 closed, HM56 startedmre
  • ac58c1e5mission: HM56mre
  • 58979c0clog: HM54 held for decision, DP65 startedmre
  • bb2ebc67log: #64 live, #53 mergedmre
  • 27cde42fMerge hm53-dom: tracker#53 inputs bound to membersmre
  • 2156cc7flog: HM54 reviewmre
  • 9fb82efclog: HM54 gap, fill continuesmre
  • b632eb8dlog: HM53 done, HM54 startedmre
  • ccb1a263tracker#53: bind editor drafts and use key event focus targetmre
  • 3356fcfclog: #52 blocked, HM53 startedmre
  • 833dcfc9Merge hm52-search: report only, tracker#52 blocked by framework gapmre
  • 73010cc0HM52: report replace-navigation search draft regressionmre
  • 1742e92bstatus: DP64 and HM52 runningmre
  • 29ad5b58log: #64 merged, DP64 and HM52 startedmre
  • fafddbf9Merge hm64-catalog: tracker#64 catalog from packed entriesmre
  • b2e2206dlog: #63 livemre