Sha256: 9061b54e0a2ec93f739f8904aedc1da3fc318cbf2d420a1e106704f3e1e3c30d

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require "cell/partial"

module Decidim
  module Plans
    # This cell renders a plan with its M-size card.
    class PlanMCell < Decidim::CardMCell
      include PlanCellsHelper

      def badge
        render if has_badge?
      end

      private

      def resource_path
        resource_locator(model).path + request_params_query
      end

      def title
        present(model).title
      end

      def body
        present(model).body
      end

      def has_state?
        model.published?
      end

      def has_badge?
        closed? || answered? || withdrawn?
      end

      def has_link_to_resource?
        model.published?
      end

      def description
        model_body = strip_tags(body)

        if options[:full_description]
          model_body.gsub(/\n/, "<br>")
        else
          truncate(model_body, length: 100)
        end
      end

      def badge_classes
        return super unless options[:full_badge]

        state_classes.concat(["label", "plan-status"]).join(" ")
      end

      def statuses
        return [:comments_count] if model.draft?

        [:creation_date, :follow, :comments_count]
      end

      def creation_date_status
        l(model.published_at.to_date, format: :decidim_short)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-plans-0.18.2 app/cells/decidim/plans/plan_m_cell.rb
decidim-plans-0.18.1 app/cells/decidim/plans/plan_m_cell.rb
decidim-plans-0.18.0 app/cells/decidim/plans/plan_m_cell.rb
decidim-plans-0.17.0 app/cells/decidim/plans/plan_m_cell.rb
decidim-plans-0.16.9 app/cells/decidim/plans/plan_m_cell.rb
decidim-plans-0.16.8 app/cells/decidim/plans/plan_m_cell.rb
decidim-plans-0.16.7 app/cells/decidim/plans/plan_m_cell.rb