Sha256: b62c10b2c049133548ce54be617b61cb868f18678cfbfe0a8aa3bd46f9af58fe

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  module CellsHelper
    def from_context
      options[:from].presence || context[:from].presence
    end

    def proposals_controller?
      context[:controller].class.to_s == "Decidim::Proposals::ProposalsController"
    end

    def collaborative_drafts_controller?
      context[:controller].class.to_s == "Decidim::Proposals::CollaborativeDraftsController"
    end

    def posts_controller?
      context[:controller].class.to_s == "Decidim::Blogs::PostsController"
    end

    def index_action?
      context[:controller].action_name == "index"
    end

    def show_action?
      context[:controller].action_name == "show"
    end

    def current_component
      from_context.component
    end

    def withdrawable?
      return unless from_context
      return unless proposals_controller?
      return if index_action?

      from_context.withdrawable_by?(current_user)
    end

    def flagable?
      return unless from_context
      return unless proposals_controller? || collaborative_drafts_controller?
      return if index_action?

      true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.22.0 app/helpers/decidim/cells_helper.rb
decidim-core-0.21.0 app/helpers/decidim/cells_helper.rb
decidim-core-0.20.1 app/helpers/decidim/cells_helper.rb
decidim-core-0.20.0 app/helpers/decidim/cells_helper.rb
decidim-core-0.19.1 app/helpers/decidim/cells_helper.rb
decidim-core-0.19.0 app/helpers/decidim/cells_helper.rb