Sha256: ad8694c5fa7a34d6980ebd2c732e62ace0c56d700932fb46b5be39a1c5d971cd

Contents?: true

Size: 1.33 KB

Versions: 9

Compression:

Stored size: 1.33 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) 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

9 entries across 9 versions & 1 rubygems

Version Path
decidim-admin-0.30.0.rc2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.30.0.rc1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.0 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.0.rc4 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.0.rc3 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.0.rc2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.29.0.rc1 app/controllers/decidim/admin/help_sections_controller.rb