2008-02-13 08:49:08 +00:00
|
|
|
class NotesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def index
|
2010-11-11 22:14:14 +01:00
|
|
|
@all_notes = current_user.notes.all
|
2008-02-13 08:49:08 +00:00
|
|
|
@count = @all_notes.size
|
|
|
|
|
@page_title = "TRACKS::All notes"
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
format.xml { render :xml => @all_notes.to_xml( :except => :user_id ) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
@note = current_user.notes.find(params['id'])
|
|
|
|
|
@page_title = "TRACKS::Note " + @note.id.to_s
|
2008-04-19 19:15:07 +00:00
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
format.m &render_note_mobile
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def render_note_mobile
|
|
|
|
|
lambda do
|
|
|
|
|
render :action => 'note_mobile'
|
|
|
|
|
end
|
2008-02-13 08:49:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
note = current_user.notes.build
|
2010-02-03 17:33:50 +01:00
|
|
|
note.attributes = params["note"]
|
2010-11-11 22:14:14 +01:00
|
|
|
|
|
|
|
|
saved = note.save
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js do
|
2010-02-03 17:33:50 +01:00
|
|
|
if note.save
|
|
|
|
|
render :partial => 'notes_summary', :object => note
|
|
|
|
|
else
|
|
|
|
|
render :text => ''
|
|
|
|
|
end
|
2010-11-11 22:14:14 +01:00
|
|
|
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
|
2008-02-13 08:49:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
2008-03-19 20:24:41 +00:00
|
|
|
@note = current_user.notes.find(params['id'])
|
|
|
|
|
@note.destroy
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
2010-11-11 22:14:14 +01:00
|
|
|
format.js { @down_count = current_user.notes.size }
|
2008-02-13 08:49:08 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
note = current_user.notes.find(params['id'])
|
|
|
|
|
note.attributes = params["note"]
|
|
|
|
|
if note.save
|
|
|
|
|
render :partial => 'notes', :object => note
|
|
|
|
|
else
|
|
|
|
|
notify :warning, "Couldn't update note \"#{note.id}\""
|
|
|
|
|
render :text => ''
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|