Add note working again for Projects

This commit is contained in:
Eric Allen 2009-10-15 21:16:22 -04:00
parent 00da0b36aa
commit 94ec1d46bb
3 changed files with 23 additions and 3 deletions

View file

@ -11,7 +11,7 @@
<div class="container"> <div class="container">
<div id="notes"> <div id="notes">
<div class="add_note_link"><%= link_to_function( "Add a note", "Element.toggle('new-note'); Form.focusFirstElement('form-new-note');", :id=>"add_note_href") %></div> <div class="add_note_link"><%= link_to 'Add a note', '#' %> </div>
<h2>Notes</h2> <h2>Notes</h2>
<div id="empty-n" style="display:<%= @project.notes.empty? ? 'block' : 'none'%>;"> <div id="empty-n" style="display:<%= @project.notes.empty? ? 'block' : 'none'%>;">
<%= render :partial => "shared/empty", <%= render :partial => "shared/empty",
@ -26,7 +26,7 @@
:method => :post, :method => :post,
:update => "notes", :update => "notes",
:position => "bottom", :position => "bottom",
:complete => "new Effect.Highlight('notes');$('empty-n').hide();Form.reset('form-new-note');", :complete => "$('#notes').effect('highlight', 1000);$('#empty-n').hide();$('#new-note form').clearForm();",
:html => {:id=>'form-new-note', :class => 'inline-form'} do %> :html => {:id=>'form-new-note', :class => 'inline-form'} do %>
<%= hidden_field( "new_note", "project_id", "value" => "#{@project.id}" ) %> <%= hidden_field( "new_note", "project_id", "value" => "#{@project.id}" ) %>
<%= text_area( "new_note", "body", "cols" => 50, "rows" => 3, "tabindex" => 1 ) %> <%= text_area( "new_note", "body", "cols" => 50, "rows" => 3, "tabindex" => 1 ) %>
@ -39,4 +39,4 @@
<div id="input_box"> <div id="input_box">
<%= render :partial => "shared/add_new_item_form" %> <%= render :partial => "shared/add_new_item_form" %>
<%= render :file => "sidebar/sidebar.html.erb" %> <%= render :file => "sidebar/sidebar.html.erb" %>
</div><!-- End of input box --> </div><!-- End of input box -->

View file

@ -427,6 +427,12 @@ $(document).ready(function() {
$(this).parents('.edit-form').find('form').clearForm(); $(this).parents('.edit-form').find('form').clearForm();
}); });
$(".add_note_link a").live('click', function(){
$('#new-note').show();
$('#new-note form').clearForm();
$('#new-note form input:first').focus();
});
$("#list-active-projects").sortable({handle: '.handle', update: update_order}); $("#list-active-projects").sortable({handle: '.handle', update: update_order});
$("#list-hidden-projects").sortable({handle: '.handle', update: update_order}); $("#list-hidden-projects").sortable({handle: '.handle', update: update_order});
$("#list-completed-projects").sortable({handle: '.handle', update: update_order}); $("#list-completed-projects").sortable({handle: '.handle', update: update_order});

View file

@ -0,0 +1,14 @@
setup :fixtures => :all
login :as => 'admin'
#first, defer a todo
open "/projects/1"
click "css=.add_note_link a"
assert_visible "new-note"
type "new_note_body", "this is a note"
click 'css=#new-note input[type=submit]'
wait_for_text_present "this is a note"