fix new list form default values. visibility toggle only if using auth
This commit is contained in:
parent
7a1f775d31
commit
a7b9cd8d4f
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
(defn create-list-form
|
(defn create-list-form
|
||||||
[visibility-atom]
|
[visibility-atom]
|
||||||
(let [values (r/atom nil)
|
(let [values (r/atom {:public? true
|
||||||
|
:requires-qualities? true})
|
||||||
error (r/atom nil)
|
error (r/atom nil)
|
||||||
on-close (fn []
|
on-close (fn []
|
||||||
(reset! values nil)
|
(reset! values nil)
|
||||||
|
@ -56,18 +57,23 @@
|
||||||
[bs/Col {:class "text-right" :sm 4} [bs/ControlLabel "Card Qualities"]]
|
[bs/Col {:class "text-right" :sm 4} [bs/ControlLabel "Card Qualities"]]
|
||||||
[bs/Col {:sm 6}
|
[bs/Col {:sm 6}
|
||||||
[bs/Checkbox
|
[bs/Checkbox
|
||||||
{:on-change (fn [e]
|
(merge
|
||||||
(let [checked? (-> e .-target .-checked)]
|
(if (:requires-qualities? @values) {:checked true})
|
||||||
(swap! values assoc :requires-qualities?
|
{:on-change (fn [e]
|
||||||
(if checked? true false))))}]]]
|
(let [checked? (-> e .-target .-checked)]
|
||||||
[bs/FormGroup
|
(swap! values assoc :requires-qualities?
|
||||||
[bs/Col {:class "text-right" :sm 4} [bs/ControlLabel "Public"]]
|
(if checked? true false))))})]]]
|
||||||
[bs/Col {:sm 6}
|
(if (auth/auth-required?)
|
||||||
[bs/Checkbox
|
[bs/FormGroup
|
||||||
{:on-change (fn [e]
|
[bs/Col {:class "text-right" :sm 4} [bs/ControlLabel "Public"]]
|
||||||
(let [checked? (-> e .-target .-checked)]
|
[bs/Col {:sm 6}
|
||||||
(swap! values assoc :public?
|
[bs/Checkbox
|
||||||
(if checked? true false))))}]]]]]
|
(merge
|
||||||
|
(if (:public? @values) {:checked true})
|
||||||
|
{:on-change (fn [e]
|
||||||
|
(let [checked? (-> e .-target .-checked)]
|
||||||
|
(swap! values assoc :public?
|
||||||
|
(if checked? true false))))})]]])]]
|
||||||
[bs/Modal.Footer
|
[bs/Modal.Footer
|
||||||
[bs/Button {:bsStyle "primary" :on-click on-submit} "OK"]
|
[bs/Button {:bsStyle "primary" :on-click on-submit} "OK"]
|
||||||
[bs/Button {:on-click on-close} "Cancel"]]])))
|
[bs/Button {:on-click on-close} "Cancel"]]])))
|
||||||
|
@ -182,7 +188,8 @@
|
||||||
(if (:require_qualities @list) [:span.large-font [bs/Label {:bsStyle "primary"} "Card Qualities"] " "])
|
(if (:require_qualities @list) [:span.large-font [bs/Label {:bsStyle "primary"} "Card Qualities"] " "])
|
||||||
[bs/DropdownButton {:title "Actions"}
|
[bs/DropdownButton {:title "Actions"}
|
||||||
[bs/MenuItem {:on-click #(js/alert "TODO: Copy to Owned")} "Copy to Owned"]
|
[bs/MenuItem {:on-click #(js/alert "TODO: Copy to Owned")} "Copy to Owned"]
|
||||||
[bs/MenuItem {:on-click #(change-list-visibility! list-id (not (:is_public @list)))} (if (:is_public @list) "Make Private" "Make Public")]
|
(if (auth/auth-required?)
|
||||||
|
[bs/MenuItem {:on-click #(change-list-visibility! list-id (not (:is_public @list)))} (if (:is_public @list) "Make Private" "Make Public")])
|
||||||
[bs/MenuItem {:on-click #(reset! show-delete-confirm? true)} "Delete"]]])
|
[bs/MenuItem {:on-click #(reset! show-delete-confirm? true)} "Delete"]]])
|
||||||
[bs/PageHeader (:name @list)]
|
[bs/PageHeader (:name @list)]
|
||||||
[confirm-modal
|
[confirm-modal
|
||||||
|
|
Loading…
Reference in a new issue