Index: app/helpers/changeset_relations_helper.rb =================================================================== --- app/helpers/changeset_relations_helper.rb (revision 0) +++ app/helpers/changeset_relations_helper.rb (revision 0) @@ -0,0 +1,2 @@ +module ChangesetRelationsHelper +end Index: app/controllers/changeset_relations_controller.rb =================================================================== --- app/controllers/changeset_relations_controller.rb (revision 0) +++ app/controllers/changeset_relations_controller.rb (revision 0) @@ -0,0 +1,55 @@ +class ChangesetRelationsController < ApplicationController + + + before_filter :find_project, :authorize + + def new + @changeset = Changeset.find(:first, :conditions => {:revision => params[:changeset][:revision], :repository_id => @project.repository}) + if @changeset.nil? + @changeset = Changeset.new(:revision => params[:changeset][:revision]) + @changeset.errors.add('revision_not_found_error', '') + else + @changeset.issues << @issue + @changeset.save if request.post? + end + @issue.reload + respond_to do |format| + format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } + format.js do + render :update do |page| + page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets } + if @changeset.errors.empty? + page << "$('changeset_revision').value = ''" + end + end + end + end + end + + def destroy + changeset = Changeset.find(params[:id]) + if request.post? && ! changeset.nil? && changeset.issues.include?(@issue) + changeset.issues.delete(@issue) + @issue.reload + end + respond_to do |format| + format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } + format.js do + render(:update) do |page| + page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets } + end + end + end + end + + + private + + def find_project + @issue = Issue.find(params[:issue_id]) + @project = @issue.project + rescue ActiveRecord::RecordNotFound + render_404 + end + +end Index: app/views/changeset_relations/_form.html.erb =================================================================== --- app/views/changeset_relations/_form.html.erb (revision 0) +++ app/views/changeset_relations/_form.html.erb (revision 0) @@ -0,0 +1,8 @@ +<%= error_messages_for 'changeset' %> + +

<%= l(:label_revision) %> <%= f.text_field :revision, :size => 6 %> + <%= submit_tag l(:button_add) %> + <%= toggle_link l(:button_cancel), 'new-changeset-form'%> +

+ +<%= javascript_tag "setPredecessorFieldsVisibility();" %> Index: app/views/issues/show.rhtml =================================================================== --- app/views/issues/show.rhtml (revision 3764) +++ app/views/issues/show.rhtml (working copy) @@ -79,11 +79,18 @@ -<% if @changesets.present? %> -
-

<%=l(:label_associated_revisions)%>

-<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %> -
+<% if !@project.repository.nil? && (@changesets.present? || authorize_for('changeset_relations', 'new')) %> +
+
+ <% if authorize_for('changeset_relations', 'new') %> + <%= toggle_link l(:button_add), 'new-changeset-form'%> + <% end %> +
+

<%=l(:label_associated_revisions)%>

+
+ <%= render :partial => 'changesets', :locals => { :changesets => @changesets } %> +
+
<% end %> <% if @journals.present? %> Index: app/views/issues/_changesets.rhtml =================================================================== --- app/views/issues/_changesets.rhtml (revision 3764) +++ app/views/issues/_changesets.rhtml (working copy) @@ -1,8 +1,23 @@ -<% changesets.each do |changeset| %> +<% remote_form_for(:changeset, @changeset, + :url => {:controller => 'changeset_relations', :action => 'new', :issue_id => @issue}, + :method => :post, + :html => {:id => 'new-changeset-form', :style => (@changeset ? '' : 'display: none;')}) do |f| %> +<%= render :partial => 'changeset_relations/form', :locals => {:f => f}%> +<% end %> + +<% if !changesets.empty? %> + <% changesets.each do |changeset| %>

<%= link_to("#{l(:label_revision)} #{changeset.revision}", - :controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %>
- <%= authoring(changeset.committed_on, changeset.author) %>

+ :controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %> + + <%= link_to_remote(image_tag('delete.png'), { :url => {:controller => 'changeset_relations', :action => 'destroy', :issue_id => @issue, :id => changeset}, + :method => :post + }, :title => l(:label_changeset_delete)) if authorize_for('changeset_relations', 'destroy') %> + +
+ <%= authoring(changeset.committed_on, changeset.author) %>

<%= textilizable(changeset, :comments) %>
+ <% end %> <% end %> Index: db/migrate/20100531224709_add_manage_changeset_relations_permission.rb =================================================================== --- db/migrate/20100531224709_add_manage_changeset_relations_permission.rb (revision 0) +++ db/migrate/20100531224709_add_manage_changeset_relations_permission.rb (revision 0) @@ -0,0 +1,13 @@ +class AddManageChangesetRelationsPermission < ActiveRecord::Migration + def self.up + Role.find(:all).each do |r| + r.add_permission!(:manage_changeset_relations) if r.has_permission?(:manage_issue_relations) + end + end + + def self.down + Role.find(:all).each do |r| + r.remove_permission!(:manage_changeset_relations) + end + end +end Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 3764) +++ config/locales/en.yml (working copy) @@ -900,4 +900,6 @@ enumeration_doc_categories: Document categories enumeration_activities: Activities (time tracking) enumeration_system_activity: System Activity - + + label_changeset_delete: Delete associated revision + field_revision_not_found_error: Revision not found in project repository Index: lib/redmine.rb =================================================================== --- lib/redmine.rb (revision 3764) +++ lib/redmine.rb (working copy) @@ -65,6 +65,7 @@ map.permission :add_issues, {:issues => [:new, :create, :update_form]} map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]} map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} + map.permission :manage_changeset_relations, {:changeset_relations => [:new, :destroy]} map.permission :manage_subtasks, {} map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]} map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin Index: public/stylesheets/application.css =================================================================== --- public/stylesheets/application.css (revision 3764) +++ public/stylesheets/application.css (working copy) @@ -285,7 +285,7 @@ fieldset#filters td.add-filter { text-align: right; vertical-align: top; } .buttons { font-size: 0.9em; margin-bottom: 1.4em; margin-top: 1em; } -div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 1em; background: #fff; padding-left: 1em; font-size: 90%;} +div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 0em; background: #fff; padding-left: 1em; font-size: 90%;} div#issue-changesets .changeset { padding: 4px;} div#issue-changesets .changeset { border-bottom: 1px solid #ddd; } div#issue-changesets p { margin-top: 0; margin-bottom: 1em;}