Sha256: 222c8cc6b05f4d607790d59d6180b55ff26d13b90014ac87f707a2539a64dac6

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

require "cell/partial"

module Decidim
  module Proposals
    # This cell renders the participatory text proposal card for an instance of a Proposal
    # the default size is the Medium Card (:m)
    class ParticipatoryTextProposalCell < Decidim::ViewModel
      include ProposalCellsHelper
      include Cell::ViewModel::Partial
      include Messaging::ConversationHelper

      def show
        render
      end

      private

      def section_title
        decidim_html_escape(present(model).title).html_safe
      end

      def body
        return unless model.participatory_text_level == "article"

        formatted = simple_format(present(model).body)
        decidim_sanitize_editor(strip_links(formatted))
      end

      def resource_path
        resource_locator(model).path
      end

      def amend_resource_path
        decidim.new_amend_path(amendable_gid: model.to_sgid.to_s)
      end

      def resource_comments_path
        resource_locator(model).path(anchor: "comments")
      end

      def resource_amendments_path
        resource_locator(model).path(anchor: "amendments")
      end

      def current_participatory_space
        model.component.participatory_space
      end

      def component_name
        translated_attribute current_component.name
      end

      def component_type_name
        model.class.model_name.human
      end

      def participatory_space_name
        translated_attribute current_participatory_space.title
      end

      def participatory_space_type_name
        translated_attribute current_participatory_space.model_name.human
      end

      def visible_emendations
        @visible_emendations ||= model.visible_emendations_for(current_user)
      end

      def amendment_creation_enabled?
        (current_component.settings.amendments_enabled? && current_settings.amendment_creation_enabled?)
      end

      def amend_button_disabled?
        !amendment_creation_enabled?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-proposals-0.29.1 app/cells/decidim/proposals/participatory_text_proposal_cell.rb
decidim-proposals-0.29.0 app/cells/decidim/proposals/participatory_text_proposal_cell.rb
decidim-proposals-0.29.0.rc4 app/cells/decidim/proposals/participatory_text_proposal_cell.rb
decidim-proposals-0.29.0.rc3 app/cells/decidim/proposals/participatory_text_proposal_cell.rb
decidim-proposals-0.29.0.rc2 app/cells/decidim/proposals/participatory_text_proposal_cell.rb
decidim-proposals-0.29.0.rc1 app/cells/decidim/proposals/participatory_text_proposal_cell.rb