Sha256: b07fb1da3386d83ad95a8de60444642186d0c7903aa240757181404bdd4f790d
Contents?: true
Size: 1.64 KB
Versions: 9
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true module Decidim::Amendable # This cell renders the callout with information about the state of the emendation class AnnouncementCell < Decidim::ViewModel include Decidim::ApplicationHelper def show cell "decidim/announcement", announcement, callout_class: state_classes end private def announcement emendation_message + promoted_message end def emendation_message message(model.state, amendable_type, proposal_link, announcement_date) end def promoted_message return "" unless model.amendment.promoted? proposal = model.linked_promoted_resource text = message(:promoted, amendable_type) %(<br><strong>#{proposal_link(proposal, text)}</strong>) end def message(state, type, link = nil, date = nil) t(state, scope: "decidim.amendments.emendation.announcement", amendable_type: type, proposal_link: link, date: date) end def proposal_link(resource = model.amendable, text = nil) text ||= %(<strong>#{decidim_sanitize(present(model.amendable).title, strip_tags: true)}</strong>) link_to resource_locator(resource).path do text end end def amendable_type @amendable_type ||= t(model.class.model_name.i18n_key, scope: "activerecord.models", count: 1).downcase end def announcement_date model.amendment.updated_at end def state_classes case model.state when "accepted" "success" when "rejected", "withdrawn" "alert" when "evaluating" "warning" else "muted" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems