Sha256: f732e2e781a1f2d7d415a77b21cded3211ec76f10fae829ddba8dffb8fe07c66

Contents?: true

Size: 699 Bytes

Versions: 38

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The form object that handles the data behind updating a user's
  # interests in her profile page.
  class UserInterestScopeForm < Form
    mimic :scope

    attribute :name, String
    attribute :checked, Boolean
    attribute :children, Array[UserInterestScopeForm]

    def map_model(model_hash)
      scope = model_hash[:scope]
      user = model_hash[:user]

      self.id = scope.id
      self.name = scope.name
      self.checked = user.interested_scopes_ids.include?(scope.id)
      self.children = scope.children.map do |children_scope|
        UserInterestScopeForm.from_model(scope: children_scope, user: user)
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-core-0.26.1 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.26.0 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.26.0.rc2 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.26.0.rc1 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.2 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.1 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.0 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.0.rc4 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.0.rc3 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.0.rc2 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.25.0.rc1 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.24.3 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.23.6 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.24.2 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.23.5 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.24.1 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.24.0 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.24.0.rc2 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.23.4 app/forms/decidim/user_interest_scope_form.rb
decidim-core-0.24.0.rc1 app/forms/decidim/user_interest_scope_form.rb