simple_calendar 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +11 -1
- data/app/views/simple_calendar/_calendar.html.erb +2 -2
- data/app/views/simple_calendar/_month_calendar.html.erb +2 -2
- data/app/views/simple_calendar/_week_calendar.html.erb +2 -2
- data/lib/simple_calendar/calendar.rb +5 -1
- data/lib/simple_calendar/version.rb +1 -1
- data/spec/calendar_spec.rb +7 -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: 69891494cb62017e3108ade832d816c2fef2b021
|
4
|
+
data.tar.gz: f19a0f244c702b7aa4a0598793fa65a224905d71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c97daf53d52237fa6495af26fc1a6b630bd8879cc14d4dbd7cb0e72f8f9f388244a033e5c9348277cd2da095f160ae51516ba78b0c9856595d37304774b76a
|
7
|
+
data.tar.gz: f39d52be3eae79ea61b22cb814f53768a59a83c43ca1b6acfb3041ed16783a23d262b6ddcac1b4db90aaedd6aba7ca9cbc913f6e0690e390a6fa42f5aa5394db
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -92,6 +92,16 @@ pass it in as the `attribute` option**
|
|
92
92
|
<%= day %>
|
93
93
|
<% end %>
|
94
94
|
```
|
95
|
+
**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**
|
96
|
+
```ruby
|
97
|
+
class MyModel
|
98
|
+
## Other code related to your model lives here
|
99
|
+
|
100
|
+
def start_time
|
101
|
+
self.my_related_model.start ##Where 'start' is a attribute of type 'Date' accessible through MyModel's relationship
|
102
|
+
end
|
103
|
+
end
|
104
|
+
```
|
95
105
|
|
96
106
|
In your controller, query for these meetings and store them in an instance
|
97
107
|
variable. Normally you'll want to search for the ones that only show up
|
@@ -298,7 +308,7 @@ To render this in the view, you can do:
|
|
298
308
|
|
299
309
|
```erb
|
300
310
|
<%= SimpleCalendar::BusinessWeekCalendar.new(self).render do |date| %>
|
301
|
-
<%=
|
311
|
+
<%= date %>
|
302
312
|
<% end %>
|
303
313
|
```
|
304
314
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="simple-calendar">
|
2
|
-
<%= link_to "Previous", start_date: date_range.first - 1.day
|
2
|
+
<%= link_to "Previous", url_for(params.merge(start_date: date_range.first - 1.day)) %>
|
3
3
|
<%= I18n.t("date.month_names")[start_date.month] %> <%= start_date.year %>
|
4
|
-
<%= link_to "Next", start_date: date_range.last + 1.day
|
4
|
+
<%= link_to "Next", url_for(params.merge(start_date: date_range.last + 1.day)) %>
|
5
5
|
|
6
6
|
<table class="table table-striped">
|
7
7
|
<thead>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="simple-calendar">
|
2
|
-
<%= link_to "Previous", start_date: date_range.first - 1.day
|
2
|
+
<%= link_to "Previous", url_for(params.merge(start_date: date_range.first - 1.day)) %>
|
3
3
|
<%= I18n.t("date.month_names")[start_date.month] %> <%= start_date.year %>
|
4
|
-
<%= link_to "Next", start_date: date_range.last + 1.day %>
|
4
|
+
<%= link_to "Next", url_for(params.merge(start_date: date_range.last + 1.day)) %>
|
5
5
|
|
6
6
|
<table class="table table-striped">
|
7
7
|
<thead>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="simple-calendar">
|
2
|
-
<%= link_to "Previous", start_date: date_range.first - 1.day
|
2
|
+
<%= link_to "Previous", url_for(params.merge(start_date: date_range.first - 1.day)) %>
|
3
3
|
Week <%= start_date.strftime("%U").to_i %>
|
4
|
-
<%= link_to "Next", start_date: date_range.last + 1.day
|
4
|
+
<%= link_to "Next", url_for(params.merge(start_date: date_range.last + 1.day)) %>
|
5
5
|
|
6
6
|
<table class="table table-striped">
|
7
7
|
<thead>
|
@@ -66,7 +66,11 @@ module SimpleCalendar
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def start_date
|
69
|
-
|
69
|
+
if options.has_key?(:start_date)
|
70
|
+
options.fetch(:start_date).to_date
|
71
|
+
else
|
72
|
+
view_context.params.fetch(:start_date, Date.today).to_date
|
73
|
+
end
|
70
74
|
end
|
71
75
|
|
72
76
|
def date_range
|
data/spec/calendar_spec.rb
CHANGED
@@ -45,11 +45,17 @@ describe SimpleCalendar::Calendar do
|
|
45
45
|
expect(calendar.send(:start_date)).to eq(Date.today)
|
46
46
|
end
|
47
47
|
|
48
|
-
it "uses the params start_date to override" do
|
48
|
+
it "uses the view context's params start_date to override" do
|
49
49
|
view_context = ViewContext.new(Date.yesterday)
|
50
50
|
calendar = SimpleCalendar::Calendar.new(view_context)
|
51
51
|
expect(calendar.send(:start_date)).to eq(Date.yesterday)
|
52
52
|
end
|
53
|
+
|
54
|
+
it "uses the optional argument's start_date to override view_context's start_date" do
|
55
|
+
view_context = ViewContext.new(Date.yesterday)
|
56
|
+
calendar = SimpleCalendar::Calendar.new(view_context, start_date: Date.tomorrow)
|
57
|
+
expect(calendar.send(:start_date)).to eq(Date.tomorrow)
|
58
|
+
end
|
53
59
|
end
|
54
60
|
|
55
61
|
it 'has a param that determines the start date of the calendar'
|
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.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|