Sha256: 1ebaf187056c1cdd57917923b547cc3a09bc8b0cc2aba5afa472640feca79009

Contents?: true

Size: 982 Bytes

Versions: 7

Compression:

Stored size: 982 Bytes

Contents

# frozen_string_literal: true

require "cell/partial"

module Decidim
  module Proposals
    # This cell renders the cost report for a proposal.
    class CostReportCell < Decidim::ViewModel
      include ActionView::Helpers::NumberHelper
      include Decidim::SanitizeHelper
      include Decidim::LayoutHelper
      include ProposalCellsHelper

      private

      def cost
        number_to_currency(model.cost, unit: Decidim.currency_unit)
      end

      def cost_report
        decidim_sanitize(translated_attribute(model.cost_report).html_safe)
      end

      def needs_text_toggle?
        cost_report != cost_report_short
      end

      def cost_report_short
        decidim_sanitize(
          html_truncate(
            translated_attribute(model.cost_report).html_safe,
            length: 200
          )
        )
      end

      def execution_period
        decidim_sanitize(translated_attribute(model.execution_period).html_safe)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-proposals-0.25.2 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.25.1 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.25.0 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.25.0.rc4 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.25.0.rc3 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.25.0.rc2 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.25.0.rc1 app/cells/decidim/proposals/cost_report_cell.rb