##// END OF EJS Templates
Added plugin hooks around Journal editing...
Eric Davis -
r2119:da98386bf748
parent child
Show More
@@ -1,40 +1,41
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class JournalsController < ApplicationController
18 class JournalsController < ApplicationController
19 before_filter :find_journal
19 before_filter :find_journal
20
20
21 def edit
21 def edit
22 if request.post?
22 if request.post?
23 @journal.update_attributes(:notes => params[:notes]) if params[:notes]
23 @journal.update_attributes(:notes => params[:notes]) if params[:notes]
24 @journal.destroy if @journal.details.empty? && @journal.notes.blank?
24 @journal.destroy if @journal.details.empty? && @journal.notes.blank?
25 call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params})
25 respond_to do |format|
26 respond_to do |format|
26 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
27 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
27 format.js { render :action => 'update' }
28 format.js { render :action => 'update' }
28 end
29 end
29 end
30 end
30 end
31 end
31
32
32 private
33 private
33 def find_journal
34 def find_journal
34 @journal = Journal.find(params[:id])
35 @journal = Journal.find(params[:id])
35 render_403 and return false unless @journal.editable_by?(User.current)
36 render_403 and return false unless @journal.editable_by?(User.current)
36 @project = @journal.journalized.project
37 @project = @journal.journalized.project
37 rescue ActiveRecord::RecordNotFound
38 rescue ActiveRecord::RecordNotFound
38 render_404
39 render_404
39 end
40 end
40 end
41 end
@@ -1,7 +1,8
1 <% form_remote_tag(:url => {}, :html => { :id => "journal-#{@journal.id}-form" }) do %>
1 <% form_remote_tag(:url => {}, :html => { :id => "journal-#{@journal.id}-form" }) do %>
2 <%= text_area_tag :notes, @journal.notes, :class => 'wiki-edit',
2 <%= text_area_tag :notes, @journal.notes, :class => 'wiki-edit',
3 :rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %>
3 :rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %>
4 <%= call_hook(:view_journals_notes_form_after_notes, { :journal => @journal}) %>
4 <p><%= submit_tag l(:button_save) %>
5 <p><%= submit_tag l(:button_save) %>
5 <%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " +
6 <%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " +
6 "Element.show('journal-#{@journal.id}-notes'); return false;" %></p>
7 "Element.show('journal-#{@journal.id}-notes'); return false;" %></p>
7 <% end %>
8 <% end %>
@@ -1,8 +1,10
1 if @journal.frozen?
1 if @journal.frozen?
2 # journal was destroyed
2 # journal was destroyed
3 page.remove "change-#{@journal.id}"
3 page.remove "change-#{@journal.id}"
4 else
4 else
5 page.replace "journal-#{@journal.id}-notes", render_notes(@journal)
5 page.replace "journal-#{@journal.id}-notes", render_notes(@journal)
6 page.show "journal-#{@journal.id}-notes"
6 page.show "journal-#{@journal.id}-notes"
7 page.remove "journal-#{@journal.id}-form"
7 page.remove "journal-#{@journal.id}-form"
8 end
8 end
9
10 call_hook(:view_journals_update_rjs_bottom, { :page => page, :journal => @journal })
General Comments 0
You need to be logged in to leave comments. Login now