Sha256: ee6cbd8037c8ba9ddb4f7a48de40fd4deb5947be9004b3cdf8cd649878b4f049

Contents?: true

Size: 1013 Bytes

Versions: 6

Compression:

Stored size: 1013 Bytes

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

6 entries across 6 versions & 1 rubygems

Version Path
decidim-budgets-0.29.1 app/cells/decidim/budgets/project_votes_count_cell.rb
decidim-budgets-0.29.0 app/cells/decidim/budgets/project_votes_count_cell.rb
decidim-budgets-0.29.0.rc4 app/cells/decidim/budgets/project_votes_count_cell.rb
decidim-budgets-0.29.0.rc3 app/cells/decidim/budgets/project_votes_count_cell.rb
decidim-budgets-0.29.0.rc2 app/cells/decidim/budgets/project_votes_count_cell.rb
decidim-budgets-0.29.0.rc1 app/cells/decidim/budgets/project_votes_count_cell.rb