Sha256: 2c78533bc490e1fabeb8b3f59c3781c7e5b54b2d17078c0f551890eaeb411040

Contents?: true

Size: 1.23 KB

Versions: 76

Compression:

Stored size: 1.23 KB

Contents

module Pageflow
  module Admin
    class UserAccountBadgeList < ViewComponent
      builder_method :user_account_badge_list

      def build(user)
        ul class: 'badge_list' do
          user.account_memberships.each do |membership|
            if authorized?(:see_badge_belonging_to, membership.entity)
              build_badge(membership)
            end
          end

          build_admin_badge if user.admin?
        end
      end

      private

      def build_badge(membership)
        li do
          if authorized?(:read, membership.entity)
            account_name_display = span(link_to(membership.entity.name,
                                                main_app.admin_account_path(membership.entity)),
                                        class: 'abbreviation')
            div class: 'tooltip' do
              account_name_display +
                " (#{I18n.t(membership.role, scope: 'activerecord.values.pageflow/membership.role')})"
            end
          else
            span(membership.entity.name, class: 'abbreviation')
          end
        end
      end

      def build_admin_badge
        li do
          span(I18n.t('pageflow.admin.users.roles.admin'), class: 'abbreviation')
        end
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.6.1 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.6.0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.5.0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.4.0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.3.0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.2.2 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.2.1 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.2.0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.2 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.1 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.rc0 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.beta6 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.beta5 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.beta4 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.beta3 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.beta2 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.1.0.beta1 app/views/components/pageflow/admin/user_account_badge_list.rb
pageflow-15.0.2 app/views/components/pageflow/admin/user_account_badge_list.rb