2010-01-14 10:30:53 +00:00
|
|
|
class Admin::ComponentsController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
|
|
|
before_filter :find_parent_item
|
|
|
|
|
|
|
|
def show
|
|
|
|
#TODO
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@component = Component.new
|
|
|
|
@component.is_published = true
|
2010-01-18 07:52:52 +00:00
|
|
|
@component.parent_name = @parent_item.name
|
2010-01-14 10:30:53 +00:00
|
|
|
|
|
|
|
@component.engine_name = 'Announcement' # only support Announcement now
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@component = Component.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@component = Component.new(params[:component])
|
|
|
|
|
|
|
|
if @component.save
|
|
|
|
flash[:notice] = 'Component was successfully created.'
|
2010-01-18 07:52:52 +00:00
|
|
|
redirect_to admin_items_url( :parent_name => @component.parent_name )
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
|
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@component = Component.find(params[:id])
|
|
|
|
|
|
|
|
if @component.update_attributes(params[:component])
|
|
|
|
flash[:notice] = 'Component was successfully updated.'
|
2010-01-18 07:52:52 +00:00
|
|
|
redirect_to admin_items_url( :parent_name => @component.parent_name )
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
|
|
|
render :action => "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@component = Component.find(params[:id])
|
|
|
|
@component.destroy
|
|
|
|
|
|
|
|
#TODO: destroy engine data
|
|
|
|
|
2010-01-18 07:52:52 +00:00
|
|
|
redirect_to admin_items_url( :parent_name => @component.parent_name )
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|