tickets
All repositories: gitoria
2.6 KB
// components/project-form.hl — the form that opens a project (ticket #20), used by the page `/new-project` (components/new_project.hl) and by// 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// 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// it. Title / slug / description can be changed later on the project's settings page. The host hears the result through `onCreated(title,// settingsHref)`; a refusal is shown under the form. ONE per page (a composed component's members are the page's state).import { createProject, slugFromTitle, uniqueSlug } from '../lib/projects.hl'import { writerOfSession } from '../lib/users.hl'import { messageLook } from '../lib/looks.hl'onCreated = nulltitle = ''slug = ''slugEdited = falsemessage = ''Style {pMessage = messageLook + { }}View {form { id = "projectform"on submit(e) {e.preventDefault()emit create(e)}label { "Title"input { id = "projecttitle" name = "title" required = "required" maxlength = "100" autocomplete = "off" value = title on input(e) { emit setTitle(e.target.value) } }}label { "Slug (the address of the project)"input { id = "projectslug" name = "slug" maxlength = "100" autocomplete = "off" value = slug on input(e) { emit setSlug(e.target.value) } }}button { id = "projectcreate" type = "submit" "Create project" }p { id = "projectmessage" Style.pMessage message }}}on setTitle(v) {title = vif (!slugEdited) {r = emit server proposeSlug(v)if (r != null && r.slug != null) { slug = r.slug }}}on setSlug(v) {slug = vslugEdited = true}on create(e) {if (title.trim() == '') { return null }r = emit server makeProject(title, slug)if (r == null || r.error != null) {message = r != null ? r.error : 'could not create the project'return null}message = ''made = rtitle = ''slug = ''slugEdited = falseif (onCreated != null) { onCreated(made.title, made.settingsHref) }}on server proposeSlug(text, session) {if (hlTypeName(text) != 'String' || text.trim() == '') { return { slug = '' } }return { slug = uniqueSlug(slugFromTitle(text)) }}on server makeProject(title, slug, session) {w = writerOfSession(session)if (w.error != null) { return { error = w.error } }if (hlTypeName(title) != 'String' || hlTypeName(slug) != 'String') { return { error = 'title and slug must be text' } }r = createProject(w.user, title, slug, '')if (r.error != null) { return { error = r.error } }return { title = r.project.title slug = r.project.slug settingsHref = r.project.settingsHref }}
Branches
Latest commits
- 8d8e2053Document subscription contract and exercise delta deliverymre
- fd23726aAdd subscription delta API and signed wake bridgemre
- c5d28fb5Tickets conductor: S51 startedmre
- fd6ca1e6Tickets conductor: brief 027 waker design, push-test projectmre
- e448e656Tickets conductor: STATUS #51mre
- 1c10857bTickets conductor: P51 eval, brief 027mre
- e725969dTickets conductor: #51 directionmre
- 1b5c63ddTickets conductor: P51 startedmre
- 9f13fbdaTickets conductor: brief 026 prioritymre
- acc477d9Tickets conductor: brief 026 + Vinzenz recommendationsmre
- 9233a734Tickets conductor: brief 026 completemre
- 5da589fdTickets conductor: brief 026 + Gitoria's answermre
- a3cd5329Tickets conductor: tickets#51 opened, brief 026 draftmre
- 6f6e5797Tickets conductor: STATUS wordingmre
- 957de51fTickets conductor: T36 live, #36 review, #50 donemre
- bc2fde32Merge branch 'main' into t36-stylemre
- b7ca093atests: wait for the new row and normalize editor marker spacesmre
- 41da3525Tickets conductor: flake cause, T36 deploy stepmre
- 64c477e6Tickets conductor: deploy waits for Arachnemre
- 467d7286Tickets conductor: T36 done, deploy questionmre