Feature #3058 » 0002-show-issue-history-in-tabs.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
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
|
||
| app/views/issues/_history.html.erb | ||
|---|---|---|
|
<%
|
||
|
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 %>">
|
||
| app/views/issues/show.html.erb | ||
|---|---|---|
|
</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? %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
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
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
$('#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) {
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
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 => {
|
||