@@ -1,42 +1,44 | |||
|
1 | 1 | module CalendarsHelper |
|
2 | def link_to_previous_month(year, month) | |
|
2 | def link_to_previous_month(year, month, options={}) | |
|
3 | 3 | target_year, target_month = if month == 1 |
|
4 | 4 | [year - 1, 12] |
|
5 | 5 | else |
|
6 | 6 | [year, month - 1] |
|
7 | 7 | end |
|
8 | 8 | |
|
9 | 9 | name = if target_month == 12 |
|
10 | 10 | "#{month_name(target_month)} #{target_year}" |
|
11 | 11 | else |
|
12 | 12 | "#{month_name(target_month)}" |
|
13 | 13 | end |
|
14 | 14 | |
|
15 | link_target = calendar_path(:year => target_year, :month => target_month) | |
|
15 | project_id = options[:project].present? ? options[:project].to_param : nil | |
|
16 | link_target = calendar_path(:year => target_year, :month => target_month, :project_id => project_id) | |
|
16 | 17 | |
|
17 | 18 | link_to_remote(('« ' + name), |
|
18 | 19 | {:update => "content", :url => link_target, :method => :put}, |
|
19 | 20 | {:href => link_target}) |
|
20 | 21 | end |
|
21 | 22 | |
|
22 | def link_to_next_month(year, month) | |
|
23 | def link_to_next_month(year, month, options={}) | |
|
23 | 24 | target_year, target_month = if month == 12 |
|
24 | 25 | [year + 1, 1] |
|
25 | 26 | else |
|
26 | 27 | [year, month + 1] |
|
27 | 28 | end |
|
28 | 29 | |
|
29 | 30 | name = if target_month == 1 |
|
30 | 31 | "#{month_name(target_month)} #{target_year}" |
|
31 | 32 | else |
|
32 | 33 | "#{month_name(target_month)}" |
|
33 | 34 | end |
|
34 | 35 | |
|
35 | link_target = calendar_path(:year => target_year, :month => target_month) | |
|
36 | project_id = options[:project].present? ? options[:project].to_param : nil | |
|
37 | link_target = calendar_path(:year => target_year, :month => target_month, :project_id => project_id) | |
|
36 | 38 | |
|
37 | 39 | link_to_remote((name + ' »'), |
|
38 | 40 | {:update => "content", :url => link_target, :method => :put}, |
|
39 | 41 | {:href => link_target}) |
|
40 | 42 | |
|
41 | 43 | end |
|
42 | 44 | end |
@@ -1,50 +1,50 | |||
|
1 | 1 | <h2><%= l(:label_calendar) %></h2> |
|
2 | 2 | |
|
3 | 3 | <% form_tag(calendar_path, :method => :put, :id => 'query_form') do %> |
|
4 | 4 | <%= hidden_field_tag('project_id', @project.to_param) if @project%> |
|
5 | 5 | <fieldset id="filters" class="collapsible"> |
|
6 | 6 | <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend> |
|
7 | 7 | <div> |
|
8 | 8 | <%= render :partial => 'queries/filters', :locals => {:query => @query} %> |
|
9 | 9 | </div> |
|
10 | 10 | </fieldset> |
|
11 | 11 | |
|
12 | 12 | <p style="float:right;"> |
|
13 | <%= link_to_previous_month(@year, @month) %> | <%= link_to_next_month(@year, @month) %> | |
|
13 | <%= link_to_previous_month(@year, @month, :project => @project) %> | <%= link_to_next_month(@year, @month, :project => @project) %> | |
|
14 | 14 | </p> |
|
15 | 15 | |
|
16 | 16 | <p class="buttons"> |
|
17 | 17 | <%= label_tag('month', l(:label_month)) %> |
|
18 | 18 | <%= select_month(@month, :prefix => "month", :discard_type => true) %> |
|
19 | 19 | <%= label_tag('year', l(:label_year)) %> |
|
20 | 20 | <%= select_year(@year, :prefix => "year", :discard_type => true) %> |
|
21 | 21 | |
|
22 | 22 | <%= link_to_remote l(:button_apply), |
|
23 | 23 | { :url => { :set_filter => (@query.new_record? ? 1 : nil) }, |
|
24 | 24 | :update => "content", |
|
25 | 25 | :with => "Form.serialize('query_form')" |
|
26 | 26 | }, :class => 'icon icon-checked' %> |
|
27 | 27 | |
|
28 | 28 | <%= link_to_remote l(:button_clear), |
|
29 | 29 | { :url => { :set_filter => (@query.new_record? ? 1 : nil) }, |
|
30 | 30 | :update => "content", |
|
31 | 31 | }, :class => 'icon icon-reload' if @query.new_record? %> |
|
32 | 32 | </p> |
|
33 | 33 | <% end %> |
|
34 | 34 | |
|
35 | 35 | <%= error_messages_for 'query' %> |
|
36 | 36 | <% if @query.valid? %> |
|
37 | 37 | <%= render :partial => 'common/calendar', :locals => {:calendar => @calendar} %> |
|
38 | 38 | |
|
39 | 39 | <p class="legend cal"> |
|
40 | 40 | <span class="starting"><%= l(:text_tip_task_begin_day) %></span> |
|
41 | 41 | <span class="ending"><%= l(:text_tip_task_end_day) %></span> |
|
42 | 42 | <span class="starting ending"><%= l(:text_tip_task_begin_end_day) %></span> |
|
43 | 43 | </p> |
|
44 | 44 | <% end %> |
|
45 | 45 | |
|
46 | 46 | <% content_for :sidebar do %> |
|
47 | 47 | <%= render :partial => 'issues/sidebar' %> |
|
48 | 48 | <% end %> |
|
49 | 49 | |
|
50 | 50 | <% html_title(l(:label_calendar)) -%> |
General Comments 0
You need to be logged in to leave comments.
Login now