Sha256: fcfbc3af6f34dd8d51b42a1f21e5dbded0c03083ca041d2a039450c636fa1667

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # This cell renders the vote count.
    # Two possible layouts: One or two lines
    class ProjectVotesCountCell < Decidim::ViewModel
      include Decidim::IconHelper

      def show
        return unless show_votes_count?

        content_tag :span, content, class: css_class
      end

      private

      def show_votes_count?
        model.component.current_settings.show_votes?
      end

      def content
        if options[:layout] == :one_line
          safe_join([model.confirmed_orders_count, " ", count_label])
        else
          safe_join([number, count_label])
        end
      end

      def number
        content_tag :div, model.confirmed_orders_count
      end

      def count_label
        content_tag(:span, t("decidim.budgets.projects.project.votes", count: model.confirmed_orders_count))
      end

      def css_class
        css = ["project-votes"]
        css << options[:class] if options[:class]
        css.join(" ")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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