Class: LesliView::Elements::Table

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
lib/lesli_view/elements/table.rb

Defined Under Namespace

Classes: TableRow

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(columns: nil, records: nil, id: nil, class_name: "is-striped", pagination: nil, loading: false, headless: false, link: nil) ⇒ Table

Returns a new instance of Table.



40
41
42
43
44
45
46
47
48
49
# File 'lib/lesli_view/elements/table.rb', line 40

def initialize(columns: nil, records: nil, id: nil, class_name: "is-striped", pagination: nil, loading: false, headless: false, link: nil)
    @id = id
    @class_name = class_name
    @pagination = pagination
    @loading = loading
    @headless = headless
    @columns = columns
    @records = records
    @link = link
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def class_name
  @class_name
end

#columnsObject (readonly)

Returns the value of attribute columns.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def columns
  @columns
end

#headlessObject (readonly)

Returns the value of attribute headless.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def headless
  @headless
end

#idObject (readonly)

Returns the value of attribute id.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def id
  @id
end

Returns the value of attribute link.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def link
  @link
end

#loadingObject (readonly)

Returns the value of attribute loading.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def loading
  @loading
end

#paginationObject (readonly)

Returns the value of attribute pagination.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def pagination
  @pagination
end

#recordsObject (readonly)

Returns the value of attribute records.



36
37
38
# File 'lib/lesli_view/elements/table.rb', line 36

def records
  @records
end

Instance Method Details

#table_body_class(column) ⇒ Object



55
56
57
# File 'lib/lesli_view/elements/table.rb', line 55

def table_body_class(column)
    column[:field] == "id" || column[:align] == "center" ? "has-text-centered" : ""
end

#table_header_class(column) ⇒ Object



51
52
53
# File 'lib/lesli_view/elements/table.rb', line 51

def table_header_class(column)
    column[:field] == "id" || column[:align] == "center" ? "has-text-centered" : ""
end