mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 22:36:12 +02:00
Upload multiple images
This commit is contained in:
parent
4237f3a04e
commit
3a7e97bc60
3 changed files with 13 additions and 6 deletions
|
@ -171,10 +171,16 @@
|
||||||
(defrecord CreateImages [coll-id files]
|
(defrecord CreateImages [coll-id files]
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(-apply-watch [_ state s]
|
||||||
(let [image-data {:coll coll-id
|
(let [files-to-array (fn [js-col]
|
||||||
:id (uuid/random)
|
(-> (clj->js [])
|
||||||
:files files}]
|
(.-slice)
|
||||||
(->> (rp/req :create/image image-data)
|
(.call js-col)
|
||||||
|
(js->clj)))
|
||||||
|
images-data (map (fn [file] {:coll coll-id
|
||||||
|
:id (uuid/random)
|
||||||
|
:file file}) (files-to-array files))]
|
||||||
|
(->> (rx/from-coll images-data)
|
||||||
|
(rx/flat-map #(rp/req :create/image %))
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map image-created)))))
|
(rx/map image-created)))))
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@
|
||||||
(send! params)))
|
(send! params)))
|
||||||
|
|
||||||
(defmethod request :create/image
|
(defmethod request :create/image
|
||||||
[_ {:keys [coll id files] :as body}]
|
[_ {:keys [coll id file] :as body}]
|
||||||
(let [body (doto (js/FormData.)
|
(let [body (doto (js/FormData.)
|
||||||
(.append "file" (aget files 0))
|
(.append "file" file)
|
||||||
(.append "id" id))
|
(.append "id" id))
|
||||||
params {:url (str url "/library/image-collections/" coll "/images")
|
params {:url (str url "/library/image-collections/" coll "/images")
|
||||||
:method :post
|
:method :post
|
||||||
|
|
|
@ -208,6 +208,7 @@
|
||||||
[:span "+ New image"]
|
[:span "+ New image"]
|
||||||
[:input.upload-image-input
|
[:input.upload-image-input
|
||||||
{:style {:display "none"}
|
{:style {:display "none"}
|
||||||
|
:multiple true
|
||||||
:ref "file-input"
|
:ref "file-input"
|
||||||
:type "file"
|
:type "file"
|
||||||
:on-change on-file-selected}]])
|
:on-change on-file-selected}]])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue