avo 3.0.0.beta1 → 3.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +5 -5
- data/Gemfile.lock +81 -92
- data/{public/avo-assets/avo.css → app/assets/builds/avo.base.css} +686 -728
- data/app/assets/builds/avo.base.js +93804 -0
- data/app/assets/builds/avo.base.js.map +7 -0
- data/app/assets/stylesheets/avo.base.css +2 -1
- data/app/assets/svgs/failed_to_load.svg +1 -0
- data/app/assets/svgs/grid-empty-state.svg +1 -0
- data/app/assets/svgs/table-empty-state.svg +1 -0
- data/app/assets/svgs/triangle-up.svg +1 -1
- data/app/components/avo/actions_component.html.erb +1 -1
- data/app/components/avo/actions_component.rb +16 -42
- data/app/components/avo/alert_component.html.erb +1 -1
- data/app/components/avo/base_component.rb +7 -7
- data/app/components/avo/field_wrapper_component.html.erb +4 -4
- data/app/components/avo/field_wrapper_component.rb +1 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +5 -5
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +4 -8
- data/app/components/avo/fields/boolean_field/edit_component.html.erb +0 -1
- data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/code_field/edit_component.html.erb +0 -1
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +5 -0
- data/app/components/avo/fields/common/files_list_viewer_component.rb +8 -0
- data/app/components/avo/fields/common/heading_component.html.erb +1 -1
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +56 -0
- data/app/components/avo/fields/common/single_file_viewer_component.rb +55 -0
- data/app/components/avo/fields/country_field/edit_component.html.erb +1 -3
- data/app/components/avo/fields/file_field/edit_component.html.erb +2 -4
- data/app/components/avo/fields/file_field/edit_component.rb +0 -1
- data/app/components/avo/fields/file_field/index_component.rb +2 -2
- data/app/components/avo/fields/file_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/edit_component.html.erb +2 -4
- data/app/components/avo/fields/files_field/edit_component.rb +0 -1
- data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/has_many_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/has_one_field/show_component.html.erb +4 -5
- data/app/components/avo/fields/has_one_field/show_component.rb +2 -6
- data/app/components/avo/fields/index_component.rb +0 -1
- data/app/components/avo/fields/markdown_field/edit_component.html.erb +3 -4
- data/app/components/avo/fields/markdown_field/show_component.html.erb +3 -3
- data/app/components/avo/fields/number_field/edit_component.html.erb +1 -3
- data/app/components/avo/fields/password_field/edit_component.html.erb +1 -3
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +0 -1
- data/app/components/avo/fields/select_field/edit_component.html.erb +1 -2
- data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/text_field/edit_component.html.erb +2 -3
- data/app/components/avo/fields/textarea_field/edit_component.html.erb +0 -1
- data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -2
- data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.rb +12 -0
- data/app/components/avo/index/grid_item_component.html.erb +35 -9
- data/app/components/avo/index/grid_item_component.rb +10 -36
- data/app/components/avo/index/resource_controls_component.rb +11 -8
- data/app/components/avo/index/resource_table_component.rb +1 -1
- data/app/components/avo/item_switcher_component.html.erb +5 -10
- data/app/components/avo/item_switcher_component.rb +1 -2
- data/app/components/avo/modal_component.html.erb +1 -1
- data/app/components/avo/panel_component.html.erb +1 -6
- data/app/components/avo/panel_component.rb +0 -1
- data/app/components/avo/profile_item_component.html.erb +2 -17
- data/app/components/avo/profile_item_component.rb +1 -13
- data/app/components/avo/referrer_params_component.html.erb +0 -2
- data/app/components/avo/resource_component.rb +6 -69
- data/app/components/avo/resource_sidebar_component.rb +1 -1
- data/app/components/avo/sidebar/link_component.html.erb +0 -2
- data/app/components/avo/sidebar/link_component.rb +3 -5
- data/app/components/avo/sidebar_component.html.erb +3 -3
- data/app/components/avo/sidebar_component.rb +4 -4
- data/app/components/avo/sidebar_profile_component.html.erb +27 -27
- data/app/components/avo/views/resource_edit_component.html.erb +5 -5
- data/app/components/avo/views/resource_edit_component.rb +1 -1
- data/app/components/avo/views/resource_index_component.html.erb +10 -19
- data/app/components/avo/views/resource_index_component.rb +16 -22
- data/app/components/avo/views/resource_show_component.html.erb +4 -4
- data/app/controllers/avo/actions_controller.rb +20 -20
- data/app/controllers/avo/application_controller.rb +67 -90
- data/app/controllers/avo/associations_controller.rb +7 -5
- data/app/controllers/avo/attachments_controller.rb +7 -22
- data/app/controllers/avo/base_controller.rb +35 -47
- data/app/controllers/avo/home_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +16 -20
- data/app/controllers/concerns/avo/initializes_avo.rb +8 -3
- data/app/helpers/avo/application_helper.rb +6 -13
- data/app/javascript/js/application.js +0 -2
- data/app/javascript/js/controllers/fields/{easy_mde_controller.js → simple_mde_controller.js} +3 -4
- data/app/javascript/js/controllers/search_controller.js +1 -3
- data/app/javascript/js/controllers.js +2 -2
- data/app/views/avo/actions/show.html.erb +3 -5
- data/app/views/avo/associations/new.html.erb +3 -3
- data/app/views/avo/debug/status.html.erb +5 -6
- data/app/views/avo/home/index.html.erb +1 -1
- data/app/views/avo/partials/_custom_tools_alert.html.erb +2 -2
- data/app/views/avo/partials/_footer.html.erb +1 -1
- data/app/views/avo/partials/_javascript.html.erb +1 -1
- data/app/views/avo/partials/_navbar.html.erb +1 -1
- data/app/views/avo/partials/_table_header.html.erb +8 -0
- data/app/views/avo/partials/_view_toggle_button.html.erb +0 -9
- data/app/views/avo/private/design.html.erb +2 -2
- data/app/views/layouts/avo/application.html.erb +3 -2
- data/avo.gemspec +1 -2
- data/config/initializers/pagy.rb +10 -12
- data/config/routes.rb +5 -5
- data/db/factories.rb +0 -17
- data/lib/avo/app.rb +165 -0
- data/lib/avo/base_action.rb +18 -31
- data/lib/avo/base_resource.rb +213 -238
- data/lib/avo/concerns/breadcrumbs.rb +2 -2
- data/lib/avo/concerns/can_replace_items.rb +7 -3
- data/lib/avo/concerns/filters_session_handler.rb +4 -5
- data/lib/avo/concerns/has_item_type.rb +0 -4
- data/lib/avo/concerns/has_items.rb +115 -93
- data/lib/avo/concerns/is_visible.rb +1 -1
- data/lib/avo/concerns/model_class_constantized.rb +2 -0
- data/lib/avo/configuration.rb +8 -9
- data/lib/avo/current.rb +1 -35
- data/lib/avo/dsl/field_parser.rb +1 -1
- data/lib/avo/dynamic_router.rb +2 -13
- data/lib/avo/engine.rb +13 -11
- data/lib/avo/execution_context.rb +2 -4
- data/lib/avo/fields/base_field.rb +14 -51
- data/lib/avo/fields/belongs_to_field.rb +13 -20
- data/lib/avo/fields/concerns/is_searchable.rb +1 -1
- data/lib/avo/fields/concerns/use_resource.rb +1 -1
- data/lib/avo/fields/date_field.rb +3 -16
- data/lib/avo/fields/field_manager.rb +3 -13
- data/lib/avo/fields/file_field.rb +0 -2
- data/lib/avo/fields/files_field.rb +0 -6
- data/lib/avo/fields/has_base_field.rb +5 -5
- data/lib/avo/fields/has_one_field.rb +1 -2
- data/lib/avo/fields/id_field.rb +1 -2
- data/lib/avo/filters/base_filter.rb +0 -9
- data/lib/avo/grid_collector.rb +40 -0
- data/lib/avo/html/builder.rb +1 -3
- data/lib/avo/licensing/h_q.rb +6 -11
- data/lib/avo/licensing/license.rb +1 -1
- data/lib/avo/licensing/license_manager.rb +1 -1
- data/lib/avo/licensing/{nil_license.rb → null_license.rb} +1 -1
- data/lib/avo/loaders/fields_loader.rb +1 -7
- data/lib/avo/plugin.rb +0 -10
- data/lib/avo/plugin_manager.rb +4 -2
- data/lib/avo/reloader.rb +1 -1
- data/lib/avo/resources/controls/actions_list.rb +1 -2
- data/lib/avo/resources/controls/create_button.rb +1 -1
- data/lib/avo/resources/controls/delete_button.rb +1 -1
- data/lib/avo/resources/controls/detach_button.rb +1 -1
- data/lib/avo/resources/controls/edit_button.rb +1 -1
- data/lib/avo/resources/controls/show_button.rb +1 -1
- data/lib/avo/resources/items/holder.rb +5 -13
- data/lib/avo/resources/items/item_group.rb +0 -1
- data/lib/avo/resources/resource_manager.rb +18 -11
- data/lib/avo/services/debug_service.rb +5 -6
- data/lib/avo/services/telemetry_service.rb +2 -3
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +25 -109
- data/lib/generators/avo/action_generator.rb +8 -8
- data/lib/generators/avo/card/chartkick_generator.rb +18 -0
- data/lib/generators/avo/card/metric_generator.rb +18 -0
- data/lib/generators/avo/card/partial_generator.rb +19 -0
- data/lib/generators/avo/eject_generator.rb +0 -1
- data/lib/generators/avo/filter_generator.rb +8 -8
- data/lib/generators/avo/install_generator.rb +1 -11
- data/lib/generators/avo/resource_generator.rb +4 -22
- data/lib/generators/avo/tailwindcss/install_generator.rb +1 -4
- data/lib/generators/avo/templates/action.tt +5 -7
- data/lib/generators/avo/templates/cards/chartkick_card.tt +1 -1
- data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +1 -1
- data/lib/generators/avo/templates/cards/metric_card.tt +1 -1
- data/lib/generators/avo/templates/cards/metric_card_sample.tt +1 -1
- data/lib/generators/avo/templates/cards/partial_card.tt +1 -1
- data/lib/generators/avo/templates/cards/partial_card_sample.tt +1 -1
- data/lib/generators/avo/templates/dashboards/dashboard.tt +3 -5
- data/lib/generators/avo/templates/initializer/avo.tt +2 -4
- data/lib/generators/avo/templates/resource/resource.tt +6 -6
- data/lib/generators/avo/templates/scope.tt +1 -1
- data/lib/generators/avo/templates/standalone_action.tt +8 -0
- data/lib/generators/avo/templates/tailwindcss/Procfile.dev +1 -1
- data/lib/tasks/avo_tasks.rake +0 -5
- metadata +19 -56
- data/app/assets/svgs/map-empty-state.svg +0 -35
- data/app/assets/svgs/map-view-type.svg +0 -3
- data/app/components/avo/fields/area_field/edit_component.html.erb +0 -7
- data/app/components/avo/fields/area_field/edit_component.rb +0 -4
- data/app/components/avo/fields/area_field/show_component.html.erb +0 -8
- data/app/components/avo/fields/area_field/show_component.rb +0 -4
- data/app/components/avo/fields/common/files/controls_component.html.erb +0 -29
- data/app/components/avo/fields/common/files/controls_component.rb +0 -19
- data/app/components/avo/fields/common/files/list_viewer_component.html.erb +0 -20
- data/app/components/avo/fields/common/files/list_viewer_component.rb +0 -41
- data/app/components/avo/fields/common/files/view_type/grid_component.html.erb +0 -27
- data/app/components/avo/fields/common/files/view_type/grid_component.rb +0 -51
- data/app/components/avo/fields/common/files/view_type/list_component.html.erb +0 -22
- data/app/components/avo/fields/common/files/view_type/list_component.rb +0 -15
- data/app/components/avo/fields/location_field/edit_component.html.erb +0 -22
- data/app/components/avo/fields/location_field/edit_component.rb +0 -4
- data/app/components/avo/fields/location_field/show_component.html.erb +0 -7
- data/app/components/avo/fields/location_field/show_component.rb +0 -4
- data/app/components/avo/index/resource_map_component.html.erb +0 -16
- data/app/components/avo/index/resource_map_component.rb +0 -109
- data/app/components/avo/row_component.html.erb +0 -3
- data/app/components/avo/row_component.rb +0 -12
- data/app/views/avo/attachments/destroy.turbo_stream.erb +0 -7
- data/app/views/avo/partials/_profile_menu_extra.html.erb +0 -2
- data/lib/avo/concerns/has_description.rb +0 -23
- data/lib/avo/fields/area_field.rb +0 -39
- data/lib/avo/fields/concerns/file_authorization.rb +0 -31
- data/lib/avo/fields/location_field.rb +0 -86
- data/lib/avo/resources/items/row.rb +0 -54
- data/lib/generators/avo/card_generator.rb +0 -27
- data/public/avo-assets/avo.base.css +0 -10542
- data/public/avo-assets/avo.base.js +0 -949
- data/public/avo-assets/avo.base.js.map +0 -7
- data/public/avo-assets/avo.js +0 -513
- data/public/avo-assets/avo.js.map +0 -7
@@ -1,22 +0,0 @@
|
|
1
|
-
<div id="<%= dom_id file %>" class="relative min-h-full max-w-full flex-1 flex">
|
2
|
-
<% if file.present? %>
|
3
|
-
<div class="grid grid-cols-6 gap-2 items-center max-w-full w-full">
|
4
|
-
<div class="col-span-4 flex-1 flex flex-row items-center text-gray-700 overflow-x-auto mac-styled-scrollbar ">
|
5
|
-
<div class="rounded-full bg-slate-100 border border-gray-500 p-1.5 flex items-center justify-center">
|
6
|
-
<%= helpers.svg icon_for_file, class: "h-5 text-gray-600" %>
|
7
|
-
</div>
|
8
|
-
<p class="items-center h-full p-2 flex-shrink-0">
|
9
|
-
<%= file.filename %>
|
10
|
-
</p>
|
11
|
-
</div>
|
12
|
-
<div class="text-gray-700 flex-shrink-0 text-sm">
|
13
|
-
<%= helpers.number_to_human_size(file.byte_size) %>
|
14
|
-
</div>
|
15
|
-
<div class="flex space-x-2 justify-end col-span-1 flex-shrink-0">
|
16
|
-
<%= render Avo::Fields::Common::Files::ControlsComponent.new(field: field, file: file, resource: resource) %>
|
17
|
-
</div>
|
18
|
-
</div>
|
19
|
-
<% else %>
|
20
|
-
–
|
21
|
-
<% end %>
|
22
|
-
</div>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Avo::Fields::Common::Files::ViewType::ListComponent < Avo::Fields::Common::Files::ViewType::GridComponent
|
4
|
-
def icon_for_file
|
5
|
-
if is_image?
|
6
|
-
"photo"
|
7
|
-
elsif is_audio?
|
8
|
-
"speaker-wave"
|
9
|
-
elsif is_video?
|
10
|
-
"video-camera"
|
11
|
-
else
|
12
|
-
"document"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<%= field_wrapper **field_wrapper_args do %>
|
2
|
-
<% if field.value_as_array? %>
|
3
|
-
<div class="flex gap-4">
|
4
|
-
<%= @form.text_field @field.as_lat_long_field_id(:lat),
|
5
|
-
value: @field.as_lat_long_value(:lat),
|
6
|
-
class: classes("w-full"),
|
7
|
-
placeholder: @field.as_lat_long_placeholder(:lat)
|
8
|
-
%>
|
9
|
-
<%= @form.text_field @field.as_lat_long_field_id(:long),
|
10
|
-
value: @field.as_lat_long_value(:long),
|
11
|
-
class: classes("w-full"),
|
12
|
-
placeholder: @field.as_lat_long_placeholder(:long)
|
13
|
-
%>
|
14
|
-
</div>
|
15
|
-
<% else %>
|
16
|
-
<%= @form.text_field @field.id,
|
17
|
-
value: @field.value,
|
18
|
-
class: classes("w-full"),
|
19
|
-
placeholder: @field.placeholder
|
20
|
-
%>
|
21
|
-
<% end %>
|
22
|
-
<% end %>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<% if @resources.present? %>
|
2
|
-
<div class="map-view-container grid <%= grid_layout_classes %>">
|
3
|
-
<div class="map-component min-h-full <%= map_component_order_class %>">
|
4
|
-
<%= js_map(resource_location_markers, **resource_mapkick_options) %>
|
5
|
-
</div>
|
6
|
-
<% if render_table? %>
|
7
|
-
<div class="overflow-auto <%= table_component_order_class %>">
|
8
|
-
<%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
|
9
|
-
</div>
|
10
|
-
<% end %>
|
11
|
-
</div>
|
12
|
-
<% else %>
|
13
|
-
<div class="bg-white rounded shadow-panel">
|
14
|
-
<%= helpers.empty_state by_association: params[:related_name].present?, view_type: :map %>
|
15
|
-
</div>
|
16
|
-
<% end %>
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avo
|
4
|
-
module Index
|
5
|
-
# Render a map view for a list of resources, where each resource is
|
6
|
-
# expected to have an attribute/attribute set representing its location.
|
7
|
-
class ResourceMapComponent < ViewComponent::Base
|
8
|
-
attr_reader :resources
|
9
|
-
|
10
|
-
def initialize(resources: nil, resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, pagy: nil, query: nil)
|
11
|
-
super
|
12
|
-
@resources = resources
|
13
|
-
@resource = resource
|
14
|
-
@reflection = reflection
|
15
|
-
@parent_record = parent_record
|
16
|
-
@parent_resource = parent_resource
|
17
|
-
@pagy = pagy
|
18
|
-
@query = query
|
19
|
-
end
|
20
|
-
|
21
|
-
def grid_layout_classes
|
22
|
-
return unless render_table?
|
23
|
-
|
24
|
-
if table_positioned_horizontally
|
25
|
-
"grid-flow-row sm:grid-flow-col grid-rows-1 auto-cols-fr"
|
26
|
-
elsif table_positioned_vertically
|
27
|
-
"grid-flow-row grid-cols-1"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def table_positioned_horizontally
|
32
|
-
%i[left right].include?(map_view_table_layout)
|
33
|
-
end
|
34
|
-
|
35
|
-
def table_positioned_vertically
|
36
|
-
%i[bottom top].include?(map_view_table_layout)
|
37
|
-
end
|
38
|
-
|
39
|
-
def map_component_order_class
|
40
|
-
if render_table? && table_positioned_at_the_start
|
41
|
-
"order-last"
|
42
|
-
else
|
43
|
-
"order-first"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def table_component_order_class
|
48
|
-
if table_positioned_at_the_start
|
49
|
-
"order-first"
|
50
|
-
else
|
51
|
-
"order-last"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def table_positioned_at_the_start
|
56
|
-
%i[left top].include?(map_view_table_layout)
|
57
|
-
end
|
58
|
-
|
59
|
-
def map_view_table_layout
|
60
|
-
map_options.dig(:table, :layout)
|
61
|
-
end
|
62
|
-
|
63
|
-
def resource_location_markers
|
64
|
-
# If we have no proc and no default location method, don't try to create markers
|
65
|
-
return [] unless resource_mappable?
|
66
|
-
|
67
|
-
resources
|
68
|
-
.map do |resource|
|
69
|
-
Avo::ExecutionContext.new(target: marker_proc, record: resource.record).handle
|
70
|
-
end
|
71
|
-
.compact
|
72
|
-
.filter do |coordinates|
|
73
|
-
coordinates[:latitude].present? && coordinates[:longitude].present?
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def resource_mapkick_options
|
78
|
-
map_options[:mapkick_options] || {}
|
79
|
-
end
|
80
|
-
|
81
|
-
def render_table?
|
82
|
-
map_options.dig(:table, :visible)
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def default_record_marker_proc
|
88
|
-
lambda {
|
89
|
-
{
|
90
|
-
latitude: record.coordinates.first,
|
91
|
-
longitude: record.coordinates.last
|
92
|
-
}
|
93
|
-
}
|
94
|
-
end
|
95
|
-
|
96
|
-
def map_options
|
97
|
-
@resource.map_view || {}
|
98
|
-
end
|
99
|
-
|
100
|
-
def marker_proc
|
101
|
-
map_options[:record_marker] || default_record_marker_proc
|
102
|
-
end
|
103
|
-
|
104
|
-
def resource_mappable?
|
105
|
-
map_options[:record_marker].present? || @resources.first.record.respond_to?(:coordinates)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Adds the ability to set the visibility of an item in the execution context.
|
2
|
-
module Avo
|
3
|
-
module Concerns
|
4
|
-
module HasDescription
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
class_methods do
|
8
|
-
attr_accessor :description
|
9
|
-
end
|
10
|
-
|
11
|
-
def description
|
12
|
-
Avo::ExecutionContext.new(target: @description || self.class.description, **description_attributes).handle
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
# Override this method to add custom attributes to the description execution context.
|
18
|
-
def description_attributes
|
19
|
-
{}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avo
|
4
|
-
module Fields
|
5
|
-
class AreaField < BaseField
|
6
|
-
attr_reader :mapkick_options
|
7
|
-
attr_reader :datapoint_options
|
8
|
-
|
9
|
-
def initialize(id, **args, &block)
|
10
|
-
hide_on :index
|
11
|
-
|
12
|
-
super(id, **args, &block)
|
13
|
-
|
14
|
-
@geometry = args[:geometry].presence || :polygon # Accepts: `:polygon` or `:multi_polygon`
|
15
|
-
@mapkick_options = args[:mapkick_options].presence || {}
|
16
|
-
@datapoint_options = args[:datapoint_options].presence || {}
|
17
|
-
end
|
18
|
-
|
19
|
-
def map_data
|
20
|
-
data_source = {
|
21
|
-
geometry: {
|
22
|
-
type: @geometry.to_s.classify,
|
23
|
-
coordinates: value
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
[data_source.merge(datapoint_options)]
|
28
|
-
end
|
29
|
-
|
30
|
-
def coordinates
|
31
|
-
value.present? ? JSON.parse(value) : []
|
32
|
-
end
|
33
|
-
|
34
|
-
def geometry
|
35
|
-
@geometry.to_s.classify
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Avo
|
2
|
-
module Fields
|
3
|
-
module Concerns
|
4
|
-
module FileAuthorization
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
delegate :authorization, to: :@resource
|
8
|
-
delegate :authorize_action, to: :authorization
|
9
|
-
delegate :id, :record, to: :@field
|
10
|
-
|
11
|
-
def can_upload_file?
|
12
|
-
authorize_file_action(:upload)
|
13
|
-
end
|
14
|
-
|
15
|
-
def can_delete_file?
|
16
|
-
authorize_file_action(:delete)
|
17
|
-
end
|
18
|
-
|
19
|
-
def can_download_file?
|
20
|
-
authorize_file_action(:download)
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def authorize_file_action(action)
|
26
|
-
authorize_action("#{action}_#{id}?", record: record, raise_exception: false)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avo
|
4
|
-
module Fields
|
5
|
-
class LocationField < BaseField
|
6
|
-
attr_reader :stored_as, :zoom
|
7
|
-
|
8
|
-
def initialize(id, **args, &block)
|
9
|
-
hide_on :index
|
10
|
-
super(id, **args, &block)
|
11
|
-
|
12
|
-
@stored_as = args[:stored_as].present? ? args[:stored_as] : nil # You can pass it an array of db columns [:latitude, :longitude]
|
13
|
-
@zoom = args[:zoom].present? ? args[:zoom].to_i : 15
|
14
|
-
end
|
15
|
-
|
16
|
-
def value_as_array?
|
17
|
-
stored_as.is_a?(Array) && stored_as.count == 2
|
18
|
-
end
|
19
|
-
|
20
|
-
def as_lat_long_field_id(get)
|
21
|
-
if get == :lat
|
22
|
-
"#{id}[#{stored_as.first}]"
|
23
|
-
elsif get == :long
|
24
|
-
"#{id}[#{stored_as.last}]"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def as_lat_long_placeholder(get)
|
29
|
-
if get == :lat
|
30
|
-
"Enter #{stored_as.first}"
|
31
|
-
elsif get == :long
|
32
|
-
"Enter #{stored_as.last}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def as_lat_long_value(get)
|
37
|
-
if get == :lat
|
38
|
-
record.send(stored_as.first)
|
39
|
-
elsif get == :long
|
40
|
-
record.send(stored_as.last)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def fill_field(record, key, value, params)
|
45
|
-
if value_as_array?
|
46
|
-
latitude_field, longitude_field = stored_as
|
47
|
-
record.send("#{latitude_field}=", value[latitude_field])
|
48
|
-
record.send("#{longitude_field}=", value[longitude_field])
|
49
|
-
record
|
50
|
-
else
|
51
|
-
super(record, key, value.split(","), params)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_permitted_param
|
56
|
-
if value_as_array?
|
57
|
-
[:"#{id}", "#{id}": {}]
|
58
|
-
else
|
59
|
-
super
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def value
|
64
|
-
if value_as_array?
|
65
|
-
[@record.send(stored_as.first), @record.send(stored_as.last)]
|
66
|
-
else
|
67
|
-
super
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def value_present?
|
72
|
-
return value.first.present? && value.second.present? if value.is_a?(Array) && value.count == 2
|
73
|
-
|
74
|
-
value.present?
|
75
|
-
end
|
76
|
-
|
77
|
-
def assign_value(record:, value:)
|
78
|
-
return super if stored_as.blank?
|
79
|
-
|
80
|
-
stored_as.each_with_index do |database_id, index|
|
81
|
-
record.send("#{database_id}=", value[index])
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
class Avo::Resources::Items::Row
|
2
|
-
include Avo::Concerns::IsResourceItem
|
3
|
-
include Avo::Concerns::HasItems
|
4
|
-
include Avo::Concerns::HasItemType
|
5
|
-
include Avo::Concerns::IsVisible
|
6
|
-
|
7
|
-
class_attribute :item_type, default: :row
|
8
|
-
|
9
|
-
attr_reader :view
|
10
|
-
attr_accessor :items_holder
|
11
|
-
|
12
|
-
delegate :items, :add_item, to: :items_holder
|
13
|
-
|
14
|
-
def initialize(view: nil)
|
15
|
-
@view = view
|
16
|
-
@items_holder = Avo::Resources::Items::Holder.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def hydrate(view: nil, resource: nil, **args)
|
20
|
-
@view = view
|
21
|
-
@resource = resource
|
22
|
-
|
23
|
-
self
|
24
|
-
end
|
25
|
-
|
26
|
-
def has_items?
|
27
|
-
@items.present?
|
28
|
-
end
|
29
|
-
|
30
|
-
class Builder
|
31
|
-
class << self
|
32
|
-
def parse_block(**args, &block)
|
33
|
-
Docile.dsl_eval(new(**args), &block).build
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
attr_reader :items_holder
|
38
|
-
|
39
|
-
delegate :field, to: :items_holder
|
40
|
-
delegate :tool, to: :items_holder
|
41
|
-
delegate :items, to: :items_holder
|
42
|
-
|
43
|
-
def initialize(**args)
|
44
|
-
@row = Avo::Resources::Items::Row.new(**args)
|
45
|
-
@items_holder = Avo::Resources::Items::Holder.new
|
46
|
-
end
|
47
|
-
|
48
|
-
# Fetch the tab
|
49
|
-
def build
|
50
|
-
@row.items_holder = @items_holder
|
51
|
-
@row
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "named_base_generator"
|
2
|
-
|
3
|
-
module Generators
|
4
|
-
module Avo
|
5
|
-
class Card < NamedBaseGenerator
|
6
|
-
namespace "avo:card"
|
7
|
-
source_root File.expand_path("templates", __dir__)
|
8
|
-
class_option :type, type: :string
|
9
|
-
|
10
|
-
def handle
|
11
|
-
raise "Invalid card type '#{options[:type]}'" unless card_types.include? options[:type]
|
12
|
-
|
13
|
-
template "cards/#{options[:type]}_card_sample.tt", "app/avo/cards/#{name.underscore}.rb"
|
14
|
-
|
15
|
-
if options[:type].to_sym == :partial
|
16
|
-
template "cards/partial_card_partial.tt", "app/views/avo/cards/_#{name.underscore}.html.erb"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def card_types
|
23
|
-
%w[metric chartkick partial]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|