File tree Expand file tree Collapse file tree 3 files changed +73
-2
lines changed Expand file tree Collapse file tree 3 files changed +73
-2
lines changed Original file line number Diff line number Diff line change 1
- (defproject org.clojars.intception /om-widgets " 0.3.25 "
1
+ (defproject org.clojars.intception /om-widgets " 0.3.26 "
2
2
:description " Widgets for OM/React"
3
3
:url " https://github.com/orgs/intception/"
4
4
:license {:name " Eclipse Public License"
Original file line number Diff line number Diff line change 6
6
[cljs.reader :as reader]
7
7
[cljs-time.core :as time]
8
8
[cljs-time.coerce :as timec])
9
- (:use [om-widgets.datepicker :only [weeks-component day-header days-short]]))
9
+ (:use [om-widgets.datepicker :only [weeks-component day-header days-short week-component ]]))
10
10
11
11
(defn calendar
12
12
" Calendar does not support date selection nor shows a specific date either"
41
41
(map #(om/build day-header %) days-short))]
42
42
(om/build weeks-component app
43
43
{:state {:path path :date date}})]]])))))
44
+
45
+
46
+
47
+ (defn week-calendar
48
+ " Calendar with only one week shown"
49
+ [app owner]
50
+ (reify
51
+ om/IInitState
52
+ (init-state [_]
53
+ {:date (time/now )})
54
+
55
+ om/IRenderState
56
+ (render-state [_ {:keys [date path id on-week-changed] :as state}]
57
+ (letfn [(change-date [d]
58
+ (om/set-state! owner :date d)
59
+ (when on-week-changed
60
+ (on-week-changed (timec/to-date
61
+ (time/date-time (time/year d)
62
+ (time/month d)
63
+ (time/day d))))))]
64
+ (html
65
+ [:div {:id id}
66
+ [:div {:class " box-header" }
67
+ [:a {:onClick #(change-date (time/minus date (time/weeks 1 )))}
68
+ [:span {:class " icn-big-left-arrow" }]]
69
+ [:h2
70
+ (str (utils/get-hr-month date) " " (time/year date))]
71
+ [:a {:onClick #(change-date (time/plus date (time/weeks 1 )))}
72
+ [:span {:class " icn-big-right-arrow" }]]]
73
+ [:div {:class " calendar-content" }
74
+ [:table
75
+ [:thead
76
+ (utils/make-childs [:tr ]
77
+ (map #(om/build day-header %) days-short))]
78
+ (om/build week-component app
79
+ {:state {:path path :date date}})]]])))))
Original file line number Diff line number Diff line change 127
127
(when onChange (onChange date-updated)))}
128
128
(day-renderer app owner {:day day})))))
129
129
130
+ (defn days-of-week
131
+ [date]
132
+ (let [start-day (time/minus date
133
+ (time/days (time/day-of-week date)))]
134
+ (map #(time/plus start-day
135
+ (time/days %))
136
+ (range 1 8 ))))
137
+
138
+ (defn current-week
139
+ " Returns a list of days for the current week"
140
+ [date]
141
+ (let [dow (days-of-week date)
142
+ start-day (first dow)]
143
+ (map (fn [d]
144
+ {:day (time/day d)
145
+ :month (time/month d)
146
+ :year (time/year d)
147
+ :belongs-to-month (cond
148
+ (< (time/month d) (time/month start-day)) :previous
149
+ (> (time/month d) (time/month start-day)) :next
150
+ :else :current )} )
151
+ dow)))
152
+
153
+ (defn week-component [app owner]
154
+ (reify
155
+ om/IDisplayName
156
+ (display-name [_] " DatepickerWeek" )
157
+ om/IRenderState
158
+ (render-state [this {:keys [date path onChange] :as state}]
159
+ (dom/tbody nil
160
+ (apply dom/tr nil
161
+ (map (fn [d]
162
+ (om/build day-component app {:state {:day d :path path :date date :onChange onChange}}))
163
+ (current-week date)))))))
164
+
130
165
(defn- weeks-component [app owner]
131
166
(reify
132
167
om/IDisplayName
You can’t perform that action at this time.
0 commit comments