Module: Decidim::CellsHelper

Included in:
AuthorCell, CollapsibleAuthorsCell, EndorsementButtonsCell, ProfileSidebarCell
Defined in:
app/helpers/decidim/cells_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_componentObject



17
18
19
# File 'app/helpers/decidim/cells_helper.rb', line 17

def current_component
  from_context.component
end

#flaggable?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'app/helpers/decidim/cells_helper.rb', line 29

def flaggable?
  return unless from_context
  return unless context[:controller].try(:flaggable_controller?)
  return if index_action?

  true
end

#from_contextObject



5
6
7
# File 'app/helpers/decidim/cells_helper.rb', line 5

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

#index_action?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/helpers/decidim/cells_helper.rb', line 9

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

#show_action?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/helpers/decidim/cells_helper.rb', line 13

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

#user_flaggable?Boolean

Returns:

  • (Boolean)


37
38
39
40
41
# File 'app/helpers/decidim/cells_helper.rb', line 37

def user_flaggable?
  return unless context[:controller].try(:flaggable_controller?)

  true
end

#withdrawable?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'app/helpers/decidim/cells_helper.rb', line 21

def withdrawable?
  return unless from_context
  return unless context[:controller].try(:withdrawable_controller?)
  return if index_action?

  from_context.withdrawable_by?(current_user)
end