Module: Decidim::ResourceVersionsHelper

Includes:
ResourceHelper
Included in:
Initiatives::InitiativeHelper
Defined in:
decidim-core/app/helpers/decidim/resource_versions_helper.rb

Overview

Helper to print resource versions.

Instance Method Summary collapse

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #linked_resources_for, #resource_locator, #resource_title

Instance Method Details


36
37
38
39
40
41
42
43
44
# File 'decidim-core/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 'decidim-core/app/helpers/decidim/resource_versions_helper.rb', line 15

def resource_version(resource, options = {})
  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(options[:versions_path]) if options[:versions_path]

  (:div, safe_join(html), class: "tech-info #{options[:class]}")
end

#resource_version_number(count, css_class = "") ⇒ Object


28
29
30
# File 'decidim-core/app/helpers/decidim/resource_versions_helper.rb', line 28

def resource_version_number(count, css_class = "")
  (:strong, t("version", scope: "decidim.versions.resource_version", number: count), class: css_class)
end

#resource_version_of(count) ⇒ Object


32
33
34
# File 'decidim-core/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