Class: Spina::Admin::Journal::ArticlesListComponent

Inherits:
ListComponent show all
Defined in:
app/components/spina/admin/journal/articles_list_component.rb

Overview

A list of articles. Articles should only be sortable if presented within the contex of an issue.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(articles:, sortable: false) ⇒ ArticlesListComponent

Returns a new instance of ArticlesListComponent.



11
12
13
14
# File 'app/components/spina/admin/journal/articles_list_component.rb', line 11

def initialize(articles:, sortable: false)
  @articles = articles
  @sortable = sortable
end

Instance Attribute Details

#sortableObject (readonly)

Returns the value of attribute sortable.



9
10
11
# File 'app/components/spina/admin/journal/articles_list_component.rb', line 9

def sortable
  @sortable
end

Instance Method Details

#before_renderObject



16
17
18
# File 'app/components/spina/admin/journal/articles_list_component.rb', line 16

def before_render
  @list_items = generate_list_items(@articles)
end

#callObject



20
21
22
23
24
# File 'app/components/spina/admin/journal/articles_list_component.rb', line 20

def call
  render ListComponent.new(list_items: @list_items,
                           sortable: sortable?,
                           sort_path: generate_sort_path)
end

#sortable?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/components/spina/admin/journal/articles_list_component.rb', line 26

def sortable?
  sortable
end