From b4dd70286d44f1264301ce6f21644547037f9da7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 13 Jan 2016 17:51:39 +2000 Subject: [PATCH] Add copy impl on layers toolbox. --- src/uxbox/data/workspace.cljs | 13 +++++++++++++ src/uxbox/ui/workspace/toolboxes.cljs | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index 0794e4cf9..fb281f868 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -263,6 +263,19 @@ (-apply-update [_ state] (assoc-in state [:workspace :selected] #{})))) +(defn copy-selected + "Copy the selected shapes." + [] + (reify + rs/WatchEvent + (-apply-watch [_ state] + (let [selected (get-in state [:workspace :selected])] + (as-> selected $ + (map #(get-in state [:shapes-by-id %]) $) + (map #(assoc % :id (random-uuid)) $) + (map #(add-shape % %) $) + (rx/from-coll $)))))) + (defn delete-selected "Deselect all and remove all selected shapes." [] diff --git a/src/uxbox/ui/workspace/toolboxes.cljs b/src/uxbox/ui/workspace/toolboxes.cljs index 40891c535..f5d53d525 100644 --- a/src/uxbox/ui/workspace/toolboxes.cljs +++ b/src/uxbox/ui/workspace/toolboxes.cljs @@ -158,6 +158,7 @@ shapes-by-id (rum/react shapes-by-id) page (rum/react (focus-page (:page workspace))) close #(rs/emit! (dw/toggle-toolbox :layers)) + copy #(rs/emit! (dw/copy-selected)) delete #(rs/emit! (dw/delete-selected))] (html [:div#layers.tool-window @@ -172,7 +173,8 @@ (rum/with-key component (:id shape)))]] [:div.layers-tools [:ul.layers-tools-content - [:li.clone-layer i/copy] + [:li.clone-layer {:on-click copy} + i/copy] [:li.group-layer i/folder] [:li.delete-layer {:on-click delete} i/trash]