Sha256: bcc8acb3cdbb4d21952d64bedcc3072a58a71046d2931af6df2aa61584c6c3da

Contents?: true

Size: 924 Bytes

Versions: 3

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryDocuments
    class SuggestionCell < Decidim::ViewModel
      include Decidim::ParticipatoryDocuments::Admin::SuggestionHelper
      include Decidim::IconHelper
      include Decidim::Admin::IconLinkHelper

      def show
        render
      end

      def admin_answer
        render
      end

      def answered_at
        return unless has_answer?

        l(model.answered_at, format: :decidim_short)
      end

      def humanize_suggestion_state
        I18n.t(model.state, scope: "decidim.participatory_documents.suggestions.answers")
      end

      def author_cell
        cell("decidim/participatory_documents/suggestion_author", model)
      end

      protected

      def has_answer?
        return false if %w(not_answered withdrawn).include?(model.state)

        model.answered? && model.answer_is_published?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-participatory_documents-0.2.2 app/cells/decidim/participatory_documents/suggestion_cell.rb
decidim-participatory_documents-0.2.1 app/cells/decidim/participatory_documents/suggestion_cell.rb
decidim-participatory_documents-0.2.0 app/cells/decidim/participatory_documents/suggestion_cell.rb