Sha256: 232546e0757f08738f58f0f0c46620e5f1561f923ca38779bc4d4e7d74a84d2f

Contents?: true

Size: 1.1 KB

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.18.1 app/helpers/decidim/cells_helper.rb
decidim-core-0.17.2 app/helpers/decidim/cells_helper.rb
decidim-core-0.18.0 app/helpers/decidim/cells_helper.rb
decidim-core-0.17.1 app/helpers/decidim/cells_helper.rb
decidim-core-0.17.0 app/helpers/decidim/cells_helper.rb