To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / issue_relations_controller.rb @ 441:cbce1fd3b1b7
History | View | Annotate | Download (2.39 KB)
| 1 |
# redMine - project management software
|
|---|---|
| 2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
| 3 |
#
|
| 4 |
# This program is free software; you can redistribute it and/or
|
| 5 |
# modify it under the terms of the GNU General Public License
|
| 6 |
# as published by the Free Software Foundation; either version 2
|
| 7 |
# of the License, or (at your option) any later version.
|
| 8 |
#
|
| 9 |
# This program is distributed in the hope that it will be useful,
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
# GNU General Public License for more details.
|
| 13 |
#
|
| 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
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 17 |
|
| 18 |
class IssueRelationsController < ApplicationController |
| 19 |
before_filter :find_issue, :find_project_from_association, :authorize |
| 20 |
|
| 21 |
def new |
| 22 |
@relation = IssueRelation.new(params[:relation]) |
| 23 |
@relation.issue_from = @issue |
| 24 |
if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/) |
| 25 |
@relation.issue_to = Issue.visible.find_by_id(m[1].to_i) |
| 26 |
end
|
| 27 |
@relation.save if request.post? |
| 28 |
respond_to do |format|
|
| 29 |
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
| 30 |
format.js do
|
| 31 |
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
| 32 |
render :update do |page| |
| 33 |
page.replace_html "relations", :partial => 'issues/relations' |
| 34 |
if @relation.errors.empty? |
| 35 |
page << "$('relation_delay').value = ''"
|
| 36 |
page << "$('relation_issue_to_id').value = ''"
|
| 37 |
end
|
| 38 |
end
|
| 39 |
end
|
| 40 |
end
|
| 41 |
end
|
| 42 |
|
| 43 |
def destroy |
| 44 |
relation = IssueRelation.find(params[:id]) |
| 45 |
if request.post? && @issue.relations.include?(relation) |
| 46 |
relation.destroy |
| 47 |
@issue.reload
|
| 48 |
end
|
| 49 |
respond_to do |format|
|
| 50 |
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
| 51 |
format.js {
|
| 52 |
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
| 53 |
render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} |
| 54 |
} |
| 55 |
end
|
| 56 |
end
|
| 57 |
|
| 58 |
private |
| 59 |
def find_issue |
| 60 |
@issue = @object = Issue.find(params[:issue_id]) |
| 61 |
rescue ActiveRecord::RecordNotFound |
| 62 |
render_404 |
| 63 |
end
|
| 64 |
end
|