Sha256: 64d14b0ea82a703eb3a0117c6ae656419d80c7053b17c4beb95a33c7c94881e3

Contents?: true

Size: 991 Bytes

Versions: 6

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

require "cell/partial"

module Decidim
  module EnhancedTextwork
    # This cell renders the cost report for a paragraph.
    class CostReportCell < Decidim::ViewModel
      include ActionView::Helpers::NumberHelper
      include Decidim::SanitizeHelper
      include Decidim::LayoutHelper
      include ParagraphCellsHelper

      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

6 entries across 6 versions & 1 rubygems

Version Path
decidim-enhanced_textwork-1.0.5 app/cells/decidim/enhanced_textwork/cost_report_cell.rb
decidim-enhanced_textwork-1.0.4 app/cells/decidim/enhanced_textwork/cost_report_cell.rb
decidim-enhanced_textwork-1.0.3 app/cells/decidim/enhanced_textwork/cost_report_cell.rb
decidim-enhanced_textwork-1.0.2 app/cells/decidim/enhanced_textwork/cost_report_cell.rb
decidim-enhanced_textwork-1.0.1 app/cells/decidim/enhanced_textwork/cost_report_cell.rb
decidim-enhanced_textwork-1.0.0 app/cells/decidim/enhanced_textwork/cost_report_cell.rb