Sha256: 4b69f5193cb809fff93c48ad77a2eef5340bd8ddb033f522ba37007022fc8fbb

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 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

      add_breadcrumb_item_from_menu :admin_settings_menu

      helper_method :sections

      before_action do
        enforce_permission_to :update, :help_sections
      end

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

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

        UpdateHelpSections.call(@form, current_organization, current_user) 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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-admin-0.28.4 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.28.3 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.28.2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.28.1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.28.0 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.28.0.rc5 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.28.0.rc4 app/controllers/decidim/admin/help_sections_controller.rb