mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-23 02:30:12 +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
|
|
@ -1,7 +1,7 @@
|
|||
class NotesController < ApplicationController
|
||||
|
||||
def index
|
||||
@all_notes = current_user.notes
|
||||
@all_notes = current_user.notes.all
|
||||
@count = @all_notes.size
|
||||
@page_title = "TRACKS::All notes"
|
||||
respond_to do |format|
|
||||
|
|
@ -28,49 +28,38 @@ class NotesController < ApplicationController
|
|||
def create
|
||||
note = current_user.notes.build
|
||||
note.attributes = params["note"]
|
||||
|
||||
saved = note.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
|
||||
saved = note.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
if note.save
|
||||
render :partial => 'notes_summary', :object => note
|
||||
else
|
||||
render :text => ''
|
||||
end
|
||||
end
|
||||
format.xml do
|
||||
if saved
|
||||
head :created, :location => note_url(note), :text => "new note with id #{note.id}"
|
||||
else
|
||||
render_failure note.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
format.html do
|
||||
render :text => 'unexpected request for html rendering'
|
||||
end
|
||||
end
|
||||
end
|
||||
format.xml do
|
||||
if saved
|
||||
head :created, :location => note_url(note), :text => "new note with id #{note.id}"
|
||||
else
|
||||
render_failure note.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
format.html do
|
||||
render :text => 'unexpected request for html rendering'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@note = current_user.notes.find(params['id'])
|
||||
|
||||
@note.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js do
|
||||
@count = current_user.notes.size
|
||||
render
|
||||
end
|
||||
format.js { @down_count = current_user.notes.size }
|
||||
end
|
||||
|
||||
# if note.destroy
|
||||
# render :text => ''
|
||||
# else
|
||||
# notify :warning, "Couldn't delete note \"#{note.id}\""
|
||||
# render :text => ''
|
||||
# end
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue