Sha256: 821f11f81df07317ba4554df1588db55ac94032a96d4197eb06cbfb1eebe253a

Contents?: true

Size: 953 Bytes

Versions: 16

Compression:

Stored size: 953 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)
      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

16 entries across 16 versions & 1 rubygems

Version Path
decidim-proposals-0.24.3 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.6 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.24.2 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.5 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.24.1 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.24.0 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.24.0.rc2 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.4 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.24.0.rc1 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.3 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.2 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.1 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.1.rc1 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.23.0 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.22.0 app/cells/decidim/proposals/cost_report_cell.rb
decidim-proposals-0.21.0 app/cells/decidim/proposals/cost_report_cell.rb