Structure page with json
This commit is contained in:
1 parent
6d5f1a2f12
commit
a4d1c68299
15 files changed
+470
-144
No files matched your search
@@ -25,5 +25,25 @@ class Admin::ItemsController < OrbitBackendController
|
||||
item.shift_to(params[:parent_id], params[:position].to_i)
|
||||
render :nothing => true, status: 200
|
||||
end
|
||||
|
||||
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 = {}
|
||||
m["main"] = [module_app.title, module_app.id.to_s]
|
||||
m["sub"] = module_app.app_pages.map{|name, data| [t(data["i18n"]), name]} rescue []
|
||||
m["sub"] << [I18n.t('default_widget.name'),'default_widget'] if module_app.has_default_widget?
|
||||
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 ''
|
||||
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
|
||||
|
||||
end
|
||||
@@ -2,6 +2,8 @@ class Admin::PagesController < Admin::ItemsController
|
||||
helper Admin::PagePartsHelper
|
||||
include Admin::FrontendWidgetInterface
|
||||
|
||||
include ActionView::Helpers::DynamicForm
|
||||
|
||||
def show
|
||||
@item = Page.find(params[:id])
|
||||
@no_orbit_bar = true
|
||||
@@ -128,18 +130,35 @@ class Admin::PagesController < Admin::ItemsController
|
||||
def update
|
||||
clean_tags_and_category_params
|
||||
@item = Page.find(params[:id])
|
||||
|
||||
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
|
||||
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
||||
end
|
||||
if @item.update_attributes(params[:page])
|
||||
flash[:notice] = t('update.success.page')
|
||||
respond_to do |format|
|
||||
format.js { render 'admin/items/reload_items' }
|
||||
unless @item.update_attributes(params[:page])
|
||||
@error = error_messages_for(@item)
|
||||
end
|
||||
end
|
||||
|
||||
def get_display_style
|
||||
|
||||
end
|
||||
|
||||
def get_page_setting_json
|
||||
begin
|
||||
page = Page.find(params[:id])
|
||||
design = {main: page.design_id.to_s, sub: page.theme_id.to_s}
|
||||
m = {}
|
||||
m["main"] = page.module_app_id.to_s
|
||||
m["sub"] = page.app_frontend_url
|
||||
m["category"] = page.category.present? ? [0, page.category.map{|c| c.to_s}] : [1]
|
||||
m["tags"] = page.tag.present? ? [0, page.tag.map{|c| c.to_s}] : [1]
|
||||
m["public"] = page.is_published ? 1 : 0
|
||||
m["link"] = @site_valid_locales.inject([]) do |link, locale|
|
||||
link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale]) ? 1 :0]
|
||||
end
|
||||
else
|
||||
get_variables_for_edit
|
||||
render :action => "edit"
|
||||
m["count"] = page.frontend_data_count
|
||||
render json: JSON.pretty_generate({design: design, module: m})
|
||||
rescue
|
||||
render :json => {error: 'hahah'}, status: 422
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user