event_calendar_engine 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/events_controller.rb +3 -1
- data/app/helpers/event_calendar/application_helper.rb +32 -2
- data/app/models/event.rb +2 -43
- data/app/models/event_instance_methods.rb +47 -0
- data/app/models/event_revision.rb +1 -0
- data/app/views/attendees/_add_attendees.html.erb +32 -0
- data/app/views/event_revisions/_event_revision.html.erb +6 -0
- data/app/views/event_revisions/_list_group.html.erb +30 -0
- data/app/views/event_revisions/index.html.erb +2 -31
- data/app/views/event_revisions/show.html.erb +4 -4
- data/app/views/events/_calendar.html.erb +20 -0
- data/app/views/events/_current_event.html.erb +6 -0
- data/app/views/events/_details.html.erb +11 -0
- data/app/views/events/_event.html.erb +5 -10
- data/app/views/events/_event_details.html.erb +11 -13
- data/app/views/events/_list.html.erb +13 -0
- data/app/views/events/_list_group.html.erb +24 -0
- data/app/views/events/_multi_day_list_event.html.erb +4 -0
- data/app/views/events/_one_day_list_event.html.erb +2 -0
- data/app/views/events/_times.html.erb +3 -0
- data/app/views/events/index.html.erb +10 -23
- data/app/views/events/show.html.erb +1 -38
- data/public/javascripts/event_calendar/event_calendar.js +1 -27
- data/public/javascripts/event_calendar/event_calendar_behaviors.js +39 -0
- data/spec/controllers/events_controller_spec.rb +13 -3
- metadata +15 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
@@ -46,7 +46,9 @@ class EventsController < EventCalendar::ApplicationController
|
|
46
46
|
if params[:start] && params[:end]
|
47
47
|
@events = Event.between(Time.at(params[:start].to_i), Time.at(params[:end].to_i))
|
48
48
|
else
|
49
|
-
@
|
49
|
+
@past_events = Event.past.order("start_on ASC")
|
50
|
+
@future_events = Event.future.order("start_on ASC")
|
51
|
+
@current_events = Event.current.order("start_on ASC")
|
50
52
|
end
|
51
53
|
|
52
54
|
respond_to do |format|
|
@@ -1,4 +1,12 @@
|
|
1
1
|
module EventCalendar::ApplicationHelper
|
2
|
+
def div_for_record(record, options={}, &block)
|
3
|
+
options.merge!({:class => "span-10 #{options[:class]}"})
|
4
|
+
div_for(record, options){ yield }
|
5
|
+
end
|
6
|
+
def tag_for_record(tag, record, *args, &block)
|
7
|
+
content_tag_for(tag, record, *args){ yield }
|
8
|
+
end
|
9
|
+
|
2
10
|
def link_wrapper(path, wrapper_options={}, link_options={})
|
3
11
|
tag = wrapper_options.delete(:tag) || :p
|
4
12
|
link_text = link_options.delete(:link_text) || path
|
@@ -21,6 +29,28 @@ module EventCalendar::ApplicationHelper
|
|
21
29
|
end
|
22
30
|
end
|
23
31
|
|
32
|
+
def time_with_zones(time=Time.now)
|
33
|
+
out = {}
|
34
|
+
format = "%H:%M"
|
35
|
+
ActiveSupport::TimeZone.us_zones.map(&:name).each do |us_zone|
|
36
|
+
next unless us_zone =~ /Pacific|Mountain|Central|Eastern/
|
37
|
+
key = time.in_time_zone(us_zone).strftime("%Z")
|
38
|
+
out[key] = time.in_time_zone(us_zone).strftime(format)
|
39
|
+
end
|
40
|
+
out
|
41
|
+
end
|
42
|
+
|
43
|
+
def times_with_zones(event)
|
44
|
+
begin
|
45
|
+
[
|
46
|
+
time_with_zones(event.start_time),
|
47
|
+
time_with_zones(event.end_time)
|
48
|
+
]
|
49
|
+
rescue NoMethodError => e
|
50
|
+
raise "#{e.message} - #{event.inspect}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
24
54
|
def link_to_events(wrapper_options={}, link_options={})
|
25
55
|
return unless has_authorization?(:read, Event.new)
|
26
56
|
link_wrapper(events_path, wrapper_options, link_options.reverse_merge!({
|
@@ -49,7 +79,7 @@ module EventCalendar::ApplicationHelper
|
|
49
79
|
def link_to_deleted_events(wrapper_options={})
|
50
80
|
return unless has_authorization?(:update, Event.new)
|
51
81
|
link_wrapper(event_revisions_path, wrapper_options, {
|
52
|
-
:link_text => "
|
82
|
+
:link_text => "Browse Deleted Events (#{EventRevision.deleted.count})"
|
53
83
|
})
|
54
84
|
end
|
55
85
|
|
@@ -73,7 +103,7 @@ module EventCalendar::ApplicationHelper
|
|
73
103
|
:highlight => false
|
74
104
|
}.merge!(wrapper_options), {
|
75
105
|
:link_text => "Delete <em>#{event.name}</em>".html_safe,
|
76
|
-
:confirm => "Are you sure you want to permanently delete the #{event.name} #{event.
|
106
|
+
:confirm => "Are you sure you want to permanently delete the #{event.name} #{event.event_type}?",
|
77
107
|
:method => "delete"
|
78
108
|
}.merge!(link_options))
|
79
109
|
end
|
data/app/models/event.rb
CHANGED
@@ -3,7 +3,7 @@ class Event < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
include ActionView::Helpers::TextHelper
|
5
5
|
|
6
|
-
|
6
|
+
include EventInstanceMethods
|
7
7
|
|
8
8
|
has_many :attendees
|
9
9
|
|
@@ -38,48 +38,7 @@ class Event < ActiveRecord::Base
|
|
38
38
|
end
|
39
39
|
|
40
40
|
protected
|
41
|
-
public
|
42
|
-
|
43
|
-
def start_time
|
44
|
-
@start_time ||= start_on
|
45
|
-
end
|
46
|
-
|
47
|
-
def end_time
|
48
|
-
@end_time ||= end_on
|
49
|
-
end
|
50
|
-
|
51
|
-
def start_date
|
52
|
-
@start_date ||= start_on.present? ? start_on.to_date : start_on
|
53
|
-
end
|
54
|
-
|
55
|
-
def end_date
|
56
|
-
@end_date ||= end_on.present? ? end_on.to_date : end_on
|
57
|
-
end
|
58
|
-
|
59
|
-
def start_year
|
60
|
-
start_on.year
|
61
|
-
end
|
62
|
-
|
63
|
-
def start_month
|
64
|
-
start_on.strftime("%B")
|
65
|
-
end
|
66
|
-
|
67
|
-
def start_day
|
68
|
-
start_on.day
|
69
|
-
end
|
70
|
-
|
71
|
-
def end_year
|
72
|
-
end_on.year
|
73
|
-
end
|
74
|
-
|
75
|
-
def end_month
|
76
|
-
end_on.strftime("%B")
|
77
|
-
end
|
78
|
-
|
79
|
-
def end_day
|
80
|
-
end_on.day
|
81
|
-
end
|
82
|
-
|
41
|
+
public
|
83
42
|
def participants
|
84
43
|
return [] if attendees.count == 0
|
85
44
|
attendees.all.collect do |attendee|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module EventInstanceMethods
|
2
|
+
attr_accessor :start_time, :end_time, :start_date, :end_date
|
3
|
+
|
4
|
+
def start_time
|
5
|
+
@start_time ||= start_on
|
6
|
+
end
|
7
|
+
|
8
|
+
def end_time
|
9
|
+
@end_time ||= end_on
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_date
|
13
|
+
@start_date ||= start_on.present? ? start_on.to_date : start_on
|
14
|
+
end
|
15
|
+
|
16
|
+
def end_date
|
17
|
+
@end_date ||= end_on.present? ? end_on.to_date : end_on
|
18
|
+
end
|
19
|
+
|
20
|
+
def start_year
|
21
|
+
start_on.year
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_month
|
25
|
+
start_on.strftime("%B")
|
26
|
+
end
|
27
|
+
|
28
|
+
def start_day
|
29
|
+
start_on.day
|
30
|
+
end
|
31
|
+
|
32
|
+
def end_year
|
33
|
+
end_on.year
|
34
|
+
end
|
35
|
+
|
36
|
+
def end_month
|
37
|
+
end_on.strftime("%B")
|
38
|
+
end
|
39
|
+
|
40
|
+
def end_day
|
41
|
+
end_on.day
|
42
|
+
end
|
43
|
+
|
44
|
+
def one_day?
|
45
|
+
start_day == end_day
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!--
|
2
|
+
<h3>Attendees/Participants</h3>
|
3
|
+
|
4
|
+
<%
|
5
|
+
#if @event.attendees.empty?
|
6
|
+
%>
|
7
|
+
<p><em>No attendees for this event.</em></p>
|
8
|
+
<%
|
9
|
+
#else
|
10
|
+
%>
|
11
|
+
|
12
|
+
form stub
|
13
|
+
|
14
|
+
<% @event.participants.group_by(&:class).map do |type, participants| %>
|
15
|
+
<h4><%= link_to(pluralize(participants.size, type.to_s), polymorphic_path(type)) %></h4>
|
16
|
+
<ol>
|
17
|
+
<% participants.each do |participant| %>
|
18
|
+
<% name_attr = participant.attribute_names.detect{|m_attr| m_attr =~ /name/} %>
|
19
|
+
<% if participant.respond_to?(:name) %>
|
20
|
+
<li><%= link_to(participant.send(name_attr), polymorphic_path(participant)) %></li>
|
21
|
+
<% elsif name_attr %>
|
22
|
+
<li><%= link_to(participant.name, polymorphic_path(participant)) %></li>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
</ol>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
form stub end
|
29
|
+
<%
|
30
|
+
#end
|
31
|
+
%>
|
32
|
+
-->
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= tag_for_record :tr, event_revision, :style => 'background-color: #f5c6d7' do %>
|
2
|
+
<td><%= link_to event_revision.name, event_revision_path(event_revision) %></td>
|
3
|
+
<td><%= truncate(event_revision.location, :length => 100) %></td>
|
4
|
+
<td><%= truncate(event_revision.description, :length => 100) %></td>
|
5
|
+
<td></td>
|
6
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<ul class="events">
|
2
|
+
<% events.group_by(&:start_year).each do |year, years_events| %>
|
3
|
+
<li><%= year %>
|
4
|
+
<ul>
|
5
|
+
<% years_events.group_by(&:start_month).each do |month, months_events| %>
|
6
|
+
<li><%= month %>
|
7
|
+
<ul>
|
8
|
+
<% months_events.each do |event| %>
|
9
|
+
<li>
|
10
|
+
<p>
|
11
|
+
<%= link_to event.name, event_revision_path(event) %>
|
12
|
+
<%= link_to 'restore', restore_event_revision_path(event),
|
13
|
+
:confirm => 'Are you sure you want to restore this deleted event?',
|
14
|
+
:method => "post",
|
15
|
+
:class => 'fake_button' %>
|
16
|
+
</p>
|
17
|
+
<%- if event.one_day? -%>
|
18
|
+
<%= render :partial => 'events/one_day_list_event', :object => event %>
|
19
|
+
<%- else -%>
|
20
|
+
<%= render :partial => 'events/multi_day_list_event', :object => event %>
|
21
|
+
<%- end -%>
|
22
|
+
</li>
|
23
|
+
<% end %>
|
24
|
+
</ul>
|
25
|
+
</li>
|
26
|
+
<% end %>
|
27
|
+
</ul>
|
28
|
+
</li>
|
29
|
+
<% end %>
|
30
|
+
</ul>
|
@@ -1,31 +1,2 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
<tr>
|
4
|
-
<th>Event</th>
|
5
|
-
<th>Location</th>
|
6
|
-
<th>Description</th>
|
7
|
-
<th style="border: 1px #CCF dashed; text-align:center">Manage</th>
|
8
|
-
</tr>
|
9
|
-
</thead>
|
10
|
-
<tbody>
|
11
|
-
<% for event in @deleted_events %>
|
12
|
-
<tr style="background-color: #f5c6d7;">
|
13
|
-
<td><%= link_to event.name, event_revision_path(event) %></td>
|
14
|
-
<td><%= truncate(event.location, :length => 100) %></td>
|
15
|
-
<td><%= truncate(event.description, :length => 100) %></td>
|
16
|
-
<td><%= link_to 'restore', restore_event_revision_path(event),
|
17
|
-
:confirm => 'Are you sure you want to restore this deleted event?',
|
18
|
-
:method => "post",
|
19
|
-
:class => 'fake_button' %></td>
|
20
|
-
</tr>
|
21
|
-
<% end %>
|
22
|
-
</tbody>
|
23
|
-
</table>
|
24
|
-
|
25
|
-
<script type="text/javascript">
|
26
|
-
$(document).ready(function()
|
27
|
-
{
|
28
|
-
$(".nice_table").tablesorter( { widgets: ['zebra'], headers: { 3:{sorter: false}, 4:{sorter: false}, 5:{sorter: false}} });
|
29
|
-
}
|
30
|
-
);
|
31
|
-
</script>
|
1
|
+
<h2>Deleted Events (<em><%= @deleted_events.count %></em>)</h2>
|
2
|
+
<%= render :partial => 'event_revisions/list_group', :locals => {:events => @deleted_events} %>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
1
|
<p>
|
3
2
|
<% if Event.where(:id => @event_revision.current_revision).count > 0 %>
|
4
3
|
<%= link_to "< Current Version", event_path(@event_revision.current_revision), :class => 'fake_button' %>
|
5
4
|
<% else %>
|
6
|
-
<%= link_to "< Browse
|
5
|
+
<%= link_to "< Browse Deleted", event_revisions_path, :class => 'fake_button' %>
|
7
6
|
<% end %>
|
8
7
|
</p>
|
9
8
|
|
10
|
-
<
|
11
|
-
|
9
|
+
<p style="float: right;" class="fake_button">Revision <%= @event_revision.revision_number %></p>
|
10
|
+
|
11
|
+
<%= render :partial => 'events/event', :object => @event_revision %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<p><em>mouse over an event to preview; click on an event for full details</em></p>
|
2
|
+
|
3
|
+
<div id="event_quick_description" class="span-12" style="display:none"></div>
|
4
|
+
|
5
|
+
<div style="clear:both"></div>
|
6
|
+
|
7
|
+
<div id="calendar" class="calendars"></div>
|
8
|
+
|
9
|
+
<% content_for :javascript do %>
|
10
|
+
<script type="text/javascript">
|
11
|
+
$(document).ready(function()
|
12
|
+
{
|
13
|
+
$('#calendar').fullCalendar({
|
14
|
+
editable: false, events: '<%= events_path %>', height: 500, aspectRatio: 1,
|
15
|
+
eventMouseover: updateEventDescription
|
16
|
+
});
|
17
|
+
}
|
18
|
+
);
|
19
|
+
</script>
|
20
|
+
<% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%- if current_event_counter == 0; then current_event_counter += 1; end -%>
|
2
|
+
<div class="span-2<%= current_event_counter % 8 == 0 ? ' last' : '' %>">
|
3
|
+
<p><strong><%= link_to current_event.name, event_path(current_event) %></strong></p>
|
4
|
+
<p><em><%= current_event.start_on.strftime("%a, %b %d") %></em></p>
|
5
|
+
<p><em><%= current_event.end_on.strftime("%a, %b %d") %></em></p>
|
6
|
+
</div>
|
@@ -1,2 +1,13 @@
|
|
1
|
+
<%- unless details.one_day? %>
|
1
2
|
<%= textilize(details.location) %>
|
2
3
|
<%= textilize(details.description) %>
|
4
|
+
<%- else -%>
|
5
|
+
<div class="span-6">
|
6
|
+
<%= textilize(details.location) %>
|
7
|
+
<%= textilize(details.description) %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="span-6 last">
|
11
|
+
<%= render :partial => 'events/times', :object => times_with_zones(details) %>
|
12
|
+
</div>
|
13
|
+
<%- end -%>
|
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<% end %>
|
7
|
-
<p>from <%=h event.start_on.strftime "%a, %b %d %Y (%I:%M%p)" %></p>
|
8
|
-
<p>until <%=h event.end_on.strftime "%a, %b %d %Y (%I:%M%p)" %></p>
|
9
|
-
<p><%=h event.description[0..60] %></p>
|
10
|
-
</div>
|
1
|
+
<%= div_for_record(event) do -%>
|
2
|
+
<h1><%= link_to event.name, event_path(event) %> (<em><%= event.event_type %></em>)</h1>
|
3
|
+
|
4
|
+
<%= render :partial => 'events/event_details', :object => event %>
|
5
|
+
<% end %>
|
@@ -1,19 +1,17 @@
|
|
1
|
-
<p>
|
2
|
-
<strong><%= event_details.name %></strong><br/>
|
3
|
-
<em><%= event_details.event_type %></em>
|
4
|
-
</p>
|
5
|
-
|
6
1
|
<p>
|
7
2
|
<strong>Starts</strong><br />
|
8
|
-
<%= event_details.start_on.in_time_zone(event_details.timezone).strftime('%A, %B %d %Y
|
3
|
+
<%= event_details.start_on.in_time_zone(event_details.timezone).strftime('%A, %B %d %Y') %>
|
9
4
|
</p>
|
10
|
-
|
11
|
-
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
<%- unless event_details.one_day? %>
|
6
|
+
<% if event_details.end_on %>
|
7
|
+
<p>
|
8
|
+
<strong>Ends</strong><br />
|
9
|
+
<%= event_details.end_on.in_time_zone(event_details.timezone).strftime('%A, %B %d %Y') %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
12
|
+
<%- else -%>
|
13
|
+
<%= render :partial => 'events/times', :object => times_with_zones(event_details) %>
|
14
|
+
<%- end -%>
|
17
15
|
<% unless event_details.location.blank? %>
|
18
16
|
<p>
|
19
17
|
<strong>Location</strong><br/>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="span-16 last">
|
2
|
+
<h2>Current Events (<em><%= @current_events.count %></em>)</h2>
|
3
|
+
<%= render :partial => 'events/current_event', :collection => @current_events %>
|
4
|
+
</div>
|
5
|
+
<div class="span-8 last">
|
6
|
+
<h2>Past Events (<em><%= @past_events.count %></em>)</h2>
|
7
|
+
<%= render :partial => 'events/list_group', :locals => {:events => @past_events} %>
|
8
|
+
</div>
|
9
|
+
<div class="span-8">
|
10
|
+
<h2>Future Events (<em><%= @future_events.count %></em>)</h2>
|
11
|
+
<%= render :partial => 'events/list_group', :locals => {:events => @future_events} %>
|
12
|
+
</div>
|
13
|
+
<div style="clear:both;"></div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<ul class="events">
|
2
|
+
<% events.group_by(&:start_year).each do |year, years_events| %>
|
3
|
+
<li><%= year %>
|
4
|
+
<ul>
|
5
|
+
<% years_events.group_by(&:start_month).each do |month, months_events| %>
|
6
|
+
<li><%= month %>
|
7
|
+
<ul>
|
8
|
+
<% months_events.each do |event| %>
|
9
|
+
<li>
|
10
|
+
<p><%= link_to event.name, event_path(event) %></p>
|
11
|
+
<%- if event.one_day? -%>
|
12
|
+
<%= render :partial => 'events/one_day_list_event', :object => event %>
|
13
|
+
<%- else -%>
|
14
|
+
<%= render :partial => 'events/multi_day_list_event', :object => event %>
|
15
|
+
<%- end -%>
|
16
|
+
</li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
</li>
|
20
|
+
<% end %>
|
21
|
+
</ul>
|
22
|
+
</li>
|
23
|
+
<% end %>
|
24
|
+
</ul>
|
@@ -1,23 +1,10 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
<div id="
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<% content_for :javascript do %>
|
12
|
-
<script type="text/javascript">
|
13
|
-
$(document).ready(function()
|
14
|
-
{
|
15
|
-
$('#calendar').fullCalendar({
|
16
|
-
editable: false, events: '<%= events_path %>', height: 500, aspectRatio: 1,
|
17
|
-
eventMouseover: updateEventDescription
|
18
|
-
});
|
19
|
-
}
|
20
|
-
);
|
21
|
-
|
22
|
-
</script>
|
23
|
-
<% end %>
|
1
|
+
<p style="float: right;">
|
2
|
+
<a href="#" class="fake_button view_events calendar">Calendar</a>
|
3
|
+
<a href="#" class="fake_button view_events list">List</a>
|
4
|
+
</p>
|
5
|
+
<div id="event_calendar">
|
6
|
+
<%= render :partial => 'calendar' %>
|
7
|
+
</div>
|
8
|
+
<div id="event_list" style="display: none;">
|
9
|
+
<%= render :partial => 'list' %>
|
10
|
+
</div>
|
@@ -1,38 +1 @@
|
|
1
|
-
|
2
|
-
<h1>Event</h1>
|
3
|
-
|
4
|
-
<%= render :partial => 'event_details', :object => @event %>
|
5
|
-
|
6
|
-
<!--
|
7
|
-
<h3>Attendees/Participants</h3>
|
8
|
-
|
9
|
-
<%
|
10
|
-
#if @event.attendees.empty?
|
11
|
-
%>
|
12
|
-
<p><em>No attendees for this event.</em></p>
|
13
|
-
<%
|
14
|
-
#else
|
15
|
-
%>
|
16
|
-
|
17
|
-
form stub
|
18
|
-
|
19
|
-
<% @event.participants.group_by(&:class).map do |type, participants| %>
|
20
|
-
<h4><%= link_to(pluralize(participants.size, type.to_s), polymorphic_path(type)) %></h4>
|
21
|
-
<ol>
|
22
|
-
<% participants.each do |participant| %>
|
23
|
-
<% name_attr = participant.attribute_names.detect{|m_attr| m_attr =~ /name/} %>
|
24
|
-
<% if participant.respond_to?(:name) %>
|
25
|
-
<li><%= link_to(participant.send(name_attr), polymorphic_path(participant)) %></li>
|
26
|
-
<% elsif name_attr %>
|
27
|
-
<li><%= link_to(participant.name, polymorphic_path(participant)) %></li>
|
28
|
-
<% end %>
|
29
|
-
<% end %>
|
30
|
-
</ol>
|
31
|
-
<% end %>
|
32
|
-
|
33
|
-
form stub end
|
34
|
-
<%
|
35
|
-
#end
|
36
|
-
%>
|
37
|
-
-->
|
38
|
-
</div>
|
1
|
+
<%= render @event %>
|
@@ -12,6 +12,7 @@ var updateEventDescription = function(event, jsEvent) {
|
|
12
12
|
|
13
13
|
jQuery(function($) {
|
14
14
|
$('a.show_hide_link').attach(ShowHideLink);
|
15
|
+
$('a.view_events').attach(EventView);
|
15
16
|
});
|
16
17
|
|
17
18
|
/*
|
@@ -30,30 +31,3 @@ $.fn.clearForm = function() {
|
|
30
31
|
this.selectedIndex = -1;
|
31
32
|
});
|
32
33
|
};
|
33
|
-
|
34
|
-
DynamicForm = $.klass({
|
35
|
-
initialize: function(options) {
|
36
|
-
this.formId = options.formId; // new_description
|
37
|
-
this.formContainer = options.formContainer; // blank_description_form
|
38
|
-
this.targetIdName = options.targetIdName; // file_attachment_id
|
39
|
-
this.targetContentName = options.targetContentName; // file_attachment[description]
|
40
|
-
this.targetContentType = options.targetContentType;
|
41
|
-
this.actionPrefix = options.actionPrefix; // /file_attachments
|
42
|
-
},
|
43
|
-
onclick: function(e) {
|
44
|
-
e.preventDefault();
|
45
|
-
|
46
|
-
var targetIdValue = this.element.attr(this.targetIdName);
|
47
|
-
var targetContentValue = this.element.attr(this.targetContentName);
|
48
|
-
|
49
|
-
$('#' + this.formId).attr("action", this.actionPrefix + "/" + targetIdValue);
|
50
|
-
|
51
|
-
$('#' + this.formId).clearForm();
|
52
|
-
|
53
|
-
$('#' + this.formContainer).insertBefore(this.element);
|
54
|
-
|
55
|
-
$(this.targetContentType + '[name='+ this.targetContentName +']').val(targetContentValue);
|
56
|
-
|
57
|
-
$('#' + this.formContainer).show();
|
58
|
-
}
|
59
|
-
});
|
@@ -129,3 +129,42 @@ ShowHideLink = $.klass({
|
|
129
129
|
return this.doNotStop;
|
130
130
|
}
|
131
131
|
});
|
132
|
+
|
133
|
+
DynamicForm = $.klass({
|
134
|
+
initialize: function(options) {
|
135
|
+
this.formId = options.formId; // new_description
|
136
|
+
this.formContainer = options.formContainer; // blank_description_form
|
137
|
+
this.targetIdName = options.targetIdName; // file_attachment_id
|
138
|
+
this.targetContentName = options.targetContentName; // file_attachment[description]
|
139
|
+
this.targetContentType = options.targetContentType;
|
140
|
+
this.actionPrefix = options.actionPrefix; // /file_attachments
|
141
|
+
},
|
142
|
+
onclick: function(e) {
|
143
|
+
e.preventDefault();
|
144
|
+
|
145
|
+
var targetIdValue = this.element.attr(this.targetIdName);
|
146
|
+
var targetContentValue = this.element.attr(this.targetContentName);
|
147
|
+
|
148
|
+
$('#' + this.formId).attr("action", this.actionPrefix + "/" + targetIdValue);
|
149
|
+
|
150
|
+
$('#' + this.formId).clearForm();
|
151
|
+
|
152
|
+
$('#' + this.formContainer).insertBefore(this.element);
|
153
|
+
|
154
|
+
$(this.targetContentType + '[name='+ this.targetContentName +']').val(targetContentValue);
|
155
|
+
|
156
|
+
$('#' + this.formContainer).show();
|
157
|
+
}
|
158
|
+
});
|
159
|
+
|
160
|
+
EventView = $.klass({
|
161
|
+
onclick: function(e) {
|
162
|
+
if( this.element.hasClass('calendar') ) {
|
163
|
+
$('#event_list').hide();
|
164
|
+
$('#event_calendar').show();
|
165
|
+
} else if( this.element.hasClass('list') ) {
|
166
|
+
$('#event_calendar').hide();
|
167
|
+
$('#event_list').show();
|
168
|
+
}
|
169
|
+
}
|
170
|
+
});
|
@@ -19,13 +19,23 @@ describe EventsController do
|
|
19
19
|
end
|
20
20
|
before(:each) do
|
21
21
|
subject.stub(:find).with("37"){ event }
|
22
|
+
subject.stub_chain(:past, :order){ ['past'] }
|
23
|
+
subject.stub_chain(:current, :order){ ['current'] }
|
24
|
+
subject.stub_chain(:future, :order){ ['future'] }
|
22
25
|
end
|
23
26
|
|
24
27
|
describe "GET index" do
|
25
|
-
it "assigns
|
26
|
-
subject.stub(:all){ [event] }
|
28
|
+
it "assigns past events as @past_events" do
|
27
29
|
get :index
|
28
|
-
assigns(:
|
30
|
+
assigns(:past_events).should eq ['past']
|
31
|
+
end
|
32
|
+
it "assigns current events as @current_events" do
|
33
|
+
get :index
|
34
|
+
assigns(:current_events).should eq ['current']
|
35
|
+
end
|
36
|
+
it "assigns future events as @future_events" do
|
37
|
+
get :index
|
38
|
+
assigns(:future_events).should eq ['future']
|
29
39
|
end
|
30
40
|
end
|
31
41
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_calendar_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason LaPier
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-01-
|
19
|
+
date: 2011-01-11 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -403,21 +403,32 @@ files:
|
|
403
403
|
- app/models/attendee.rb
|
404
404
|
- app/models/deletable_instance_methods.rb
|
405
405
|
- app/models/event.rb
|
406
|
+
- app/models/event_instance_methods.rb
|
406
407
|
- app/models/event_revision.rb
|
407
408
|
- app/models/participant.rb
|
408
409
|
- app/models/participator.rb
|
410
|
+
- app/views/attendees/_add_attendees.html.erb
|
409
411
|
- app/views/attendees/index.html.erb
|
410
412
|
- app/views/attendees/new.html.erb
|
411
413
|
- app/views/event-calendar-shared/_flash.html.erb
|
412
414
|
- app/views/event-calendar-shared/_main_menu.html.erb
|
413
415
|
- app/views/event-calendar-shared/_navigation.html.erb
|
416
|
+
- app/views/event_revisions/_event_revision.html.erb
|
417
|
+
- app/views/event_revisions/_list_group.html.erb
|
414
418
|
- app/views/event_revisions/index.html.erb
|
415
419
|
- app/views/event_revisions/show.html.erb
|
416
420
|
- app/views/events/_browse_event_revisions.html.erb
|
421
|
+
- app/views/events/_calendar.html.erb
|
422
|
+
- app/views/events/_current_event.html.erb
|
417
423
|
- app/views/events/_details.html.erb
|
418
424
|
- app/views/events/_event.html.erb
|
419
425
|
- app/views/events/_event_details.html.erb
|
420
426
|
- app/views/events/_form.html.erb
|
427
|
+
- app/views/events/_list.html.erb
|
428
|
+
- app/views/events/_list_group.html.erb
|
429
|
+
- app/views/events/_multi_day_list_event.html.erb
|
430
|
+
- app/views/events/_one_day_list_event.html.erb
|
431
|
+
- app/views/events/_times.html.erb
|
421
432
|
- app/views/events/attendees.html.erb
|
422
433
|
- app/views/events/edit.html.erb
|
423
434
|
- app/views/events/index.html.erb
|