Sha256: 93decdb148c772e3b39f8946b3f0fe7d1b3810891132268e9d4846e61511bd42

Contents?: true

Size: 1013 Bytes

Versions: 13

Compression:

Stored size: 1013 Bytes

Contents

# frozen_string_literal: true
module Decidim
  module Admin
    # A form object used to attach a feature to a participatory process from the
    # admin panel.
    #
    class FeatureForm < Decidim::Form
      include TranslatableAttributes

      mimic :feature

      translatable_attribute :name, String
      validates :name, translatable_presence: true

      attribute :settings, Object
      attribute :manifest
      attribute :weight, Integer, default: 0

      attribute :step_settings, Hash[String => Object]
      attribute :participatory_process

      def map_model(model)
        self.attributes = model.attributes
        self.settings = model.settings
      end

      def settings?
        settings.manifest.attributes.any?
      end

      def step_settings?
        return false unless participatory_process.steps.any?

        step_settings
          .values
          .map(&:manifest)
          .flat_map(&:attributes)
          .flat_map(&:keys)
          .any?
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
decidim-admin-0.1.0 app/forms/decidim/admin/feature_form.rb
decidim-0.1.0 decidim-admin/app/forms/decidim/admin/feature_form.rb
decidim-admin-0.0.8.1 app/forms/decidim/admin/feature_form.rb
decidim-0.0.8.1 decidim-admin/app/forms/decidim/admin/feature_form.rb
decidim-admin-0.0.7 app/forms/decidim/admin/feature_form.rb
decidim-0.0.7 decidim-admin/app/forms/decidim/admin/feature_form.rb
decidim-admin-0.0.6 app/forms/decidim/admin/feature_form.rb
decidim-0.0.6 decidim-admin/app/forms/decidim/admin/feature_form.rb
decidim-admin-0.0.5 app/forms/decidim/admin/feature_form.rb
decidim-0.0.5 decidim-admin/app/forms/decidim/admin/feature_form.rb
decidim-0.0.4 decidim-admin/app/forms/decidim/admin/feature_form.rb
decidim-admin-0.0.3 app/forms/decidim/admin/feature_form.rb
decidim-0.0.3 decidim-admin/app/forms/decidim/admin/feature_form.rb