Sha256: 1b69fcf8bbe90b54a0ef17a79a9ac8b44f8ed25ff34d344855bcbad90018b6cd

Contents?: true

Size: 1.4 KB

Versions: 24

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Decidim
  # Helper to print resource versions.
  module ResourceVersionsHelper
    include ResourceHelper

    # 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.
    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]

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

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

    def resource_version_of(count)
      t("of_versions", scope: "decidim.versions.resource_version", number: count)
    end

    def link_to_other_resource_versions(versions_path)
      link_to(
        t(
          "see_other_versions",
          scope: "decidim.versions.resource_version"
        ),
        versions_path
      )
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.8 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.7 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.6 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.10 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.9 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.5 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.8 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.4 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.3 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.7 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.5 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.2 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.1 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.4 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.0 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.3 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.0.rc2 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.27.0.rc1 app/helpers/decidim/resource_versions_helper.rb
decidim-core-0.26.2 app/helpers/decidim/resource_versions_helper.rb