mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 18:20:12 +01:00
change notes controller to enable adding notes through REST api.
see http://www.getontracks.org/forums/viewthread/530/
This commit is contained in:
parent
226d902127
commit
c9566047fc
2 changed files with 25 additions and 9 deletions
|
|
@ -27,14 +27,30 @@ class NotesController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
note = current_user.notes.build
|
note = current_user.notes.build
|
||||||
note.attributes = params["new_note"]
|
note.attributes = params["note"]
|
||||||
|
|
||||||
|
saved = note.save
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js do
|
||||||
if note.save
|
if note.save
|
||||||
render :partial => 'notes_summary', :object => note
|
render :partial => 'notes_summary', :object => note
|
||||||
else
|
else
|
||||||
render :text => ''
|
render :text => ''
|
||||||
end
|
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
|
def destroy
|
||||||
@note = current_user.notes.find(params['id'])
|
@note = current_user.notes.find(params['id'])
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@
|
||||||
:position => "bottom",
|
:position => "bottom",
|
||||||
:complete => "$('#notes').effect('highlight', 1000);$('#empty-n').hide();$('#new-note form').clearForm();",
|
: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( "note", "project_id", "value" => "#{@project.id}" ) %>
|
||||||
<%= text_area( "new_note", "body", "cols" => 50, "rows" => 3, "tabindex" => 1 ) %>
|
<%= text_area( "note", "body", "cols" => 50, "rows" => 3, "tabindex" => 1 ) %>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<input type="submit" value="Add note" name="add-new-note" tabindex="2" />
|
<input type="submit" value="Add note" name="add-new-note" tabindex="2" />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue