gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb1496147b1496147Merge branch 'ap61' into mainTrackerb1496147/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

  • b1496147Merge branch 'ap61' into mainTracker
  • 2047955bMerge branch 'u12-gateports' into mainTracker
  • c8da40f3|||PR AP61: re-vendor Hybriel set day61 (source a05af47c, bin a11042e5)Tracker
  • 4e018678|||PR deploy.sh: gates use Tracker's ports 8716-8719 and LC_ALL=C; README: 2 backups keptTracker
  • 0b86324aMerge branch 'records-dp73' into mainTracker
  • 9ce5f59b|||PR records: DP73 live 613ae0e; deploy.sh keeps 2 backupsTracker
  • 613ae0ecMerge branch 'bs3' into mainTracker
  • 1383264b|||PR BS3: keep shared synchronous sorting fastTracker
  • 63e5ba1a|||PR BS3: guard boot imports and share resumable sort buffersTracker
  • 310613f1Merge branch 'records-dp72' into mainTracker
  • 6f7b61ba|||PR records: deploy-swap fix live, Kunibert findingsTracker
  • c41587d2Merge branch 'bs2' into mainTracker
  • 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
  • 019d5cedMerge branch 'records-1110' into mainTracker
  • f88ae8b9|||PR records: day56 toggle live, reviewTracker
  • b6b3bb4dMerge branch 'ap56e' into mainTracker
  • 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker
  • 7c9ec236|||PR AP56e: re-vendor Hybriel set day56 (source 36ae83a8, bin c1f595a2)Tracker
  • 4b54f6f9Merge branch 'records-audit' into mainTracker
  • cab4a3bc|||PR records: branch audit, PR-onlyTracker