Sha256: 8e75c1c599807ee5c8ac423f67167a542297818a7e45710dab7656dfa93d87ad

Contents?: true

Size: 1.36 KB

Versions: 9

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Decidim
  class ProfileCell < Decidim::ViewModel
    include Decidim::ApplicationHelper
    include Decidim::Core::Engine.routes.url_helpers
    include Decidim::UserProfileHelper
    include Decidim::AriaSelectedLinkToHelper
    include ActiveLinkTo

    delegate :current_organization, :current_user, :user_groups_enabled?, to: :controller

    def show
      render :show
    end

    def profile_holder
      model
    end

    def content_cell
      context[:content_cell]
    end

    def active_content
      context[:active_content]
    end

    def own_profile?
      current_user && current_user == profile_holder
    end

    def manageable_group?
      return false unless profile_holder.is_a?(Decidim::UserGroup)

      current_user && current_user.manageable_user_groups.include?(profile_holder)
    end

    def profile_tabs
      return render :user_group_tabs if profile_holder.is_a?(Decidim::UserGroup)

      render :user_tabs
    end

    def unread_count
      return profile_holder.unread_messages_count_for(current_user) if profile_holder.is_a?(Decidim::UserGroup)

      current_user.unread_messages_count
    end

    def label_conversations
      label = I18n.t("decidim.profiles.show.conversations")
      label = "#{label} <span class=\"badge\">#{unread_count}</span>" if unread_count.positive?
      label
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/cells/decidim/profile_cell.rb
decidim-core-0.23.5 app/cells/decidim/profile_cell.rb
decidim-core-0.23.4 app/cells/decidim/profile_cell.rb
decidim-core-0.23.3 app/cells/decidim/profile_cell.rb
decidim-core-0.23.2 app/cells/decidim/profile_cell.rb
decidim-core-0.23.1 app/cells/decidim/profile_cell.rb
decidim-core-0.23.1.rc1 app/cells/decidim/profile_cell.rb
decidim-core-0.23.0 app/cells/decidim/profile_cell.rb
decidim-core-0.22.0 app/cells/decidim/profile_cell.rb