Sha256: 10f634766df2c1be61023979d85a3fffa00529dd7b8aed62cddca464b116303b

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    # Simple helpers to handle markup variations for proposals
    module ProposalsHelper
      def proposal_reason_callout_announcement
        {
          title: translated_attribute(@proposal.proposal_state&.announcement_title),
          body: decidim_sanitize_editor_admin(translated_attribute(@proposal.answer))
        }
      end

      def proposal_has_costs?
        @proposal.cost.present? &&
          translated_attribute(@proposal.cost_report).present? &&
          translated_attribute(@proposal.execution_period).present?
      end

      def toggle_view_mode_link(current_mode, target_mode, title, params)
        path = proposals_path(params.permit(:order, filter: {}).merge({ view_mode: target_mode }))
        icon_name = target_mode == "grid" ? "layout-grid-fill" : "list-check"
        icon_class = "view-icon--disabled" unless current_mode == target_mode

        link_to path, remote: true, title: do
          icon(icon_name, class: icon_class, role: "img", "aria-hidden": true)
        end
      end

      def proposals_container_class(view_mode)
        view_mode == "grid" ? "card__grid-grid" : "card__list-list"
      end

      def card_size_for_view_mode(view_mode)
        view_mode == "grid" ? :g : nil
      end

      def resource_version(resource, options = {})
        return unless resource.respond_to?(:amendable?) && resource.amendable?

        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-proposals-0.29.1 app/helpers/decidim/proposals/proposals_helper.rb
decidim-proposals-0.29.0 app/helpers/decidim/proposals/proposals_helper.rb
decidim-proposals-0.29.0.rc4 app/helpers/decidim/proposals/proposals_helper.rb