diff --git a/src/main/frontend/components/right_sidebar.cljs b/src/main/frontend/components/right_sidebar.cljs index b67bd33ff..2a6177adf 100644 --- a/src/main/frontend/components/right_sidebar.cljs +++ b/src/main/frontend/components/right_sidebar.cljs @@ -181,8 +181,12 @@ (state/clear-sidebar-blocks!) (state/hide-right-sidebar!))} "Close all" nil) [:hr.menu-separator] - (ui/menu-link {:on-click #(state/sidebar-block-toggle-collapse! db-id)} (if collapsed? "Expand" "Collapse") nil) + (when-not collapsed? (ui/menu-link {:on-click #(state/sidebar-block-toggle-collapse! db-id)} "Collapse" nil)) (ui/menu-link {:on-click #(state/sidebar-block-collapse-rest! db-id)} "Collapse others" nil) + (ui/menu-link {:on-click #(state/sidebar-block-set-collapsed-all! true)} "Collapse all" nil) + [:hr.menu-separator] + (when collapsed? (ui/menu-link {:on-click #(state/sidebar-block-toggle-collapse! db-id)} "Expand" nil)) + (ui/menu-link {:on-click #(state/sidebar-block-set-collapsed-all! false)} "Expand all" nil) (when (integer? db-id) [:hr.menu-separator]) (when (integer? db-id) (let [name (:block/name (db/entity db-id))] @@ -218,7 +222,6 @@ (reset! *drag-from nil)) :on-click (fn [event] (.preventDefault event) - (js/console.log event.which) (state/sidebar-block-toggle-collapse! db-id)) :on-mouse-up (fn [event] (when (= (.-which (.-nativeEvent event)) 2) diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 214da9722..918b3bbdd 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -1130,7 +1130,13 @@ Similar to re-frame subscriptions" (defn sidebar-block-collapse-rest! [db-id] (let [items (disj (set (map second (:sidebar/blocks @state))) db-id)] - (for [item items] (set-state! [:ui/sidebar-collapsed-blocks item] true)))) + (doseq [item items] (set-state! [:ui/sidebar-collapsed-blocks item] true)))) + +(defn sidebar-block-set-collapsed-all! + [collapsed?] + (let [items (map second (:sidebar/blocks @state))] + (doseq [item items] + (set-state! [:ui/sidebar-collapsed-blocks item] collapsed?)))) (defn get-edit-block []