Commit ad80b504db359d01d309783ac77fc14d7b775856
1 parent
f2305c51
Exists in
master
and in
8 other branches
Tasks: fix filtering by task type
Showing
3 changed files
with
7 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
... | ... | @@ -4,6 +4,7 @@ class TasksController < MyProfileController |
4 | 4 | |
5 | 5 | def index |
6 | 6 | @filter = params[:filter_type].blank? ? nil : params[:filter_type] |
7 | + @task_types = Task.pending_types_for(profile) | |
7 | 8 | @tasks = Task.to(profile).without_spam.pending.of(@filter).order_by('created_at', 'asc').paginate(:per_page => Task.per_page, :page => params[:page]) |
8 | 9 | @failed = params ? params[:failed] : {} |
9 | 10 | end | ... | ... |
app/models/task.rb
... | ... | @@ -250,6 +250,10 @@ class Task < ActiveRecord::Base |
250 | 250 | { :conditions => [environment_condition, profile_condition].compact.join(' OR ') } |
251 | 251 | } |
252 | 252 | |
253 | + def self.pending_types_for(profile) | |
254 | + Task.to(profile).pending.select('distinct type').map { |t| [t.class.name, t.title] } | |
255 | + end | |
256 | + | |
253 | 257 | def opened? |
254 | 258 | status == Task::Status::ACTIVE || status == Task::Status::HIDDEN |
255 | 259 | end | ... | ... |
app/views/tasks/index.html.erb
... | ... | @@ -4,11 +4,9 @@ |
4 | 4 | <p> |
5 | 5 | |
6 | 6 | <% |
7 | - type_collection = [[nil, _('All')]] | |
8 | - type_collection += @tasks.map { |t| [t.name, t.title] }.uniq | |
7 | + type_collection = [[nil, _('All')]] + @task_types | |
9 | 8 | %> |
10 | 9 | |
11 | - | |
12 | 10 | <% if !@failed.blank? %> |
13 | 11 | <div id="errorExplanation"> |
14 | 12 | <% @failed.each do |error, tasks_descriptions|%> |
... | ... | @@ -40,7 +38,7 @@ |
40 | 38 | |
41 | 39 | <ul class='task-list'> |
42 | 40 | <p> |
43 | - <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :onchange => 'document.location.href = "?filter_type="+this.value')%> | |
41 | + <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :onchange => "document.location.href = '?filter_type='+this.value") %> | |
44 | 42 | </p> |
45 | 43 | <p> |
46 | 44 | <%= labelled_select(_("Set all to: "), 'set-decisions', 'first', 'last', nil, [['',""],['accept',_("Accept")],['reject',_("Reject")],['skip',_("Skip")]], :id => "up-set-all-tasks-to") %> | ... | ... |