Sha256: a6c937ba3871ef5a894df2348d75e973fb9e2c2db5568a1e22d88e06c9216a8a

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

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::ApplicationHelper
    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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/members_cell.rb
decidim-core-0.28.3 app/cells/decidim/members_cell.rb
decidim-core-0.28.2 app/cells/decidim/members_cell.rb
decidim-core-0.28.1 app/cells/decidim/members_cell.rb
decidim-core-0.28.0 app/cells/decidim/members_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/members_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/members_cell.rb