forked from bofh/fetsite
pretty toolbar Neuigkeiten
This commit is contained in:
@@ -8,10 +8,13 @@ class NeuigkeitenController < ApplicationController
|
||||
|
||||
def show
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
if can? :edit, @neuigkeit
|
||||
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil}
|
||||
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>"Sure?" }
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> "publish",:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" }
|
||||
if params[:verwalten]
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> "publish",:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } if can? :publish, @neuigkeit
|
||||
|
||||
@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-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
|
||||
|
||||
end
|
||||
end
|
||||
@@ -26,7 +29,11 @@ class NeuigkeitenController < ApplicationController
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
@neuigkeit.publish
|
||||
@neuigkeit.save
|
||||
if params[:verwalten]
|
||||
redirect_to verwalten_rubrik_path(@neuigkeit.rubrik)
|
||||
end
|
||||
redirect_to @neuigkeit
|
||||
|
||||
end
|
||||
def edit
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
@@ -38,7 +45,7 @@ class NeuigkeitenController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @neuigkeit.save
|
||||
format.html { redirect_to @neuigkeit, notice: 'Neuigkeit was successfully created.' }
|
||||
format.html { redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit was successfully created.' }
|
||||
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
|
||||
@@ -22,7 +22,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
translates :title,:text, :versioning=>true, :fallbacks_for_empty_translations => true
|
||||
has_one :calentry, :as => :object
|
||||
mount_uploader :picture, PictureUploader
|
||||
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)}
|
||||
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order}
|
||||
scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)}
|
||||
def datum_nilsave
|
||||
self.datum.nil? ? Time.now + 42.years : self.datum
|
||||
|
||||
27
app/views/gremien/verwalten.html.erb
Normal file
27
app/views/gremien/verwalten.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h1>Listing gremien</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Desc</th>
|
||||
<th>Typ</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @gremien.each do |gremium| %>
|
||||
<tr>
|
||||
<td><%= gremium.name %></td>
|
||||
<td><%= gremium.desc %></td>
|
||||
<td><%= gremium.typ %></td>
|
||||
<td><%= link_to 'Show', gremium %></td>
|
||||
<td><%= link_to 'Edit', edit_gremium_path(gremium) %></td>
|
||||
<td><%= link_to 'Destroy', gremium, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Gremium', new_gremium_path %>
|
||||
@@ -8,6 +8,6 @@ Verwendung: Aufruf mit
|
||||
<span class="label"><%= I18n.t("common.actions")%></span>
|
||||
<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=>"btn" %>
|
||||
<%= 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") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= tinymce_assets %>
|
||||
<%= semantic_form_for @neuigkeit do |f| %>
|
||||
<%= semantic_form_for [@neuigkeit.rubrik,@neuigkeit] do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :title, :placeholder=>"Titel" %>
|
||||
<%= f.input :text, :as=>:tinymce_text %>
|
||||
|
||||
@@ -29,4 +29,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= toolbar_html (@toolbar_elements) %>
|
||||
<%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %>
|
||||
|
||||
Reference in New Issue
Block a user