2012-11-15 07:51:44 +00:00
|
|
|
class Admin::LinksController < Admin::ItemsController
|
2010-01-14 10:30:53 +00:00
|
|
|
|
|
|
|
def show
|
2011-05-25 06:50:56 +00:00
|
|
|
@item ||= Link.find(params[:id])
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Link.new
|
2012-02-17 06:54:11 +00:00
|
|
|
@item.parent = Page.find(params[:parent_id]) rescue nil
|
2013-04-11 19:13:03 +00:00
|
|
|
render layout: false
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Link.find(params[:id])
|
2013-04-11 19:13:03 +00:00
|
|
|
render layout: false
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Link.new(params[:link])
|
2010-01-14 10:30:53 +00:00
|
|
|
|
2011-05-25 06:50:56 +00:00
|
|
|
if @item.save
|
2012-09-12 11:12:50 +00:00
|
|
|
flash.now[:notice] = t('create.success.link')
|
2011-05-13 01:08:42 +00:00
|
|
|
respond_to do |format|
|
2013-04-11 19:13:03 +00:00
|
|
|
format.js { render 'admin/items/reload_items' }
|
2011-05-13 01:08:42 +00:00
|
|
|
end
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
2012-09-12 11:12:50 +00:00
|
|
|
flash.now[:error] = t('create.error.link')
|
2011-05-13 01:08:42 +00:00
|
|
|
render :action => "new"
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Link.find(params[:id])
|
2010-01-14 10:30:53 +00:00
|
|
|
|
2011-05-25 06:50:56 +00:00
|
|
|
if @item.update_attributes(params[:link])
|
2012-09-12 11:12:50 +00:00
|
|
|
flash.now[:notice] = t('update.success.link')
|
2011-05-13 01:08:42 +00:00
|
|
|
respond_to do |format|
|
2013-04-11 19:13:03 +00:00
|
|
|
format.js { render 'admin/items/reload_items' }
|
2011-05-13 01:08:42 +00:00
|
|
|
end
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
2012-09-12 11:12:50 +00:00
|
|
|
flash.now[:error] = t('update.error.link')
|
2010-01-14 10:30:53 +00:00
|
|
|
render :action => "edit"
|
|
|
|
end
|
|
|
|
end
|
2011-05-13 01:59:29 +00:00
|
|
|
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|