Remove storage colors and select first collection with content on workspace

This commit is contained in:
Jesús Espino 2016-12-22 16:45:42 +01:00
parent 95604f84ab
commit c6d60b5fbf

View file

@ -27,7 +27,7 @@
[local collections] [local collections]
(if-let [selected (:selected @local)] (if-let [selected (:selected @local)]
(first (filter #(= selected (:id %)) collections)) (first (filter #(= selected (:id %)) collections))
(first collections))) (first (filter #(and (:id %) (> (count (:colors %)) 0)) collections))))
(mx/defc palette-items (mx/defc palette-items
{:mixins [mx/static]} {:mixins [mx/static]}
@ -54,8 +54,9 @@
(let [local (:rum/local own) (let [local (:rum/local own)
collections (->> (mx/react collections-ref) collections (->> (mx/react collections-ref)
(vals) (vals)
(filter :id)
(sort-by :name)) (sort-by :name))
collection (get-selected-collection local collections)] selected-collection (get-selected-collection local collections)]
(letfn [(select-collection [event] (letfn [(select-collection [event]
(let [value (read-string (dom/event->value event))] (let [value (read-string (dom/event->value event))]
(swap! local assoc :selected value :position 0))) (swap! local assoc :selected value :position 0)))
@ -66,8 +67,9 @@
[:select.input-select {:on-change select-collection} [:select.input-select {:on-change select-collection}
(for [collection collections] (for [collection collections]
[:option {:key (str (:id collection)) [:option {:key (str (:id collection))
:value (pr-str (:id collection))} :value (pr-str (:id collection))
(:name collection "Storage")])] :selected (when (= collection selected-collection) "selected")}
(:name collection)])]
#_[:div.color-palette-buttons #_[:div.color-palette-buttons
[:div.btn-palette.edit.current i/pencil] [:div.btn-palette.edit.current i/pencil]
[:div.btn-palette.create i/close]]] [:div.btn-palette.create i/close]]]
@ -76,9 +78,9 @@
{:on-click #(swap! local update :position dec)} {:on-click #(swap! local update :position dec)}
{:class :disabled}) {:class :disabled})
i/arrow-slide] i/arrow-slide]
(palette-items (:colors collection) (:position @local)) (palette-items (:colors selected-collection) (:position @local))
[:span.right-arrow [:span.right-arrow
(if (< (* (+ 1 (:position @local)) 10) (count (:colors collection))) (if (< (* (+ 1 (:position @local)) 10) (count (:colors selected-collection)))
{:on-click #(swap! local update :position inc)} {:on-click #(swap! local update :position inc)}
{:class :disabled}) {:class :disabled})
i/arrow-slide] i/arrow-slide]