Sha256: 3616cdc79983d2d812d967d83a4adae2f1896b711d6b745d0ee282b70daa42f2

Contents?: true

Size: 1008 Bytes

Versions: 6

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell is intended to be used on profiles.
  # Lists the members of the given user group.
  class MembersCell < Decidim::ViewModel
    include Decidim::CellsPaginateHelper
    include Decidim::Core::Engine.routes.url_helpers
    include Decidim::CardHelper

    def show
      render :show
    end

    def memberships
      @memberships ||= case role
                       when "member"
                         Decidim::UserGroups::MemberMemberships.for(model).page(params[:page]).per(20)
                       when "admin"
                         Decidim::UserGroups::AdminMemberships.for(model).page(params[:page]).per(20)
                       else
                         Decidim::UserGroups::AcceptedMemberships.for(model).page(params[:page]).per(20)
                       end
    end

    def role
      options[:role].to_s
    end

    def validation_messages
      [t("decidim.members.no_members")] if memberships.blank?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/cells/decidim/members_cell.rb
decidim-core-0.29.0 app/cells/decidim/members_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/members_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/members_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/members_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/members_cell.rb