Class: Decidim::ResourceHistoryCell

Inherits:
ViewModel
  • Object
show all
Defined in:
app/cells/decidim/resource_history_cell.rb

Instance Method Summary collapse

Instance Method Details

#creation_itemObject

return the creation item to show in the history, it will be added only if there are linked resources

Raises:

  • (NotImplementedError)


33
34
35
# File 'app/cells/decidim/resource_history_cell.rb', line 33

def creation_item
  raise NotImplementedError
end

#history_cell_idObject

return an unique id to identify the type of history cell

Raises:

  • (NotImplementedError)


23
24
25
# File 'app/cells/decidim/resource_history_cell.rb', line 23

def history_cell_id
  raise NotImplementedError
end

#history_itemsObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/cells/decidim/resource_history_cell.rb', line 9

def history_items
  return @history_items if @history_items.present?

  @history_items = []
  linked_resources_items.each do |item|
    add_linked_resources_items(item[:resources], item)
  end

  @history_items << creation_item if @history_items.any?

  @history_items.sort_by! { |item| item[:date] }
end

#linked_resources_itemsObject

return an array of linked resources to show in the history

Raises:

  • (NotImplementedError)


28
29
30
# File 'app/cells/decidim/resource_history_cell.rb', line 28

def linked_resources_items
  raise NotImplementedError
end

#render?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/cells/decidim/resource_history_cell.rb', line 37

def render?
  linked_resources_items.any? { |item| item[:resources].present? }
end

#showObject



5
6
7
# File 'app/cells/decidim/resource_history_cell.rb', line 5

def show
  render
end