diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 73afc79d5..79077017c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,7 +20,7 @@ class IssuesController < ApplicationController default_search_scope :issues - before_action :find_issue, :only => [:show, :edit, :update] + before_action :find_issue, :only => [:show, :edit, :update, :issue_tab] before_action :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_action :authorize, :except => [:index, :new, :create] before_action :find_optional_project, :only => [:index, :new, :create] @@ -86,13 +86,10 @@ class IssuesController < ApplicationController def show @journals = @issue.visible_journals_with_index - @changesets = @issue.changesets.visible.preload(:repository, :user).to_a + @has_changesets = @issue.changesets.visible.preload(:repository, :user).exists? @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } - if User.current.wants_comments_in_reverse_order? - @journals.reverse! - @changesets.reverse! - end + @journals.reverse! if User.current.wants_comments_in_reverse_order? if User.current.allowed_to?(:view_time_entries, @project) Issue.load_visible_spent_hours([@issue]) @@ -109,7 +106,10 @@ class IssuesController < ApplicationController retrieve_previous_and_next_issue_ids render :template => 'issues/show' } - format.api + format.api { + @changesets = @issue.changesets.visible.preload(:repository, :user).to_a + @changesets.reverse! if User.current.wants_comments_in_reverse_order? + } format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf" @@ -194,6 +194,21 @@ class IssuesController < ApplicationController end end + def issue_tab + return render_error :status => 422 unless request.xhr? + tab = params[:name] + + case tab + when 'time_entries' + @time_entries = @issue.time_entries.visible.preload(:activity, :user).to_a + render :partial => 'issues/tabs/time_entries', :locals => {:time_entries => @time_entries} + when 'changesets' + @changesets = @issue.changesets.visible.preload(:repository, :user).to_a + changesets.reverse! if User.current.wants_comments_in_reverse_order? + render :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets} + end + end + # Bulk edit/copy a set of issues def bulk_edit @issues.sort! diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 3068afe09..300111330 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -557,8 +557,9 @@ module IssuesHelper tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any? tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any? end - tabs << {:name => 'time_entries', :label => :label_time_entry_plural, :partial => 'issues/tabs/time_entries', :locals => {:time_entries => @time_entries}} if User.current.allowed_to?(:view_time_entries, @project) && @issue.spent_hours > 0 - tabs << {:name => 'changesets', :label => :label_associated_revisions, :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets}} if @changesets.present? + tabs << {:name => 'time_entries', :label => :label_time_entry_plural, :remote => true, :onclick => "getRemoteTab('time_entries', '#{tab_issue_path(@issue, :name => 'time_entries')}', '#{issue_path(@issue, :tab => 'time_entries')}')"} if User.current.allowed_to?(:view_time_entries, @project) && @issue.spent_hours > 0 + tabs << {:name => 'changesets', :label => :label_associated_revisions, :remote => true, :onclick => "getRemoteTab('changesets', '#{tab_issue_path(@issue, :name => 'changesets')}', '#{issue_path(@issue, :tab => 'changesets')}')"} if @has_changesets tabs end + end diff --git a/app/views/common/_tabs.html.erb b/app/views/common/_tabs.html.erb index df7513e42..def21ff45 100644 --- a/app/views/common/_tabs.html.erb +++ b/app/views/common/_tabs.html.erb @@ -18,10 +18,10 @@ <% tabs.each do |tab| -%> - <%= content_tag('div', render(:partial => tab[:partial], :locals => {:tab => tab} ), + <%= content_tag('div', (render(:partial => tab[:partial], :locals => {:tab => tab}) if tab[:partial]) , :id => "tab-content-#{tab[:name]}", :style => (tab[:name] != selected_tab ? 'display:none' : nil), - :class => 'tab-content') if tab[:partial] %> + :class => 'tab-content') if tab[:partial] || tab[:remote] %> <% end -%> <%= javascript_tag default_action if default_action %> diff --git a/app/views/issues/_changesets.html.erb b/app/views/issues/_changesets.html.erb deleted file mode 100644 index 3bd775c06..000000000 --- a/app/views/issues/_changesets.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -<% changesets.each do |changeset| %> -
<%= link_to_revision(changeset, changeset.repository,
- :text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
- <% if changeset.filechanges.any? && User.current.allowed_to?(:browse_repository, changeset.project) %>
- (<%= link_to(l(:label_diff),
- :controller => 'repositories',
- :action => 'diff',
- :id => changeset.project,
- :repository_id => changeset.repository.identifier_param,
- :path => "",
- :rev => changeset.identifier) %>)
- <% end %>
-
-