replace small partials with helper to improve performance

This commit is contained in:
Reinier Balt 2011-01-10 17:20:40 +01:00
parent 8cbe077784
commit 05ba6060fc
5 changed files with 25 additions and 27 deletions

View file

@ -50,17 +50,24 @@ module TodosHelper
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => t('todos.defer_x_days', :count => days), :align => "absmiddle")+" "+t('todos.defer_x_days', :count => days)
end
# waiting stuff can be deleted after migration of defer
def todo_start_waiting_js(todo)
return "$('#ul#{dom_id(todo)}').css('visibility', 'hidden'); $('##{dom_id(todo)}').block({message: null})"
end
# waiting stuff can be deleted after migration of defer and dependencies
def successor_start_waiting_js(successor)
return "$('##{dom_id(successor, "successor")}').block({message: null})"
end
def todo_stop_waiting_js(todo)
return "$('##{dom_id(todo)}').unblock();enable_rich_interaction();"
def collapsed_notes_image(todo)
link = link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_notes', :title => 'Show notes'})
notes = content_tag(:div, {:class => "todo_notes", :id => dom_id(todo, 'notes'), :style => "display:none"}) { format_note(todo.notes) }
return link+notes
end
def collapsed_successors_image(todo)
link = link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_successors', :title => 'Show successors'})
successors = content_tag(:div, {:class => "todo_successors", :id => dom_id(todo, 'successors'), :style => "display:none"}) do
render :partial => "todos/successor", :collection => todo.pending_successors,
:locals => { :parent_container_type => parent_container_type, :suppress_dependencies => true, :predecessor => todo }
end
return link+successors
end
def image_tag_for_recurring_todo(todo)

View file

@ -32,8 +32,8 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<%= tag_list %>
<%= deferred_due_date %>
<%= project_and_context_links( parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %>
<%= render(:partial => "todos/toggle_notes", :object => todo) if todo.notes? %>
<%= render(:partial => "todos/toggle_successors", :object => todo) unless todo.pending_successors.empty? %>
<%= collapsed_notes_image(todo) if todo.notes? %>
<%= collapsed_successors_image(todo) unless todo.pending_successors.empty? %>
</div>
</div>
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none">

View file

@ -1,6 +0,0 @@
<% item = toggle_notes -%>
<%= link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_notes', :title => 'Show notes'}) %>
<div class="todo_notes" id="<%= dom_id(item, 'notes') %>" style="display:none">
<%= format_note(item.notes) %>
</div>

View file

@ -1,12 +0,0 @@
<% item = toggle_successors %>
<%= link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_successors', :title => 'Show successors'}) %>
<div class="todo_successors" id="<%= dom_id(item, 'successors') %>">
<%= render :partial => "todos/successor",
:collection => item.pending_successors,
:locals => { :parent_container_type => parent_container_type,
:suppress_dependencies => true,
:predecessor => item }
%>
</div>

View file

@ -10,6 +10,15 @@ Feature: Manage deferred todos
And there exists a project "manage me" for user "testuser"
And I have logged in as "testuser" with password "secret"
@selenium @wip
Scenario: I can add a deferred todo and it will show in the tickler
# also adding the first deferred todo will hide the empty message
When I go to the tickler
Then I should see the empty tickler message
When I submit a deferred new action with description "a new next action"
Then I should see "a new next action"
And I should not see the empty tickler message
Scenario: Editing the description of a todo updated the todo
Given this is a pending scenario