Sha256: c18fd541b445e8ef82b9fec225ed5aa8cde923d9daafc9ea55ae9ae573a5b2ae

Contents?: true

Size: 923 Bytes

Versions: 56

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Pages
    module Admin
      # This controller allows the user to update a Page.
      class PagesController < Admin::ApplicationController
        def edit
          @form = form(Admin::PageForm).from_model(page)
        end

        def update
          @form = form(Admin::PageForm).from_params(params)

          Admin::UpdatePage.call(@form, page) do
            on(:ok) do
              flash[:notice] = I18n.t("pages.update.success", scope: "decidim.pages.admin")
              redirect_to parent_path
            end

            on(:invalid) do
              flash.now[:alert] = I18n.t("pages.update.invalid", scope: "decidim.pages.admin")
              render action: "edit"
            end
          end
        end

        private

        def page
          @page ||= Pages::Page.find_by(feature: current_feature)
        end
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

Version Path
decidim-pages-0.10.1 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.10.0 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.9.3 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.9.2 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.9.1 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.9.0 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.8.4 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.8.3 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.8.2 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.8.1 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.8.0 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.7.4 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.7.3 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.7.2 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.7.1 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.7.0 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.6.8 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-0.6.8 decidim-pages/app/controllers/decidim/pages/admin/pages_controller.rb
decidim-pages-0.6.7 app/controllers/decidim/pages/admin/pages_controller.rb
decidim-0.6.7 decidim-pages/app/controllers/decidim/pages/admin/pages_controller.rb