Files
fetsite/app/views/layouts/_pretty_toolbar.html.erb

60 lines
2.1 KiB
Plaintext

<!--
Verwendung: Aufruf mit
< % = render 'layouts/pretty_toolbar % > verwendet die Elemente die im Controller per @toolbar_elements vorgegeben werden. Sonst kann man über
< % = render :partial=>'layouts/pretty_toolbar', :object=>@foo % > einen beliebigen array @foo übergeben
-->
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
<% unless toolbar_elements.nil? || toolbar_elements.empty? %>
<!--<span class="label"><% I18n.t("common.actions")%></span>
--><div class="btn-group">
<% toolbar_elements.each do |t| %>
<% unless t[:method]==:versions %>
<% unless t[:method]==:dropdown %>
<% text=ff_icon(t[:hicon])+t[:text] %>
<%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %>
<% else %>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<%= t[:text] %><span class="caret"></span>
</a>
<ul class="dropdown-menu">
<% t[:elements].each do |t2| %>
<li>
<% text=ff_icon(t2[:hicon])+"&nbsp;".html_safe + t2[:text] %>
<%= link_to text, t2[:path], :method=>t2[:method], :confirm=>t2[:confirm].to_s, :data=>t2[:data], :class=>((t2[:method].to_s=='delete') ? "btn-danger" : "") ,:remote=>(t2[:remote])?true : false %>
</li>
<% end %>
</ul>
<% end %>
<% else %>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<%= I18n.t("common.versions") %><span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li> <%= link_to I18n.t("common.activeversion"), t[:path] %>
</li>
<% t[:versions].each_with_index do |v,i| %>
<li>
<% unless t[:path].nil?
uri= URI.parse(t[:path]);
q=[];
q= q.merge(URI.decode_www_form(uri.query)) unless uri.query.nil?
uri.query= URI.encode_www_form(q<<["version",i.to_s])
%>
<%= link_to I18n.l(v[:created_at]).to_s,uri.to_s ,:version=>v[:id] %>
<% end %>
</li>
<% end %>
</ul>
</div>
<% end %>
<% end %>
</div>
<% end %>