make todos editable on the search page. Fix #716.

This commit is contained in:
Reinier Balt 2011-09-16 12:38:35 +02:00
parent 83133e3cdc
commit bed46847b3
7 changed files with 153 additions and 17 deletions

View file

@ -308,6 +308,7 @@ module TodosHelper
page.stats { return @todo.completed? }
page.tag { return (@context_changed && !@todo.hidden?) || @tag_was_removed || @todo_hidden_state_changed || @todo_deferred_state_changed }
page.todo { return @context_changed || @todo.hidden? || @todo.deferred? || @todo.pending?}
page.search { return false }
end
return false
end
@ -321,6 +322,7 @@ module TodosHelper
page.stats { return !@todo.completed? }
page.tag { return !update_needs_to_remove_todo_from_container && !@tag_was_removed }
page.todo { return !update_needs_to_remove_todo_from_container }
page.search { return true }
end
return false
end

View file

@ -5,18 +5,22 @@
redirect_after_complete();
<% else
animation = []
animation << "remove_todo"
if @todo.completed?
animation << "add_to_completed_container" unless source_view_is_one_of(:calendar, :deferred)
animation << "add_new_recurring_todo"
animation << "activate_pending_todos"
animation << "remove_source_container"
unless source_view_is(:search)
animation << "remove_todo"
if @todo.completed?
animation << "add_to_completed_container" unless source_view_is_one_of(:calendar, :deferred)
animation << "add_new_recurring_todo"
animation << "activate_pending_todos"
animation << "remove_source_container"
else
animation << "add_todo_to_context" unless source_view_is(:done)
animation << "block_predecessors"
end
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo)
animation << "regenerate_predecessor_family"
else
animation << "add_todo_to_context" unless source_view_is(:done)
animation << "block_predecessors"
end
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo)
animation << "regenerate_predecessor_family" -%>
animation << "replace_todo"
end -%>
<%= render_animation(animation) %>
TracksPages.set_page_badge(<%= @down_count %>);
<% end -%>
@ -55,6 +59,11 @@ function add_to_completed_container(next_steps) {
<% end -%>
}
function replace_todo(next_steps) {
$('#<%= dom_id(@todo) %>').html(html_for_todo());
next_steps.go();
}
function add_todo_to_context(next_steps) {
$('#<%= item_container_id(@todo) %>').append(html_for_todo());
<% if should_make_context_visible -%>

View file

@ -27,8 +27,8 @@
function remove_todo(next_steps) {
$('#<%= dom_id(@todo) %>').fadeOut(400, function() {
$('#<%= dom_id(@todo) %>').remove();
<% if source_view_is :calendar
# in calendar view it is possible to have a todo twice on the page
<% if source_view_is :calendar
# in calendar view it is possible to have a todo twice on the page
-%>
$('#<%= dom_id(@todo) %>').remove();
<% end %>
@ -46,7 +46,7 @@ function add_to_existing_container(next_steps) {
<% end -%>
<% else -%>
<% unless (@todo_hidden_state_changed && @todo.hidden?) || @todo_was_deferred_from_active_state -%>
$('#c<%= @todo.context_id %>').fadeIn(500, function() {
$('#c<%= @todo.context_id %>').fadeIn(500, function() {
next_steps.go();
<% if @target_context_count==1 -%>
$("#<%= empty_container_msg_div_id %>").slideUp(100);
@ -110,7 +110,7 @@ function html_for_error_messages() {
return "<%= escape_javascript(error_messages_for('todo')) %>";
}
function update_predecessors() {
function update_predecessors(next_steps) {
<% @todo.uncompleted_predecessors.each do |p| -%>
if ($('#<%=item_container_id(p)%>')) {
$('#<%=dom_id(p)%>').html('<%=escape_javascript(render(:partial => p, :locals => { :parent_container_type => parent_container_type }))%>');
@ -123,4 +123,5 @@ function update_predecessors() {
}
<% end -%>
<% end -%>
next_steps.go();
}

81
features/search.feature Normal file
View file

@ -0,0 +1,81 @@
Feature: Show all due actions in a calendar view
As a Tracks user
In order to keep overview of my due todos
I want to manage due todos in a calendar view
Background:
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
Scenario: I can search for todos by partial description
Given I have the following todos:
| description | context |
| tester of stuff | @home |
| testing search | @work |
| unrelated stuff | @home |
When I go to the search page
And I search for "test"
Then I should see "tester"
And I should see "testing search"
When I go to the search page
And I search for "stuff"
Then I should see "tester of stuff"
And I should see "unrelated stuff"
@selenium
Scenario: I can edit found todos
Given I have the following todos:
| description | context |
| tester of stuff | @home |
| testing search | @work |
When I go to the search page
And I search for "test"
Then I should see "tester of stuff"
When I star the action "tester of stuff"
Then I should see a starred "tester of stuff"
When I edit the description of "tester of stuff" to "test 1-2-3"
Then I should not see "tester of stuff"
And I should see "test 1-2-3"
When I go to the search page
And I search for "test"
Then I should not see "tester of stuff"
And I should see "test 1-2-3"
@selenium
Scenario: I can delete found todos
Given I have the following todos:
| description | context |
| tester of stuff | @home |
| testing search | @work |
When I go to the search page
And I search for "test"
Then I should see "tester of stuff"
When I delete the action "tester of stuff"
Then I should not see "tester of stuff"
When I go to the search page
And I search for "test"
Then I should not see "tester of stuff"
@selenium @wip
Scenario: I can mark found todos complete and uncomplete
Given I have the following todos:
| description | context |
| tester of stuff | @home |
| testing search | @work |
When I go to the search page
And I search for "test"
Then I should see an active todo "tester of stuff"
When I mark "tester of stuff" as complete
Then I should see a completed todo "tester of stuff"
# the completed todo should show up on the next search too
When I go to the search page
And I search for "test"
Then I should see a completed todo "tester of stuff"
When I mark "tester of stuff" as uncompleted
Then I should see an active todo "tester of stuff"
# the active todo should show up on the next search too
When I go to the search page
And I search for "test"
Then I should see an active todo "tester of stuff"

View file

@ -0,0 +1,4 @@
When /^I search for "([^"]*)"$/ do |search_arg|
fill_in "search", :with => search_arg
click_button "Search"
end

View file

@ -40,6 +40,12 @@ Given /^I have a todo "([^"]*)"$/ do |description|
Given "I have a todo \"#{description}\" in the context \"Context A\""
end
Given /^I have the following todos:$/ do |table|
table.hashes.each do | todo |
Given "I have a todo \"#{todo[:description]}\" in the context \"#{todo[:context]}\""
end
end
Given /^I have a todo "([^"]*)" with notes "([^"]*)"$/ do |description, notes|
Given "I have a todo \"#{description}\" in the context \"Context A\""
@todo.notes = notes

View file

@ -71,13 +71,46 @@ Then /^I should see the todo "([^\"]*)"$/ do |todo_description|
end
Then /^I should not see the todo "([^\"]*)"$/ do |todo_description|
if selenium.is_element_present("//span[.=\"#{todo_description}\"]")
xpath = "//span[.=\"#{todo_description}\"]"
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present("//span[.=\"#{todo_description}\"]")
!selenium.is_element_present(xpath)
end
end
end
Then /^I should see a completed todo "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
# only completed todos have a grey span with the completed_at date
xpath = "//div[@id='line_todo_#{todo.id}']/div/span[@class='grey']"
unless selenium.is_element_present(xpath)
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
selenium.is_visible(xpath).should be_true
end
Then /^I should see an active todo "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
# only active todos have a grip div
xpath = "//div[@id='line_todo_#{todo.id}']/img[@class='grip']"
unless selenium.is_element_present(xpath)
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
selenium.is_visible(xpath).should be_true
end
Then /^the number of actions should be (\d+)$/ do |count|
@current_user.todos.count.should == count.to_i
end