forked from bofh/fetsite
versionen wiederherstellen
This commit is contained in:
@@ -3,16 +3,21 @@ class NeuigkeitenController < ApplicationController
|
|||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@neuigkeit = Neuigkeit.find(params[:id])
|
@neuigkeit = Neuigkeit.find(params[:id])
|
||||||
if params[:verwalten]
|
if !params[:version].nil?
|
||||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } if can? :publish, @neuigkeit
|
@neuigkeit.versions.reverse[params[:version].to_i].reify.save!
|
||||||
@toolbar_elements << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } if can? :unpublish, @neuigkeit
|
@neuigkeit=Neuigkeit.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:verwalten]
|
||||||
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit
|
@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-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>"Sure?" } if can? :delete, @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
|
||||||
|
@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
|
else
|
||||||
@toolbar_elements << {:text=>I18n.t('common.verwalten'),:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit,{:verwalten=>true}),:icon=>:pencil} if can? :verwalten, @neuigkeit
|
@toolbar_elements << {:text=>I18n.t('common.verwalten'),:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit,{:verwalten=>true}),:icon=>:pencil} if can? :verwalten, @neuigkeit
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,8 +6,24 @@ Verwendung: Aufruf mit
|
|||||||
-->
|
-->
|
||||||
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
|
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
|
||||||
<span class="label"><%= I18n.t("common.actions")%></span>
|
<span class="label"><%= I18n.t("common.actions")%></span>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<% toolbar_elements.each do |t| %>
|
<% 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") %>
|
<% unless t[:method]==:versions %>
|
||||||
<% end %>
|
<% 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">
|
||||||
|
<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>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user