simple_calendar 2.2.5 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -7
- data/lib/simple_calendar/calendar.rb +4 -0
- data/lib/simple_calendar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d48c34ef8c59455fb303e967c9974f5fe8f8cd8e
|
4
|
+
data.tar.gz: ddb4c3b79eed4ce5c40b699720e81e7008f1e4f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62df456ab1f6cd88d39c47ca837da47e5fdc8e25c5ec3c509fa31181bc60a4fd8eb361debadd006b97bf98a891af7bf2734383a4e032994fd7d24c6eae6d30d
|
7
|
+
data.tar.gz: 10dfbc74095af375642fcda64b032f153d3284257bd71531bb0c3c73a0b13da819fc2a857318e89cf4cb5afd195fa3ae0703cf147abb9e26caf9647d921eff3d
|
data/README.md
CHANGED
@@ -45,6 +45,8 @@ method.
|
|
45
45
|
<% end %>
|
46
46
|
```
|
47
47
|
|
48
|
+
To show the day of the month instead of the date, use `<%= date.day %>`
|
49
|
+
|
48
50
|
### Week Calendar
|
49
51
|
|
50
52
|
You can generate a week calendar with the `week_calendar` method.
|
@@ -110,17 +112,26 @@ $ rails g scaffold Meeting name start_time:datetime
|
|
110
112
|
$ rails g scaffold Meeting name start_time:datetime end_time:datetime
|
111
113
|
```
|
112
114
|
|
113
|
-
By default it uses `start_time` as the attribute name.
|
114
|
-
|
115
|
-
|
116
|
-
**If you'd like to use another attribute other than start_time or end_time, just
|
117
|
-
pass it in as the `attribute` or `end_attribute` options respectively**
|
115
|
+
By default it uses `start_time` as the attribute name.
|
116
|
+
**If you'd like to use another attribute other than start_time, just
|
117
|
+
pass it in as the `attribute`**
|
118
118
|
|
119
119
|
```erb
|
120
120
|
<%= month_calendar(attribute: :starts_at) do |date| %>
|
121
121
|
<%= date %>
|
122
122
|
<% end %>
|
123
123
|
```
|
124
|
+
|
125
|
+
Optionally the `end_time` attribute can be used which enables multi-day event rendering.
|
126
|
+
|
127
|
+
**Just pass in the `attribute` and `end_attribute` options respectively**
|
128
|
+
|
129
|
+
```erb
|
130
|
+
<%= month_calendar(attribute: :start_date, end_attribute: :end_date) do |date| %>
|
131
|
+
<%= date %>
|
132
|
+
<% end %>
|
133
|
+
```
|
134
|
+
|
124
135
|
**If you already have a model with a start time attribute called something other than `start_time` or accesses it through a relationship, you can alias the attribute by defining a `start_time` method in the my_model.rb file and not have to specify it separately as in the above example**
|
125
136
|
```ruby
|
126
137
|
class MyModel
|
@@ -319,7 +330,7 @@ The main method you'll need to implement is the `date_range` so that
|
|
319
330
|
your calendar can have a custom length.
|
320
331
|
|
321
332
|
```ruby
|
322
|
-
class SimpleCalendar::BusinessWeekCalendar
|
333
|
+
class SimpleCalendar::BusinessWeekCalendar < SimpleCalendar::Calendar
|
323
334
|
private
|
324
335
|
|
325
336
|
def date_range
|
@@ -333,7 +344,7 @@ end
|
|
333
344
|
To render this in the view, you can do:
|
334
345
|
|
335
346
|
```erb
|
336
|
-
<%= SimpleCalendar::BusinessWeekCalendar.new(self).render do |date| %>
|
347
|
+
<%= SimpleCalendar::BusinessWeekCalendar.new(self, {}).render do |date| %>
|
337
348
|
<%= date %>
|
338
349
|
<% end %>
|
339
350
|
```
|
@@ -10,9 +10,13 @@ module SimpleCalendar
|
|
10
10
|
@view_context = view_context
|
11
11
|
@options = opts
|
12
12
|
|
13
|
+
# Next and previous view links should use the same params as the current view
|
13
14
|
@params = @view_context.respond_to?(:params) ? @view_context.params : Hash.new
|
14
15
|
@params = @params.to_unsafe_h if @params.respond_to?(:to_unsafe_h)
|
15
16
|
@params = @params.with_indifferent_access.except(*PARAM_KEY_BLACKLIST)
|
17
|
+
|
18
|
+
# Add in any additonal params the user passed in
|
19
|
+
@params.merge!(@options.fetch(:params, {}))
|
16
20
|
end
|
17
21
|
|
18
22
|
def render(&block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|