Sha256: eaa9f26c65365a494be6f639dce80365ce84620216bc630e44c7820979b7fdb7

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command with all the business logic for updating the current
    # organization appearance.
    class UpdateOrganizationAppearance < Decidim::Commands::UpdateResource
      fetch_file_attributes :logo, :highlighted_content_banner_image, :favicon, :official_img_footer

      fetch_form_attributes :cta_button_path, :cta_button_text, :description, :official_url,
                            :highlighted_content_banner_enabled, :highlighted_content_banner_action_url,
                            :highlighted_content_banner_title, :highlighted_content_banner_short_description,
                            :highlighted_content_banner_action_title,
                            :highlighted_content_banner_action_subtitle, :enable_omnipresent_banner, :omnipresent_banner_url,
                            :omnipresent_banner_title, :omnipresent_banner_short_description

      private

      def attributes
        super
          .merge(colors_attributes)
          .delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
          .tap do |attributes|
            attributes[:header_snippets] = form.header_snippets if Decidim.enable_html_header_snippets
          end
      end

      def colors_attributes
        {
          colors: {
            primary: form.primary_color,
            secondary: form.secondary_color,
            tertiary: form.tertiary_color
          }.compact_blank
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/update_organization_appearance.rb
decidim-admin-0.29.0 app/commands/decidim/admin/update_organization_appearance.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/update_organization_appearance.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/update_organization_appearance.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/update_organization_appearance.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/update_organization_appearance.rb