Change dropdown component: remove doall, use into instead of conj

This commit is contained in:
Vitaliy Vlasov 2018-01-31 17:48:26 +02:00
parent a52f5f2b20
commit 9e9d0f6d4d
1 changed files with 5 additions and 5 deletions

View File

@ -15,21 +15,21 @@
"If val-ratom is set, preselect it in the dropdown. "If val-ratom is set, preselect it in the dropdown.
Add value of val-ratom if it's missing from items list. Add value of val-ratom if it's missing from items list.
Otherwise, prepend title as a disabled option" Otherwise, prepend title as a disabled option"
(let [items (cond-> items (let [items (cond->> items
(and @val-ratom (and @val-ratom
(not (contains? (set items) @val-ratom))) (not (contains? (set items) @val-ratom)))
(conj @val-ratom) (into [@val-ratom])
(not @val-ratom) (not @val-ratom)
(conj title))] (into [title]))]
(fn [] (fn []
[:select.ui.basic.selection.dropdown [:select.ui.basic.selection.dropdown
(merge props {:on-change (merge props {:on-change
#(reset! val-ratom (-> % .-target .-value)) #(reset! val-ratom (-> % .-target .-value))
:default-value (or @val-ratom title)}) :default-value (or @val-ratom title)})
(doall (for [item items] (for [item items]
^{:key item} [:option {:value item ^{:key item} [:option {:value item
:disabled (= item title)} :disabled (= item title)}
item]))]))) item])])))
(defn moment-timestamp [time] (defn moment-timestamp [time]
(let [now (.now js/Date.) (let [now (.now js/Date.)