Class: Avo::ViewTypes::MapComponent
Overview
Render a map view for a list of resources, where each resource is expected to have an attribute/attribute set representing its location.
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#paginator_component
#component_name
#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table
#find_association_field
Instance Attribute Details
#resources ⇒ Object
Returns the value of attribute resources.
6
7
8
|
# File 'app/components/avo/view_types/map_component.rb', line 6
def resources
@resources
end
|
Instance Method Details
#grid_layout_classes ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'app/components/avo/view_types/map_component.rb', line 10
def grid_layout_classes
return unless render_table?
if horizontal_layout?
"grid-flow-row sm:grid-flow-col grid-rows-1 auto-cols-fr"
elsif vertical_layout?
"grid-flow-row grid-cols-1"
end
end
|
#horizontal_layout? ⇒ Boolean
20
21
22
|
# File 'app/components/avo/view_types/map_component.rb', line 20
def horizontal_layout?
%i[left right].include?(map_position)
end
|
#map_component_order_class ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/components/avo/view_types/map_component.rb', line 28
def map_component_order_class
if render_table? && table_positioned_at_the_start?
"order-last"
else
"order-first"
end
end
|
#map_position ⇒ Object
48
49
50
|
# File 'app/components/avo/view_types/map_component.rb', line 48
def map_position
map_options.dig(:map, :position)
end
|
#render_table? ⇒ Boolean
84
85
86
|
# File 'app/components/avo/view_types/map_component.rb', line 84
def render_table?
map_options.dig(:table, :visible)
end
|
#resource_location_markers ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/components/avo/view_types/map_component.rb', line 52
def resource_location_markers
return [] unless resource_mappable?
records_markers = resources
.map do |resource|
Avo::ExecutionContext.new(target: marker_proc, record: resource.record).handle
end
.compact
.filter do |coordinates|
coordinates[:latitude].present? && coordinates[:longitude].present?
end
return records_markers if map_options[:extra_markers].nil?
records_markers + Avo::ExecutionContext.new(target: map_options[:extra_markers]).handle
end
|
#resource_mapkick_options ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/components/avo/view_types/map_component.rb', line 70
def resource_mapkick_options
options = map_options[:mapkick_options] || {}
options[:height] = if horizontal_layout?
"100%"
else
"26rem"
end
options[:style] ||= "mapbox://styles/mapbox/light-v11"
options
end
|
#table_component_order_class ⇒ Object
36
37
38
39
40
41
42
|
# File 'app/components/avo/view_types/map_component.rb', line 36
def table_component_order_class
if table_positioned_at_the_start?
"order-first"
else
"order-last"
end
end
|
#table_positioned_at_the_start? ⇒ Boolean
44
45
46
|
# File 'app/components/avo/view_types/map_component.rb', line 44
def table_positioned_at_the_start?
%i[right bottom].include?(map_position)
end
|
#vertical_layout? ⇒ Boolean
24
25
26
|
# File 'app/components/avo/view_types/map_component.rb', line 24
def vertical_layout?
%i[bottom top].include?(map_position)
end
|