mongoid_occurrence_views 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3ffeb3d7b442d27f68887e73ec5d02b84d9e35b391d2d498a65c4982b636112
|
4
|
+
data.tar.gz: da20afd3da6af7d2f027bb16868ef74151c31f1403dcd6847337c15a8f914d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c07710cb02f5e2ac2c12b0bcc35acd64b01b830d44c1cf326c69fd2fb88e3e3b1b47483f8c6ad9b60ac2289079952976b4d4b79b061c8e2b9d2d1e1c462854
|
7
|
+
data.tar.gz: 563f4d924c63357793699d99539be0b724acb90d74e6364c262491726bd9c7b0c70c40d7d711653135dfc48a168e86d9a1a043ddca121ef3750df9406c7cbd32
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
* [PR#3](https://github.com/tomasc/mongoid_occurrence_views/pull/3) `all_day` becomes a field
|
6
|
+
|
3
7
|
## 0.1.1
|
4
8
|
|
5
9
|
* [PR#2](https://github.com/tomasc/mongoid_occurrence_views/pull/2) allow :assign_daily_occurrences to be triggerred manually
|
@@ -18,6 +18,13 @@ module MongoidOccurrenceViews
|
|
18
18
|
DateTime.demongoize(self[:_dtend])
|
19
19
|
end
|
20
20
|
|
21
|
+
def all_day
|
22
|
+
return unless dtstart.present? && dtend.present?
|
23
|
+
dtstart.to_i == dtstart.beginning_of_day.to_i &&
|
24
|
+
dtend.to_i == dtend.end_of_day.to_i
|
25
|
+
end
|
26
|
+
alias all_day? all_day
|
27
|
+
|
21
28
|
module ClassMethods
|
22
29
|
def occurrences_ordering_view_name
|
23
30
|
[collection.name, ORDERING_VIEW_NAME_SUFFIX].join('__').freeze
|
@@ -12,6 +12,7 @@ module MongoidOccurrenceViews
|
|
12
12
|
def embedded_in_event(options = {})
|
13
13
|
field :dtstart, type: DateTime
|
14
14
|
field :dtend, type: DateTime
|
15
|
+
field :all_day, type: Boolean
|
15
16
|
|
16
17
|
field :schedule, type: MongoidIceCubeExtension::Schedule
|
17
18
|
field :schedule_dtend, type: Time
|
@@ -38,17 +39,14 @@ module MongoidOccurrenceViews
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def all_day
|
41
|
-
return unless dtstart.present?
|
42
|
-
return unless
|
42
|
+
return super unless dtstart.present? && dtend.present?
|
43
|
+
return super unless super.nil?
|
43
44
|
|
44
|
-
|
45
|
+
dtstart.to_i == dtstart.beginning_of_day.to_i &&
|
46
|
+
dtend.to_i == dtend.end_of_day.to_i
|
45
47
|
end
|
46
48
|
alias all_day? all_day
|
47
49
|
|
48
|
-
def all_day=(val)
|
49
|
-
@all_day = [true, 'true', 1, '1'].include?(val)
|
50
|
-
end
|
51
|
-
|
52
50
|
def recurring?
|
53
51
|
schedule.present?
|
54
52
|
end
|
@@ -66,8 +64,8 @@ module MongoidOccurrenceViews
|
|
66
64
|
def adjust_dates_for_all_day
|
67
65
|
return unless all_day?
|
68
66
|
|
69
|
-
|
70
|
-
|
67
|
+
write_attribute(:dtstart, dtstart.try(:beginning_of_day))
|
68
|
+
write_attribute(:dtend, dtend.try(:end_of_day))
|
71
69
|
end
|
72
70
|
|
73
71
|
def assign_daily_occurrences
|
@@ -87,6 +85,7 @@ module MongoidOccurrenceViews
|
|
87
85
|
|
88
86
|
def daily_occurrences_from_date_range
|
89
87
|
return [] if recurring?
|
88
|
+
|
90
89
|
date_range = Range.new(dtstart.to_date, dtend.to_date)
|
91
90
|
is_single_day = (date_range.first == date_range.last)
|
92
91
|
|
@@ -109,10 +108,10 @@ module MongoidOccurrenceViews
|
|
109
108
|
field :de, as: :dtend, type: DateTime
|
110
109
|
|
111
110
|
def all_day
|
112
|
-
return unless dtstart.present?
|
113
|
-
return unless dtend.present?
|
111
|
+
return unless dtstart.present? && dtend.present?
|
114
112
|
|
115
|
-
dtstart == dtstart.beginning_of_day &&
|
113
|
+
dtstart.to_i == dtstart.beginning_of_day.to_i &&
|
114
|
+
dtend.to_i == dtend.end_of_day.to_i
|
116
115
|
end
|
117
116
|
alias all_day? all_day
|
118
117
|
end
|