From 5d2023d18b94a25467f445bf7599a0ab3d6e4ced Mon Sep 17 00:00:00 2001 From: lrbalt Date: Sun, 27 Apr 2008 19:23:19 +0000 Subject: [PATCH] keep tracks of last url in mobile view to be able to return to last page after edit of action. Fixes #696. Also applies patch to fix selenium test and update them for the navigation with the new return path. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@835 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/contexts_controller.rb | 7 +++ tracks/app/controllers/projects_controller.rb | 4 ++ tracks/app/controllers/todos_controller.rb | 26 ++++++----- tracks/app/views/todos/new_mobile.rhtml | 2 +- .../selenium/mobile/create_new_action.rsel | 2 +- tracks/test/selenium/mobile/navigation.rsel | 44 +++++++++++++------ 6 files changed, 57 insertions(+), 28 deletions(-) diff --git a/tracks/app/controllers/contexts_controller.rb b/tracks/app/controllers/contexts_controller.rb index 1b6c26e7..912de11e 100644 --- a/tracks/app/controllers/contexts_controller.rb +++ b/tracks/app/controllers/contexts_controller.rb @@ -127,14 +127,21 @@ class ContextsController < ApplicationController def render_contexts_mobile lambda do + @page_title = "TRACKS::List Contexts" @active_contexts = @contexts.find(:all, { :conditions => ["hide = ?", false]}) @hidden_contexts = @contexts.find(:all, { :conditions => ["hide = ?", true]}) + @down_count = @active_contexts.size + @hidden_contexts.size + cookies[:mobile_url]=request.request_uri render :action => 'index_mobile' end end def render_context_mobile lambda do + @page_title = "TRACKS::List actions in "+@context.name + @not_done = @not_done_todos.select {|t| t.context_id == @context.id } + @down_count = @not_done.size + cookies[:mobile_url]=request.request_uri render :action => 'mobile_show_context' end end diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb index 139eafe2..d63aaba6 100644 --- a/tracks/app/controllers/projects_controller.rb +++ b/tracks/app/controllers/projects_controller.rb @@ -51,6 +51,7 @@ class ProjectsController < ApplicationController @max_completed = current_user.prefs.show_number_completed @count = @not_done.size + @down_count = @count + @deferred.size @next_project = current_user.projects.next_from(@project) @previous_project = current_user.projects.previous_from(@project) @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json @@ -196,6 +197,8 @@ class ProjectsController < ApplicationController @active_projects = @projects.select{ |p| p.active? } @hidden_projects = @projects.select{ |p| p.hidden? } @completed_projects = @projects.select{ |p| p.completed? } + @down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size + cookies[:mobile_url]=request.request_uri render :action => 'index_mobile' end end @@ -208,6 +211,7 @@ class ProjectsController < ApplicationController @project_default_context = "The default context for this project is "+ @project.default_context.name end + cookies[:mobile_url]=request.request_uri render :action => 'project_mobile' end end diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb index d4533691..721675ed 100644 --- a/tracks/app/controllers/todos_controller.rb +++ b/tracks/app/controllers/todos_controller.rb @@ -32,6 +32,7 @@ class TodosController < ApplicationController respond_to do |format| format.m { @new_mobile = true + @return_path=cookies[:mobile_url] render :action => "new_mobile" } end @@ -102,6 +103,7 @@ class TodosController < ApplicationController @projects = current_user.projects.select { |p| p.active? } @contexts = current_user.contexts.find(:all) @edit_mobile = true + @return_path=cookies[:mobile_url] render :action => 'show_mobile' end format.xml { render :xml => @todo.to_xml( :root => 'todo', :except => :user_id ) } @@ -208,7 +210,11 @@ class TodosController < ApplicationController format.xml { render :xml => @todo.to_xml( :except => :user_id ) } format.m do if @saved - redirect_to formatted_todos_path(:m) + if cookies[:mobile_url] + redirect_to cookies[:mobile_url] + else + redirect_to formatted_todos_path(:m) + end else render :action => "edit", :format => :m end @@ -275,6 +281,7 @@ class TodosController < ApplicationController current_user.deferred_todos.find_and_activate_ready @not_done_todos = current_user.deferred_todos @count = @not_done_todos.size + @down_count = @count @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json unless mobile? respond_to do |format| @@ -332,11 +339,13 @@ class TodosController < ApplicationController @done = tag_collection.find(:all, :limit => max_completed, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'completed']) # Set count badge to number of items with this tag @not_done_todos.empty? ? @count = 0 : @count = @not_done_todos.size - # #@default_project_context_name_map = + @down_count = @count + # @default_project_context_name_map = # build_default_project_context_name_map(@projects).to_json respond_to do |format| format.html format.m { + cookies[:mobile_url]=request.request_uri render :action => "mobile_tag" } end @@ -555,16 +564,9 @@ class TodosController < ApplicationController def render_todos_mobile lambda do @page_title = "All actions" - if @context - @page_title += " in context #{@context.name}" - @down_count = @context.not_done_todo_count - elsif @project - @page_title += " in project #{@project.name}" - @down_count = @project.not_done_todo_count - else - @home = true - determine_down_count - end + @home = true + cookies[:mobile_url]=request.request_uri + determine_down_count render :action => 'index_mobile' end diff --git a/tracks/app/views/todos/new_mobile.rhtml b/tracks/app/views/todos/new_mobile.rhtml index 9ce1090a..17144323 100644 --- a/tracks/app/views/todos/new_mobile.rhtml +++ b/tracks/app/views/todos/new_mobile.rhtml @@ -2,4 +2,4 @@ <%= render :partial => 'edit_mobile' %>

<% end -%> -<%= link_to "Back", formatted_todos_path(:m) %> \ No newline at end of file +<%= link_to "Back", @return_path %> \ No newline at end of file diff --git a/tracks/test/selenium/mobile/create_new_action.rsel b/tracks/test/selenium/mobile/create_new_action.rsel index bbb77831..a8501da1 100644 --- a/tracks/test/selenium/mobile/create_new_action.rsel +++ b/tracks/test/selenium/mobile/create_new_action.rsel @@ -4,7 +4,7 @@ login :as => 'admin' open '/m' wait_for_text 'css=h1 span.count', '10' -click_and_wait "link=+" +click_and_wait "link=0-Add new action" type "todo_notes", "test notes" type "todo_description", "test name" diff --git a/tracks/test/selenium/mobile/navigation.rsel b/tracks/test/selenium/mobile/navigation.rsel index 25e987cb..d2fbab4c 100644 --- a/tracks/test/selenium/mobile/navigation.rsel +++ b/tracks/test/selenium/mobile/navigation.rsel @@ -1,25 +1,41 @@ setup :fixtures => :all login :as => 'admin' +# open home page open '/m' wait_for_title "All actions" wait_for_text 'css=h1 span.count', '10' -click_and_wait "link=2" -verify_title "All actions" -wait_for_text 'css=h1 span.count', '10' - -select "context_id", "label=agenda" -click_and_wait "change_context" -verify_title "All actions in context agenda" +# open context page +click_and_wait "link=2-Contexts" +verify_title "TRACKS::List Contexts" +# choose agenda context +click_and_wait "link=agenda" +verify_title "TRACKS::List actions in agenda" wait_for_text 'css=h1 span.count', '5' -select "context_id", "label=call" -click_and_wait "change_context" -verify_title "All actions in context call" +# click on tag foo to go to tag page +click_and_wait "link=foo" +verify_title "TRACKS::Tagged with 'foo'" +wait_for_text 'css=h1 span.count', '2' + +click_and_wait "link=3-Projects" +wait_for_text 'css=h1 span.count', '3' +click_and_wait "link=Build a working time machine" wait_for_text 'css=h1 span.count', '3' -select "project_id", "label=Build a working time machine" -click_and_wait "change_project" -verify_title "All actions in project Build a working time machine" -wait_for_text 'css=h1 span.count', '2' +# follow link of action to edit form and mark done +click_and_wait "link=Select Delorean model" +open_and_wait '/todos/6.m' +click "done" +click_and_wait "//input[@value='Update']" +# should return to project view +verify_title "TRACKS::Project: Build a working time machine" +open_and_wait '/m' +# on home page the count should be increased +wait_for_text 'css=h1 span.count', '9' + +# just test the navigation. +click_and_wait "link=Tickler" +wait_for_text 'css=h1 span.count', '1' +click_and_wait "link=Feeds"