Sha256: 6faba6b98301b5b9e5528a98048a81091faac1287e16d2ce16a6af13d1aa7177

Contents?: true

Size: 1.01 KB

Versions: 66

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell is intended to be used on forms.
  class RepresentUserGroupCell < Decidim::ViewModel
    def show
      return unless show_cell?

      render :show
    end

    private

    def show_cell?
      return unless current_user && current_organization.user_groups_enabled?
      return unless manageable_user_groups.verified.any?

      true
    end

    # Only users with a UserGroup role of `:admin` or `:creator` can represent a group.
    def manageable_user_groups
      Decidim::UserGroups::ManageableUserGroups.for(current_user)
    end

    def form
      model
    end

    def user_groups
      current_user.user_groups.verified.map { |g| [g.name, g.id] }
    end

    def selected
      form.object.user_group_id.presence
    end

    def checkbox_text
      I18n.t("represent_user_group", scope: "decidim.shared.represent_user_group")
    end

    def include_blank_text
      I18n.t("select_user_group", scope: "decidim.shared.represent_user_group")
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.4 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.27.9 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.29.0 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.3 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.27.8 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.2 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.27.7 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.1 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.27.6 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.26.10 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.26.9 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.0 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.27.5 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/represent_user_group_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/represent_user_group_cell.rb