Patch #2106 ยป add_ability_choose_count_days_in_timelog_and_number_of_watched_issues.diff
app/controllers/my_controller.rb | ||
---|---|---|
33 | 33 |
'right' => ['issuesreportedbyme'] |
34 | 34 |
}.freeze |
35 | 35 | |
36 |
DEFAULT_TIMELOG_DAYS_COUNT = 7 |
|
37 |
DEFAULT_WATCHED_ISSUES_COUNT = 10 |
|
38 | ||
36 | 39 |
verify :xhr => true, |
37 | 40 |
:session => :page_layout, |
38 | 41 |
:only => [:add_block, :remove_block, :order_blocks] |
... | ... | |
46 | 49 |
def page |
47 | 50 |
@user = User.current |
48 | 51 |
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT |
52 |
@timelog_days_count = @user.pref[:timelog_days_count] || DEFAULT_TIMELOG_DAYS_COUNT |
|
53 |
@watched_issues_count = @user.pref[:watched_issues_count] || DEFAULT_WATCHED_ISSUES_COUNT |
|
49 | 54 |
end |
50 | 55 | |
51 | 56 |
# Edit user's account |
... | ... | |
104 | 109 |
def page_layout |
105 | 110 |
@user = User.current |
106 | 111 |
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup |
112 |
@timelog_days_count = @user.pref[:timelog_days_count] || DEFAULT_TIMELOG_DAYS_COUNT |
|
113 |
@watched_issues_count = @user.pref[:watched_issues_count] || DEFAULT_WATCHED_ISSUES_COUNT |
|
107 | 114 |
session[:page_layout] = @blocks |
108 | 115 |
%w(top left right).each {|f| session[:page_layout][f] ||= [] } |
109 | 116 |
@block_options = [] |
... | ... | |
148 | 155 |
end |
149 | 156 |
render :nothing => true |
150 | 157 |
end |
158 | ||
151 | 159 |
|
152 | 160 |
# Save user's page layout |
153 | 161 |
def page_layout_save |
... | ... | |
157 | 165 |
session[:page_layout] = nil |
158 | 166 |
redirect_to :action => 'page' |
159 | 167 |
end |
168 | ||
169 |
def change_timelog_days_count |
|
170 |
@user = User.current |
|
171 |
@user.pref[:timelog_days_count] = Integer( params[:timelog_days_count]) |
|
172 |
@user.pref.save |
|
173 |
@timelog_days_count = @user.pref[:timelog_days_count] || DEFAULT_TIMELOG_DAYS_COUNT |
|
174 |
render :partial => 'my/blocks/timelog' |
|
175 |
end |
|
176 | ||
177 |
def change_watched_issues_count |
|
178 |
@user = User.current |
|
179 |
@user.pref[:watched_issues_count] = Integer( params[:watched_issues_count]) |
|
180 |
@user.pref.save |
|
181 |
@watched_issues_count = @user.pref[:watched_issues_count] || DEFAULT_WATCHED_ISSUES_COUNT |
|
182 |
render :partial => 'my/blocks/issueswatched', :locals => { :user => @user } |
|
183 |
end |
|
184 | ||
160 | 185 |
end |
app/views/my/blocks/_issueswatched.rhtml | ||
---|---|---|
1 |
<h3><%=l(:label_watched_issues)%></h3> |
|
1 |
<div id="watched-issues"> |
|
2 |
|
|
3 |
<div class="contextual"> |
|
4 |
<% form_remote_tag :url => { :action => "change_watched_issues_count", :id => "watched-issues-customization-form" }, |
|
5 |
:update => 'watched-issues' do %> |
|
6 |
<%= text_field_tag 'watched_issues_count', @watched_issues_count, :size => 3 %> |
|
7 |
<%= submit_tag l(:button_save), :class => 'icon icon-save' %> |
|
8 |
<% end %> |
|
9 |
</div> |
|
10 |
|
|
11 |
<h3><%=l(:label_watched_issues)%> </h3> |
|
12 |
|
|
2 | 13 |
<% watched_issues = Issue.find(:all, |
3 | 14 |
:include => [:status, :project, :tracker, :watchers], |
4 |
:limit => 10,
|
|
15 |
:limit => @watched_issues_count,
|
|
5 | 16 |
:conditions => ["#{Watcher.table_name}.user_id = ? AND #{Project.table_name}.status=#{Project::STATUS_ACTIVE}", user.id], |
6 | 17 |
:order => "#{Issue.table_name}.updated_on DESC") %> |
7 | 18 |
<%= render :partial => 'issues/list_simple', :locals => { :issues => watched_issues } %> |
8 | 19 |
<% if watched_issues.length > 0 %> |
9 | 20 |
<p><%=lwr(:label_last_updates, watched_issues.length)%></p> |
10 | 21 |
<% end %> |
22 |
</div> |
app/views/my/blocks/_timelog.rhtml | ||
---|---|---|
1 |
<h3><%=l(:label_spent_time)%> (<%= l(:label_last_n_days, 7) %>)</h3> |
|
1 |
<div id="timelog"> |
|
2 | ||
3 |
<div class="contextual"> |
|
4 |
<% form_remote_tag :url => { :action => "change_timelog_days_count", :id => "timelog-customization-form" }, |
|
5 |
:update => 'timelog' do %> |
|
6 |
<%= text_field_tag 'timelog_days_count', @timelog_days_count, :size => 2 %> |
|
7 |
<%= submit_tag l(:button_save), :class => 'icon icon-save' %> |
|
8 |
<% end %> |
|
9 |
</div> |
|
10 | ||
11 |
<h3><%=l(:label_spent_time)%> (<%= l(:label_last_n_days, @timelog_days_count) %>) </h3> |
|
2 | 12 |
<% |
3 | 13 |
entries = TimeEntry.find(:all, |
4 |
:conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today], |
|
14 |
:conditions => |
|
15 |
["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - @timelog_days_count - 1, Date.today], |
|
5 | 16 |
:include => [:activity, :project, {:issue => [:tracker, :status]}], |
6 | 17 |
:order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC") |
7 | 18 |
entries_by_day = entries.group_by(&:spent_on) |
... | ... | |
49 | 60 |
<% end -%> |
50 | 61 |
</tbdoy> |
51 | 62 |
</table> |
63 |
</div> |
|
52 | 64 |
<% end %> |