Sha256: 6107360549fe3ef3212a4d1df92230e141672c430ddb49acfa68be7004830be5

Contents?: true

Size: 828 Bytes

Versions: 19

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    class UpdateExternalDomainWhitelist < Decidim::Command
      attr_reader :form, :organization

      def initialize(form, organization, user)
        @form = form
        @organization = organization
        @user = user
      end

      def call
        return broadcast(:invalid) if form.invalid?

        Decidim.traceability.perform_action!("update_external_domain", @organization, @user) do
          save_domains!
        end

        broadcast(:ok)
      end

      private

      def save_domains!
        organization.external_domain_whitelist = form.external_domains.filter_map do |external_domain_form|
          external_domain_form.value unless external_domain_form.deleted
        end.flatten

        organization.save!
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-admin-0.28.4 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.9 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.28.3 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.8 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.28.2 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.7 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.28.1 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.6 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.28.0 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.5 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.4 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.3 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.2 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.1 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.0 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.0.rc2 app/commands/decidim/admin/update_external_domain_whitelist.rb
decidim-admin-0.27.0.rc1 app/commands/decidim/admin/update_external_domain_whitelist.rb