Sha256: e04ab5bc539c21ec6cc1a4e400edc9234aec02798b90c416f640eed51bef3a09

Contents?: true

Size: 1.58 KB

Versions: 24

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # This cell renders the budget item list in the budgets list
    class BudgetListItemCell < BaseCell
      include Decidim::SanitizeHelper
      include Decidim::ApplicationHelper
      include ActiveSupport::NumberHelper
      include Decidim::Budgets::ProjectsHelper

      delegate :voting_finished?, to: :controller
      delegate :highlighted, to: :current_workflow

      property :title, :description, :total_budget
      alias budget model

      private

      def card_class
        ["card--list__item"].tap do |list|
          unless voting_finished?
            list << "card--list__data-added" if voted?
            list << "card--list__data-progress" if progress?
          end
          list << "budget--highlighted" if highlighted?
        end.join(" ")
      end

      def link_class
        "card__link card--list__heading"
      end

      def voted?
        current_user && status == :voted
      end

      def progress?
        current_user && status == :progress
      end

      def highlighted?
        highlighted.include?(budget)
      end

      def status
        @status ||= current_workflow.status(budget)
      end

      def button_class
        "hollow" if voted? || !highlighted?
      end

      def button_text
        key = if current_workflow.vote_allowed?(budget) && !voted?
                progress? ? :progress : :vote
              else
                :show
              end

        t(key, scope: i18n_scope)
      end

      def i18n_scope
        "decidim.budgets.budgets_list"
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-budgets-0.27.9 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.8 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.7 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.6 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.10 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.9 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.5 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.8 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.4 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.3 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.7 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.5 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.2 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.1 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.4 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.0 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.3 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.0.rc2 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.27.0.rc1 app/cells/decidim/budgets/budget_list_item_cell.rb
decidim-budgets-0.26.2 app/cells/decidim/budgets/budget_list_item_cell.rb