From f9c0e55b01f05fa156aa64a505c6eed2e7ca6d8a Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 14 Jun 2018 23:48:30 -0700 Subject: [PATCH] in progreess date fixes. --- .../auto_ap/views/pages/unpaid_invoices.cljs | 20 ++++++++++++++++--- src/cljs/auto_ap/views/utils.cljs | 12 +++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index 89c80413..313da504 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -395,14 +395,28 @@ :max outstanding-balance :step "0.01"}]]]]]])]]]))) +#_(defn date-picker [] + (let [cal (r/atom nil)] + (r/create-class + {:component-did-mount (fn [this] + + (reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "mm/dd/yyyy"} ))) + nil) + + :component-will-unmount (fn [this] + (.hide @cal) + nil) + :reagent-render (fn [props] + [:input ])}))) (defn my-date [props] (let [cal (r/atom nil)] (r/create-class {:component-did-mount (fn [this] - (reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "mm/dd/yyyy"} ))) + (reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "yyyy-mm-dd"} ))) + nil) :reagent-render (fn [props] - [:input.input (merge props {:on-blur (fn [] (js/setTimeout 100 #(.hide @cal)) )}) ])}))) + [:input.input (merge props {:on-blur (fn [] (js/setTimeout 100 #(.hide @cal)) )}) ])}))) @@ -432,7 +446,7 @@ [bind-field - [my-date {:type "text" + [my-date {:type "date" :field [:date] :event change-event :spec ::invoice/date diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 42d16e0b..36510da1 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -83,6 +83,18 @@ keys (dissoc keys :field :subscription :event :spec)] (into [dom keys] (with-keys rest)))) +(defmethod do-bind "date" [dom {:keys [field event subscription class spec] :as keys} & rest] + (let [field (if (keyword? field) [field] field) + event (if (keyword? event) [event] event) + keys (assoc keys + :on-change (dispatch-value-change (conj event field)) + :value (doto (get-in subscription field) println) + :class (str class + (when (and spec (not (s/valid? spec (get-in subscription field)))) + " is-danger"))) + keys (dissoc keys :field :subscription :event :spec)] + (into [dom keys] (with-keys rest)))) + (defmethod do-bind :default [dom {:keys [field event subscription class spec] :as keys} & rest] (let [field (if (keyword? field) [field] field) event (if (keyword? event) [event] event)