2013-03-06 07:16:20 +00:00
|
|
|
class Admin::ItemsController < OrbitBackendController
|
2013-10-30 10:53:23 +00:00
|
|
|
include ActionView::Helpers::TagHelper
|
2013-10-23 10:28:09 +00:00
|
|
|
include ActionView::Helpers::DynamicForm
|
2010-01-14 10:30:53 +00:00
|
|
|
|
2013-07-02 08:46:44 +00:00
|
|
|
layout "structure"
|
|
|
|
|
2013-10-18 03:38:30 +00:00
|
|
|
open_for_admin
|
2010-01-14 10:30:53 +00:00
|
|
|
|
|
|
|
def index
|
2011-05-09 10:49:57 +00:00
|
|
|
if params[:item_id]
|
2011-05-13 01:08:42 +00:00
|
|
|
@item = Item.find(params[:item_id])
|
2011-05-09 10:49:57 +00:00
|
|
|
else
|
2011-09-01 01:12:41 +00:00
|
|
|
@item = get_homepage
|
2011-05-09 10:49:57 +00:00
|
|
|
end
|
2010-02-22 08:10:13 +00:00
|
|
|
end
|
2012-05-11 02:00:45 +00:00
|
|
|
|
2013-07-02 08:46:44 +00:00
|
|
|
def destroy
|
|
|
|
@item = Item.find(params[:id])
|
|
|
|
@item.destroy
|
|
|
|
respond_to do |format|
|
|
|
|
format.js { render 'admin/items/reload_items' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-11 02:00:45 +00:00
|
|
|
def update_position
|
2012-05-11 09:56:26 +00:00
|
|
|
item = Item.find(params[:id])
|
2013-11-04 14:20:50 +00:00
|
|
|
item.shift_to(params[:parent_id], params[:position].to_i, params[:next_sibling_id])
|
2013-10-07 07:52:10 +00:00
|
|
|
render :nothing => true, status: 200
|
2012-05-11 02:00:45 +00:00
|
|
|
end
|
2013-10-23 07:51:49 +00:00
|
|
|
|
|
|
|
def get_page_design_module_json
|
|
|
|
designs = Design.all.inject([]) do |designs, design|
|
|
|
|
d = {}
|
|
|
|
d["main"] = [design.title, design.id.to_s, (design.site.present? ? 1 : 0)]
|
|
|
|
d["sub"] = design.themes.map{|theme| [theme.name, theme.id.to_s]} rescue ''
|
|
|
|
designs << d
|
|
|
|
end
|
|
|
|
modules = ModuleApp.for_frontend_select.inject([]) do |module_apps, module_app|
|
|
|
|
m = {}
|
2013-10-29 03:17:02 +00:00
|
|
|
m["main"] = [module_app.label, module_app.id.to_s]
|
2013-10-23 07:51:49 +00:00
|
|
|
m["sub"] = module_app.app_pages.map{|name, data| [t(data["i18n"]), name]} rescue []
|
2013-10-27 16:59:38 +00:00
|
|
|
m["sub"] << [I18n.t('default_widget.default_widget'),'default_widget'] if module_app.has_default_widget?
|
2013-11-15 08:58:11 +00:00
|
|
|
m["category"] = module_app.categories.map{|category| [category.title, category.id.to_s] } rescue ''
|
|
|
|
m["tags"] = module_app.tags.map{|tag| [tag.name, tag.id.to_s] } rescue ''
|
2013-10-23 07:51:49 +00:00
|
|
|
m["count"] = module_app.get_registration.get_data_count.to_a
|
|
|
|
module_apps << m
|
|
|
|
end
|
|
|
|
render json: JSON.pretty_generate({design: designs, module: modules})
|
|
|
|
end
|
2010-02-22 08:10:13 +00:00
|
|
|
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|