From f395a37e6305d815e245c826b02a6af330afc79c Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 4 Jun 2006 14:02:35 +0000 Subject: [PATCH] Added the lightbox interface to the project and context pages too, but altered it so that it's activated by a hidden link (using the hotkey Ctrl/Alt Q). The actual link on the page opens the inline form as usual, and is activated by Ctrl/Alt N). So the lightbox is still available, but optional. For some reason that I really can't figure out, adding an action to the context page results in the badge being incremented by two, but almost identical code on the project page gives the correct count. Baffling, but I'm sure I'm missing something that's staring me in the face. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@252 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/context_controller.rb | 2 ++ tracks/app/views/context/add_item.rjs | 11 +++++---- tracks/app/views/context/show.rhtml | 5 ++-- tracks/app/views/project/add_item.rjs | 11 +++++---- tracks/app/views/project/show.rhtml | 3 ++- .../app/views/shared/_add_new_item_form.rhtml | 2 +- .../app/views/shared/_new_action_form.rhtml | 23 +++++++++++++++++-- tracks/app/views/todo/add_item.rjs | 1 + tracks/app/views/todo/list.rhtml | 3 ++- tracks/doc/CHANGELOG | 2 +- tracks/doc/README_FOR_APP | 2 +- 11 files changed, 46 insertions(+), 19 deletions(-) diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index 6e3b03f6..51788a9d 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -64,6 +64,8 @@ class ContextController < ApplicationController @saved = @item.save @on_page = "context" if @saved + # This reports real count +1 for some reason that I don't understand + # Almost identical code for add_item in projects reports correct num @up_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = ? and todos.context_id IN (?)", @user.id, false, @item.context_id]).size.to_s end diff --git a/tracks/app/views/context/add_item.rjs b/tracks/app/views/context/add_item.rjs index 3f1f8ad7..cb648b08 100644 --- a/tracks/app/views/context/add_item.rjs +++ b/tracks/app/views/context/add_item.rjs @@ -1,12 +1,13 @@ if @saved - page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item' - page.hide "status" + page.show "status" page.replace_html "status", content_tag("div", "Added new next action", "class" => "confirmation") - page.visual_effect :appear, 'status', :duration => 0.5 - page.replace_html "badge_count", @up_count + page.visual_effect :fade, 'status', :duration => 2 + page['badge_count'].replace_html @up_count + page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')" + page.send :record, "Form.reset('todo-form-new-action-lightbox');Form.focusFirstElement('todo-form-new-action-lightbox')" + page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item' page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3 page.hide "empty-nd" # If we are adding an new action, the uncompleted actions must be > 0 - page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')" else page.hide "status" page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation") diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index 4b45492f..f36f0058 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -14,7 +14,8 @@
- -<%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %> + <%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %> + <%= render :partial => "shared/new_action_form", :locals => {:hide_link => false, :msg => ""} %> + <%= render :partial => "shared/new_action_form" %> <%= render "shared/sidebar" %>
\ No newline at end of file diff --git a/tracks/app/views/project/add_item.rjs b/tracks/app/views/project/add_item.rjs index f94e5b31..fdb06db4 100644 --- a/tracks/app/views/project/add_item.rjs +++ b/tracks/app/views/project/add_item.rjs @@ -1,12 +1,13 @@ if @saved - page.insert_html :bottom, "p#{@item.project_id}", :partial => 'todo/item' - page.hide "status" + page.show "status" page.replace_html "status", content_tag("div", "Added new next action", "class" => "confirmation") - page.visual_effect :appear, 'status', :duration => 0.5 - page.replace_html "badge_count", @up_count + page.visual_effect :fade, 'status', :duration => 2 + page['badge_count'].replace_html @up_count + page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')" + page.send :record, "Form.reset('todo-form-new-action-lightbox');Form.focusFirstElement('todo-form-new-action-lightbox')" + page.insert_html :bottom, "p#{@item.project_id}", :partial => 'todo/item' page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3 page.hide "empty-nd" # If we are adding an new action, the uncompleted actions must be > 0 - page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')" else page.hide "status" page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation") diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index 39ec875a..19e64352 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -47,6 +47,7 @@
-<%= render "shared/_add_new_item_form" %> + <%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %> + <%= render :partial => "shared/new_action_form", :locals => {:hide_link => false, :msg => ""} %> <%= render "shared/sidebar" %>
diff --git a/tracks/app/views/shared/_add_new_item_form.rhtml b/tracks/app/views/shared/_add_new_item_form.rhtml index 93c902f4..bc1167fe 100644 --- a/tracks/app/views/shared/_add_new_item_form.rhtml +++ b/tracks/app/views/shared/_add_new_item_form.rhtml @@ -49,7 +49,7 @@ <% unless controller.controller_name == "project" -%>
- <%= collection_select( "todo", "project_id", @projects.reject{|p| p.done}, "id", "name", + <%= collection_select( "todo", "project_id", @projects.reject{|p| p.done?}, "id", "name", { :include_blank => true }, {"tabindex" => 4}) %>
<% end -%> diff --git a/tracks/app/views/shared/_new_action_form.rhtml b/tracks/app/views/shared/_new_action_form.rhtml index 1683a334..53814a47 100644 --- a/tracks/app/views/shared/_new_action_form.rhtml +++ b/tracks/app/views/shared/_new_action_form.rhtml @@ -1,8 +1,16 @@ +<% hide_link ||= false %> +<% unless hide_link -%> +<%= link_to_function( + " ", + "onclick=new Lightbox.base('mybox', { closeOnOverlayClick : true });Form.focusFirstElement('todo-form-new-action-lightbox'); return false;", + {:title => "Add the next action", :accesskey => "q"}) %> +<% end -%> +