Project

General

Profile

Feature #2009 » manual-changeset-relation-1.1.2.patch

Patch for 1.1.2 stable release - Oxan -, 2011-03-08 16:38

View differences:

app/helpers/changeset_relations_helper.rb (revision 0)
1
module ChangesetRelationsHelper
2
end
app/controllers/changeset_relations_controller.rb (revision 0)
1
class ChangesetRelationsController < ApplicationController
2
  
3
  
4
  before_filter  :find_project, :authorize
5
  
6
  def new
7
    @changeset = Changeset.find(:first, :conditions => {:revision => params[:changeset][:revision], :repository_id => @project.repository})
8
    if @changeset.nil?
9
      @changeset = Changeset.new(:revision => params[:changeset][:revision])
10
      @changeset.errors.add('revision_not_found_error', '')
11
    else
12
      @changeset.issues << @issue
13
      @changeset.save if request.post?
14
    end
15
    @issue.reload
16
    respond_to do |format|
17
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
18
      format.js do
19
        render :update do |page|
20
          page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets }
21
          if @changeset.errors.empty?
22
            page << "$('changeset_revision').value = ''"
23
          end
24
        end
25
      end
26
    end
27
  end
28
  
29
  def destroy
30
    changeset = Changeset.find(params[:id])
31
    if request.post? && ! changeset.nil? && changeset.issues.include?(@issue)
32
      changeset.issues.delete(@issue)
33
      @issue.reload
34
    end
35
    respond_to do |format|
36
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
37
      format.js do
38
        render(:update) do |page|
39
          page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets }
40
        end
41
      end
42
    end
43
  end
44
  
45
  
46
  private
47
  
48
  def find_project
49
    @issue = Issue.find(params[:issue_id])
50
    @project = @issue.project
51
  rescue ActiveRecord::RecordNotFound
52
    render_404
53
  end
54
  
55
end
app/views/changeset_relations/_form.html.erb (revision 0)
1
<%= error_messages_for 'changeset' %>
2

  
3
<p><%= l(:label_revision) %> <%= f.text_field :revision, :size => 6 %>
4
  <%= submit_tag l(:button_add) %>
5
  <%= toggle_link l(:button_cancel), 'new-changeset-form'%>
6
</p>
7

  
8
<%= javascript_tag "setPredecessorFieldsVisibility();" %>
app/views/issues/show.rhtml (working copy)
82 82

  
83 83
</div>
84 84

  
85
<% if @changesets.present? %>
86
<div id="issue-changesets">
87
<h3><%=l(:label_associated_revisions)%></h3>
88
<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
89
</div>
85
<% if !@project.repository.nil? && (@changesets.present? || authorize_for('changeset_relations', 'new')) %>
86
  <div id="issue-changesets">
87
    <div class="contextual">
88
      <% if authorize_for('changeset_relations', 'new') %>
89
        <%= toggle_link l(:button_add), 'new-changeset-form'%>
90
      <% end %>
91
    </div>
92
    <h3><%=l(:label_associated_revisions)%></h3>
93
    <div id="issue-changesets-list">
94
      <%= render :partial => 'changesets', :locals => { :changesets => @changesets } %>
95
    </div>
96
  </div>
90 97
<% end %>
91 98

  
92 99
<% if @journals.present? %>
app/views/issues/_changesets.rhtml (working copy)
1
<% changesets.each do |changeset| %>
1
<% remote_form_for(:changeset, @changeset,
2
                 :url => {:controller => 'changeset_relations', :action => 'new', :issue_id => @issue},
3
                 :method => :post,
4
                 :html => {:id => 'new-changeset-form', :style => (@changeset ? '' : 'display: none;')}) do |f| %>
5
<%= render :partial => 'changeset_relations/form', :locals => {:f => f}%>
6
<% end %>
7
<% if !changesets.empty? %>
8
  <% changesets.each do |changeset| %>
2 9
    <div class="changeset <%= cycle('odd', 'even') %>">
3
    <p><%= link_to_revision(changeset, changeset.project,
4
                            :text => "#{l(:label_revision)} #{changeset.format_identifier}") %><br />
5
        <span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p>
10
    <p><%= link_to("#{l(:label_revision)} #{changeset.revision}",
11
                :controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %>
12
       <span class="contextual">
13
       <%= link_to_remote(image_tag('delete.png'), { :url => {:controller => 'changeset_relations', :action => 'destroy', :issue_id => @issue, :id => changeset},
14
                                                     :method => :post
15
                                                   }, :title => l(:label_changeset_delete)) if authorize_for('changeset_relations', 'destroy') %>
16
       </span><br />
17
       <span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span>
18
    </p>
19

  
6 20
    <div class="changeset-changes">
7 21
        <%= textilizable(changeset, :comments) %>
8 22
    </div>
9 23
    </div>
24
  <% end %>
10 25
<% end %>
26

  
db/migrate/20100531224709_add_manage_changeset_relations_permission.rb (revision 0)
1
class AddManageChangesetRelationsPermission < ActiveRecord::Migration
2
  def self.up
3
    Role.find(:all).each do |r|
4
      r.add_permission!(:manage_changeset_relations) if r.has_permission?(:manage_issue_relations)
5
    end
6
  end
7

  
8
  def self.down
9
    Role.find(:all).each do |r|
10
      r.remove_permission!(:manage_changeset_relations)
11
    end
12
  end
13
end
lib/redmine.rb (working copy)
68 68
    map.permission :add_issues, {:issues => [:new, :create, :update_form]}
69 69
    map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
70 70
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
71
    map.permission :manage_changeset_relations, {:changeset_relations => [:new, :destroy]}
71 72
    map.permission :manage_subtasks, {}
72 73
    map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
73 74
    map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
public/stylesheets/application.css (working copy)
289 289
fieldset#filters td.add-filter { text-align: right; vertical-align: top; }
290 290
.buttons { font-size: 0.9em; margin-bottom: 1.4em; margin-top: 1em; }
291 291

  
292
div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 1em; background: #fff; padding-left: 1em; font-size: 90%;}
292
div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 0em; background: #fff; padding-left: 1em; font-size: 90%;}
293 293
div#issue-changesets div.changeset { padding: 4px;}
294 294
div#issue-changesets div.changeset { border-bottom: 1px solid #ddd; }
295 295
div#issue-changesets p { margin-top: 0; margin-bottom: 1em;}
config/locales/en.yml (working copy)
935 935
  enumeration_doc_categories: Document categories
936 936
  enumeration_activities: Activities (time tracking)
937 937
  enumeration_system_activity: System Activity
938

  
938
  
939
  label_changeset_delete: Delete associated revision
940
  field_revision_not_found_error: Revision not found in project repository
(14-14/14)