From d0e72646610d589021959803529777684310b9d2 Mon Sep 17 00:00:00 2001 From: tim madden Date: Mon, 18 Jul 2011 17:37:11 -0500 Subject: [PATCH 1/5] changes for done checkbox on mobile page adding recent completed todos in case you accidentally tick one by mistake --- app/controllers/todos_controller.rb | 47 +++++++++++++++++++++++++ app/helpers/todos_helper.rb | 6 ++++ app/views/projects/project_mobile.rhtml | 3 +- app/views/todos/_mobile_actions.rhtml | 6 +++- app/views/todos/_mobile_todo.rhtml | 15 ++++---- app/views/todos/mobile_show_notes.rhtml | 2 +- config/routes.rb | 2 +- public/stylesheets/mobile.css | 9 +++-- 8 files changed, 74 insertions(+), 16 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 1661f22f..ffce91b9 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -361,6 +361,49 @@ class TodosController < ApplicationController end end + def mobile_done + # copied from toggle_check, left out other formats as they shouldn't come here + # ultimately would like to just use toggle_check + @todo = current_user.todos.find(params['id']) + @source_view = params['_source_view'] || 'todo' + @original_item_due = @todo.due + @original_item_was_deferred = @todo.deferred? + @original_item_was_pending = @todo.pending? + @original_item_was_hidden = @todo.hidden? + @original_item_context_id = @todo.context_id + @original_item_project_id = @todo.project_id + @todo_was_completed_from_deferred_or_blocked_state = @original_item_was_deferred || @original_item_was_pending + @saved = @todo.toggle_completion! + + @todo_was_blocked_from_completed_state = @todo.pending? # since we toggled_completion the previous state was completed + + # check if this todo has a related recurring_todo. If so, create next todo + @new_recurring_todo = check_for_next_todo(@todo) if @saved + + @predecessors = @todo.uncompleted_predecessors + if @saved + if @todo.completed? + @pending_to_activate = @todo.activate_pending_todos + else + @active_to_block = @todo.block_successors + end + end + + if @saved + if cookies[:mobile_url] + old_path = cookies[:mobile_url] + cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']} + notify(:notice, t("todos.action_marked_complete", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete')) + redirect_to old_path + else + notify(:notice, t("todos.action_marked_complete", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete')) + redirect_to todos_path(:format => 'm') + end + else + render :action => "edit", :format => :m + end + end + def toggle_star @todo = current_user.todos.find(params['id']) @todo.toggle_star! @@ -1176,6 +1219,10 @@ class TodosController < ApplicationController lambda do @page_title = t('todos.mobile_todos_page_title') @home = true + + max_completed = current_user.prefs.show_number_completed + @done = current_user.todos.completed.find(:all, :limit => max_completed, :include => Todo::DEFAULT_INCLUDES) unless max_completed == 0 + cookies[:mobile_url]= { :value => request.request_uri, :secure => SITE_CONFIG['secure_cookies']} determine_down_count diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 2f3ef48e..d6f3ed53 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -89,6 +89,12 @@ module TodosHelper :title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.map(&:description).join(', ')) : "", :readonly => todo.pending?) end + def remote_mobile_checkbox(todo=@todo) + form_tag mobile_done_todo_path(@todo, :format => 'm'), :method => :put, :class => "mobile-done", :name => "mobile_complete_#{@todo.id}" do + check_box_tag('_source_view', 'todo', @todo && @todo.completed?, "onClick" => "document.mobile_complete_#{@todo.id}.submit()") + end + end + def date_span(todo=@todo) if todo.completed? content_tag(:span, {:class => :grey}) { format_date( todo.completed_at ) } diff --git a/app/views/projects/project_mobile.rhtml b/app/views/projects/project_mobile.rhtml index d79cad08..414cb297 100644 --- a/app/views/projects/project_mobile.rhtml +++ b/app/views/projects/project_mobile.rhtml @@ -4,6 +4,7 @@ <% unless @project.description.blank? -%>
<%= sanitize(@project.description) %>
<% end -%> + <% else -%> <%= t('todos.no_deferred_actions_with', :tag_name => @tag_title) %> <% end -%>

<%= t('todos.completed_actions_with', :tag_name => @tag_title) %>

<% unless (@done.nil? or @done.size == 0) -%> - +
+ <% else -%> <%= t('todos.no_completed_actions_with', :tag_name => @tag_title) %> <% end -%> - \ No newline at end of file + diff --git a/public/stylesheets/mobile.css b/public/stylesheets/mobile.css index 9ee9973f..f4795a55 100644 --- a/public/stylesheets/mobile.css +++ b/public/stylesheets/mobile.css @@ -3,36 +3,41 @@ body { font-size: smaller; } +#content { + margin-top: 50px; +} + div.footer { font-size: XX-small; color: #999999; text-align: center; } +a, a:link, a:active, a:visited { + color: #CC3334; + padding-left: 1px; + padding-right: 1px; + text-decoration: none; +} + +a:hover { + background-color: #CC3334; + color: #FFFFFF; +} + div.footer a { text-decoration: underline; color: #999999; } -.m_t_d a { - text-decoration: none; - color: #000000; -} - -.m_t_d a:hover { - text-decoration: underline; - color: #0000FF; -} - -.m_t_d .red, .m_t_d .amber, .m_t_d .orange, .m_t_d .green{ - background-color: #999999; -} - h1 { - color: #f00; + color: #fff; font-size: small; - margin-top:.3em; - margin-bottom:.3em; + padding-top: 0.2em; + padding-bottom: 0.2em; + padding-left:8px; + margin-top:0; + margin-bottom:0; } h2 { @@ -43,6 +48,17 @@ h2 { border-top: 1px solid #777777; } +h2 a, h2 a:link, h2 a:active, h2 a:visited { + color: #666666; + text-decoration: none; +} + +h2 a:hover { + background-color: transparent; + color: #CC3334; + text-decoration: none; +} + h4.alert { border: 1px solid #666666; text-align: center; @@ -79,6 +95,15 @@ span.r { span.prj, span.ctx{ font-size: X-small; } + +#ctx, #pjr { + margin: 0.5em 0; +} + +#ctx a, #pjr a { + padding: 0.1em 0; +} + /* Draw attention to some text Same format as traffic lights */ .red { @@ -118,8 +143,8 @@ span.prj, span.ctx{ .count { color: #fff; - background: #000; - font-size: medium; + background: #f00; + padding: 0.2em; } .errors { @@ -149,7 +174,44 @@ span.r { display:none; } +#topbar { + background-color: #000000; + clear: both; + color: #EEEEEE; + height: 45px; + left: 0; + margin-bottom: 5px; + position: fixed; + top: 0; + width: 100%; + z-index: 501; +} + .nav { + color: #fff; + background: #000; + padding-top: 0.2em; + padding-bottom: 0.2em; +} + +#topbar .nav { + padding-left:8px; + margin-bottom:0.3em; +} + +.nav a, .nav a:link, .nav a:active, .nav a:visited { + color: #fff; + padding-top: 1.0em; + padding-bottom: 0.5em; +} + +.nav a:focus, .nav a:hover, .nav a:active { + background: transparent; + text-decoration: underline; +} + +.nav li:hover, .nav a:focus, .nav a:hover, .nav a:active { + color: #CCCCCC; } #database_auth_form table td { @@ -162,3 +224,7 @@ table.c { .mobile-done { display:inline; } + +input#todo_description, input#tag_list, textarea#todo_notes, select#todo_project_id, select#todo_context_id { + width: 95%; +} From c7cd46ee1d4dd9665f35fde48dedd3584775af2b Mon Sep 17 00:00:00 2001 From: Tim Madden Date: Tue, 22 Nov 2011 09:46:44 -0600 Subject: [PATCH 4/5] update to mobile todo edit view removing the done checkout (with new intermediate mobile todo view with done button, this is needed) rearranging fields to put the most important fields first --- app/views/todos/_edit_mobile_form.rhtml | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/views/todos/_edit_mobile_form.rhtml b/app/views/todos/_edit_mobile_form.rhtml index 63ede714..df130e65 100644 --- a/app/views/todos/_edit_mobile_form.rhtml +++ b/app/views/todos/_edit_mobile_form.rhtml @@ -4,37 +4,34 @@ <%= error_messages_for("todo") %> <% this_year = current_user.time.to_date.strftime("%Y").to_i -%> -<% if parent_container_type == 'show_mobile' -%> -

 <%= check_box_tag("done", 1, @todo && @todo.completed?, "tabindex" => 1, "onClick" => "document.mobileEdit.submit()") %>

-<% end -%>

-<%= text_field( "todo", "description", "tabindex" => 2, "maxlength" => 100, "size" => 50) %> -

-<%= text_area( "todo", "notes", "cols" => 40, "rows" => 3, "tabindex" => 3) %> +<%= text_field( "todo", "description", "tabindex" => 1, "maxlength" => 100, "size" => 50) %> +

+<%= text_field_tag "tag_list", @tag_list_text, :size => 50, :tabindex => 2 %>

<%= unless @mobile_from_context - collection_select( "todo", "context_id", @contexts, "id", "name", {}, {"tabindex" => 4} ) + collection_select( "todo", "context_id", @contexts, "id", "name", {}, {"tabindex" => 3} ) else select_tag("todo[context_id]", options_from_collection_for_select( @contexts, "id", "name", @mobile_from_context.id), - {"id" => :todo_context_id, :tabindex => 4} ) + {"id" => :todo_context_id, :tabindex => 3} ) end %>

<%= unless @mobile_from_project collection_select( "todo", "project_id", @projects, "id", "name", - {:include_blank => t('todos.no_project')}, {"tabindex" => 5} ) + {:include_blank => t('todos.no_project')}, {"tabindex" => 4} ) else # manually add blank option since :include_blank does not work # with options_from_collection_for_select select_tag("todo[project_id]", ""+options_from_collection_for_select( @projects, "id", "name", @mobile_from_project.id), - {"id" => :todo_project_id, :tabindex => 5} ) + {"id" => :todo_project_id, :tabindex => 4} ) end %> -

-<%= text_field_tag "tag_list", @tag_list_text, :size => 50, :tabindex => 6 %> +

+<%= text_area( "todo", "notes", "cols" => 40, "rows" => 3, "tabindex" => 5) %>

<%= date_select("todo", "due", {:order => [:day, :month, :year], - :start_year => this_year, :include_blank => '--'}, :tabindex => 7) %> + :start_year => this_year, :include_blank => '--'}, :tabindex => 6) %>

<%= date_select("todo", "show_from", {:order => [:day, :month, :year], - :start_year => this_year, :include_blank => true}, :tabindex => 8) %> + :start_year => this_year, :include_blank => true}, :tabindex => 7) %> From e9277676b2a7627b1fa5ecb5710ffdd5700db1bf Mon Sep 17 00:00:00 2001 From: tim madden Date: Tue, 20 Dec 2011 10:35:21 -0600 Subject: [PATCH 5/5] updates to tests for changes to mobile interface Updated mobile_add_action.feature with new navigation text Updated modile_edit_a_todo.feature to not look for removed 'done' checkbox in the edit form, but to use the previously created "mark complete" button. Added completed_container to mobile_actions so the test could find the completed todo that is no longer not visible --- app/views/todos/_mobile_actions.rhtml | 2 ++ features/mobile_add_action.feature | 4 ++-- features/mobile_edit_a_todo.feature | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/todos/_mobile_actions.rhtml b/app/views/todos/_mobile_actions.rhtml index 794b055e..2d45c0ee 100644 --- a/app/views/todos/_mobile_actions.rhtml +++ b/app/views/todos/_mobile_actions.rhtml @@ -4,8 +4,10 @@ <%= render :partial => "contexts/mobile_context", :collection => @contexts_to_show -%> <% end -%> <% unless @done.nil? -%> +

<%= t('todos.completed_actions') %>

    <%= render :partial => "todos/mobile_todo", :collection => @done %>
+
<% end %> diff --git a/features/mobile_add_action.feature b/features/mobile_add_action.feature index 80d9939d..86537d9f 100644 --- a/features/mobile_add_action.feature +++ b/features/mobile_add_action.feature @@ -14,7 +14,7 @@ Feature: Add new next action from mobile page Scenario Outline: The new action form is prefilled with context and project Given I am on the - When I follow "0-New action" + When I follow "New" Then the selected project should be "" And the selected context should be "" @@ -29,7 +29,7 @@ Feature: Add new next action from mobile page Scenario: I can add a new todo using the mobile interface Given I am on the home page Then the badge should show 0 - When I follow "0-New action" + When I follow "New" And I fill in "Description" with "test me" And I press "Create" Then I should see "test me" diff --git a/features/mobile_edit_a_todo.feature b/features/mobile_edit_a_todo.feature index 5726d99a..3589d072 100644 --- a/features/mobile_edit_a_todo.feature +++ b/features/mobile_edit_a_todo.feature @@ -14,6 +14,7 @@ Feature: Edit a next action from the mobile view | context | description | | @mobile | test action | + @selenium Scenario: I can edit an action on the mobile page When I am on the home page Then the badge should show 1 @@ -27,10 +28,8 @@ Feature: Edit a next action from the mobile view Then I should see "changed action" And I should not see "test action" When I follow "changed action" - And I press "Edit this action" - And I check "done" - And I press "Update" - Then I should not see "changed action" + And I press "Mark complete" + Then I should see "changed action" in the completed container Scenario: Navigate from home page move this to separate features when other scenarios are created for these features