mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 13:46:38 +02:00
WIP: project creation now work.
This commit is contained in:
parent
62b9267d4f
commit
56f7613453
11 changed files with 201 additions and 103 deletions
32
frontend/uxbox/data/projects.cljs
Normal file
32
frontend/uxbox/data/projects.cljs
Normal file
|
@ -0,0 +1,32 @@
|
|||
(ns uxbox.data.projects
|
||||
(:require [uxbox.rstore :as rs]
|
||||
[uxbox.state :as st]
|
||||
[uxbox.schema :as sc]
|
||||
[bouncer.validators :as v]))
|
||||
|
||||
(def ^:static +project-schema+
|
||||
{:name [v/required v/string]
|
||||
:width [v/required v/integer]
|
||||
:height [v/required v/integer]
|
||||
:layout [v/required sc/keyword?]})
|
||||
|
||||
(defn create-project
|
||||
[{:keys [name width height layout] :as data}]
|
||||
(sc/validate! +project-schema+ data)
|
||||
(println "create-project")
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(let [uuid (random-uuid)
|
||||
proj {:id uuid
|
||||
:name name
|
||||
:width width
|
||||
:height height
|
||||
:pages []}]
|
||||
(-> state
|
||||
(update-in [:projects] conj uuid)
|
||||
(update-in [:projects-by-id] assoc uuid {:name name}))))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.s.p/create-project>"))))
|
Loading…
Add table
Add a link
Reference in a new issue