avo 2.12.1.pre.1 → 2.13.0

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -3
  3. data/README.md +2 -1
  4. data/app/components/avo/actions_component.html.erb +3 -3
  5. data/app/components/avo/actions_component.rb +12 -3
  6. data/app/components/avo/button_component.rb +1 -3
  7. data/app/components/avo/fields/common/gravatar_viewer_component.html.erb +1 -1
  8. data/app/components/avo/fields/date_field/edit_component.html.erb +0 -3
  9. data/app/components/avo/fields/date_time_field/edit_component.html.erb +0 -2
  10. data/app/components/avo/fields/has_one_field/show_component.html.erb +1 -1
  11. data/app/components/avo/fields/tags_field/show_component.rb +0 -2
  12. data/app/components/avo/item_switcher_component.html.erb +1 -1
  13. data/app/components/avo/panel_component.html.erb +1 -1
  14. data/app/components/avo/panel_component.rb +3 -4
  15. data/app/components/avo/resource_component.rb +6 -4
  16. data/app/components/avo/sidebar_component.html.erb +1 -1
  17. data/app/components/avo/tab_group_component.html.erb +1 -1
  18. data/app/components/avo/tab_switcher_component.rb +2 -2
  19. data/app/components/avo/views/resource_edit_component.html.erb +1 -1
  20. data/app/components/avo/views/resource_edit_component.rb +1 -1
  21. data/app/components/avo/views/resource_index_component.html.erb +3 -3
  22. data/app/components/avo/views/resource_index_component.rb +18 -1
  23. data/app/components/avo/views/resource_show_component.html.erb +139 -48
  24. data/app/components/avo/views/resource_show_component.rb +1 -0
  25. data/app/controllers/avo/base_controller.rb +8 -11
  26. data/app/controllers/avo/search_controller.rb +57 -20
  27. data/app/javascript/js/controllers/menu_controller.js +2 -2
  28. data/app/javascript/js/controllers/search_controller.js +42 -15
  29. data/app/views/avo/associations/new.html.erb +1 -0
  30. data/app/views/avo/dashboards/show.html.erb +1 -1
  31. data/app/views/avo/debug/index.html.erb +1 -1
  32. data/app/views/avo/debug/report.html.erb +1 -0
  33. data/app/views/avo/home/index.html.erb +1 -1
  34. data/app/views/avo/partials/_resource_search.html.erb +6 -0
  35. data/app/views/avo/private/design.html.erb +2 -2
  36. data/app/views/layouts/avo/application.html.erb +1 -1
  37. data/lib/avo/base_resource.rb +5 -1
  38. data/lib/avo/concerns/has_editable_controls.rb +34 -0
  39. data/lib/avo/fields/base_field.rb +1 -1
  40. data/lib/avo/fields/date_field.rb +1 -3
  41. data/lib/avo/fields/field_extensions/has_include_blank.rb +1 -1
  42. data/lib/avo/fields/has_base_field.rb +2 -0
  43. data/lib/avo/fields/key_value_field.rb +6 -6
  44. data/lib/avo/hosts/search_scope_host.rb +7 -0
  45. data/lib/avo/licensing/h_q.rb +12 -4
  46. data/lib/avo/licensing/pro_license.rb +1 -0
  47. data/lib/avo/menu/builder.rb +2 -0
  48. data/lib/avo/resources/controls/action.rb +32 -0
  49. data/lib/avo/resources/controls/actions_list.rb +19 -0
  50. data/lib/avo/resources/controls/back_button.rb +13 -0
  51. data/lib/avo/resources/controls/base_control.rb +59 -0
  52. data/lib/avo/resources/controls/delete_button.rb +13 -0
  53. data/lib/avo/resources/controls/detach_button.rb +13 -0
  54. data/lib/avo/resources/controls/edit_button.rb +13 -0
  55. data/lib/avo/resources/controls/execution_context.rb +58 -0
  56. data/lib/avo/resources/controls/items_holder.rb +19 -0
  57. data/lib/avo/resources/controls/link_to.rb +27 -0
  58. data/lib/avo/version.rb +1 -1
  59. data/lib/generators/avo/templates/action.tt +1 -1
  60. data/lib/generators/avo/templates/initializer/avo.tt +1 -0
  61. data/lib/generators/avo/templates/resource/resource.tt +1 -1
  62. data/lib/generators/avo/templates/resource_tools/partial.tt +1 -1
  63. data/lib/generators/avo/templates/standalone_action.tt +1 -1
  64. data/public/avo-assets/avo.css +564 -44
  65. data/public/avo-assets/avo.js +47 -47
  66. data/public/avo-assets/avo.js.map +2 -2
  67. metadata +16 -5
  68. data/lib/avo/concerns/has_model.rb +0 -11
@@ -0,0 +1,13 @@
1
+ module Avo
2
+ module Resources
3
+ module Controls
4
+ class EditButton < BaseControl
5
+ def initialize(**args)
6
+ super(**args)
7
+
8
+ @label = I18n.t("avo.edit").capitalize
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,58 @@
1
+ require "dry-initializer"
2
+
3
+ # This object holds some data tha is usually needed to compute blocks around the app.
4
+ module Avo
5
+ module Resources
6
+ module Controls
7
+ class ExecutionContext
8
+ extend Dry::Initializer
9
+
10
+ option :context, default: proc { Avo::App.context }
11
+ option :params, default: proc { Avo::App.params }
12
+ option :view_context, default: proc { Avo::App.view_context }
13
+ option :current_user, default: proc { Avo::App.current_user }
14
+ option :items_holder, default: proc { Avo::Resources::Controls::ItemsHolder.new }
15
+ option :resource, optional: true
16
+ option :record, optional: true
17
+ option :view, optional: true
18
+ option :block, optional: true
19
+
20
+ delegate :authorize, to: Avo::Services::AuthorizationService
21
+
22
+ def handle
23
+ instance_exec(&block)
24
+ end
25
+
26
+ private
27
+
28
+ def back_button(**args)
29
+ items_holder.add_item Avo::Resources::Controls::BackButton.new(**args)
30
+ end
31
+
32
+ def delete_button(**args)
33
+ items_holder.add_item Avo::Resources::Controls::DeleteButton.new(**args)
34
+ end
35
+
36
+ def detach_button(**args)
37
+ items_holder.add_item Avo::Resources::Controls::DetachButton.new(**args)
38
+ end
39
+
40
+ def edit_button(**args)
41
+ items_holder.add_item Avo::Resources::Controls::EditButton.new(**args)
42
+ end
43
+
44
+ def link_to(label, path, **args)
45
+ items_holder.add_item Avo::Resources::Controls::LinkTo.new(label: label, path: path, **args)
46
+ end
47
+
48
+ def actions_list(**args)
49
+ items_holder.add_item Avo::Resources::Controls::ActionsList.new(**args)
50
+ end
51
+
52
+ def action(klass, **args)
53
+ items_holder.add_item Avo::Resources::Controls::Action.new(klass, record: record, resource: resource, view: view, **args)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,19 @@
1
+ module Avo
2
+ module Resources
3
+ module Controls
4
+ class ItemsHolder
5
+ attr_reader :items
6
+
7
+ def initialize
8
+ @items = []
9
+ end
10
+
11
+ def add_item(instance)
12
+ @items << instance
13
+
14
+ self
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ module Avo
2
+ module Resources
3
+ module Controls
4
+ class LinkTo < BaseControl
5
+ def initialize(**args)
6
+ super(**args)
7
+ end
8
+
9
+ def path
10
+ @args[:path]
11
+ end
12
+
13
+ def target
14
+ @args[:target] || nil
15
+ end
16
+
17
+ def data
18
+ @args[:data] || {}
19
+ end
20
+
21
+ def class
22
+ @args[:class] || nil
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.12.1.pre.1" unless const_defined?(:VERSION)
2
+ VERSION = "2.13.0" unless const_defined?(:VERSION)
3
3
  end
@@ -1,5 +1,5 @@
1
1
  class <%= class_name.camelize %> < Avo::BaseAction
2
- self.name = '<%= name.underscore.humanize %>'
2
+ self.name = "<%= name.underscore.humanize %>"
3
3
 
4
4
  def handle(**args)
5
5
  models, fields, current_user, resource = args.values_at(:models, :fields, :current_user, :resource)
@@ -51,6 +51,7 @@ Avo.configure do |config|
51
51
  # config.view_component_path = "app/components"
52
52
  # config.display_license_request_timeout_error = true
53
53
  # config.disabled_features = []
54
+ # config.resource_controls = :right
54
55
 
55
56
 
56
57
  ## == Breadcrumbs ==
@@ -1,7 +1,7 @@
1
1
  class <%= resource_class %> < Avo::BaseResource
2
2
  self.title = :id
3
3
  self.includes = []
4
- # self.search_query = ->(params:) do
4
+ # self.search_query = -> do
5
5
  # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
6
6
  # end
7
7
 
@@ -1,7 +1,7 @@
1
1
  <div class="flex flex-col">
2
2
  <%%= render Avo::PanelComponent.new(name: "<%= human_name %>") do |c| %>
3
3
  <%% c.tools do %>
4
- <%%= a_link('/avo', icon: 'heroicons/solid/academic-cap', style: :primary) do %>
4
+ <%%= a_link('/avo', icon: 'heroicons/solid/academic-cap', color: :primary, style: :primary) do %>
5
5
  Dummy link
6
6
  <%% end %>
7
7
  <%% end %>
@@ -1,5 +1,5 @@
1
1
  class <%= class_name.camelize %> < Avo::BaseAction
2
- self.name = '<%= name.underscore.humanize %>'
2
+ self.name = "<%= name.underscore.humanize %>"
3
3
  self.standalone = true
4
4
 
5
5
  def handle(fields:)