Properly handle files and pages deletion (frontend).

This commit is contained in:
Andrey Antukh 2019-12-11 16:35:30 +01:00
parent 87d41700fc
commit 4c5b41b6b2
5 changed files with 55 additions and 57 deletions

View file

@ -131,7 +131,7 @@
[{:keys [file] :as props}]
(let [local (mf/use-state {})
on-navigate #(st/emit! (udp/go-to (:id file)))
delete-fn #(st/emit! nil #_(udp/delete-file (:id file)))
delete-fn #(st/emit! nil (udp/delete-file (:id file)))
on-delete #(do
(dom/stop-propagation %)
(modal/show! confirm-dialog {:on-accept delete-fn}))
@ -257,8 +257,10 @@
(def files-ref
(letfn [(selector [state]
(let [id (get-in state [:dashboard-projects :id])
ids (get-in state [:dashboard-projects :files id])]
(mapv #(get-in state [:files %]) ids)))]
ids (get-in state [:dashboard-projects :files id])
xf (comp (map #(get-in state [:files %]))
(remove nil?))]
(into [] xf ids)))]
(-> (l/lens selector)
(l/derive st/state))))

View file

@ -30,7 +30,7 @@
(mf/defc page-item
[{:keys [page index deletable? selected?] :as props}]
(let [on-edit #(modal/show! page-form-dialog {:page page})
delete-fn #(st/emit! (dw/delete-page (:id page)))
delete-fn #(st/emit! (udp/delete-page (:id page)))
on-delete #(do
(dom/prevent-default %)
(dom/stop-propagation %)