Skip to content

Instantly share code, notes, and snippets.


futuro/timepicker.cljs Secret

Created Feb 14, 2016
What would you like to do?
Cached function in componenetDidMount
(defn set-timekey [comp dbkey timeval]
(println "dbkey is " dbkey)
(om/transact! comp
{:value ~timeval
:attrkey ~dbkey})
(defn set-beginning [comp timeval]
(set-timekey comp :newevent/beginning timeval))
(defn set-ending [comp timeval]
(set-timekey comp :newevent/ending timeval))
(defui TimePicker
static om/IQuery
(query [this]
[:db/id :newevent/beginning :newevent/ending])
(componentDidMount [this]
(let [{:keys [dbkey id]} (om/props this)
elem (util/elem-by-id id)
options (clj->js {:timeFormat "military"})
time-selected (condp = dbkey
:newevent/beginning #(set-beginning this %)
:newevent/ending #(set-ending this %)
#(.log js/console "No dbkey specified."))
tpicker (new js/TimePicker. time-selected)]
(.log js/console "key:%o:picker:%o:" (str dbkey) tpicker)
(.bindInput tpicker elem options)))
(render [this]
(let [{:keys [id desc dbkey] :as props} (om/props this)
time (get props dbkey)]
#_(println props)
[:div {:class "time-picker" :position "relative"}
(create-time-input this time "text" id desc)]))))
(def timepicker (om/factory TimePicker {:keyfn :id}))
(defui CreateEvent
static om/IQuery
(query [this]
[{:newevent (om/get-query TimePicker)}])
(render [this]
(let [props (om/props this)
active-button (om/get-state this :active-button)]
[:div {:id "create-event"}
[:h2 "Create Event"]
(timepicker (merge {:id "ce-end" :desc "Choose an end time."
:dbkey :newevent/ending}
(get props :newevent)))
(timepicker (merge {:id "ce-beginning" :desc "Choose a start time."
:dbkey :newevent/beginning}
(get props :newevent)))]]])))
(componentDidMount [this]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.