Sha256: b1ecbbd5e1c99f2823ec89c23635ac38605cf09f6b40a5aab647c1f72b22804c

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # A command with all the business logic when updating assemblies
      # settings in admin area.
      class UpdateAssembliesSetting < Decidim::Command
        # Public: Initializes the command.
        #
        # assemblies_setting - A assemblies_setting object to update.
        # form - A form object with the params.
        def initialize(assemblies_settings, form)
          @assemblies_settings = assemblies_settings
          @form = form
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form or assemblies_settings isn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          return broadcast(:invalid) if form.invalid? || assemblies_settings.invalid?

          update_assemblies_setting!

          broadcast(:ok)
        end

        private

        attr_reader :form, :assemblies_settings

        def update_assemblies_setting!
          Decidim.traceability.update!(
            @assemblies_settings,
            form.current_user,
            enable_organization_chart: form.enable_organization_chart
          )
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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