in progreess date fixes.

This commit is contained in:
BC
2018-06-14 23:48:30 -07:00
parent 4780f65ee7
commit f9c0e55b01
2 changed files with 29 additions and 3 deletions

View File

@@ -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

View File

@@ -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)