Skip to content

Commit

Permalink
Show the number of comments, attachments, versions on the tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hirayama-evolni committed Apr 28, 2014
1 parent e111312 commit 8df554d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/helpers/knowledgebase_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def write_article(pdf, article)

def article_tabs
tabs = [{:name => 'content', :action => :content, :partial => 'articles/sections/content', :label => :label_content},
{:name => 'comments', :action => :comments, :partial => 'articles/sections/comments', :label => :label_comment_plural},
{:name => 'attachments', :action => :attachments, :partial => 'articles/sections/attachments', :label => :label_attachment_plural},
{:name => 'history', :action => :history, :partial => 'articles/sections/history', :label => :label_history}
{:name => 'comments', :action => :comments, :partial => 'articles/sections/comments', :label => :label_comment_plural, :count => @comments.length},
{:name => 'attachments', :action => :attachments, :partial => 'articles/sections/attachments', :label => :label_attachment_plural, :count => @attachments.length},
{:name => 'history', :action => :history, :partial => 'articles/sections/history', :label => :label_history, :count => @versions.length}
]
# TODO permissions?
# tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
Expand Down
26 changes: 26 additions & 0 deletions app/views/common/_tabs.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="tabs">
<ul>
<% tabs.each do |tab| -%>
<li><%= link_to l(tab[:label])+(tab.has_key?(:count) ? "(#{tab[:count]})" : ""), { :tab => tab[:name] },
:id => "tab-#{tab[:name]}",
:class => (tab[:name] != selected_tab ? nil : 'selected'),
:onclick => "showTab('#{tab[:name]}', this.href); this.blur(); return false;" %></li>
<% end -%>
</ul>
<div class="tabs-buttons" style="display:none;">
<button class="tab-left" onclick="moveTabLeft(this);"></button>
<button class="tab-right" onclick="moveTabRight(this);"></button>
</div>
</div>

<script>
$(document).ready(displayTabsButtons);
$(window).resize(displayTabsButtons);
</script>

<% tabs.each do |tab| -%>
<%= content_tag('div', render(:partial => tab[:partial], :locals => {:tab => tab} ),
:id => "tab-content-#{tab[:name]}",
:style => (tab[:name] != selected_tab ? 'display:none' : nil),
:class => 'tab-content') %>
<% end -%>

0 comments on commit 8df554d

Please sign in to comment.