app/controllers/spina/admin/pages_controller.rb in spina-1.2.0 vs app/controllers/spina/admin/pages_controller.rb in spina-2.0.0.alpha
- old
+ new
@@ -6,41 +6,38 @@
before_action :set_page, only: [:edit, :update, :destroy, :children]
def index
add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
redirect_to admin_pages_path unless current_admin_path.starts_with?('/pages')
- @pages = Page.active.sorted.roots.regular_pages
+ @pages = Page.active.sorted.roots.regular_pages.includes(:translations)
end
def new
@resource = Resource.find_by(id: params[:resource_id])
@page = Page.new(resource: @resource, parent: Page.find_by(id: params[:parent_id]))
add_index_breadcrumb
if current_theme.new_page_templates.any? { |template| template[0] == params[:view_template] }
@page.view_template = params[:view_template]
end
add_breadcrumb I18n.t('spina.pages.new')
- @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
render layout: 'spina/admin/admin'
end
def create
@page = Page.new(page_params)
add_breadcrumb I18n.t('spina.pages.new')
if @page.save
@page.navigations << Spina::Navigation.where(auto_add_pages: true)
redirect_to spina.edit_admin_page_url(@page), flash: {success: t('spina.pages.saved')}
else
- @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
render :new, layout: 'spina/admin/admin'
end
end
def edit
add_index_breadcrumb
add_breadcrumb @page.title
- @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
render layout: 'spina/admin/admin'
end
def update
respond_to do |format|
@@ -49,10 +46,9 @@
@page.touch
format.html { redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale}), flash: {success: t('spina.pages.saved')} }
format.js
else
format.html do
- @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
Mobility.locale = I18n.default_locale
render :edit, layout: 'spina/admin/admin'
end
end
end