orbit-basic/app/controllers/admin/components_controller.rb

54 lines
1.2 KiB
Ruby

class Admin::ComponentsController < ApplicationController
layout "admin"
before_filter :find_parent_item
def show
#TODO
end
def new
@component = Component.new
@component.is_published = true
@component.parent_item_name = @parent_item.name
@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.'
redirect_to admin_items_url( :parent_item_name => @component.parent_item_name )
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.'
redirect_to admin_items_url( :parent_item_name => @component.parent_item_name )
else
render :action => "edit"
end
end
def destroy
@component = Component.find(params[:id])
@component.destroy
#TODO: destroy engine data
redirect_to admin_items_url( :parent_item_name => @component.parent_item_name )
end
end