Class: Decidim::AuthorizationTransferPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::AuthorizationTransferPresenter
- Defined in:
- decidim-core/app/presenters/decidim/authorization_transfer_presenter.rb
Overview
Decorator for authorization transfer.
Instance Method Summary collapse
-
#records_list_html ⇒ String
Generates a HTML list of the record counts with the translated.
-
#translated_record_counts ⇒ Hash<String => String>
Simplifies the informational hash returned by the ‘#information` for the display in the user interface.
-
#translated_record_texts ⇒ Array<String>
Returns an array of the translated record counts containing only the texts to be displayed for the user.
Instance Method Details
#records_list_html ⇒ String
Generates a HTML list of the record counts with the translated.
49 50 51 52 53 54 55 |
# File 'decidim-core/app/presenters/decidim/authorization_transfer_presenter.rb', line 49 def records_list_html items = translated_record_texts.map do |description| "<li>#{CGI.escapeHTML(description)}</li>" end "<ul>#{items.join}</ul>".html_safe end |
#translated_record_counts ⇒ Hash<String => String>
Simplifies the informational hash returned by the ‘#information` for the display in the user interface. Returns a hash containing the record types (their class names as strings) as its keys and the translated amount of the records as its values.
The record names are always in plural format for maximum language compatibility, as otherwise we would have to specify the translatable strings for all records in singular and plural formats.
26 27 28 29 30 31 32 33 34 35 |
# File 'decidim-core/app/presenters/decidim/authorization_transfer_presenter.rb', line 26 def translated_record_counts resources = information.map do |type, info| resource_class = info[:class] name = resource_class.model_name [type, "#{name.human(count: 2)}: #{info[:count]}"] end resources.sort_by { |v| v[1] }.to_h end |
#translated_record_texts ⇒ Array<String>
Returns an array of the translated record counts containing only the texts to be displayed for the user.
41 42 43 |
# File 'decidim-core/app/presenters/decidim/authorization_transfer_presenter.rb', line 41 def translated_record_texts translated_record_counts.values end |