Class: Decidim::CollaborativeTexts::SuggestionPresenter
- Inherits:
-
ResourcePresenter
- Object
- ResourcePresenter
- Decidim::CollaborativeTexts::SuggestionPresenter
- Includes:
- ApplicationHelper
- Defined in:
- app/presenters/decidim/collaborative_texts/suggestion_presenter.rb
Overview
Decorator for collaborative texts suggestions.
Instance Method Summary collapse
- #original ⇒ Object
- #safe_json ⇒ Object
- #suggestion ⇒ Object
-
#summary ⇒ Object
A summary to print in the UI.
-
#text ⇒ Object
A text representation of the changeset.
-
#title(html_escape: false, all_locales: false) ⇒ Object
Render the suggestion title.
- #type ⇒ Object
Instance Method Details
#original ⇒ Object
23 24 25 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 23 def original @original ||= ActionView::Base.full_sanitizer.sanitize(changeset["original"]&.join(" ")&.strip).to_s end |
#safe_json ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 45 def safe_json { id:, changeset:, summary:, status:, type:, createdAt: created_at } end |
#suggestion ⇒ Object
27 28 29 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 27 def suggestion __getobj__ end |
#summary ⇒ Object
A summary to print in the UI
13 14 15 16 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 13 def summary txt = type == :remove ? original : text @summary ||= I18n.t("decidim.collaborative_texts.suggestion.#{type}_html", text: txt.truncate(150)) end |
#text ⇒ Object
A text representation of the changeset. Without HTML.
19 20 21 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 19 def text @text ||= ActionView::Base.full_sanitizer.sanitize(changeset["replace"]&.join(" ")&.strip).to_s end |
#title(html_escape: false, all_locales: false) ⇒ Object
Render the suggestion title
Returns a String.
34 35 36 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 34 def title(html_escape: false, all_locales: false) super(suggestion.document.title, html_escape, all_locales) end |
#type ⇒ Object
38 39 40 41 42 43 |
# File 'app/presenters/decidim/collaborative_texts/suggestion_presenter.rb', line 38 def type return :remove if text.blank? return :add if text.include?(original.to_s) :replace end |