Sha256: 9d87d912f78afeae92b143a8c619dadd6fdc574e68aca7071cb756d5f6fd9bf6

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    # This cell renders:
    # - The category of a resource shown with the translated name (parent)
    # - The scope of a resource shown with the translated name (parent)
    # - The assigned tags from the plans
    #
    # The context `resource` must be present example use inside another `cell`:
    #   <%= cell("decidim/category", model.category, context: {resource: model}) %>
    #
    class TagsCell < Decidim::TagsCell
      def show
        render if category? || scope? || taggings?
      end

      def taggings
        render if taggings?
      end

      private

      def category?
        model.category.present?
      end

      def scope?
        has_visible_scopes?(model)
      end

      def taggings?
        model.tags.any?
      end

      def link_to_tag(tag)
      end

      def link_to_tag(tag)
        link_to tag_name(tag), tag_path(tag)
      end

      def tag_name(tag)
        translated_attribute(tag.name)
      end

      def tag_path(tag)
        resource_locator(model).index(filter: { tag_id: [tag.id] })
      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/tags_cell.rb
decidim-plans-0.18.1 app/cells/decidim/plans/tags_cell.rb
decidim-plans-0.18.0 app/cells/decidim/plans/tags_cell.rb
decidim-plans-0.17.0 app/cells/decidim/plans/tags_cell.rb
decidim-plans-0.16.9 app/cells/decidim/plans/tags_cell.rb
decidim-plans-0.16.8 app/cells/decidim/plans/tags_cell.rb
decidim-plans-0.16.7 app/cells/decidim/plans/tags_cell.rb