Module: Decidim::ResourceVersionsHelper
- Includes:
- ResourceHelper
- Defined in:
- decidim-core/app/helpers/decidim/resource_versions_helper.rb
Overview
Helper to print resource versions.
Instance Method Summary collapse
- #link_to_other_resource_versions(versions_path, options = {}) ⇒ Object
-
#resource_version(resource, options = {}) ⇒ Object
Displays the localized version for the given resource.
- #resource_version_number(count, css_class = "") ⇒ Object
- #resource_version_of(count) ⇒ Object
Methods included from ResourceHelper
#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title
Instance Method Details
#link_to_other_resource_versions(versions_path, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'decidim-core/app/helpers/decidim/resource_versions_helper.rb', line 37 def link_to_other_resource_versions(versions_path, = {}) link_to( t( "see_other_versions", scope: "decidim.versions.resource_version" ), versions_path, ** ) end |
#resource_version(resource, options = {}) ⇒ Object
Displays the localized version for the given resource.
resource - the Resource that has the version to display. options - An optional hash of options
* class: A string of extra css classes
Returns a String.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'decidim-core/app/helpers/decidim/resource_versions_helper.rb', line 15 def resource_version(resource, = {}) return unless resource.respond_to?(:versions) && resource.versions_count.positive? path = .delete(:versions_path) html = [] html << resource_version_number(resource.versions_count) html << " " html << resource_version_of(resource.versions_count) html << " " html << link_to_other_resource_versions(path, ) if path.present? safe_join(html) end |
#resource_version_number(count, css_class = "") ⇒ Object
29 30 31 |
# File 'decidim-core/app/helpers/decidim/resource_versions_helper.rb', line 29 def resource_version_number(count, css_class = "") content_tag(:strong, t("version", scope: "decidim.versions.resource_version", number: count), class: css_class) end |
#resource_version_of(count) ⇒ Object
33 34 35 |
# File 'decidim-core/app/helpers/decidim/resource_versions_helper.rb', line 33 def resource_version_of(count) t("of_versions", scope: "decidim.versions.resource_version", number: count) end |