Sha256: 31964a506da660a3e68e3643f14e98f77d48928c58674e94485e7a231da734e9
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true module Decidim # This cell is used to render public activities performed by users. # # Each model that we want to represent should inherit from this cell and # tweak the necessary methods (usually `title` is enough). class ActivityCell < Decidim::ViewModel include Cell::ViewModel::Partial include Decidim::IconHelper include Decidim::ApplicationHelper def show return unless renderable? render end # Since activity logs could be linked to resource no longer available # this method is added in order to skip rendering a cell if there's # not enough data. def renderable? resource.present? && participatory_space.present? && published? end # The resource linked to the activity. def resource model.resource_lazy end # The title to show at the card. # # The card will also be displayed OK if there's no title. def title return unless resource.respond_to?(:title) if resource.title.is_a?(String) resource.title elsif resource.title.is_a?(Hash) translated_attribute(resource.title) end end # The link to the resource linked to the activity. def resource_link_path resource_locator(resource).path end # The text to show as the link to the resource. def resource_link_text translated_attribute(resource.title) end private def published? return true unless resource.respond_to?(:published?) resource.published? end def component model.component_lazy end def organization model.organization_lazy end def user model.user_lazy end def participatory_space return resource if resource.is_a?(Decidim::Participable) model.participatory_space_lazy end def participatory_space_link link_to( translated_attribute(participatory_space.title), resource_locator(participatory_space).path ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
decidim-core-0.15.2 | app/cells/decidim/activity_cell.rb |
decidim-core-0.15.1 | app/cells/decidim/activity_cell.rb |
decidim-core-0.15.0 | app/cells/decidim/activity_cell.rb |