2009-01-16 16:19:26 +01:00
|
|
|
class ArticleCategoriesController < ApplicationController
|
|
|
|
|
|
|
|
before_filter :authenticate_article_meta
|
2009-01-18 17:42:51 +01:00
|
|
|
|
|
|
|
def index
|
|
|
|
@article_categories = ArticleCategory.all :order => 'name'
|
|
|
|
end
|
|
|
|
|
2009-01-16 16:19:26 +01:00
|
|
|
def new
|
|
|
|
@article_category = ArticleCategory.new
|
|
|
|
|
|
|
|
render :update do |page|
|
|
|
|
page['category_form'].replace_html :partial => 'article_categories/form'
|
|
|
|
page['category_form'].show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@article_category = ArticleCategory.find(params[:id])
|
|
|
|
|
|
|
|
render :update do |page|
|
|
|
|
page['category_form'].replace_html :partial => 'article_categories/form'
|
|
|
|
page['category_form'].show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@article_category = ArticleCategory.new(params[:article_category])
|
|
|
|
|
|
|
|
if @article_category.save
|
|
|
|
render :update do |page|
|
|
|
|
page['category_form'].hide
|
|
|
|
page['category_list'].replace_html :partial => 'article_categories/list'
|
|
|
|
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
|
|
|
|
:duration => 2)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
render :update do |page|
|
|
|
|
page['category_form'].replace_html :partial => 'article_categories/form'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@article_category = ArticleCategory.find(params[:id])
|
|
|
|
|
|
|
|
if @article_category.update_attributes(params[:article_category])
|
|
|
|
render :update do |page|
|
|
|
|
page['category_form'].hide
|
|
|
|
page['category_list'].replace_html :partial => 'article_categories/list'
|
|
|
|
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
|
|
|
|
:duration => 2)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
render :update do |page|
|
|
|
|
page['category_form'].replace_html :partial => 'article_categories/form'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@article_category = ArticleCategory.find(params[:id])
|
|
|
|
@article_category.destroy
|
|
|
|
|
|
|
|
if @article_category.destroy
|
|
|
|
render :update do |page|
|
2010-05-28 12:01:19 +02:00
|
|
|
page['category_'+@article_category.id.to_s].visual_effect :drop_out
|
2009-01-16 16:19:26 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|