Feature #3058 » 0002-show-issue-history-in-tabs.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
| 542 | 542 |
end |
| 543 | 543 |
end |
| 544 | 544 |
end |
| 545 | ||
| 546 |
# Issue history tabs |
|
| 547 |
def issue_history_tabs() |
|
| 548 |
tabs = [] |
|
| 549 |
if @journals.present? |
|
| 550 |
journals_without_notes = @journals.select{|value| value.notes.blank?}
|
|
| 551 |
journals_with_notes = @journals.reject{|value| value.notes.blank?}
|
|
| 552 | ||
| 553 |
tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'history', :locals => {:issue => @issue, :journals => @journals}}
|
|
| 554 |
tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any?
|
|
| 555 |
tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any?
|
|
| 556 |
end |
|
| 557 |
tabs |
|
| 558 |
end |
|
| 545 | 559 |
end |
| app/views/issues/_history.html.erb | ||
|---|---|---|
| 1 |
<% |
|
| 2 |
issue = tab[:locals][:issue] |
|
| 3 |
journals = tab[:locals][:journals] |
|
| 4 |
%> |
|
| 5 | ||
| 1 | 6 |
<% reply_links = issue.notes_addable? -%> |
| 2 | 7 |
<% for journal in journals %> |
| 3 | 8 |
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>"> |
| app/views/issues/show.html.erb | ||
|---|---|---|
| 129 | 129 | |
| 130 | 130 |
<%= render partial: 'action_menu_edit' if User.current.wants_comments_in_reverse_order? %> |
| 131 | 131 | |
| 132 |
<% if @journals.present? %> |
|
| 133 | 132 |
<div id="history"> |
| 134 | 133 |
<h3><%=l(:label_history)%></h3> |
| 135 |
<%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
|
|
| 134 |
<%= render_tabs issue_history_tabs, params[:tab] ? params[:tab] : 'notes' %>
|
|
| 136 | 135 |
</div> |
| 137 |
<% end %> |
|
| 138 | 136 | |
| 139 | 137 |
<%= render partial: 'action_menu_edit' unless User.current.wants_comments_in_reverse_order? %> |
| 140 | 138 | |
| config/locales/en.yml | ||
|---|---|---|
| 1035 | 1035 |
label_font_proportional: Proportional font |
| 1036 | 1036 |
label_last_notes: Last notes |
| 1037 | 1037 |
label_nothing_to_preview: Nothing to preview |
| 1038 |
label_issue_history_properties: Property changes |
|
| 1039 |
label_issue_history_notes: Notes |
|
| 1038 | 1040 | |
| 1039 | 1041 |
button_login: Login |
| 1040 | 1042 |
button_submit: Submit |
| public/javascripts/application.js | ||
|---|---|---|
| 345 | 345 |
$('#tab-content-' + name).show();
|
| 346 | 346 |
$('#tab-' + name).closest('.tabs').find('a').removeClass('selected');
|
| 347 | 347 |
$('#tab-' + name).addClass('selected');
|
| 348 |
//replaces current URL with the "href" attribute of the current link |
|
| 349 |
//(only triggered if supported by browser) |
|
| 348 | ||
| 349 |
replaceInHistory(url) |
|
| 350 | ||
| 351 |
return false; |
|
| 352 |
} |
|
| 353 | ||
| 354 |
function showIssueHistory(journal, url) {
|
|
| 355 |
tab_content = $('#tab-content-history');
|
|
| 356 |
tab_content.parent().find('.tab-content').hide();
|
|
| 357 |
tab_content.show(); |
|
| 358 |
tab_content.parent().find('div.tabs a').removeClass('selected');
|
|
| 359 | ||
| 360 |
$('#tab-' + journal).addClass('selected');
|
|
| 361 | ||
| 362 |
replaceInHistory(url) |
|
| 363 | ||
| 364 |
switch(journal) {
|
|
| 365 |
case 'notes': |
|
| 366 |
tab_content.find('.journal:not(.has-notes)').hide();
|
|
| 367 |
tab_content.find('.journal.has-notes').show();
|
|
| 368 |
break; |
|
| 369 |
case 'properties': |
|
| 370 |
tab_content.find('.journal.has-notes').hide();
|
|
| 371 |
tab_content.find('.journal:not(.has-notes)').show();
|
|
| 372 |
break; |
|
| 373 |
default: |
|
| 374 |
tab_content.find('.journal').show();
|
|
| 375 |
} |
|
| 376 | ||
| 377 |
return false; |
|
| 378 |
} |
|
| 379 | ||
| 380 |
//replaces current URL with the "href" attribute of the current link |
|
| 381 |
//(only triggered if supported by browser) |
|
| 382 |
function replaceInHistory(url) {
|
|
| 350 | 383 |
if ("replaceState" in window.history) {
|
| 351 | 384 |
window.history.replaceState(null, document.title, url); |
| 352 | 385 |
} |
| 353 |
return false; |
|
| 354 | 386 |
} |
| 355 | 387 | |
| 356 | 388 |
function moveTabRight(el) {
|
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 2424 | 2424 |
assert_select 'a', :text => 'Delete', :count => 0 |
| 2425 | 2425 |
end |
| 2426 | 2426 | |
| 2427 |
def test_show_should_not_display_history_tabs_for_issue_without_journals |
|
| 2428 |
@request.session[:user_id] = 1 |
|
| 2429 | ||
| 2430 |
get :show, :params => {:id => 5}
|
|
| 2431 |
assert_response :success |
|
| 2432 |
assert_select '#history div.tabs', 0 |
|
| 2433 |
assert_select '#history p.nodata', :text => 'No data to display' |
|
| 2434 |
end |
|
| 2435 | ||
| 2436 |
def test_show_display_only_all_and_notes_tabs_for_issue_with_notes_only |
|
| 2437 |
@request.session[:user_id] = 1 |
|
| 2438 | ||
| 2439 |
get :show, :params => {:id => 6}
|
|
| 2440 |
assert_response :success |
|
| 2441 |
assert_select '#history' do |
|
| 2442 |
assert_select 'div.tabs ul a', 2 |
|
| 2443 |
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History' |
|
| 2444 |
assert_select 'div.tabs a[id=?]', 'tab-notes', :text => 'Notes' |
|
| 2445 |
end |
|
| 2446 |
end |
|
| 2447 | ||
| 2448 |
def test_show_display_only_all_and_history_tabs_for_issue_with_history_changes_only |
|
| 2449 |
journal = Journal.create!(:journalized => Issue.find(5), :user_id => 1) |
|
| 2450 |
detail = JournalDetail.create!(:journal => journal, :property => 'attr', :prop_key => 'description', |
|
| 2451 |
:old_value => 'Foo', :value => 'Bar') |
|
| 2452 | ||
| 2453 |
@request.session[:user_id] = 1 |
|
| 2454 | ||
| 2455 |
get :show, :params => {:id => 5}
|
|
| 2456 |
assert_response :success |
|
| 2457 |
assert_select '#history' do |
|
| 2458 |
assert_select 'div.tabs ul a', 2 |
|
| 2459 |
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History' |
|
| 2460 |
assert_select 'div.tabs a[id=?]', 'tab-properties', :text => 'Property changes' |
|
| 2461 |
end |
|
| 2462 |
end |
|
| 2463 | ||
| 2464 |
def test_show_display_all_notes_and_history_tabs_for_issue_with_notes_and_history_changes |
|
| 2465 |
journal = Journal.create!(:journalized => Issue.find(6), :user_id => 1) |
|
| 2466 |
detail = JournalDetail.create!(:journal => journal, :property => 'attr', :prop_key => 'description', |
|
| 2467 |
:old_value => 'Foo', :value => 'Bar') |
|
| 2468 | ||
| 2469 |
@request.session[:user_id] = 1 |
|
| 2470 | ||
| 2471 |
get :show, :params => {:id => 6}
|
|
| 2472 |
assert_response :success |
|
| 2473 |
assert_select '#history' do |
|
| 2474 |
assert_select 'div.tabs ul a', 3 |
|
| 2475 |
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History' |
|
| 2476 |
assert_select 'div.tabs a[id=?]', 'tab-notes', :text => 'Notes' |
|
| 2477 |
assert_select 'div.tabs a[id=?]', 'tab-properties', :text => 'Property changes' |
|
| 2478 |
end |
|
| 2479 |
end |
|
| 2480 | ||
| 2427 | 2481 |
def test_get_new |
| 2428 | 2482 |
@request.session[:user_id] = 2 |
| 2429 | 2483 |
get :new, :params => {
|