Commit 0f9307fe2c214d197c057747b111976ccd27329a

Authored by Victor Costa
1 parent 8a4dc901

Move email template selection to task partials

app/helpers/task_helper.rb
1 1 module TaskHelper
2 2  
3   - def task_email_template(description, email_templates, task)
  3 + def task_email_template(description, email_templates, task, include_blank=true)
4 4 return '' unless email_templates.present?
5 5  
6 6 content_tag(
7 7 :div,
8   - labelled_form_field(description, select_tag("tasks[#{task.id}][task][email_template_id]", options_from_collection_for_select(email_templates, :id, :name), :include_blank => true, 'data-url' => url_for(:controller => 'email_templates', :action => 'show_parsed', :profile => profile.identifier))),
  8 + 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))),
9 9 :class => 'template-selection'
10 10 )
11 11 end
... ...
app/views/tasks/_approve_article_accept_details.html.erb
  1 +<%= task_email_template(_('Select a rejection email template:'), @rejection_email_templates, task) %>
  2 +
1 3 <%= render :file => 'shared/tiny_mce' %>
2 4  
3 5 <%= labelled_form_field(_('Create a link'), f.check_box(:create_link)) %>
... ...
app/views/tasks/_task.html.erb
... ... @@ -52,14 +52,12 @@
52 52 <%= fields_for "tasks[#{task.id}][task]", task do |f| %>
53 53 <% if task.accept_details %>
54 54 <div id="on-accept-information-<%=task.id%>" style="display: none">
55   - <%= task_email_template(_('Select an acceptance email template:'), @acceptance_email_templates, task) %>
56 55 <%= render :partial => partial_for_class(task.class, nil, :accept_details), :locals => {:task => task, :f => f} %>
57 56 </div>
58 57 <% end %>
59 58  
60 59 <% if task.reject_details %>
61 60 <div id="on-reject-information-<%=task.id%>" style="display: none">
62   - <%= task_email_template(_('Select a rejection email template:'), @rejection_email_templates, task) %>
63 61 <%= render :partial => partial_for_class(task.class, nil, :reject_details), :locals => {:task => task, :f => f} %>
64 62 </div>
65 63 <% end %>
... ...
app/views/tasks/_task_reject_details.html.erb
  1 +<%= task_email_template(_('Select a rejection email template:'), @rejection_email_templates, task) %>
  2 +
1 3 <%= labelled_form_field(_('Rejection explanation'), f.text_area(:reject_explanation, :rows => 5)) %>
... ...