Skip to content

Commit

Permalink
[webui] Show superseded comments on request page
Browse files Browse the repository at this point in the history
to avoid opening the superseded requests in a seperate tab.
Requested by openSUSE review team.
  • Loading branch information
ChrisBr committed Oct 2, 2017
1 parent ef88d30 commit 7458c5a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
29 changes: 15 additions & 14 deletions src/api/app/assets/javascripts/webui/application/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ function sz(t) {
if (b > t.rows) t.rows = b;
}

function setup_comment_page() {
// setup toggle events
$('.togglable_comment').click(function () {
var toggleid = $(this).data("toggle");
$("#" + toggleid).toggle();
});

// prevent duplicate comment submissions
$('.comment_new').submit(function() {
$(this).find('input[type="submit"]').prop('disabled', true);
});
}

$(document).ready(function(){
$('a.delete_link').on('ajax:success', function(event, data, status, xhr){
$('#flash-messages').remove();
Expand All @@ -33,4 +20,18 @@ $(document).ready(function(){
$('#flash-messages').remove();
$(response.flash).filter('#flash-messages').insertAfter('#subheader').fadeIn('slow');
});
});
$('a.supersed_comments_link').on('click', function(){
var link = $(this).text();
$(this).text(link == 'Show outdated comments' ? 'Hide outdated comments' : 'Show outdated comments');
$(this).parent().siblings('.superseded_comments').toggle();
});
$('.togglable_comment').click(function () {
var toggleid = $(this).data("toggle");
$("#" + toggleid).toggle();
});

// prevent duplicate comment submissions
$('.comment_new').submit(function() {
$(this).find('input[type="submit"]').prop('disabled', true);
});
});
4 changes: 1 addition & 3 deletions src/api/app/views/webui/comment/_show.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.comments
- @comments.walk_tree do |comment, level|
- commentable.comments.walk_tree do |comment, level|
%div{class: "comment thread_level_#{level >= 4 ? 4 : level}"}
= user_with_realname_and_icon(comment.user, no_icon: true, short: true)
wrote
Expand All @@ -10,5 +10,3 @@
= render partial: 'webui/comment/reply', locals: { comment: comment, level: 0, commentable: commentable }
.comment_new.alpha.omega
= render partial: 'webui/comment/new', locals: { commentable: commentable }
- content_for :ready_function do
setup_comment_page();
10 changes: 10 additions & 0 deletions src/api/app/views/webui/request/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@

<div class="grid_16 alpha omega">
<div class="grid_10 alpha">
<% if @superseding %>
<% @superseding.each do |supersed| %>
<div class="grid_10 box box-shadow alpha omega">
<h2 class="box-header"><a class="supersed_comments_link">Show outdated comments</a>for superseded <%= link_to "request #{supersed.number}", number: supersed.number %></h2>
<div class="superseded_comments hidden">
<%= render :partial => 'webui/comment/show', locals: { commentable: supersed } %>
</div>
</div>
<% end %>
<% end %>

<div class="grid_10 box box-shadow alpha omega">
<h2 class="box-header">Comments for request <%= @number %> (<%= @comments.length %>)</h2>
Expand Down

0 comments on commit 7458c5a

Please sign in to comment.