Sha256: 560234b7ca729930c1fe2f133c63f9a0ca198b0c654df368e8d61815b1be0bd8

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 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, 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

12 entries across 12 versions & 1 rubygems

Version Path
decidim-admin-0.27.9 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.8 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.7 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.6 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.5 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.4 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.3 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.1 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.0 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.0.rc2 app/controllers/decidim/admin/help_sections_controller.rb
decidim-admin-0.27.0.rc1 app/controllers/decidim/admin/help_sections_controller.rb