Skip to content

Commit

Permalink
add sort functionality to tag_for_author questions
Browse files Browse the repository at this point in the history
  • Loading branch information
noordean committed Feb 22, 2018
1 parent 1dfccf7 commit a72a334
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def show_for_author

@notes = nodes.where('node.nid NOT IN (?)', qids) if @node_type == 'note'
@questions = nodes.where('node.nid IN (?)', qids) if @node_type == 'questions'
ans_ques = Answer.where(uid: @user.id, accepted: true).includes(:node).map do |ans|
ans.node
end
@answered_questions = ans_ques.paginate(page: params[:page], per_page: 24)
@wikis = nodes if @node_type == 'wiki'
@nodes = nodes if @node_type == 'maps'
@title = "'" + @tagname.to_s + "' by " + params[:author]
Expand Down
25 changes: 23 additions & 2 deletions app/views/tag/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,24 @@

<% if @node_type == "questions" %>
<div class="tab-pane active" id="questions">
<%= render :partial => "questions/questions" %>
<div class="tab-pane" id="questions-tab">
<div class="btn-group text-center">
<a href="#asked-tab" class="btn btn-default active" data-toggle="tab">Asked</a>
<a href="#answered-tab" class="btn btn-default" data-toggle="tab">Answered</a>
</div>

<div class="tab-content">
<div class="tab-pane active" id="asked-tab">
<%= render :partial => "questions/questions" %>
</div>

<div class="tab-pane" id="answered-tab">
<% if @answered_questions %>
<%= render :partial => "users/answered" %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>

Expand Down Expand Up @@ -130,7 +147,11 @@
<hr />

</div>

<script type="text/javascript">
$('#questions .btn-group .btn').click(function(){
$(this).addClass('active').siblings().removeClass('active');
});
</script>
</div>
<%= stylesheet_link_tag "dashboard" %>
<%= javascript_include_tag "dashboard" %>

0 comments on commit a72a334

Please sign in to comment.