From 53ab0dd10cb097456d7f149df20fc2cacbda2477 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 31 Jul 2016 15:57:17 -0400 Subject: [PATCH] add generic modal yes/no confirmation component --- src/mtgcoll/client/components/utils.cljs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mtgcoll/client/components/utils.cljs b/src/mtgcoll/client/components/utils.cljs index 7ccf4e5..48f7326 100644 --- a/src/mtgcoll/client/components/utils.cljs +++ b/src/mtgcoll/client/components/utils.cljs @@ -119,4 +119,24 @@ (let [value (string/trim (str @current-value))] (reset! editing? false) (if on-update (on-update (if (string/blank? value) nil value))))) - :on-change #(reset! current-value (get-field-value %))}])]))) \ No newline at end of file + :on-change #(reset! current-value (get-field-value %))}])]))) + +(defn confirm-modal + [visibility-atom {:keys [title body yes-label no-label on-yes on-no]}] + [bs/Modal + {:show (boolean @visibility-atom) + :on-hide #(reset! visibility-atom false)} + [bs/Modal.Header [bs/Modal.Title title]] + [bs/Modal.Body body] + [bs/Modal.Footer + [bs/Button + {:bsStyle "primary" + :on-click (fn [_] + (on-yes) + (reset! visibility-atom false))} + (or yes-label "Yes")] + [bs/Button + {:on-click (fn [_] + (if on-no (on-no)) + (reset! visibility-atom false))} + (or no-label "No")]]])