diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2019-06-20 07:12:30 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2019-06-20 07:12:30 +0000 |
commit | 94c2356f383000cea42072a94b351f79ff4567d4 (patch) | |
tree | a1162b7ee00ddd498d1cb52d3d6299fd9bde9b08 /app | |
parent | 0714ced81572a1501d37bc866855a7f339c3bf03 (diff) | |
download | redmine-94c2356f383000cea42072a94b351f79ff4567d4.tar.gz redmine-94c2356f383000cea42072a94b351f79ff4567d4.zip |
Load changesets and time entries tabs async (#3058).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@18275 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/issues_controller.rb | 29 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 5 | ||||
-rw-r--r-- | app/views/common/_tabs.html.erb | 4 | ||||
-rw-r--r-- | app/views/issues/_changesets.html.erb | 20 | ||||
-rw-r--r-- | app/views/issues/tabs/_changesets.html.erb | 2 | ||||
-rw-r--r-- | app/views/issues/tabs/_time_entries.html.erb | 2 |
6 files changed, 29 insertions, 33 deletions
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 @@ </div> <% 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| %> - <div class="changeset"> - <p><%= 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 %> - <br /> - <span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> - <div class="wiki changeset-comments"> - <%= format_changeset_comments changeset %> - </div> - </div> -<% end %> diff --git a/app/views/issues/tabs/_changesets.html.erb b/app/views/issues/tabs/_changesets.html.erb index 7e2b01a3d..f869a5da2 100644 --- a/app/views/issues/tabs/_changesets.html.erb +++ b/app/views/issues/tabs/_changesets.html.erb @@ -1,4 +1,4 @@ -<% tab[:locals][:changesets].each do |changeset| %> +<% @changesets.each do |changeset| %> <div id="changeset-<%= changeset.id %>" class="changeset journal"> <h4> <%= avatar(changeset.user, :size => "24") %> diff --git a/app/views/issues/tabs/_time_entries.html.erb b/app/views/issues/tabs/_time_entries.html.erb index 931a8df39..c34edc074 100644 --- a/app/views/issues/tabs/_time_entries.html.erb +++ b/app/views/issues/tabs/_time_entries.html.erb @@ -1,4 +1,4 @@ -<% for time_entry in tab[:locals][:time_entries] %> +<% for time_entry in time_entries%> <div id="time-entry-<%= time_entry.id %>" class="time_entry journal"> <% if time_entry.editable_by?(User.current) -%> <div class="contextual"> |