gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain5d144817Merge branch 'records-t40' into mainTicketsmain/components/project-form.hl

2.4 KB

  1. import { makeProjectForSession } from '../lib/projects.hl'
  2. // components/project-form.hl — the form that opens a project (ticket #20), used by the page `/new-project` (components/new_project.hl) and by
  3. // the "New project" window of the ticket list (components/ticket_list.hl). Any logged-in user with a display name may; they become its first
  4. // admin. The slug (the URL part) is proposed from the title as you type and stays editable — once you edit it, the title no longer overwrites
  5. // it. Title / slug / description can be changed later on the project's settings page. The host hears the result through `onCreated(title,
  6. // settingsHref)`; a refusal is shown under the form. ONE per page (a composed component's members are the page's state).
  7. import { createProject, slugFromTitle, uniqueSlug } from '../lib/projects.hl'
  8. import { writerOfSession } from '../lib/users.hl'
  9. import { messageLook } from '../lib/looks.hl'
  10. onCreated = null
  11. title = ''
  12. slug = ''
  13. slugEdited = false
  14. message = ''
  15. Style {
  16. pMessage = messageLook + { }
  17. }
  18. View {
  19. form { id = "projectform"
  20. on submit(e) {
  21. e.preventDefault()
  22. emit create(e)
  23. }
  24. label { "Title"
  25. input { id = "projecttitle" name = "title" required = "required" maxlength = "100" autocomplete = "off" value = title on input(e) { emit setTitle(e.target.value) } }
  26. }
  27. label { "Slug (the address of the project)"
  28. input { id = "projectslug" name = "slug" maxlength = "100" autocomplete = "off" value = slug on input(e) { emit setSlug(e.target.value) } }
  29. }
  30. button { id = "projectcreate" type = "submit" "Create project" }
  31. p { id = "projectmessage" Style.pMessage message }
  32. }
  33. }
  34. on setTitle(v) {
  35. title = v
  36. if (!slugEdited) {
  37. r = emit server proposeSlug(v)
  38. if (r != null && r.slug != null) { slug = r.slug }
  39. }
  40. }
  41. on setSlug(v) {
  42. slug = v
  43. slugEdited = true
  44. }
  45. on create(e) {
  46. if (title.trim() == '') { return null }
  47. r = emit server makeProject(title, slug)
  48. if (r == null || r.error != null) {
  49. message = r != null ? r.error : 'could not create the project'
  50. return null
  51. }
  52. message = ''
  53. made = r
  54. title = ''
  55. slug = ''
  56. slugEdited = false
  57. if (onCreated != null) { onCreated(made.title, made.settingsHref) }
  58. }
  59. on server proposeSlug(text, session) {
  60. if (hlTypeName(text) != 'String' || text.trim() == '') { return { slug = '' } }
  61. return { slug = uniqueSlug(slugFromTitle(text)) }
  62. }
  63. on server makeProject(title, slug, session) {
  64. return makeProjectForSession(title, slug, session)
  65. }

Branches

Latest commits

  • 5d144817Merge branch 'records-t40' into mainTickets
  • 44ee6f06|||PR records: #43 #45 livemre
  • b8fdeee9Merge branch 'p39-routes' into mainTickets
  • a0187a0a|||PR Remove redundant route-order loopmre
  • 369e4b9cMerge branch 'k40-lists' into mainTickets
  • 9af8e780|||PR Use keyed list mutations for live ticket updatesmre
  • 610d8e8aMerge branch 'records-t39' into mainTickets
  • 32bcdf24|||PR records: GO P39 K40mre
  • 4123c6d1Merge branch 'records-t38' into mainTickets
  • cd3641a1|||PR records: day72 deploy live, tickets closedmre
  • 7d44d852Merge branch 'records-t37' into mainTickets
  • 926f7061|||PR records: merges, D36 deploymre
  • bf58534eMerge branch 'l33-final' into mainTickets
  • 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
  • 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
  • 5822cb3aMerge branch 'o34-clean' into mainTickets
  • 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
  • 14cf96b4Merge branch 'records-t36' into mainTickets
  • 07749fa1|||PR records: day72 + #40 mergedmre
  • ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre