Sha256: c6abcfb592c029f4c2cd643b787fb04aa21f70b275eaf7983ff324ed5a39fb54
Contents?: true
Size: 1.85 KB
Versions: 4
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true module Decidim module Budgets # This cell renders a horizontal project card # for an given instance of a Project in a budget list class ProjectListItemCell < Decidim::ViewModel include ActiveSupport::NumberHelper include Decidim::LayoutHelper include Decidim::ActionAuthorizationHelper include Decidim::Budgets::ProjectsHelper include Decidim::Budgets::Engine.routes.url_helpers delegate :current_user, :current_settings, :current_order, :current_component, :current_participatory_space, :can_have_order?, :voting_open?, :voting_finished?, to: :parent_controller private def resource_path resource_locator([model.budget, model]).path end def resource_title decidim_escape_translated model.title end def resource_added? current_order && current_order.projects.include?(model) end def resource_allocation current_order.allocation_for(model) end def data_class [].tap do |list| list << "budget-list__data--added" if can_have_order? && resource_added? list << "show-for-medium" if voting_finished? || (current_order_checked_out? && !resource_added?) end.join(" ") end def vote_button_disabled? current_user && !can_have_order? end def vote_button_class return "success" if resource_added? "hollow" end def vote_button_method return :delete if resource_added? :post end def vote_button_label if resource_added? return t( "decidim.budgets.projects.project.remove", resource_name: resource_title ) end t("decidim.budgets.projects.project.add", resource_name: resource_title) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems