Toggle subscription pods open and closed

This commit is contained in:
Daniel Compton 2018-01-17 16:43:50 +13:00
parent 18d0a9b145
commit 96ab1730f9
3 changed files with 29 additions and 10 deletions

View File

@ -447,3 +447,15 @@
[(rf/path [:subs :ignore-unchanged-subs?])] [(rf/path [:subs :ignore-unchanged-subs?])]
(fn [_ [_ ignore?]] (fn [_ [_ ignore?]]
ignore?)) ignore?))
(rf/reg-event-db
:subs/open-pod?
[(rf/path [:subs :expansions])]
(fn [expansions [_ id open?]]
(assoc-in expansions [id :open?] open?)))
(rf/reg-event-db
:subs/diff-pod?
[(rf/path [:subs :expansions])]
(fn [expansions [_ id diff?]]
(assoc-in expansions [id :diff?] diff?)))

View File

@ -317,9 +317,7 @@
;; TODO: data for sub ;; TODO: data for sub
;; TODO: get layer level ;; TODO: get layer level
;; TODO: Get not run subscriptions ;; TODO: Get not run subscriptions
}))
:open? false
:diff false}))
traces) traces)
;; Filter out run if it was created ;; Filter out run if it was created
@ -375,3 +373,9 @@
:<- [:subs/root] :<- [:subs/root]
(fn [subs _] (fn [subs _]
(:ignore-unchanged-subs? subs true))) (:ignore-unchanged-subs? subs true)))
(rf/reg-sub
:subs/sub-expansions
:<- [:subs/root]
(fn [subs _]
(:expansions subs)))

View File

@ -2,7 +2,8 @@
(:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf] (:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v6v0.reagent.core :as r] [mranderson047.reagent.v0v6v0.reagent.core :as r]
[day8.re-frame.trace.utils.re-com :as rc :refer [css-join]] [day8.re-frame.trace.utils.re-com :as rc :refer [css-join]]
[day8.re-frame.trace.common-styles :as common]) [day8.re-frame.trace.common-styles :as common]
[day8.re-frame.trace.view.components :as components])
(:require-macros [day8.re-frame.trace.utils.macros :as macros])) (:require-macros [day8.re-frame.trace.utils.macros :as macros]))
;(s/def ::query-v any?) ;(s/def ::query-v any?)
@ -134,7 +135,7 @@
:class "noselect" :class "noselect"
:style {:cursor "pointer"} :style {:cursor "pointer"}
:attr {:title (str (if open? "Close" "Open") " the pod bay doors, HAL") :attr {:title (str (if open? "Close" "Open") " the pod bay doors, HAL")
:on-click (rc/handler-fn (update-pod-field id :open? (not open?)))} :on-click #(rf/dispatch [:subs/open-pod? id (not open?)])}
:child [rc/box :child [rc/box
:margin "auto" :margin "auto"
:child [:span.arrow (if open? "▼" "▶")]]] :child [:span.arrow (if open? "▼" "▶")]]]
@ -166,7 +167,7 @@
:border-radius "3px" :border-radius "3px"
:cursor "pointer"} :cursor "pointer"}
:attr {:title "Show diff" :attr {:title "Show diff"
:on-click (rc/handler-fn (update-pod-field id :diff? (not diff?)))} :on-click #(rf/dispatch [:subs/diff-pod? id (not diff?)])}
:child [:img :child [:img
{:src (str "data:image/svg+xml;utf8," copy) {:src (str "data:image/svg+xml;utf8," copy)
:style {:width "19px" :style {:width "19px"
@ -181,12 +182,12 @@
:children [[pod-header pod-info] :children [[pod-header pod-info]
(when open? (when open?
[rc/v-box [rc/v-box
:height "90px"
:min-width "100px" :min-width "100px"
:style {:background-color cljs-dev-tools-background :style {:background-color cljs-dev-tools-background
:padding common/gs-7s :padding common/gs-7s
:margin (css-join pad-padding pad-padding "0px" pad-padding)} :margin (css-join pad-padding pad-padding "0px" pad-padding)}
:children ["---main-section---"]]) :children [[components/simple-render
(:value pod-info)]]])
(when (and open? diff?) (when (and open? diff?)
[rc/v-box [rc/v-box
:height common/gs-19s :height common/gs-19s
@ -233,14 +234,16 @@
:children [[rc/label :label "There are no subscriptions to show"]]]) :children [[rc/label :label "There are no subscriptions to show"]]])
(defn pod-section [] (defn pod-section []
(let [all-subs @(rf/subscribe [:subs/visible-subs])] (let [all-subs @(rf/subscribe [:subs/visible-subs])
sub-expansions @(rf/subscribe [:subs/sub-expansions])]
(js/console.log sub-expansions)
[rc/v-box [rc/v-box
:gap pod-gap :gap pod-gap
:children (if (empty? all-subs) :children (if (empty? all-subs)
[[no-pods]] [[no-pods]]
(doall (for [p all-subs] (doall (for [p all-subs]
^{:key (:id p)} ^{:key (:id p)}
[pod p])))])) [pod (merge p (get sub-expansions (:id p)))])))]))
(defn render [] (defn render []
[] []