Commit 8541776f authored by jplang's avatar jplang

Show issue history in tabs (#3058).

Patch by Marius BALTEANU.

git-svn-id: https://svn.redmine.org/redmine/trunk@18272 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 59d850a8
......@@ -545,4 +545,18 @@ module IssuesHelper
end
end
end
# Issue history tabs
def issue_history_tabs()
tabs = []
if @journals.present?
journals_without_notes = @journals.select{|value| value.notes.blank?}
journals_with_notes = @journals.reject{|value| value.notes.blank?}
tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'history', :locals => {:issue => @issue, :journals => @journals}}
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
end
end
<%
issue = tab[:locals][:issue]
journals = tab[:locals][:journals]
%>
<% reply_links = issue.notes_addable? -%>
<% for journal in journals %>
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
......
......@@ -129,12 +129,12 @@ end %>
</div>
<% end %>
<% if @journals.present? %>
<%= render partial: 'action_menu_edit' if User.current.wants_comments_in_reverse_order? %>
<div id="history">
<h3><%=l(:label_history)%></h3>
<%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
<%= render_tabs issue_history_tabs, params[:tab] ? params[:tab] : 'notes' %>
</div>
<% end %>
<%= render partial: 'action_menu_edit' unless User.current.wants_comments_in_reverse_order? %>
......
......@@ -1056,6 +1056,8 @@ en:
label_open_trackers_description: View all trackers description
label_preferred_body_part_text: Text
label_preferred_body_part_html: HTML (experimental)
label_issue_history_properties: Property changes
label_issue_history_notes: Notes
button_login: Login
button_submit: Submit
......
......@@ -353,12 +353,44 @@ function showTab(name, url) {
$('#tab-content-' + name).show();
$('#tab-' + name).closest('.tabs').find('a').removeClass('selected');
$('#tab-' + name).addClass('selected');
//replaces current URL with the "href" attribute of the current link
//(only triggered if supported by browser)
replaceInHistory(url)
return false;
}
function showIssueHistory(journal, url) {
tab_content = $('#tab-content-history');
tab_content.parent().find('.tab-content').hide();
tab_content.show();
tab_content.parent().find('div.tabs a').removeClass('selected');
$('#tab-' + journal).addClass('selected');
replaceInHistory(url)
switch(journal) {
case 'notes':
tab_content.find('.journal:not(.has-notes)').hide();
tab_content.find('.journal.has-notes').show();
break;
case 'properties':
tab_content.find('.journal.has-notes').hide();
tab_content.find('.journal:not(.has-notes)').show();
break;
default:
tab_content.find('.journal').show();
}
return false;
}
//replaces current URL with the "href" attribute of the current link
//(only triggered if supported by browser)
function replaceInHistory(url) {
if ("replaceState" in window.history) {
window.history.replaceState(null, document.title, url);
}
return false;
}
function moveTabRight(el) {
......
......@@ -2481,6 +2481,60 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select 'a', :text => 'Delete', :count => 0
end
def test_show_should_not_display_history_tabs_for_issue_without_journals
@request.session[:user_id] = 1
get :show, :params => {:id => 5}
assert_response :success
assert_select '#history div.tabs', 0
assert_select '#history p.nodata', :text => 'No data to display'
end
def test_show_display_only_all_and_notes_tabs_for_issue_with_notes_only
@request.session[:user_id] = 1
get :show, :params => {:id => 6}
assert_response :success
assert_select '#history' do
assert_select 'div.tabs ul a', 2
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History'
assert_select 'div.tabs a[id=?]', 'tab-notes', :text => 'Notes'
end
end
def test_show_display_only_all_and_history_tabs_for_issue_with_history_changes_only
journal = Journal.create!(:journalized => Issue.find(5), :user_id => 1)
detail = JournalDetail.create!(:journal => journal, :property => 'attr', :prop_key => 'description',
:old_value => 'Foo', :value => 'Bar')
@request.session[:user_id] = 1
get :show, :params => {:id => 5}
assert_response :success
assert_select '#history' do
assert_select 'div.tabs ul a', 2
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History'
assert_select 'div.tabs a[id=?]', 'tab-properties', :text => 'Property changes'
end
end
def test_show_display_all_notes_and_history_tabs_for_issue_with_notes_and_history_changes
journal = Journal.create!(:journalized => Issue.find(6), :user_id => 1)
detail = JournalDetail.create!(:journal => journal, :property => 'attr', :prop_key => 'description',
:old_value => 'Foo', :value => 'Bar')
@request.session[:user_id] = 1
get :show, :params => {:id => 6}
assert_response :success
assert_select '#history' do
assert_select 'div.tabs ul a', 3
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History'
assert_select 'div.tabs a[id=?]', 'tab-notes', :text => 'Notes'
assert_select 'div.tabs a[id=?]', 'tab-properties', :text => 'Property changes'
end
end
def test_get_new
@request.session[:user_id] = 2
get :new, :params => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment