gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitccdde2beccdde2beticket: format Style with nested language rulesmreccdde2be/components/project-form.hl

2.6 KB

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

Branches

Latest commits

  • ccdde2beticket: format Style with nested language rulesmre
  • d083535bticket_list: nest Style rules and bare media queriesmre
  • c24608ebmarkdown: format Style with nested language rulesmre
  • de964b3bsettings: format Style with nested language rulesmre
  • 03c1de05new_project: format Style with nested language rulesmre
  • bd76cfa6connect: format Style with nested language rulesmre
  • 01fad593inbox: format Style with nested language rulesmre
  • 79dc9392you: format Style with nested language rulesmre
  • 78073baamain: format Style with nested language rulesmre
  • 5499c290Sync theme unchanged from layouts 17e0f03mre
  • fd33ee21Sync reviewed components from 8176eb1mre
  • 93348453Re-vendor tickets to Hybriel set day35mre
  • a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
  • cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
  • 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
  • b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
  • f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
  • 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
  • 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
  • d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre