Sha256: bdcbc14215ed37889a03d7cc214f17fcc49ab2a090f50dabe759e5952b168d84

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Decidim
  module TermCustomizer
    module Admin
      class TranslationSetConstraintForm < Decidim::Form
        mimic :constraint

        attribute :subject_manifest, String
        attribute :subject_model, Array[TermCustomizer::Admin::TranslationSetSubjectForm]
        attribute :deleted, Boolean, default: false

        def to_param
          return id if id.present?

          "constraint-id"
        end

        def map_model(model)
          self.subject_manifest = model.manifest_name

          return unless model.subject

          self.subject_model = [
            TermCustomizer::Admin::TranslationSetSubjectForm.from_model(
              model.subject
            )
          ]
        end

        def subject_type
          return unless subject_form

          subject_form.manifest.try(:model_class_name)
        end

        def subject
          return component if component
          return unless subject_form

          subject_form.subject
        end

        def component
          return unless subject_form

          subject_form.component
        end

        def subject_form
          @subject_form ||= subject_model.find do |sm|
            sm.subject_manifest == subject_manifest
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
decidim-term_customizer-0.23.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.22.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.21.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.20.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.19.1 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.19.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.18.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.17.1 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.17.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.16.6 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.16.5 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.16.3 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.16.2 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.16.1 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
decidim-term_customizer-0.16.0 app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb