From f39ebf6ec95fcbf4983cce4aa683e67e15b3bc1c Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 30 Oct 2005 19:12:08 +0000 Subject: [PATCH] Continued the separating out of the new item forms for all the controllers. So the new item form for todo/list, project/show/[name] and context/show/[name] all use shared/add_new_item_form. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@157 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/views/context/show.rhtml | 30 +------------------ tracks/app/views/project/_show_items.rhtml | 1 - tracks/app/views/project/show.rhtml | 30 +------------------ .../app/views/shared/add_new_item_form.rhtml | 28 ++++++++++++----- tracks/app/views/todo/_action_edit_form.rhtml | 3 ++ tracks/app/views/todo/_item.rhtml | 2 +- tracks/config/environment.rb | 2 +- 7 files changed, 28 insertions(+), 68 deletions(-) diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index ceb33fdb..bafd2b5c 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -32,35 +32,7 @@
-<%= link_to_function( "Add the next action in this context »", "Element.toggle('context_new_action'); Form.focusFirstElement('context-form-new-action');", {:title => "Add the next action", :accesskey => "n"}) %> - - - +<%= render "shared/add_new_item_form" %> <%= render "shared/sidebar" %>
diff --git a/tracks/app/views/project/_show_items.rhtml b/tracks/app/views/project/_show_items.rhtml index f25af32d..bdb7ea81 100644 --- a/tracks/app/views/project/_show_items.rhtml +++ b/tracks/app/views/project/_show_items.rhtml @@ -51,7 +51,6 @@ :update => "item-#{item.id}-container", :complete => "new Effect.Appear('item-#{item.id}-container', true);" %> <%= render_partial 'todo/action_edit_form', item %> - <%= end_form_tag %> diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index 1d3c64f8..68496e35 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -64,35 +64,7 @@
-<%= link_to_function( "Add the next action in this project »", "Element.toggle('project_new_action'); Form.focusFirstElement('project-form-new-action');", {:title => "Add the next action", :accesskey => "n"}) %> - - - +<%= render "shared/add_new_item_form" %> <%= 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 4e4a9ae2..4a216ea5 100644 --- a/tracks/app/views/shared/add_new_item_form.rhtml +++ b/tracks/app/views/shared/add_new_item_form.rhtml @@ -2,10 +2,13 @@ case controller.controller_name when "context" add_string = "Add a next action in this context »" + update_div = "next_actions" when "project" add_string = "Add a next action in this project »" + update_div = "next_actions" else add_string = "Add a next action »" + update_div = "new_actions" end %> @@ -18,7 +21,7 @@ <%= form_remote_tag( :url => { :controller => "todo", :action => "add_item" }, - :update => "new_actions", + :update => update_div, :position=> "bottom", :complete => "Form.focusFirstElement('todo-form-new-action');Form.reset('todo-form-new-action');", :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) %> @@ -29,16 +32,27 @@
<%= text_area( "new_item", "notes", "cols" => 25, "rows" => 10, "tabindex" => 2) %>
-
- <%= collection_select( "new_item", "context_id", @contexts, "id", "name", - {}, {"tabindex" => 3}) %>
+ <% unless controller.controller_name == "context" -%> +
+ <%= collection_select( "new_item", "context_id", @contexts, "id", "name", + {}, {"tabindex" => 3}) %>
+ <% end -%> -
- <%= collection_select( "new_item", "project_id", @projects, "id", "name", - { :include_blank => true }, {"tabindex" => 4}) %>
+ <% unless controller.controller_name == "project" -%> +
+ <%= collection_select( "new_item", "project_id", @projects, "id", "name", + { :include_blank => true }, {"tabindex" => 4}) %>
+ <% end -%>
<%= text_field("new_item", "due", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5) %> + + <% if controller.controller_name == "project" -%> + <%= hidden_field( "new_item", "project_id", "value" => "#{@project.id}") %> + + <% elsif controller.controller_name == "context" -%> + <%= hidden_field( "new_item", "context_id", "value" => "#{@context.id}") %> + <% end -%>

<%= end_form_tag %> diff --git a/tracks/app/views/todo/_action_edit_form.rhtml b/tracks/app/views/todo/_action_edit_form.rhtml index e9053865..643f26dd 100644 --- a/tracks/app/views/todo/_action_edit_form.rhtml +++ b/tracks/app/views/todo/_action_edit_form.rhtml @@ -48,6 +48,9 @@ + <% if controller.controller_name == "project" %> + + <% end -%> Cancel diff --git a/tracks/app/views/todo/_item.rhtml b/tracks/app/views/todo/_item.rhtml index c3ef0f56..b31636b9 100644 --- a/tracks/app/views/todo/_item.rhtml +++ b/tracks/app/views/todo/_item.rhtml @@ -17,7 +17,7 @@ <%= due_date( item.due ) %> <%= sanitize(item.description) %> - <% if @params["project"] == true %> + <% if @params["project"] == "true" %> <%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %> <% else %> <% if item.project_id %> diff --git a/tracks/config/environment.rb b/tracks/config/environment.rb index eaed51a4..8d879ef3 100644 --- a/tracks/config/environment.rb +++ b/tracks/config/environment.rb @@ -34,7 +34,7 @@ Rails::Initializer.run do |config| # Use Active Record's schema dumper instead of SQL when creating the test database # (enables use of different database adapters for development and test environments) - # config.active_record.schema_format = :ruby + config.active_record.schema_format = :ruby # See Rails::Configuration for more options end