diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 9e3c268..82937f5 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -65,4 +65,11 @@ class TasksController < MyProfileController @ticket = Ticket.find(:first, :conditions => ['(requestor_id = ? or target_id = ?) and id = ?', profile.id, profile.id, params[:id]]) end + def search_tasks + @filter = params[:filter_type].blank? ? nil : params[:filter_type] + result = Task.to(profile).without_spam.pending.of(@filter).like('data',params[:term]) + + render :json => result.map { |task| {:label => task.data[:name], :value => task.data[:name]} } + end + end diff --git a/app/models/task.rb b/app/models/task.rb index 0620e84..12bd631 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -239,6 +239,8 @@ class Task < ActiveRecord::Base scope :opened, :conditions => { :status => [Task::Status::ACTIVE, Task::Status::HIDDEN] } scope :of, lambda { |type| conditions = type ? "type LIKE '#{type}'" : "1=1"; {:conditions => [conditions]} } scope :order_by, lambda { |attribute, ord| {:order => "#{attribute} #{ord}"} } + #scope :like, lambda { |field, value| {:conditions => ["LOWER(#{field}) LIKE ?", "%#{value}%"]}} + scope :like, ->(field,value) { where("LOWER(#{field}) LIKE ?", "%#{value.downcase}%")} scope :to, lambda { |profile| environment_condition = nil diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index d5da684..a654728 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -38,11 +38,24 @@
- <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :onchange => "document.location.href = '?filter_type='+this.value") %> + <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, {:onchange => "document.location.href = '?filter_type='+this.value", :id => 'filter-type'}) %> +
++ <%= labelled_text_field(_("Text filter")+': ', :text_filter, nil, {:id => 'text-filter-autocomplete'}) %> +
<%= labelled_select(_("Set all to: "), 'set-decisions', 'first', 'last', nil, [['',""],['accept',_("Accept")],['reject',_("Reject")],['skip',_("Skip")]], :id => "up-set-all-tasks-to") %>
+ <% @tasks.each do |task| %> <%= render :partial => 'task', :locals => { :task => task } %> <% end %> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index ee90807..f9bab65 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -6746,6 +6746,10 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { /* AutoComplete*/ .formfield input.ui-autocomplete-loading { background: url('/images/loading-small.gif') right center no-repeat, url("../images/input-bg.gif") no-repeat left top; } +.ui-autocomplete-loading{ + background: url('/images/loading-small.gif') right center no-repeat +} + .ui-autocomplete-category { font-weight: bold; -- libgit2 0.21.2