Sha256: 2015dea3117d2197afc2e650c08ee3e006166fd627b939fd1f041c89200561bd

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    # Custom helpers, scoped to the proposals engine.
    #
    module ControlVersionHelper
      def versions_controller?
        return true if params[:controller] == "decidim/proposals/versions"

        false
      end

      def proposal?
        return true if item.class == Decidim::Proposals::Proposal

        false
      end

      def back_to_resource_path_text
        return unless versions_controller?

        if proposal?
          t("versions.stats.back_to_proposal", scope: "decidim.proposals")
        else
          t("versions.stats.back_to_collaborative_draft", scope: "decidim.proposals")
        end
      end

      def back_to_resource_path
        return unless versions_controller?

        if proposal?
          proposal_path(item)
        else
          collaborative_draft_path(item)
        end
      end

      def resource_version_path(index)
        return unless versions_controller?

        if proposal?
          proposal_version_path(item, index + 1)
        else
          collaborative_draft_version_path(item, index + 1)
        end
      end

      def resource_all_versions_path
        return unless versions_controller?

        if proposal?
          proposal_versions_path(item)
        else
          collaborative_draft_versions_path(item)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-proposals-0.17.2 app/helpers/decidim/proposals/control_version_helper.rb
decidim-proposals-0.17.1 app/helpers/decidim/proposals/control_version_helper.rb
decidim-proposals-0.16.1 app/helpers/decidim/proposals/control_version_helper.rb
decidim-proposals-0.17.0 app/helpers/decidim/proposals/control_version_helper.rb
decidim-proposals-0.16.0 app/helpers/decidim/proposals/control_version_helper.rb