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
- cc56798cLog gitoria PR-only requestmre
- fd83ac1fconductor: caramboleyo is the user, not owner/creatorApollo
- 3b858c91Log backup hard-link fixmre
- 7f6b37a0deploy.sh backup: tar --hard-dereference (hard links broke mpackdb sidecars on restore)mre
- e93711d9Log E30 livemre
- 59c02e4dMerge e30: preserve edited state note labels in Markdownmre
- 30970796Log E30 deploy GOmre
- 7c8e6d83Limit edited state note fix to Markdown renderingmre
- 910536d0Log E30 reviewmre
- 36984386Preserve state transitions when their notes are editedmre
- d75cb946Log E30 startmre
- 0bf3fefaMission 030: edited state note labelmre
- 691565c6Log neutral-ticket rule checkmre
- bc3bdecerecords: day38b live, #94 purgedmre
- f6c5aa0dMerge main (records)mre
- e23d42acconnect gate: wait for hydration before clicking Disconnectmre
- a5d45d00records: D38 cause, GOmre
- 19eeb938records: D38 gates, two day38b failuresmre
- f8e42a85Re-vendor tickets to Hybriel set day38b (1e554d7)mre
- 51645016Merge purge-94 (#94, identity rule)mre