From 0a6daa95a62ed03301da0e718be4b7bc8f942b52 Mon Sep 17 00:00:00 2001 From: Ábner Silva de Oliveira Date: Fri, 17 Jul 2015 15:16:44 -0300 Subject: [PATCH] changed to keep the filter applyed to tasks after action close --- app/controllers/my_profile/tasks_controller.rb | 3 ++- app/helpers/task_helper.rb | 24 ++++++++++++++++++++++++ app/views/tasks/index.html.erb | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app/helpers/task_helper.rb diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 78dcee3..821bee2 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -58,7 +58,8 @@ class TasksController < MyProfileController end end - url = { :action => 'index' } + url = task_action(:index) + if failed.blank? session[:notice] = _("All decisions were applied successfully.") else diff --git a/app/helpers/task_helper.rb b/app/helpers/task_helper.rb new file mode 100644 index 0000000..140395d --- /dev/null +++ b/app/helpers/task_helper.rb @@ -0,0 +1,24 @@ +module TaskHelper + + def task_email_template(description, email_templates, task, include_blank=true) + return '' unless email_templates.present? + + content_tag( + :div, + labelled_form_field(description, select_tag("tasks[#{task.id}][task][email_template_id]", options_from_collection_for_select(email_templates, :id, :name), :include_blank => include_blank, 'data-url' => url_for(:controller => 'email_templates', :action => 'show_parsed', :profile => profile.identifier))), + :class => 'template-selection' + ) + end + + def task_action action + require 'debugger'; debugger + base_url = { action: action } + url_for(base_url.merge(filter_params)) + end + + def filter_params + filter_fields = ['filter_type', 'filter_text', 'filter_responsible', 'filter_tags'] + params.select {|filter| filter if filter_fields.include? filter } + end + +end diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index 6eb8533..81a75e5 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -45,7 +45,7 @@ <%= _('No pending tasks for %s') % profile.name %>

<% else %> - <%= form_tag :action => 'close' do%> + <%= form_tag task_action('close') do%> <% button_bar(:class => 'task-actions') do %> <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> -- libgit2 0.21.2