mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-13 19:04:22 +01:00
migrate deleting a note from notes page to jqeury
This commit is contained in:
parent
7b3c07a754
commit
145c9105dd
13 changed files with 145 additions and 84 deletions
42
app/views/notes/_note.rhtml
Normal file
42
app/views/notes/_note.rhtml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<div class="container" id="note-<%= note.id %>-wrapper">
|
||||
<div id="<%= dom_id(note, 'container') %>">
|
||||
|
||||
<h2><%= link_to(t('notes.note_header', :id => note.id.to_s), note_path(note), :title => t('notes.note_link_title', :id => note.id.to_s)) %></h2>
|
||||
|
||||
<div class="project_notes" id="<%= dom_id(note) %>">
|
||||
|
||||
<div class="note_boby"><%= format_note(note.body) %></div>
|
||||
|
||||
<div class="note_footer">
|
||||
<% # = link_to_remote(
|
||||
#image_tag("blank.png", :title =>t('notes.delete_note_title'), :class=>"delete_item", :id => "delete_note_"+note.id.to_s),
|
||||
#:url => note_path(note),
|
||||
#:html => {:class => 'delete_note', :title => "delete note"},
|
||||
#:method => :delete,
|
||||
#:confirm => t('notes.delete_confirmation', :id => note.id.to_s),
|
||||
#:before => visual_effect(:fade, dom_id(note, 'container'))) -
|
||||
%>
|
||||
|
||||
<%= link_to_delete_note(note, image_tag( "blank.png",:title => t('notes.delete_item_title'), :class=>"delete_item")) %>
|
||||
<%= link_to_edit_note(note, image_tag( "blank.png", :title => t('notes.edit_item_title'), :class=>"edit_item") ) %>
|
||||
|
||||
<%# link_to_function(image_tag( "blank.png", :title => t('notes.edit_item_title'), :class=>"edit_item"),
|
||||
#"$('##{dom_id(note)}').toggle(); $('##{dom_id(note, 'edit')}').show(); $('##{dom_id(note, 'edit_form')} textarea').focus();" ) + " | "
|
||||
%>
|
||||
|
||||
| <%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %> |
|
||||
|
||||
<%= Note.human_attribute_name('created_at') %>: <%= format_date(note.created_at) %>
|
||||
|
||||
<% if note.updated_at? -%>
|
||||
| <%= Note.human_attribute_name('updated_at') %>: <%= format_date(note.updated_at) %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="<%= dom_id(note, 'edit') %>" class="edit-form" style="display:none;">
|
||||
<%= render :partial => "notes/note_edit_form", :object => note %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,6 +1,33 @@
|
|||
<% @note = note_edit_form %>
|
||||
<%= hidden_field( "note", "project_id" ) %>
|
||||
<%= text_area( "note", "body", "cols" => 70, "rows" => 15, "tabindex" => 1 ) %>
|
||||
<br /><br />
|
||||
<input type="submit" value="<%= t('common.update') %>" tabindex="2" />
|
||||
<% @note = nil %>
|
||||
<%
|
||||
#form_remote_tag :url => note_path(note),
|
||||
#:method => :put,
|
||||
#:html => { :id => dom_id(note, 'edit_form'), :class => "inline-form" },
|
||||
#:update => dom_id(note, 'container'),
|
||||
#:complete => visual_effect(:appear, dom_id(note, 'container')) do
|
||||
-%>
|
||||
|
||||
<% form_for(note_edit_form, :html => {
|
||||
:id => dom_id(note_edit_form, 'edit_form'),
|
||||
:class => "inline-form edit-note-form",
|
||||
:method => :put }) do
|
||||
-%>
|
||||
|
||||
<%= hidden_field( "note", "project_id" ) %>
|
||||
<%= text_area( "note", "body", "cols" => 70, "rows" => 15, "tabindex" => 1 ) %>
|
||||
<br /><br />
|
||||
<input type="submit" value="<%= t('common.update') %>" tabindex="2" />
|
||||
|
||||
<div class="submit_box">
|
||||
<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' %>
|
||||
</button>
|
||||
<a href="" onclick="" class="negative">
|
||||
<%=image_tag("cancel.png", :alt => "") %>
|
||||
<%= t 'common.cancel' %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end -%>
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
<% note = notes -%>
|
||||
<div id="<%= dom_id(note, 'container') %>">
|
||||
<h2><%= link_to(t('notes.note_header', :id => note.id.to_s), note_path(note), :title => t('notes.note_link_title', :id => note.id.to_s)) %></h2>
|
||||
<div class="project_notes" id="<%= dom_id(note) %>">
|
||||
<%= format_note(note.body) %>
|
||||
|
||||
<div class="note_footer">
|
||||
<%= link_to_remote(
|
||||
image_tag("blank.png", :title =>t('notes.delete_note_title'), :class=>"delete_item", :id => "delete_note_"+note.id.to_s),
|
||||
:url => note_path(note),
|
||||
:html => {:class => 'delete_note', :title => "delete note"},
|
||||
:method => :delete,
|
||||
:confirm => t('notes.delete_confirmation', :id => note.id.to_s),
|
||||
:before => visual_effect(:fade, dom_id(note, 'container'))) -%>
|
||||
<%= link_to_function(image_tag( "blank.png", :title => t('notes.edit_item_title'), :class=>"edit_item"),
|
||||
"$('##{dom_id(note)}').toggle(); $('##{dom_id(note, 'edit')}').show(); $('##{dom_id(note, 'edit_form')} textarea').focus();" ) + " | " %>
|
||||
<%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %> |
|
||||
<%= Note.human_attribute_name('created_at') %>: <%= format_date(note.created_at) %>
|
||||
<% if note.updated_at? -%>
|
||||
| <%= Note.human_attribute_name('updated_at') %>: <%= format_date(note.updated_at) %>
|
||||
<% end -%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="<%= dom_id(note, 'edit') %>" class="edit-form" style="display:none;">
|
||||
<% form_remote_tag :url => note_path(note),
|
||||
:method => :put,
|
||||
:html => { :id => dom_id(note, 'edit_form'), :class => "inline-form" },
|
||||
:update => dom_id(note, 'container'),
|
||||
:complete => visual_effect(:appear, dom_id(note, 'container')) do -%>
|
||||
<%= render :partial => "notes/note_edit_form", :object => note %>
|
||||
<% end -%>
|
||||
</div>
|
||||
</div>
|
||||
<% note = nil -%>
|
||||
|
||||
10
app/views/notes/destroy.js.erb
Normal file
10
app/views/notes/destroy.js.erb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
remove_deleted_note();
|
||||
set_page_badge(<%=@down_count%>);
|
||||
page_notify('notice', "<%= t('notes.deleted_note', :id => @note.id)%>", 5);
|
||||
|
||||
function remove_deleted_note() {
|
||||
$('div#note-<%=@note.id%>-wrapper').slideUp(1000,
|
||||
function() {
|
||||
$('div#note-<%=@note.id%>-wrapper').remove();
|
||||
});
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
page.notify :notice, t('notes.deleted_note', :id => @note.id), 5.0
|
||||
page['badge_count'].replace_html @count
|
||||
page.hide "busy"
|
||||
|
|
@ -2,10 +2,6 @@
|
|||
<% if @all_notes.empty? -%>
|
||||
<div class="message"><p><%= t('notes.no_notes_available') %></p></div>
|
||||
<% else -%>
|
||||
<% for notes in @all_notes -%>
|
||||
<div class="container" id="note-<%= notes.id %>-wrapper">
|
||||
<%= render :partial => 'notes', :object => notes %>
|
||||
</div>
|
||||
<% end -%>
|
||||
<%= render :partial => 'note', :collection => @all_notes %>
|
||||
<% end -%>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue