Module: Decidim::ResourceVersionsHelper
- Includes:
- ResourceHelper
- Defined in:
- app/helpers/decidim/resource_versions_helper.rb
Overview
Helper to print resource versions.
Instance Method Summary collapse
- #link_to_other_resource_versions(versions_path) ⇒ 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, #linked_resources_for, #resource_locator, #resource_title
Instance Method Details
#link_to_other_resource_versions(versions_path) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/decidim/resource_versions_helper.rb', line 36 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 |
# File 'app/helpers/decidim/resource_versions_helper.rb', line 15 def resource_version(resource, = {}) return unless resource.respond_to?(:versions) && resource.versions_count.positive? html = [] html << resource_version_number(resource.versions_count) html << " " html << resource_version_of(resource.versions_count) html << " " html << link_to_other_resource_versions([:versions_path]) if [:versions_path] content_tag(:div, safe_join(html), class: "tech-info #{[:class]}") end |
#resource_version_number(count, css_class = "") ⇒ Object
28 29 30 |
# File 'app/helpers/decidim/resource_versions_helper.rb', line 28 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
32 33 34 |
# File 'app/helpers/decidim/resource_versions_helper.rb', line 32 def resource_version_of(count) t("of_versions", scope: "decidim.versions.resource_version", number: count) end |