Class: FlexiAdmin::Components::Resources::ListViewComponent
Defined Under Namespace
Classes: Column
Instance Attribute Summary collapse
Instance Method Summary
collapse
#navigate_to
#selectable, #selectable?
#as_navigation, #format
#autocomplete_path, #bulk_action_path, #datalist_path, #edit_resource_path, #paginate, #resource__path, #resource_input_name, #resource_path, #resources_path, #scope, #scope_plural, #scope_singular
Constructor Details
35
36
37
38
39
40
41
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 35
def initialize(context)
@context = context
@resources = context.resources
@columns = []
= []
@is_selectable = false
end
|
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
33
34
35
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 33
def columns
@columns
end
|
#context ⇒ Object
Returns the value of attribute context.
33
34
35
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 33
def context
@context
end
|
#resource ⇒ Object
Returns the value of attribute resource.
33
34
35
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 33
def resource
@resource
end
|
#resources ⇒ Object
Returns the value of attribute resources.
33
34
35
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 33
def resources
@resources
end
|
Instance Method Details
#as_date(value, format: nil) ⇒ Object
52
53
54
55
56
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 52
def as_date(value, format: nil)
return if value.blank?
I18n.l(value, format:)
end
|
#as_text(value) ⇒ Object
48
49
50
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 48
def as_text(value)
value.to_s
end
|
#build_column(attribute, options, &block) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 72
def build_column(attribute, options, &block)
options[:formatter] = format(options[:as] || :text)
Column.new(attribute,
block || proc { |resource| resource.send(attribute) },
options.presence || {})
end
|
#column(attribute, options = {}, &block) ⇒ Object
68
69
70
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 68
def column(attribute, options = {}, &block)
@columns << build_column(attribute, options, &block)
end
|
#list_view ⇒ Object
58
59
60
61
62
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 58
def list_view
yield
table
end
|
#render? ⇒ Boolean
43
44
45
46
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 43
def render?
context.params.current_view == 'list' ||
(context.views.first == 'list' && context.params.current_view.blank?)
end
|
#table ⇒ Object
64
65
66
|
# File 'lib/flexi_admin/components/resources/list_view_component.rb', line 64
def table
render FlexiAdmin::Components::Resources::ListView::TableComponent.new(, columns, resources, context, selectable: true)
end
|