refactor sidebar and finish migration of notes

This commit is contained in:
Reinier Balt 2010-11-24 22:01:23 +01:00
parent 94b5aa2346
commit ea1ca130f1
18 changed files with 138 additions and 97 deletions

View file

@ -1,7 +1,8 @@
<% submit_text ||= t('common.update') -%>
<% form_for(note_edit_form, :html => {
:id => dom_id(note_edit_form, 'edit_form'),
:class => "inline-form edit-note-form",
:method => :put }) do |f|
:method => :post }) do |f|
-%>
<div id="error_status"><%= error_messages_for("note") %></div>
@ -13,7 +14,7 @@
<div class="widgets">
<button type="submit" class="positive" id="<%= dom_id(note_edit_form, 'submit') %>" tabindex="15">
<%=image_tag("accept.png", :alt => "") %>
<%= t 'common.update' %>
<%= submit_text %>
</button>
<a href="" class="negative" id="neg_<%=dom_id(note_edit_form, 'edit_form')%>">
<%=image_tag("cancel.png", :alt => "") %>

View file

@ -1,6 +1,11 @@
<% note = notes_summary -%>
<div class="note_wrapper" id="<%= dom_id(note) %>">
<%= link_to( image_tag("blank.png", :border => 0), note_path(note), :title => t('notes.show_note_title'), :class => "link_to_notes icon") %>&nbsp;
<%= link_to(
image_tag("blank.png", :border => 0),
note_path(note),
:title => t('notes.show_note_title'),
:class => "link_to_notes icon",
:id => dom_id(note, "link")) %>&nbsp;
<%= rendered_note(note) %>
</div>
<% note = nil -%>

View file

@ -0,0 +1,25 @@
<% if @saved -%>
TracksForm.hide_errors();
add_note();
clear_form();
<% else -%>
TracksForm.show_errors(html_for_error_messages());
<% end -%>
function add_note() {
$('div#notes').append(html_for_note_summary());
$('#empty-n').hide();
}
function clear_form() {
$('#new-note').hide();
$('#edit-note-form').clearForm();
}
function html_for_error_messages() {
return "<%= escape_javascript(error_messages_for('project')) %>";
}
function html_for_note_summary() {
return "<%= @saved ? escape_javascript(render(:partial => 'notes_summary', :object => @note)) : "" %>";
}

View file

@ -4,14 +4,9 @@
replace_note_form_with_updated_note();
<% else -%>
show_errors();
TracksForm.show_errors(html_for_error_messages());
<% end %>
function show_errors() {
$('div#edit_error_status').html(html_for_error_messages());
$('div#edit_error_status').show();
}
function replace_note_form_with_updated_note() {
$('#<%= dom_id(@note, 'edit')%>').fadeOut(250, function() {
$('#<%= dom_id(@note, 'edit')%>').html(html_for_updated_note_form());