0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Set proper order on page creation.

This commit is contained in:
Andrey Antukh 2017-03-14 22:04:34 +01:00
parent 7d2a3a6295
commit 6ee9d668cd
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -198,6 +198,8 @@
;; --- Create Page
(declare reorder-pages)
(deftype CreatePage [name project width height layout]
ptk/WatchEvent
(watch [this state s]
@ -207,18 +209,24 @@
:metadata {:width width
:height height
:layout layout
:order 0}}]
(->> (rp/req :create/page params)
(rx/map :payload)
(rx/map page-created)))))
:order -100}}]
(rx/concat
(->> (rp/req :create/page params)
(rx/map :payload)
(rx/map page-created))
(rx/of (reorder-pages))))))
(s/def ::create-page-event
(s/keys :req-un [::name ::project ::width ::height ::layout]))
(s/keys :req-un [::name
::project
::width
::height
::layout]))
(defn create-page
[{:keys [name project width height layout] :as data}]
{:pre [(us/valid? ::create-page-event data)]}
(->CreatePage name project width height layout))
(CreatePage. name project width height layout))
;; --- Page Persisted