From 5dfc0cb34074161f9afeaebe99bc183882cf8d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20G=C3=B3mez?= Date: Wed, 27 Jan 2016 21:05:33 +0100 Subject: [PATCH] Project deletion --- src/uxbox/data/projects.cljs | 18 ++++++++++++++++++ src/uxbox/ui/dashboard/projects.cljs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/uxbox/data/projects.cljs b/src/uxbox/data/projects.cljs index 49666b16a..5c8c4e3fa 100644 --- a/src/uxbox/data/projects.cljs +++ b/src/uxbox/data/projects.cljs @@ -34,6 +34,13 @@ (let [uuid (:id proj)] (update-in state [:projects-by-id] assoc uuid proj))) +(defn dissoc-project + "A reduce function for dissoc the project + from the state map." + [state proj] + (let [uuid (:id proj)] + (update-in state [:projects-by-id] dissoc uuid))) + (defn assoc-page "A reduce function for assoc the page to the state map." @@ -122,6 +129,17 @@ (-pr-writer [mv writer _] (-write writer "#"))))) +(defn delete-project + [proj] + (reify + rs/UpdateEvent + (-apply-update [_ state] + (dissoc-project state proj)) + + IPrintWithWriter + (-pr-writer [mv writer _] + (-write writer "#")))) + (defn go-to "A shortcut event that redirects the user to the first page of the project." diff --git a/src/uxbox/ui/dashboard/projects.cljs b/src/uxbox/ui/dashboard/projects.cljs index 34055ff9f..8e0ca6d9d 100644 --- a/src/uxbox/ui/dashboard/projects.cljs +++ b/src/uxbox/ui/dashboard/projects.cljs @@ -205,7 +205,7 @@ [:div.project-th-icon.delete {:on-click #(do (dom/stop-propagation %) - ;; (actions/delete-project conn uuid) + (rs/emit! (dp/delete-project project)) %)} i/trash]]])))