avo 2.17.1.pre.1.zeitwerk.eager.load.dir → 2.17.1.pre.3
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 +1 -2
- data/Gemfile.lock +5 -11
- data/app/components/avo/button_component.rb +2 -2
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +3 -3
- data/app/components/avo/fields/date_field/edit_component.html.erb +2 -0
- data/app/components/avo/fields/date_field/index_component.html.erb +1 -0
- data/app/components/avo/fields/date_field/show_component.html.erb +1 -0
- data/app/components/avo/fields/date_time_field/edit_component.html.erb +2 -0
- data/app/components/avo/fields/date_time_field/index_component.html.erb +1 -0
- data/app/components/avo/fields/date_time_field/show_component.html.erb +1 -0
- data/app/components/avo/fields/time_field/edit_component.html.erb +40 -0
- data/app/components/avo/fields/time_field/edit_component.rb +4 -0
- data/app/components/avo/fields/time_field/index_component.html.erb +15 -0
- data/app/components/avo/fields/time_field/index_component.rb +4 -0
- data/app/components/avo/fields/time_field/show_component.html.erb +15 -0
- data/app/components/avo/fields/time_field/show_component.rb +4 -0
- data/app/components/avo/index/resource_controls_component.html.erb +2 -2
- data/app/components/avo/sidebar_profile_component.html.erb +4 -1
- data/app/components/avo/views/resource_edit_component.html.erb +10 -12
- data/app/components/avo/views/resource_show_component.html.erb +21 -25
- data/app/controllers/avo/associations_controller.rb +1 -4
- data/app/javascript/js/controllers/fields/date_field_controller.js +61 -21
- data/app/javascript/js/controllers/search_controller.js +3 -0
- data/avo.gemspec +1 -1
- data/config/routes.rb +1 -1
- data/db/factories.rb +1 -0
- data/lib/avo/app.rb +0 -6
- data/lib/avo/concerns/handles_field_args.rb +4 -0
- data/lib/avo/dynamic_router.rb +15 -19
- data/lib/avo/engine.rb +0 -9
- data/lib/avo/fields/base_field.rb +5 -1
- data/lib/avo/fields/date_field.rb +2 -0
- data/lib/avo/fields/time_field.rb +55 -0
- data/lib/avo/version.rb +1 -1
- data/public/avo-assets/avo.base.js +64 -64
- data/public/avo-assets/avo.base.js.map +2 -2
- metadata +23 -2
data/lib/avo/dynamic_router.rb
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
module Avo
|
2
|
-
|
3
|
-
def self.routes
|
4
|
-
|
5
|
-
scope "resources", as: "resources" do
|
6
|
-
Avo::App.eager_load_resources
|
2
|
+
module DynamicRouter
|
3
|
+
def self.routes(router)
|
4
|
+
Rails.application.eager_load! unless Rails.env.production?
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
6
|
+
BaseResource.descendants
|
7
|
+
.select do |resource|
|
8
|
+
resource != :BaseResource
|
9
|
+
end
|
10
|
+
.select do |resource|
|
11
|
+
resource.is_a? Class
|
12
|
+
end
|
13
|
+
# .select do |resource|
|
14
|
+
# resource.model_class.present?
|
15
|
+
# end
|
16
|
+
.map do |resource|
|
17
|
+
router.resources resource.new.route_key
|
21
18
|
end
|
22
|
-
end
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
data/lib/avo/engine.rb
CHANGED
@@ -17,15 +17,6 @@ module Avo
|
|
17
17
|
::Avo::App.boot
|
18
18
|
end
|
19
19
|
|
20
|
-
# initializer "eager load resources" do |app|
|
21
|
-
# # puts ["app.root->", app.root.join('app', 'avo', 'resources')].inspect
|
22
|
-
# app.config.to_prepare do
|
23
|
-
# puts ["app.config.to_prepare->", app.root.join('app', 'avo', 'resources')].inspect
|
24
|
-
# Rails.autoloaders.main.eager_load_dir(app.root.join('app', 'avo', 'resources'))
|
25
|
-
# puts [".to_prepare BaseResource.descendants->", BaseResource.descendants].inspect
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
20
|
initializer "avo.autoload" do |app|
|
30
21
|
[
|
31
22
|
["app", "avo", "fields"],
|
@@ -162,7 +162,7 @@ module Avo
|
|
162
162
|
property ||= id
|
163
163
|
|
164
164
|
# Get model value
|
165
|
-
final_value = @model.send(property) if (
|
165
|
+
final_value = @model.send(property) if is_model?(@model) && @model.respond_to?(property)
|
166
166
|
|
167
167
|
# On new views and actions modals we need to prefill the fields
|
168
168
|
if @view.in?([:new, :create]) || @action.present?
|
@@ -263,6 +263,10 @@ module Avo
|
|
263
263
|
"model"
|
264
264
|
end
|
265
265
|
end
|
266
|
+
|
267
|
+
def is_model?(model)
|
268
|
+
model_or_class(model) == "model"
|
269
|
+
end
|
266
270
|
end
|
267
271
|
end
|
268
272
|
end
|
@@ -5,6 +5,7 @@ module Avo
|
|
5
5
|
attr_reader :picker_format
|
6
6
|
attr_reader :disable_mobile
|
7
7
|
attr_reader :format
|
8
|
+
attr_reader :picker_options
|
8
9
|
|
9
10
|
def initialize(id, **args, &block)
|
10
11
|
super(id, **args, &block)
|
@@ -13,6 +14,7 @@ module Avo
|
|
13
14
|
add_string_prop args, :picker_format, "Y-m-d"
|
14
15
|
add_string_prop args, :format, "yyyy-LL-dd"
|
15
16
|
add_boolean_prop args, :disable_mobile
|
17
|
+
add_object_prop args, :picker_options
|
16
18
|
end
|
17
19
|
|
18
20
|
def formatted_value
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Avo
|
2
|
+
module Fields
|
3
|
+
class TimeField < DateField
|
4
|
+
attr_reader :format
|
5
|
+
attr_reader :picker_format
|
6
|
+
attr_reader :time_24hr
|
7
|
+
attr_reader :timezone
|
8
|
+
attr_reader :relative
|
9
|
+
|
10
|
+
def initialize(id, **args, &block)
|
11
|
+
super(id, **args, &block)
|
12
|
+
|
13
|
+
add_boolean_prop args, :time_24hr
|
14
|
+
add_string_prop args, :picker_format, "H:i:S"
|
15
|
+
add_string_prop args, :format, "TT"
|
16
|
+
add_string_prop args, :timezone
|
17
|
+
add_boolean_prop args, :relative, true
|
18
|
+
end
|
19
|
+
|
20
|
+
def formatted_value
|
21
|
+
return nil if value.nil?
|
22
|
+
|
23
|
+
value.utc.to_time.iso8601
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit_formatted_value
|
27
|
+
return nil if value.nil?
|
28
|
+
|
29
|
+
value.utc.iso8601
|
30
|
+
end
|
31
|
+
|
32
|
+
def fill_field(model, key, value, params)
|
33
|
+
if value.in?(["", nil])
|
34
|
+
model[id] = value
|
35
|
+
|
36
|
+
return model
|
37
|
+
end
|
38
|
+
|
39
|
+
return model if value.blank?
|
40
|
+
|
41
|
+
model[id] = utc_time(value)
|
42
|
+
|
43
|
+
model
|
44
|
+
end
|
45
|
+
|
46
|
+
def utc_time(value)
|
47
|
+
if timezone.present?
|
48
|
+
ActiveSupport::TimeZone.new(timezone).local_to_utc(Time.parse(value))
|
49
|
+
else
|
50
|
+
value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/avo/version.rb
CHANGED