Sha256: bee13da281845be27220afa4e41b92620018d954a712ca6fbe9cf226de990a32

Contents?: true

Size: 1.29 KB

Versions: 46

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # Controller that allows managing the user organization.
    #
    class HelpSectionsController < Decidim::Admin::ApplicationController
      layout "decidim/admin/settings"
      include TranslationsHelper

      helper_method :sections

      before_action do
        enforce_permission_to :update, :help_sections
      end

      def show
        @form = form(HelpSectionsForm).from_model(
          OpenStruct.new(sections: sections)
        )
      end

      def update
        @form = form(HelpSectionsForm).from_params(
          params[:help_sections]
        )

        UpdateHelpSections.call(@form, current_organization) do
          on(:ok) do
            flash[:notice] = t("help_sections.success", scope: "decidim.admin")
            redirect_to action: :show
          end

          on(:invalid) do
            flash.now[:alert] = t("help_sections.error", scope: "decidim.admin")
          end
        end
      end

      private

      def sections
        @sections ||= Decidim.participatory_space_manifests.map do |manifest|
          OpenStruct.new(
            id: manifest.name.to_s,
            content: ContextualHelpSection.find_content(current_organization, manifest.name)
          )
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-admin-0.26.10 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.9 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.8 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.7 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.5 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.4 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.3 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.0 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.0.rc2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.26.0.rc1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.0 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.0.rc4 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.0.rc3 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.0.rc2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.25.0.rc1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.24.3 app/controllers/decidim/admin/help_sections_controller.rb