Refactor: extract link to previous and next month into helpers.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4042 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
56e984b5e7
commit
3eea03d70e
|
@ -0,0 +1,14 @@
|
||||||
|
module CalendarsHelper
|
||||||
|
def link_to_previous_month(year, month)
|
||||||
|
link_to_remote ('« ' + (month==1 ? "#{month_name(12)} #{year-1}" : "#{month_name(month-1)}")),
|
||||||
|
{:update => "content", :url => { :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1) }},
|
||||||
|
{:href => url_for(:action => 'show', :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1))}
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_to_next_month(year, month)
|
||||||
|
link_to_remote ((month==12 ? "#{month_name(1)} #{year+1}" : "#{month_name(month+1)}") + ' »'),
|
||||||
|
{:update => "content", :url => { :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1) }},
|
||||||
|
{:href => url_for(:action => 'show', :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1))}
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,14 +10,7 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<p style="float:right;">
|
<p style="float:right;">
|
||||||
<%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")),
|
<%= link_to_previous_month(@year, @month) %> | <%= link_to_next_month(@year, @month) %>
|
||||||
{:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) }},
|
|
||||||
{:href => url_for(:action => 'show', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1))}
|
|
||||||
%> |
|
|
||||||
<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'),
|
|
||||||
{:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) }},
|
|
||||||
{:href => url_for(:action => 'show', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1))}
|
|
||||||
%>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="buttons">
|
<p class="buttons">
|
||||||
|
|
Loading…
Reference in New Issue