Sha256: 043790318cb07d2f41c8f5dee82d3fadf847074122c719e0cc95cbd1adbbcc26
Contents?: true
Size: 1.27 KB
Versions: 25
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Decidim # This cell renders the category of a resource # shown with the translated name and links to # the resource parent `component` and `participatory space` index. # The context `resource` must be present # example use inside another `cell`: # <%= cell("decidim/category", model.category, context: {resource: model}) %> # class TagsCell < Decidim::ViewModel def show render if category? || scope? end def category render if category? end def scope render if scope? end private def tags_classes (["tags"] + context[:extra_classes].to_a).join(" ") end def category? model.category.present? end def link_to_category link_to category_name, category_path end def category_name model.category.translated_name end def category_path resource_locator(model).index(filter: { category_id: model.category.id }) end def scope? has_visible_scopes?(model) end def link_to_scope link_to scope_name, scope_path end def scope_name translated_attribute model.scope.name end def scope_path resource_locator(model).index(filter: { scope_id: model.scope.id }) end end end
Version data entries
25 entries across 25 versions & 1 rubygems