Sha256: 99cf0fa80308fe56c698e05a637992389776911aa78e8fddf5a2bf4c12d41190

Contents?: true

Size: 1009 Bytes

Versions: 55

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders a specific cells for the resource if it was configured
  # in the component's manifest or a default cell.
  class ReportedContentCell < Decidim::ViewModel
    def show
      if resource_cell?
        cell(resource_cell, model, options)
      else
        render :show
      end
    end

    private

    def render_value(value)
      content = I18n.with_locale(options.fetch(:locale, I18n.locale)) do
        if value.is_a? Hash
          translated_attribute(value)
        else
          value
        end
      end
      simple_format(content, sanitize: true)
    end

    def resource_cell?
      resource_cell.present?
    end

    def resource_cell
      @resource_cell ||= resource_reported_content
    end

    def resource_reported_content
      resource_manifest&.reported_content_cell.presence
    end

    def resource_manifest
      model.try(:resource_manifest) || Decidim.find_resource_manifest(model.class)
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc3 app/cells/decidim/reported_content_cell.rb
decidim-core-0.30.0.rc2 app/cells/decidim/reported_content_cell.rb
decidim-core-0.30.0.rc1 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.2 app/cells/decidim/reported_content_cell.rb
decidim-core-0.28.5 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.1 app/cells/decidim/reported_content_cell.rb
decidim-core-0.28.4 app/cells/decidim/reported_content_cell.rb
decidim-core-0.27.9 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.0 app/cells/decidim/reported_content_cell.rb
decidim-core-0.28.3 app/cells/decidim/reported_content_cell.rb
decidim-core-0.27.8 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/reported_content_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/reported_content_cell.rb
decidim-core-0.28.2 app/cells/decidim/reported_content_cell.rb
decidim-core-0.27.7 app/cells/decidim/reported_content_cell.rb
decidim-core-0.28.1 app/cells/decidim/reported_content_cell.rb
decidim-core-0.27.6 app/cells/decidim/reported_content_cell.rb
decidim-core-0.26.10 app/cells/decidim/reported_content_cell.rb