Class: CafeCar::Table::HeadBuilder
Instance Attribute Summary collapse
Attributes inherited from Builder
#ui
Instance Method Summary
collapse
#model, #policy
Methods inherited from Builder
#has?, #html_safe?, #logo, #model_name, #remaining, #remaining_attributes, #shown, #shown!, #timestamp_attribute, #timestamps, #title, #to_s, #~@
#assign_option!, #assign_options!, #get_options
#call_procs!, #clone_or_call!
Constructor Details
Returns a new instance of HeadBuilder.
5
6
7
8
|
# File 'lib/cafe_car/table/head_builder.rb', line 5
def initialize(...)
@fields = []
super
end
|
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
3
4
5
|
# File 'lib/cafe_car/table/head_builder.rb', line 3
def fields
@fields
end
|
Instance Method Details
#cell(method, *flags, label: label(method)) ⇒ Object
10
11
12
13
14
|
# File 'lib/cafe_car/table/head_builder.rb', line 10
def cell(method, *flags, label: label(method), **, &)
super
@fields << model.info.field(method)
ui.Cell(*flags) { label }
end
|
#controls ⇒ Object
22
|
# File 'lib/cafe_car/table/head_builder.rb', line 22
def controls(*, **) = cell(:controls, :controls, *, label: nil, **)
|
#label(method) ⇒ Object
16
17
18
19
20
|
# File 'lib/cafe_car/table/head_builder.rb', line 16
def label(method)
l = LabelBuilder.new(@template, objects: @objects, method:)
@objects.includes!(method) if l.association?
l
end
|
#select ⇒ Object
24
25
26
27
28
|
# File 'lib/cafe_car/table/head_builder.rb', line 24
def select(*, **)
return unless @template.bulk_actions?
check_all = @template.tag.input(type: :checkbox, data: { bulk_select_all: true }, "aria-label": "Select all")
cell(:select, :select, *, label: check_all, **)
end
|
#to_html ⇒ Object
30
|
# File 'lib/cafe_car/table/head_builder.rb', line 30
def to_html = ui.Head(:sticky) { capture(self, &@block) }
|