Feature #3058 » 0002-show-issue-history-in-tabs.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
| 545 | 545 |
end |
| 546 | 546 |
end |
| 547 | 547 |
end |
| 548 | ||
| 549 |
# Issue history tabs |
|
| 550 |
def issue_history_tabs() |
|
| 551 |
tabs = [] |
|
| 552 |
if @journals.present? |
|
| 553 |
journals_without_notes = @journals.select{|value| value.notes.blank?}
|
|
| 554 |
journals_with_notes = @journals.reject{|value| value.notes.blank?}
|
|
| 555 | ||
| 556 |
tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'history', :locals => {:issue => @issue, :journals => @journals}}
|
|
| 557 |
tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any?
|
|
| 558 |
tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any?
|
|
| 559 |
end |
|
| 560 |
tabs |
|
| 561 |
end |
|
| 548 | 562 |
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 |
</div> |
| 130 | 130 |
<% end %> |
| 131 | 131 | |
| 132 |
<% if @journals.present? %> |
|
| 132 |
<%= render partial: 'action_menu_edit' if User.current.wants_comments_in_reverse_order? %> |
|
| 133 | ||
| 133 | 134 |
<div id="history"> |
| 134 | 135 |
<h3><%=l(:label_history)%></h3> |
| 135 |
<%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
|
|
| 136 |
<%= render_tabs issue_history_tabs, params[:tab] ? params[:tab] : 'notes' %>
|
|
| 136 | 137 |
</div> |
| 137 |
<% end %> |
|
| 138 | 138 | |
| 139 | 139 |
<%= render partial: 'action_menu_edit' unless User.current.wants_comments_in_reverse_order? %> |
| 140 | 140 | |
| config/locales/en.yml | ||
|---|---|---|
| 1056 | 1056 |
label_open_trackers_description: View all trackers description |
| 1057 | 1057 |
label_preferred_body_part_text: Text |
| 1058 | 1058 |
label_preferred_body_part_html: HTML (experimental) |
| 1059 |
label_issue_history_properties: Property changes |
|
| 1060 |
label_issue_history_notes: Notes |
|
| 1059 | 1061 | |
| 1060 | 1062 |
button_login: Login |
| 1061 | 1063 |
button_submit: Submit |
| public/javascripts/application.js | ||
|---|---|---|
| 353 | 353 |
$('#tab-content-' + name).show();
|
| 354 | 354 |
$('#tab-' + name).closest('.tabs').find('a').removeClass('selected');
|
| 355 | 355 |
$('#tab-' + name).addClass('selected');
|
| 356 |
//replaces current URL with the "href" attribute of the current link |
|
| 357 |
//(only triggered if supported by browser) |
|
| 356 | ||
| 357 |
replaceInHistory(url) |
|
| 358 | ||
| 359 |
return false; |
|
| 360 |
} |
|
| 361 | ||
| 362 |
function showIssueHistory(journal, url) {
|
|
| 363 |
tab_content = $('#tab-content-history');
|
|
| 364 |
tab_content.parent().find('.tab-content').hide();
|
|
| 365 |
tab_content.show(); |
|
| 366 |
tab_content.parent().find('div.tabs a').removeClass('selected');
|
|
| 367 | ||
| 368 |
$('#tab-' + journal).addClass('selected');
|
|
| 369 | ||
| 370 |
replaceInHistory(url) |
|
| 371 | ||
| 372 |
switch(journal) {
|
|
| 373 |
case 'notes': |
|
| 374 |
tab_content.find('.journal:not(.has-notes)').hide();
|
|
| 375 |
tab_content.find('.journal.has-notes').show();
|
|
| 376 |
break; |
|
| 377 |
case 'properties': |
|
| 378 |
tab_content.find('.journal.has-notes').hide();
|
|
| 379 |
tab_content.find('.journal:not(.has-notes)').show();
|
|
| 380 |
break; |
|
| 381 |
default: |
|
| 382 |
tab_content.find('.journal').show();
|
|
| 383 |
} |
|
| 384 | ||
| 385 |
return false; |
|
| 386 |
} |
|
| 387 | ||
| 388 |
//replaces current URL with the "href" attribute of the current link |
|
| 389 |
//(only triggered if supported by browser) |
|
| 390 |
function replaceInHistory(url) {
|
|
| 358 | 391 |
if ("replaceState" in window.history) {
|
| 359 | 392 |
window.history.replaceState(null, document.title, url); |
| 360 | 393 |
} |
| 361 |
return false; |
|
| 362 | 394 |
} |
| 363 | 395 | |
| 364 | 396 |
function moveTabRight(el) {
|
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 2459 | 2459 |
assert_select 'a', :text => 'Delete', :count => 0 |
| 2460 | 2460 |
end |
| 2461 | 2461 | |
| 2462 |
def test_show_should_not_display_history_tabs_for_issue_without_journals |
|
| 2463 |
@request.session[:user_id] = 1 |
|
| 2464 | ||
| 2465 |
get :show, :params => {:id => 5}
|
|
| 2466 |
assert_response :success |
|
| 2467 |
assert_select '#history div.tabs', 0 |
|
| 2468 |
assert_select '#history p.nodata', :text => 'No data to display' |
|
| 2469 |
end |
|
| 2470 | ||
| 2471 |
def test_show_display_only_all_and_notes_tabs_for_issue_with_notes_only |
|
| 2472 |
@request.session[:user_id] = 1 |
|
| 2473 | ||
| 2474 |
get :show, :params => {:id => 6}
|
|
| 2475 |
assert_response :success |
|
| 2476 |
assert_select '#history' do |
|
| 2477 |
assert_select 'div.tabs ul a', 2 |
|
| 2478 |
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History' |
|
| 2479 |
assert_select 'div.tabs a[id=?]', 'tab-notes', :text => 'Notes' |
|
| 2480 |
end |
|
| 2481 |
end |
|
| 2482 | ||
| 2483 |
def test_show_display_only_all_and_history_tabs_for_issue_with_history_changes_only |
|
| 2484 |
journal = Journal.create!(:journalized => Issue.find(5), :user_id => 1) |
|
| 2485 |
detail = JournalDetail.create!(:journal => journal, :property => 'attr', :prop_key => 'description', |
|
| 2486 |
:old_value => 'Foo', :value => 'Bar') |
|
| 2487 | ||
| 2488 |
@request.session[:user_id] = 1 |
|
| 2489 | ||
| 2490 |
get :show, :params => {:id => 5}
|
|
| 2491 |
assert_response :success |
|
| 2492 |
assert_select '#history' do |
|
| 2493 |
assert_select 'div.tabs ul a', 2 |
|
| 2494 |
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History' |
|
| 2495 |
assert_select 'div.tabs a[id=?]', 'tab-properties', :text => 'Property changes' |
|
| 2496 |
end |
|
| 2497 |
end |
|
| 2498 | ||
| 2499 |
def test_show_display_all_notes_and_history_tabs_for_issue_with_notes_and_history_changes |
|
| 2500 |
journal = Journal.create!(:journalized => Issue.find(6), :user_id => 1) |
|
| 2501 |
detail = JournalDetail.create!(:journal => journal, :property => 'attr', :prop_key => 'description', |
|
| 2502 |
:old_value => 'Foo', :value => 'Bar') |
|
| 2503 | ||
| 2504 |
@request.session[:user_id] = 1 |
|
| 2505 | ||
| 2506 |
get :show, :params => {:id => 6}
|
|
| 2507 |
assert_response :success |
|
| 2508 |
assert_select '#history' do |
|
| 2509 |
assert_select 'div.tabs ul a', 3 |
|
| 2510 |
assert_select 'div.tabs a[id=?]', 'tab-history', :text => 'History' |
|
| 2511 |
assert_select 'div.tabs a[id=?]', 'tab-notes', :text => 'Notes' |
|
| 2512 |
assert_select 'div.tabs a[id=?]', 'tab-properties', :text => 'Property changes' |
|
| 2513 |
end |
|
| 2514 |
end |
|
| 2515 | ||
| 2462 | 2516 |
def test_get_new |
| 2463 | 2517 |
@request.session[:user_id] = 2 |
| 2464 | 2518 |
get :new, :params => {
|