avo 3.0.0.pre11 → 3.0.0.pre13

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.

Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/stylesheets/avo.base.css +1 -1
  4. data/app/components/avo/actions_component.html.erb +1 -1
  5. data/app/components/avo/actions_component.rb +40 -16
  6. data/app/components/avo/alert_component.html.erb +1 -1
  7. data/app/components/avo/field_wrapper_component.html.erb +2 -2
  8. data/app/components/avo/fields/common/heading_component.html.erb +1 -1
  9. data/app/components/avo/fields/markdown_field/edit_component.html.erb +3 -3
  10. data/app/components/avo/fields/markdown_field/show_component.html.erb +3 -3
  11. data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -1
  12. data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
  13. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  14. data/app/components/avo/index/grid_item_component.html.erb +9 -35
  15. data/app/components/avo/index/grid_item_component.rb +36 -10
  16. data/app/components/avo/panel_component.html.erb +1 -1
  17. data/app/components/avo/profile_item_component.html.erb +17 -2
  18. data/app/components/avo/profile_item_component.rb +13 -1
  19. data/app/components/avo/resource_component.rb +1 -0
  20. data/app/components/avo/sidebar_profile_component.html.erb +27 -27
  21. data/app/components/avo/views/resource_edit_component.html.erb +1 -1
  22. data/app/components/avo/views/resource_index_component.rb +1 -1
  23. data/app/components/avo/views/resource_show_component.html.erb +1 -1
  24. data/app/controllers/avo/actions_controller.rb +12 -8
  25. data/app/controllers/avo/associations_controller.rb +1 -1
  26. data/app/controllers/avo/base_controller.rb +15 -3
  27. data/app/controllers/avo/home_controller.rb +1 -1
  28. data/app/controllers/avo/search_controller.rb +7 -11
  29. data/app/javascript/js/controllers/fields/{simple_mde_controller.js → easy_mde_controller.js} +3 -3
  30. data/app/javascript/js/controllers/search_controller.js +3 -1
  31. data/app/javascript/js/controllers.js +2 -2
  32. data/app/views/avo/actions/show.html.erb +2 -1
  33. data/app/views/avo/partials/_profile_menu_extra.html.erb +2 -0
  34. data/lib/avo/app.rb +1 -1
  35. data/lib/avo/base_action.rb +8 -1
  36. data/lib/avo/base_resource.rb +81 -112
  37. data/lib/avo/concerns/breadcrumbs.rb +2 -2
  38. data/lib/avo/concerns/filters_session_handler.rb +5 -4
  39. data/lib/avo/concerns/has_description.rb +23 -0
  40. data/lib/avo/concerns/has_items.rb +8 -8
  41. data/lib/avo/configuration.rb +6 -2
  42. data/lib/avo/engine.rb +5 -0
  43. data/lib/avo/fields/base_field.rb +0 -4
  44. data/lib/avo/fields/belongs_to_field.rb +14 -8
  45. data/lib/avo/fields/has_base_field.rb +1 -1
  46. data/lib/avo/resources/controls/actions_list.rb +2 -1
  47. data/lib/avo/services/debug_service.rb +1 -1
  48. data/lib/avo/version.rb +1 -1
  49. data/lib/generators/avo/eject_generator.rb +1 -0
  50. data/lib/generators/avo/install_generator.rb +0 -1
  51. data/lib/generators/avo/resource_generator.rb +4 -1
  52. data/lib/generators/avo/templates/initializer/avo.tt +1 -1
  53. data/lib/generators/avo/templates/resource/resource.tt +3 -4
  54. data/lib/tasks/avo_tasks.rake +27 -0
  55. data/public/avo-assets/avo.base.css +273 -138
  56. data/public/avo-assets/avo.base.js +245 -217
  57. data/public/avo-assets/avo.base.js.map +3 -3
  58. metadata +5 -4
  59. data/lib/avo/grid_collector.rb +0 -40
@@ -50,7 +50,7 @@ module Avo
50
50
 
51
51
  # What the user sees in the text field
52
52
  def field_label
53
- value.send(target_resource.class.title)
53
+ target_resource.hydrate(record: value).record_title
54
54
  rescue
55
55
  nil
56
56
  end
@@ -2,13 +2,14 @@ module Avo
2
2
  module Resources
3
3
  module Controls
4
4
  class ActionsList < BaseControl
5
- attr_reader :color, :exclude, :style
5
+ attr_reader :color, :exclude, :include, :style
6
6
 
7
7
  def initialize(**args)
8
8
  super(**args)
9
9
 
10
10
  @color = args[:color] || :primary
11
11
  @exclude = args[:exclude] || []
12
+ @include = args[:include] || []
12
13
  @style = args[:style] || :outline
13
14
  end
14
15
  end
@@ -55,7 +55,7 @@ class Avo::Services::DebugService
55
55
  fields_per_resource: fields_per_resource,
56
56
  custom_fields_count: custom_fields_count,
57
57
  field_types: field_types,
58
- **other_metadata(:actions),
58
+ # **other_metadata(:actions), #FIEXME: this is fetching actions without hydration
59
59
  **other_metadata(:filters),
60
60
  main_menu_present: Avo.configuration.main_menu.present?,
61
61
  profile_menu_present: Avo.configuration.profile_menu.present?,
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.0.0.pre11" unless const_defined?(:VERSION)
2
+ VERSION = "3.0.0.pre13" unless const_defined?(:VERSION)
3
3
  end
@@ -17,6 +17,7 @@ module Generators
17
17
  pre_head: "app/views/avo/partials/_pre_head.html.erb",
18
18
  scripts: "app/views/avo/partials/_scripts.html.erb",
19
19
  sidebar_extra: "app/views/avo/partials/_sidebar_extra.html.erb",
20
+ profile_menu_extra: "app/views/avo/partials/_profile_menu_extra.html.erb",
20
21
  }
21
22
 
22
23
  def handle
@@ -13,7 +13,6 @@ module Generators
13
13
  route "mount Avo::Engine, at: Avo.configuration.root_path"
14
14
 
15
15
  template "initializer/avo.tt", "config/initializers/avo.rb"
16
- directory File.join(__dir__, "templates", "locales"), "config/locales"
17
16
  create_resources
18
17
  end
19
18
 
@@ -135,6 +135,9 @@ module Generators
135
135
  fields_string = ""
136
136
 
137
137
  fields.each do |field_name, field_options|
138
+ # if field_options are not available (likely a missing resource for an association), skip the field
139
+ fields_string += "\n # Could not generate a field for #{field_name}" and next unless field_options
140
+
138
141
  options = ""
139
142
  field_options[:options].each { |k, v| options += ", #{k}: #{v}" } if field_options[:options].present?
140
143
 
@@ -181,7 +184,7 @@ module Generators
181
184
  end
182
185
 
183
186
  def field_from_through_association(association)
184
- if association.through_reflection.is_a? ActiveRecord::Reflection::HasManyReflection
187
+ if association.through_reflection.is_a?(ActiveRecord::Reflection::HasManyReflection) || association.through_reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
185
188
  {
186
189
  field: "has_many",
187
190
  options: {
@@ -51,7 +51,7 @@ Avo.configure do |config|
51
51
  ## permanent enable or disable cache_resource_filters, default value is false
52
52
  # config.cache_resource_filters = false
53
53
  ## provide a lambda to enable or disable cache_resource_filters per user/resource.
54
- # config.cache_resource_filters = ->(current_user:, resource:) { current_user.cache_resource_filters?}
54
+ # config.cache_resource_filters = -> { current_user.cache_resource_filters? }
55
55
 
56
56
  ## == Customization ==
57
57
  # config.app_name = 'Avocadelicious'
@@ -1,9 +1,8 @@
1
1
  class Avo::Resources::<%= resource_class %> < Avo::BaseResource
2
- self.title = :id
3
2
  self.includes = []<%= model_class_from_args %>
4
- # self.search_query = -> do
5
- # query.ransack(id_eq: params[:q], m: "or").result(distinct: false)
6
- # end
3
+ # self.search = {
4
+ # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) }
5
+ # }
7
6
 
8
7
  def fields
9
8
  field :id, as: :id<%= generate_fields %>
@@ -63,3 +63,30 @@ task "avo:gem_paths" do
63
63
  # avo:/Users/adrian/work/avocado/avo-3,avo_filters:/Users/adrian/work/avocado/advanced/avo_filters
64
64
  puts result
65
65
  end
66
+
67
+ desc "Symlink registered gems in `./tmp/gems` so their views, etc. can be inspected by Tailwind CSS."
68
+ task "avo:link" do
69
+ Avo::App.boot
70
+ abort Avo.plugin_manager.plugins.inspect
71
+ if Dir.exist?("tmp/gems")
72
+ puts "Removing previously linked gems."
73
+ `rm -f tmp/gems/*`
74
+ else
75
+ if File.exist?("tmp/gems")
76
+ raise "A file named `tmp/gems` already exists? It has to be removed before we can create the required directory."
77
+ end
78
+
79
+ puts "Creating 'tmp/gems' directory."
80
+ `mkdir tmp/gems`
81
+ end
82
+
83
+ `touch tmp/gems/.keep`
84
+
85
+ Avo.plugin_manager.plugins.each do |linked_gem|
86
+ target = `bundle show #{linked_gem}`.chomp
87
+ if target.present?
88
+ puts "Linking '#{linked_gem}' to '#{target}'."
89
+ `ln -s #{target} tmp/gems/#{linked_gem}`
90
+ end
91
+ end
92
+ end