Class: Koi::SummaryListComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
Katalyst::HtmlAttributes
Defined in:
app/components/koi/summary_list_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(model: nil, skip_blank: true, **attributes) ⇒ SummaryListComponent

Returns a new instance of SummaryListComponent.



20
21
22
23
24
25
# File 'app/components/koi/summary_list_component.rb', line 20

def initialize(model: nil, skip_blank: true, **attributes)
  super(**attributes)

  @model      = model
  @skip_blank = skip_blank
end

Instance Method Details

#attachment(attribute, label: nil, skip_blank: @skip_blank, variant: :thumb) ⇒ Object



51
52
53
# File 'app/components/koi/summary_list_component.rb', line 51

def attachment(attribute, label: nil, skip_blank: @skip_blank, variant: :thumb, &)
  with_definition_attachment(@model, attribute, label:, skip_blank:, variant:, &)
end

#boolean(attribute, label: nil) ⇒ Object



27
28
29
# File 'app/components/koi/summary_list_component.rb', line 27

def boolean(attribute, label: nil, &)
  with_definition_boolean(@model, attribute, label:, &)
end

#date(attribute, label: nil, format: :admin, skip_blank: @skip_blank) ⇒ Object



31
32
33
# File 'app/components/koi/summary_list_component.rb', line 31

def date(attribute, label: nil, format: :admin, skip_blank: @skip_blank, &)
  with_definition_date(@model, attribute, label:, format:, skip_blank:, &)
end

#datetime(attribute, label: nil, format: :admin, skip_blank: @skip_blank) ⇒ Object



35
36
37
# File 'app/components/koi/summary_list_component.rb', line 35

def datetime(attribute, label: nil, format: :admin, skip_blank: @skip_blank, &)
  with_definition_datetime(@model, attribute, label:, format:, skip_blank:, &)
end

#default_html_attributesObject



71
72
73
# File 'app/components/koi/summary_list_component.rb', line 71

def default_html_attributes
  { class: "summary-list" }
end

#inspectObject



67
68
69
# File 'app/components/koi/summary_list_component.rb', line 67

def inspect
  "#<#{self.class.name}>"
end

#item(model, attribute, label: nil, skip_blank: @skip_blank) ⇒ Object

Deprecated.

legacy interface



56
57
58
# File 'app/components/koi/summary_list_component.rb', line 56

def item(model, attribute, label: nil, skip_blank: @skip_blank, &)
  with_definition_item(model, attribute, label:, skip_blank:, &)
end

#items_with(model:, attributes:, **options) ⇒ Object

Deprecated.

legacy interface



61
62
63
64
65
# File 'app/components/koi/summary_list_component.rb', line 61

def items_with(model:, attributes:, **options)
  attributes.each do |attribute|
    item(model, attribute, **options)
  end
end

#number(attribute, label: nil, skip_blank: @skip_blank) ⇒ Object



43
44
45
# File 'app/components/koi/summary_list_component.rb', line 43

def number(attribute, label: nil, skip_blank: @skip_blank, &)
  with_definition_number(@model, attribute, label:, skip_blank:, &)
end

#rich_text(attribute, label: nil, skip_blank: @skip_blank) ⇒ Object



39
40
41
# File 'app/components/koi/summary_list_component.rb', line 39

def rich_text(attribute, label: nil, skip_blank: @skip_blank, &)
  with_definition_rich_text(@model, attribute, label:, skip_blank:, &)
end

#text(attribute, label: nil, skip_blank: @skip_blank) ⇒ Object



47
48
49
# File 'app/components/koi/summary_list_component.rb', line 47

def text(attribute, label: nil, skip_blank: @skip_blank, &)
  with_definition_text(@model, attribute, label:, skip_blank:, &)
end