2010-01-14 10:30:53 +00:00
|
|
|
class Admin::ItemsController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
|
|
|
before_filter :find_parent_item
|
|
|
|
before_filter :find_snippets, :only => :index
|
|
|
|
|
|
|
|
def index
|
2010-02-22 07:27:11 +00:00
|
|
|
@items = Item.all( :conditions => { :parent_id => @parent_item.id } )
|
2010-01-18 07:52:52 +00:00
|
|
|
@items.unshift Item.find_by_name("root") if @parent_item.name == 'root'
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
2010-02-22 08:10:13 +00:00
|
|
|
def up
|
|
|
|
@item = Item.find(params[:id])
|
|
|
|
@item.move_higher
|
|
|
|
redirect_to admin_items_url( :parent_name => @item.parent_name )
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
@item = Item.find(params[:id])
|
|
|
|
@item.move_lower
|
|
|
|
redirect_to admin_items_url( :parent_name => @item.parent_name )
|
|
|
|
end
|
|
|
|
|
2010-01-14 10:30:53 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def find_snippets
|
2010-02-22 07:27:11 +00:00
|
|
|
@snippets = Snippet.all( :conditions => { :parent_id => @parent_item.id } )
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|