<% if can? :show, small %>
<a name="thema_<%=small.id%>" href="#<%=small.id%>">
<div itemscope itemtype="http://schema.org/Article">
<meta itemprop="sameAs" content="<%= thema_url(small, {theme:nil, locale:nil})%>"/>
  <h2><span itemprop="name"><%= link_to small.title,small %></span> 
<% if can?(:edit,small) %> 
<span> 	  
<div class="navbar-btn nav" style="display:inline">
  <%= link_to fa_icon("pencil"), verwalten_thema_path(small) , class: "btn btn-link navbar-btn" if can? :edit, small  %>
  <div class="btn-group">
    <button type="button" class="btn btn-link dropdown-toggle" data-hover="dropdown" aria-expanded="false">
      <%= fa_icon('plus') %>
    </button>
    <ul class="dropdown-menu" role="menu">	 
      <li><%= link_to ff_icon('ffi1-cleaning1')+" Neues Dokument", new_document_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
      </li>
      <li><%= link_to "Neues Meeting", new_meeting_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
</li>
<li><a href="#" onclick="$('#attachmentdialog_thema_<%= small.id %>').dialog('open')">Attachments</a>
</li>
</ul>	  
  </div></div>
</span>
<% end %></h2>
</a>
<%= image_tag small.titlepics.first.datei.url unless small.titlepics.first.nil? %>
<% if small.is_outdated? %>
<div class="sticker sticker-red"> <%= I18n.t("thema.outdated") %> <%= link_to"Als aktuell markieren",is_updated_thema_path(small), :class=>:btn if can? :is_updated, small%></div>
<% end %>
<% if small.isdraft %>
<div class="sticker sticker-yellow"><%= I18n.t("thema.isdraft") %>  </div>

<% end %><div>
<%= raw(small.text) %></div>
<br/>

<%= raw("<b>FAQs:</b>")  unless small.fragen.empty? %>
<br/>
<% small.fragen.each do |frage| %>
<p>
<b> <%= frage.title %> </b> <br/>
  <%= raw(frage.text) %>
</p>
<% end %>


<% if can?(:edit,small) %> 
<div id="<%= Meeting.new_divid_for(small) %>"></div>
<% if !small.meetings.empty? %>
<b>Treffen/Sitzungen</b>
<%= link_to "Neues Meeting", new_meeting_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
<div id="<%= Meeting.new_divid_for(small) %>"></div>
<ul class="nav nav-tabs">
<li><%= link_to "All", meetings_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true if small.meetings.accessible_by(current_ability).count >0 %></li>
<li><%= link_to "upcomming", meetings_path(:parent_id=>small.id, :parent_type=>"Thema",:filter=>"upcomming"), :remote=>true  if small.meetings.accessible_by(current_ability).upcomming.count >0 %></li>
</ul>
<%= render :partial=>"meetings/meeting_list", object: small.meetings, locals: {parent: small} %>
<% end %>
<% end %>


<% if can?(:edit,small) %>
<div id="<%= Document.new_divid_for(small) %>"></div>

<% unless small.documents.empty? %>
<b>Dokumente</b>
<%= link_to "Neues Dokument", new_document_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>



<% small.documents.each do |d| %>
<%= render d %>

<% end%>
<% end%>
<% end%>





<% unless small.hideattachment %>
<%= render partial: "attachments/attachment_list", object: small.attachments, locals:{editor: false, parent: small} unless small.attachments.empty? %>
<% end %>
<br/>


<% 
@small_elements = []
@small_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>small} if can? :edit, small 
@small_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('thema.remove'), :path=>small, :method=>:delete,:confirm=>I18n.t('thema.sure')} if can? :delete, small %>
<% render :partial=>'layouts/pretty_toolbar', :object=>@small_elements unless @small_elements.empty? %>
<% else %>
Error
<% end %>
</div>


<div id="attachmentdialog_thema_<%= small.id %>">	
<%= render_attachments_for(small) %>	  
</div>
<script>
  $(function() {
    $( "#attachmentdialog_thema_<%= small.id %>" ).dialog({autoOpen:false});
  });
  </script>
