Sha256: e54b663153562089ff02d42d19e34d0f1cd11a573dd5df2a94d1672fe9e98573

Contents?: true

Size: 899 Bytes

Versions: 10

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell is used to render the documents panel of a resource
  # inside a tab of a show view
  #
  # The `model` must be a resource to get the documents from.and is expected to
  # respond to documents method
  #
  # Example:
  #
  #   cell(
  #     "decidim/documents_panel",
  #     meeting
  #   )
  class DocumentsPanelCell < Decidim::ViewModel
    include Decidim::AttachmentsHelper
    include Cell::ViewModel::Partial
    include ActiveSupport::NumberHelper
    include ERB::Util

    alias resource model

    def show
      return if blank?

      render
    end

    def documents
      @documents ||= resource.try(:documents)
    end

    def components_collections
      @components_collections ||= options[:components_collections] || []
    end

    def blank?
      documents.blank? && components_collections.blank?
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc3 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.30.0.rc2 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.30.0.rc1 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.2 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.1 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.0 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/documents_panel_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/documents_panel_cell.rb