parent
71b92b49fa
commit
3d6d8bd192
@ -0,0 +1,52 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# |
||||
# Copyright (C) 2012-2013 the OpenProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
class WorkPackageRelationsController < ApplicationController |
||||
before_filter :find_work_package, :find_project_from_association, :authorize |
||||
|
||||
def create |
||||
@relation = @work_package.new_relation.tap do |r| |
||||
r.issue_to = WorkPackage.visible.find_by_id(params[:relation][:issue_to_id].match(/\d+/).to_s) |
||||
r.relation_type = params[:relation][:relation_type] |
||||
r.delay = params[:relation][:delay] |
||||
end |
||||
|
||||
@relation.save |
||||
|
||||
respond_to do |format| |
||||
format.html { redirect_to work_package_path(@work_package) } |
||||
format.js {} |
||||
end |
||||
end |
||||
|
||||
def destroy |
||||
@relation = @work_package.relation(params[:id]) |
||||
|
||||
@relation.destroy |
||||
|
||||
respond_to do |format| |
||||
format.html { redirect_to issue_path(@issue) } |
||||
format.js {} |
||||
end |
||||
end |
||||
|
||||
def work_package |
||||
@work_package |
||||
end |
||||
|
||||
private |
||||
def find_work_package |
||||
@work_package = @object = WorkPackage.find(params[:work_package_id]) |
||||
rescue ActiveRecord::RecordNotFound |
||||
render_404 |
||||
end |
||||
end |
@ -0,0 +1,27 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
|
||||
Copyright (C) 2012-2013 the OpenProject Team |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License version 3. |
||||
|
||||
See doc/COPYRIGHT.rdoc for more details. |
||||
|
||||
++#%> |
||||
|
||||
<%= error_messages_for 'relation' %> |
||||
|
||||
<p> |
||||
<%= f.select :relation_type, collection_for_relation_type_select, {}, :onchange => "setPredecessorFieldsVisibility();" %> |
||||
<%= WorkPackage.model_name.human %> #<%= f.text_field :issue_to_id, :size => 10 %> |
||||
<div id="related_issue_candidates" class="autocomplete"></div> |
||||
<%= javascript_tag "observeRelatedIssueField('#{issues_auto_complete_path(:id => controller.work_package, :project_id => @project, :escape => false) }')" %> |
||||
<span id="predecessor_fields" style="display:none;"> |
||||
<%= IssueRelation.human_attribute_name(:delay) %>: <%= f.text_field :delay, :size => 3 %> <%= l(:label_day_plural) %> |
||||
</span> |
||||
<%= submit_tag l(:button_add) %> |
||||
<%= toggle_link l(:button_cancel), 'new-relation-form'%> |
||||
</p> |
||||
|
||||
<%= javascript_tag "setPredecessorFieldsVisibility();" %> |
@ -0,0 +1,21 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
|
||||
Copyright (C) 2012-2013 the OpenProject Team |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License version 3. |
||||
|
||||
See doc/COPYRIGHT.rdoc for more details. |
||||
|
||||
++#%> |
||||
|
||||
jQuery('#relations #errorExplanation').remove(); |
||||
|
||||
<% if @relation.errors.empty? %> |
||||
jQuery('#relations tbody').append("<%= escape_javascript(render :partial => 'work_packages/relation', :locals => { :relation => @relation }) %>"); |
||||
|
||||
jQuery('#relation_issue_to_id').val(''); |
||||
<% else %> |
||||
jQuery('#relations table').after("<%= escape_javascript(error_messages_for(@relation)) %>"); |
||||
<% end %> |
@ -0,0 +1,13 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
|
||||
Copyright (C) 2012-2013 the OpenProject Team |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License version 3. |
||||
|
||||
See doc/COPYRIGHT.rdoc for more details. |
||||
|
||||
++#%> |
||||
|
||||
jQuery('#issue_relation_<%= @relation.id %>').remove(); |
@ -0,0 +1,39 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
|
||||
Copyright (C) 2012-2013 the OpenProject Team |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License version 3. |
||||
|
||||
See doc/COPYRIGHT.rdoc for more details. |
||||
|
||||
++#%> |
||||
|
||||
<tr id="issue_relation_<%= relation.id %>"> |
||||
<td> |
||||
<%= l(relation.label_for(controller.work_package)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %> |
||||
<%= h(relation.other_issue(controller.work_package).project) + ' - ' if Setting.cross_project_issue_relations? %> |
||||
<%= link_to_issue(relation.other_issue(controller.work_package), :truncate => 60) %> |
||||
</td> |
||||
<% if not relation.other_issue(controller.work_package).kind.nil? %> |
||||
<td> |
||||
<%= h(relation.other_issue(controller.work_package).kind.name) %> |
||||
</td> |
||||
<% else %> |
||||
<td></td> |
||||
<% end %> |
||||
<td> |
||||
<%= format_date(relation.other_issue(controller.work_package).start_date) %> |
||||
</td> |
||||
<td> |
||||
<%= format_date(relation.other_issue(controller.work_package).due_date) %> |
||||
</td> |
||||
<td> |
||||
<%= link_to(image_tag('delete.png'), work_package_relation_path(controller.work_package, relation), |
||||
:method => :delete, |
||||
:remote => true, |
||||
:title => l(:label_relation_delete), |
||||
:alt => l(:label_relation_delete)) if authorize_for('issue_relations', 'destroy') %> |
||||
</td> |
||||
</tr> |
@ -0,0 +1,36 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
|
||||
Copyright (C) 2012-2013 the OpenProject Team |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License version 3. |
||||
|
||||
See doc/COPYRIGHT.rdoc for more details. |
||||
|
||||
++#%> |
||||
|
||||
<p> |
||||
<strong><%=l(:label_related_issues)%></strong> |
||||
<% if authorize_for('issue_relations', 'create') %> |
||||
(<%= toggle_link l(:label_add_related_issues), 'new-relation-form', {:focus => 'relation_issue_to_id'} %>) |
||||
<% end %> |
||||
</p> |
||||
|
||||
<table style="width:100%"> |
||||
<tbody> |
||||
<%= render :partial => 'work_packages/relation', :collection => controller.work_package.relations, :as => :relation -%> |
||||
</tbody> |
||||
</table> |
||||
|
||||
<%= form_for(controller.work_package.new_relation, |
||||
:as => :relation, |
||||
:url => work_package_relations_path(controller.work_package), |
||||
:method => :post, |
||||
:remote => true, |
||||
:complete => "Form.Element.focus('relation_issue_to_id');", |
||||
:html => {:id => 'new-relation-form', :style => (@relation ? '' : 'display: none;')}) do |f| %> |
||||
|
||||
<%= render :partial => 'work_package_relations/form', :locals => {:f => f}%> |
||||
|
||||
<% end %> |
Loading…
Reference in new issue