versionen wiederherstellen

This commit is contained in:
Andreas Stephanides
2013-09-09 12:24:49 +02:00
parent 0b42db42e8
commit 5cdc99d498
2 changed files with 33 additions and 12 deletions

View File

@@ -4,12 +4,17 @@ class NeuigkeitenController < ApplicationController
def show
@neuigkeit = Neuigkeit.find(params[:id])
if !params[:version].nil?
@neuigkeit.versions.reverse[params[:version].to_i].reify.save!
@neuigkeit=Neuigkeit.find(params[:id])
end
if params[:verwalten]
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } if can? :publish, @neuigkeit
@toolbar_elements << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } if can? :unpublish, @neuigkeit
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit
@versions= @neuigkeit.versions.select([:created_at]).reverse
@toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions}
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>"Sure?" } if can? :delete, @neuigkeit
else
@toolbar_elements << {:text=>I18n.t('common.verwalten'),:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit,{:verwalten=>true}),:icon=>:pencil} if can? :verwalten, @neuigkeit

View File

@@ -6,8 +6,24 @@ Verwendung: Aufruf mit
-->
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
<span class="label"><%= I18n.t("common.actions")%></span>
<div class="btn-group">
<% toolbar_elements.each do |t| %>
<% unless t[:method]==:versions %>
<% text='<i class="'.html_safe+ t[:hicon].to_s.html_safe + '"></i>'.html_safe+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") %>
<% else %>
<div class="btn-group">
<% toolbar_elements.each do |t| %>
<%= link_to '<i class="'.html_safe+ t[:hicon].to_s.html_safe + '"></i>'.html_safe+t[:text], t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") %>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Versionen<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<% t[:versions].each_with_index do |v,i| %>
<li>
<%= link_to v[:created_at], t[:path]+"?version=#{i}" ,:version=>v[:id]%>
</li>
<% end %>
</ul>
</div>
<% end %>
<% end %>
</div>