Add Item#ancestors
This commit is contained in:
1 parent
e1440a79d8
commit
32e8bd108f
17 files changed
+60
-37
No files matched your search
@@ -10,7 +10,7 @@ class Admin::ComponentsController < ApplicationController
|
||||
def new
|
||||
@component = Component.new
|
||||
@component.is_published = true
|
||||
@component.parent_item_name = @parent_item.name
|
||||
@component.parent_name = @parent_item.name
|
||||
|
||||
@component.engine_name = 'Announcement' # only support Announcement now
|
||||
end
|
||||
@@ -24,7 +24,7 @@ class Admin::ComponentsController < ApplicationController
|
||||
|
||||
if @component.save
|
||||
flash[:notice] = 'Component was successfully created.'
|
||||
redirect_to admin_items_url( :parent_item_name => @component.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @component.parent_name )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -35,7 +35,7 @@ class Admin::ComponentsController < ApplicationController
|
||||
|
||||
if @component.update_attributes(params[:component])
|
||||
flash[:notice] = 'Component was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_item_name => @component.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @component.parent_name )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -47,7 +47,7 @@ class Admin::ComponentsController < ApplicationController
|
||||
|
||||
#TODO: destroy engine data
|
||||
|
||||
redirect_to admin_items_url( :parent_item_name => @component.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @component.parent_name )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5,13 +5,14 @@ class Admin::ItemsController < ApplicationController
|
||||
before_filter :find_snippets, :only => :index
|
||||
|
||||
def index
|
||||
@items = Item.all( :conditions => { :parent_item_name => @parent_item.name } )
|
||||
@items = Item.all( :conditions => { :parent_name => @parent_item.name } )
|
||||
@items.unshift Item.find_by_name("root") if @parent_item.name == 'root'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_snippets
|
||||
@snippets = Snippet.all( :conditions => { :parent_item_name => @parent_item.name } )
|
||||
@snippets = Snippet.all( :conditions => { :parent_name => @parent_item.name } )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -10,7 +10,7 @@ class Admin::LinksController < ApplicationController
|
||||
def new
|
||||
@link = Link.new
|
||||
@link.is_published = true
|
||||
@link.parent_item_name = @parent_item.name
|
||||
@link.parent_name = @parent_item.name
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -22,7 +22,7 @@ class Admin::LinksController < ApplicationController
|
||||
|
||||
if @link.save
|
||||
flash[:notice] = 'Link was successfully created.'
|
||||
redirect_to admin_items_url( :parent_item_name => @link.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -33,7 +33,7 @@ class Admin::LinksController < ApplicationController
|
||||
|
||||
if @link.update_attributes(params[:link])
|
||||
flash[:notice] = 'Link was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_item_name => @link.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -43,7 +43,7 @@ class Admin::LinksController < ApplicationController
|
||||
@link = Link.find(params[:id])
|
||||
@link.destroy
|
||||
|
||||
redirect_to admin_items_url( :parent_item_name => @link.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -10,7 +10,7 @@ class Admin::PagesController < ApplicationController
|
||||
def new
|
||||
@page = Page.new
|
||||
@page.is_published = true
|
||||
@page.parent_item_name = @parent_item.name
|
||||
@page.parent_name = @parent_item.name
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -22,7 +22,7 @@ class Admin::PagesController < ApplicationController
|
||||
|
||||
if @page.save
|
||||
flash[:notice] = 'Page was successfully created.'
|
||||
redirect_to admin_items_url( :parent_item_name => @page.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @page.parent_name )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -33,7 +33,7 @@ class Admin::PagesController < ApplicationController
|
||||
|
||||
if @page.update_attributes(params[:page])
|
||||
flash[:notice] = 'Page was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_item_name => @page.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @page.parent_name )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -43,7 +43,7 @@ class Admin::PagesController < ApplicationController
|
||||
@page = Page.find(params[:id])
|
||||
@page.destroy
|
||||
|
||||
redirect_to admin_items_url( :parent_item_name => @page.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @page.parent_name )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,7 +9,7 @@ class Admin::SnippetsController < ApplicationController
|
||||
|
||||
def new
|
||||
@snippet = Snippet.new
|
||||
@snippet.parent_item_name = @parent_item.name
|
||||
@snippet.parent_name = @parent_item.name
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -21,7 +21,7 @@ class Admin::SnippetsController < ApplicationController
|
||||
|
||||
if @snippet.save
|
||||
flash[:notice] = 'Snippet was successfully created.'
|
||||
redirect_to admin_items_url( :parent_item_name => @snippet.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @snippet.parent_name )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -32,7 +32,7 @@ class Admin::SnippetsController < ApplicationController
|
||||
|
||||
if @snippet.update_attributes(params[:snippet])
|
||||
flash[:notice] = 'Snippet was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_item_name => @snippet.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @snippet.parent_name )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -42,7 +42,7 @@ class Admin::SnippetsController < ApplicationController
|
||||
@snippet = Snippet.find(params[:id])
|
||||
@snippet.destroy
|
||||
|
||||
redirect_to admin_items_url( :parent_item_name => @snippet.parent_item_name )
|
||||
redirect_to admin_items_url( :parent_name => @snippet.parent_name )
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user