pagination update

This commit is contained in:
Andreas Stephanides
2014-09-24 14:39:59 +02:00
parent fc48959e48
commit a8dd419f9e
17 changed files with 109 additions and 57 deletions

View File

@@ -18,7 +18,7 @@ class BeispieleController < ApplicationController
# @lva = params([:lva]) unless params([:lva]).nil?
@beispiel = Beispiel.find(params[:id])
respond_to do |format|
format.html { redirect_to @beispiel.lva }
format.html { redirect_to lva_path(@beispiel.lva , show_comments: params[:show_comments])}
format.js
end
end

View File

@@ -1,10 +1,25 @@
class CommentsController < ApplicationController
def index
@comments=Comment.all
end
def index
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
@comments=@commentable.comments.order(:created_at).roots.page(params[:page]).per(2).reverse_order
respond_to do |format|
format.html # new.html.erb
format.json { render json: @comment }
format.js
end
end
def hide
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
respond_to do |format|
format.js
end
end
def show
@comment = Comment.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @comment }
@@ -33,15 +48,9 @@ class CommentsController < ApplicationController
c = params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
@comment = Comment.build_for(c, current_user,"", params_new)
#raise @comment.to_yaml.to_s
# @comment.commentable= c
respond_to do |format|
if @comment
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully created.' }
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully created.', show_comments: true }
format.json { render json: @comment, status: :created, location: @comment }
else
format.html { render action: "new" }
@@ -73,11 +82,13 @@ class CommentsController < ApplicationController
# DELETE /comments/1.json
def destroy
@comment = Comment.find(params[:id])
@commentable=@comment.commentable
@comment.destroy
respond_to do |format|
format.html { redirect_to comments_url }
format.html { redirect_to @commentable, :action=>"show"}
format.json { head :no_content }
end
end
end

View File

@@ -4,10 +4,10 @@ class RubrikenController < ApplicationController
def index
if can?(:showintern, Rubrik)
@rubriken = Rubrik.all
@neuigkeiten = Neuigkeit.paginate(page: params[:page], per_page:3)
@neuigkeiten = Neuigkeit.page(params[:page]).per(3)
else
@rubriken = Rubrik.where(:public=>true)
@neuigkeiten = Neuigkeit.public.published.paginate(page: params[:page], per_page:3)
@neuigkeiten = Neuigkeit.public.published.page(params[:page]).per(3)
end
@calentries= @rubriken.collect(&:calentries).flatten
@@ -31,9 +31,9 @@ class RubrikenController < ApplicationController
@moderatoren=User.with_role(:newsmoderator,@rubrik)
@calentries= @rubrik.calentries
if can?(:showunpublished, Neuigkeit)
@neuigkeiten = @rubrik.neuigkeiten.paginate(page: params[:page], per_page:3)
@neuigkeiten = @rubrik.neuigkeiten.page(params[:page]).per(3)
else
@neuigkeiten = @rubrik.neuigkeiten.published.paginate(page: params[:page], per_page:3)
@neuigkeiten = @rubrik.neuigkeiten.published..page(params[:page]).per(3)
end
@toolbar_elements << {:text=>I18n.t('neuigkeit.new.title'), :path=> new_rubrik_neuigkeit_path(@rubrik),:hicon=>'icon-plus-sign'} if can? :verwalten, @rubrik
@toolbar_elements << {:text=>I18n.t('common.verwalten'), :path=>verwalten_rubrik_path(@rubrik),:icon=>:pencil} if can? :verwalten, @rubrik

View File

@@ -18,6 +18,11 @@ class ThemenController < ApplicationController
format.js
end
end
def sanitize
@thema = Thema.find(params[:id])
@fragen=@thema.fragen
end
def verwalten
@thema = Thema.find(params[:id])
@attachment=Attachment.new