Skip to content

Commit

Permalink
Added in-page entry and editing in Task Journals
Browse files Browse the repository at this point in the history
  • Loading branch information
reddragon committed Jun 21, 2010
1 parent ec46187 commit 9dcfcea
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 61 deletions.
3 changes: 2 additions & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def inpage_new
original_comment.content = wrap(original_comment.content, 75)
original_comment.content = CGI.unescape(original_comment.content).gsub(/\n/,"<br>")
original_comment.content = enquote(original_comment.content)
original_comment.content = original_comment.content + "\n\n" + previous_content
#TODO: Fix multiple replies
#original_comment.content = original_comment.content + "\n\n" + previous_content
@comment.content = "(In reply to Comment # #{original_comment.id})" + original_comment.content
end
render :partial => "new", :locals => {:comment => @comment}
Expand Down
28 changes: 17 additions & 11 deletions app/controllers/journals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ def inpage_new

if params[:reply_to_id] != nil
original_journal = Journal.find(params[:reply_to_id])
original_journal.content = wrap(original_journal.content, 75)
original_journal.content = CGI.unescape(original_journal.content).gsub(/\n/,"<br>")
original_journal.content = enquote(original_journal.content)
@journal.content = "(In reply to Journal Entry # #{original_journal.id})" + original_journal.content
#TODO: Fix multiple replies
#original_journal.content = original_journal.content + "\n\n" + previous_content
@journal.content = "(In reply to Journal # #{original_journal.id})" + original_journal.content
end

render :partial => "new"
render :partial => "new", :locals => {:journal => @journal}
end

def edit
@journal = Journal.find(params[:id])
#Remove the br tags so that it can be displayed in a natural fashion
@journal.content = CGI.unescape(@journal.content).gsub(/<br>/,"\n")
@task = Task.find(params[:task_id])
if !can_edit_journal?(@journal)
flash[:notice] = 'You are not authorised to edit this journal entry/comment.'
def inpage_edit
@journal = Journal.find(params[:id])
@task = @journal.task
if !can_edit_journal?(@journal)
flash[:notice] = 'You are not authorised to edit this journal entry'
redirect_to project_task_journals_path(@task.project, @task)
end
end
end
@journal.content = CGI.unescape(@journal.content).gsub(/<br>/,"\n")
render :partial => "edit"
end

def update
journal = Journal.find(params[:id])
Expand Down Expand Up @@ -92,6 +96,8 @@ def create

def index
@task = Task.find(params[:task_id])
@form_journal = Journal.new
@form_journal.task = @task
if can_see_journal?(@task)
@journals = @task.journals
else
Expand Down
9 changes: 9 additions & 0 deletions app/views/journals/_edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- form_for @journal, :url => {:action => :update, :project_id => @task.project.id, :task_id => @task.id} do |f|
%p
%b
= f.label :content
%br
= f.text_area :content
%br
= f.submit 'Update'

4 changes: 2 additions & 2 deletions app/views/journals/_new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
%b
%br
New Journal Entry
- form_for @journal, :url => {:action => :create, :project_id => @task.project.id, :task_id => @task.id }do |f|
- form_for journal, :url => {:action => :create, :project_id => journal.task.project.id, :task_id => journal.task.id }do |f|
= f.error_messages
= f.text_area :content
= f.text_area(:content, :rows => 25, :cols => 80)
%br
= f.submit 'Create'

42 changes: 0 additions & 42 deletions app/views/journals/edit.html.haml

This file was deleted.

11 changes: 6 additions & 5 deletions app/views/journals/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@
= journal.id
%tr
%td
= journal.content
%br
= display_message_content(journal.content)
%small
- if can_edit_journal?(journal)
= link_to 'Edit', edit_project_task_journal_path(@task.project, @task, journal)
= link_to_remote 'Edit', :update => "journal_space#{journal.id}", :url => {:action => 'inpage_edit', :id => journal.id}
&nbsp;|&nbsp;
- if can_delete_journal?(journal)
= link_to 'Delete', project_task_journal_path(@task.project, @task, journal), :confirm => 'Are you sure?', :method => :delete
&nbsp;|&nbsp;
= link_to_remote 'Reply', :update => "journal_space#{journal.id}", :url => {:action => 'inpage_new', :project_id => @task.project.id, :task_id => @task.id, :reply_to_id => journal.id}
= link_to_remote 'Reply', :update => "journal_space", :url => {:action => 'inpage_new', :project_id => @task.project.id, :task_id => @task.id, :reply_to_id => journal.id}
%div{:id => "journal_space#{journal.id}"}

%div{:id => 'journal_space'}

- if can_add_journal_entry?(@task)
-# @form_journal.task.id
= render :partial => "new", :locals => { :journal => @form_journal }
%p.links
- if can_add_journal_entry?(@task)
= link_to_remote 'New Entry', :update => 'journal_space', :url => {:action => 'inpage_new', :project_id => @task.project.id, :task_id => @task.id}
Expand Down

0 comments on commit 9dcfcea

Please sign in to comment.