Sha256: a698fc83f4e9424667346e4a95f3ec39c59caf44766dd6daea0adf72a80c65a4
Contents?: true
Size: 1.62 KB
Versions: 45
Compression:
Stored size: 1.62 KB
Contents
class Backend::PagesController < Backend::BaseController include Concerns::Backend::TranslatableController before_action :find_model, except: [:index, :new, :create] before_action -> { breadcrumb.add t('b.pages'), backend_pages_path } def index @pages = Page.all respond_to do |format| format.html format.json { render json: Udongo::Pages::Tree.new(self).data } end end def new @model = Page.new.decorate end def create @model = Page.new(allowed_params).decorate if @model.save redirect_to edit_backend_page_path(@model), notice: translate_notice(:added, :page) else render :new end end def update if @model.update_attributes allowed_params redirect_to edit_backend_page_path(@model), notice: translate_notice(:edited, :page) else render :edit end end def toggle_visibility @model.visible? ? @model.hide! : @model.show! render json: { toggled: @model } end def tree_drag_and_drop # TODO (Dave) - check if this page is draggable. render json: { moved: @model.set_position(params[:position], params[:parent_id]) } end def destroy # TODO (Dave) - check if this page may be destroyed. render json: { trashed: @model.destroy } end private def find_model @model = Page.find(params[:id]).decorate end def allowed_params params[:page].permit(:description, :parent_id, :visible, :sitemap) end def translation_form Backend::PageTranslationForm.new( @model, @model.translation(params[:translation_locale]), @model.seo(params[:translation_locale]) ) end end
Version data entries
45 entries across 45 versions & 1 rubygems