From 41f9e6fe77d72759081022a6a8787279c2d62975 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 21 Oct 2016 16:44:06 +0200 Subject: [PATCH] Implement grid options copy tooltip. --- src/uxbox/main/ui/dashboard/icons.cljs | 36 ++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/uxbox/main/ui/dashboard/icons.cljs b/src/uxbox/main/ui/dashboard/icons.cljs index 10b00f89b..d4f1a6b4b 100644 --- a/src/uxbox/main/ui/dashboard/icons.cljs +++ b/src/uxbox/main/ui/dashboard/icons.cljs @@ -209,14 +209,38 @@ :type "file" :on-change on-file-selected}]])) -(mx/defc grid-options - [{:keys [type] :as coll}] +(mx/defc grid-options-copy + {:mixins [mx/reactive mx/static]} + [colls] + (let [colls (mx/react collections-ref) + colls (->> (vals colls) + (filter #(= :own (:type %))) + (sort-by :name colls)) + on-select (fn [event id] + (dom/prevent-default event) + (rs/emit! (di/copy-selected id)))] + [:ul.move-list + [:li.title "Copy to library"] + [:li [:a {:href "#" :on-click (partial on-select nil)} "Storage"]] + (for [coll colls + :let [id (:id coll) + name (:name coll)]] + [:li {:key (str id)} + [:a {:on-click #(on-select % id)} name]])])) + +(mx/defcs grid-options + {:mixins [(mx/local) mx/static]} + [own {:keys [type] :as coll}] (let [editable? (or (= type :own) - (nil? coll))] + (nil? coll)) + local (:rum/local own)] (letfn [(delete [] (rs/emit! (di/delete-selected))) (on-delete [event] - (udl/open! :confirm {:on-accept delete}))] + (udl/open! :confirm {:on-accept delete})) + (on-toggle [event] + (swap! local update :show-copy-tooltip not) + (println "on-toggle"))] ;; MULTISELECT OPTIONS BAR [:div.multiselect-bar (if editable? @@ -230,7 +254,9 @@ i/trash]] [:div.multiselect-nav [:span.move-item.tooltip.tooltip-top - {:alt "Copy to"} + {:on-click on-toggle} + (when (:show-copy-tooltip @local) + (grid-options-copy)) i/organize]])]))) (mx/defc grid-item