avo 2.11.3.pre.1 → 2.11.3.pre.2

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/components/avo/actions_component.html.erb +3 -3
  4. data/app/components/avo/actions_component.rb +3 -12
  5. data/app/components/avo/button_component.rb +3 -1
  6. data/app/components/avo/card_component.html.erb +8 -8
  7. data/app/components/avo/cards_list_component.html.erb +16 -0
  8. data/app/components/avo/cards_list_component.rb +13 -0
  9. data/app/components/avo/panel_component.html.erb +1 -1
  10. data/app/components/avo/resource_component.rb +4 -6
  11. data/app/components/avo/sidebar_component.html.erb +1 -1
  12. data/app/components/avo/views/resource_edit_component.rb +20 -0
  13. data/app/components/avo/views/resource_index_component.html.erb +90 -42
  14. data/app/components/avo/views/resource_show_component.html.erb +50 -137
  15. data/app/components/avo/views/resource_show_component.rb +0 -1
  16. data/app/controllers/avo/application_controller.rb +2 -2
  17. data/app/controllers/avo/associations_controller.rb +1 -1
  18. data/app/controllers/avo/base_controller.rb +7 -3
  19. data/app/controllers/avo/cards_controller.rb +18 -5
  20. data/app/controllers/avo/dashboards_controller.rb +4 -2
  21. data/app/javascript/js/controllers/{dashboard_card_controller.js → card_controller.js} +0 -0
  22. data/app/javascript/js/controllers.js +2 -2
  23. data/app/views/avo/cards/_metric_card.html.erb +2 -2
  24. data/app/views/avo/dashboards/show.html.erb +2 -19
  25. data/app/views/avo/debug/report.html.erb +0 -1
  26. data/app/views/avo/private/design.html.erb +1 -1
  27. data/app/views/layouts/avo/application.html.erb +1 -1
  28. data/config/routes.rb +3 -0
  29. data/lib/avo/base_card.rb +40 -20
  30. data/lib/avo/base_resource.rb +2 -5
  31. data/lib/avo/concerns/has_cards.rb +88 -0
  32. data/lib/avo/concerns/has_model.rb +11 -0
  33. data/lib/avo/concerns/styles_cards.rb +48 -0
  34. data/lib/avo/dashboards/base_dashboard.rb +15 -50
  35. data/lib/avo/dashboards/base_divider.rb +5 -1
  36. data/lib/avo/dashboards/chartkick_card.rb +3 -3
  37. data/lib/avo/fields/base_field.rb +2 -6
  38. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +12 -1
  39. data/lib/avo/hosts/dashboard_card.rb +1 -1
  40. data/lib/avo/licensing/pro_license.rb +0 -1
  41. data/lib/avo/tab.rb +3 -1
  42. data/lib/avo/version.rb +1 -1
  43. data/lib/generators/avo/templates/action.tt +1 -1
  44. data/lib/generators/avo/templates/cards/partial_card_partial.tt +1 -1
  45. data/lib/generators/avo/templates/resource_tools/partial.tt +1 -1
  46. data/lib/generators/avo/templates/standalone_action.tt +1 -1
  47. data/public/avo-assets/avo.css +150 -594
  48. data/public/avo-assets/avo.js +6 -6
  49. data/public/avo-assets/avo.js.map +3 -3
  50. metadata +7 -13
  51. data/lib/avo/concerns/has_editable_controls.rb +0 -34
  52. data/lib/avo/resources/controls/action.rb +0 -32
  53. data/lib/avo/resources/controls/actions_list.rb +0 -19
  54. data/lib/avo/resources/controls/back_button.rb +0 -13
  55. data/lib/avo/resources/controls/base_control.rb +0 -59
  56. data/lib/avo/resources/controls/delete_button.rb +0 -13
  57. data/lib/avo/resources/controls/detach_button.rb +0 -13
  58. data/lib/avo/resources/controls/edit_button.rb +0 -13
  59. data/lib/avo/resources/controls/execution_context.rb +0 -59
  60. data/lib/avo/resources/controls/items_holder.rb +0 -19
  61. data/lib/avo/resources/controls/link_to.rb +0 -27
@@ -6,12 +6,21 @@ module Avo
6
6
  attr_accessor :show_on_show
7
7
  attr_accessor :show_on_new
8
8
  attr_accessor :show_on_edit
9
+ attr_accessor :show_on_dashboard
9
10
 
10
- def initialize(id = nil, **args, &block)
11
+ def initialize_visibility(args = {})
12
+ # def initialize(id = nil, **args, &block)
11
13
  @show_on_index = @show_on_index.nil? ? true : @show_on_index
12
14
  @show_on_show = @show_on_show.nil? ? true : @show_on_show
13
15
  @show_on_new = @show_on_new.nil? ? true : @show_on_new
14
16
  @show_on_edit = @show_on_edit.nil? ? true : @show_on_edit
17
+ @show_on_dashboard = @show_on_dashboard.nil? ? true : @show_on_dashboard
18
+
19
+ # Set the visibility
20
+ show_on args[:show_on] if args[:show_on].present?
21
+ hide_on args[:hide_on] if args[:hide_on].present?
22
+ only_on args[:only_on] if args[:only_on].present?
23
+ except_on args[:except_on] if args[:except_on].present?
15
24
  end
16
25
 
17
26
  # Validates if the field is visible on certain view
@@ -82,6 +91,7 @@ module Avo
82
91
  end
83
92
 
84
93
  def show_on_all
94
+ @show_on_dashboard = true
85
95
  @show_on_index = true
86
96
  @show_on_show = true
87
97
  @show_on_edit = true
@@ -89,6 +99,7 @@ module Avo
89
99
  end
90
100
 
91
101
  def hide_on_all
102
+ @show_on_dashboard = false
92
103
  @show_on_index = false
93
104
  @show_on_show = false
94
105
  @show_on_edit = false
@@ -7,7 +7,7 @@ module Avo
7
7
 
8
8
  option :context
9
9
  option :range
10
- option :dashboard
10
+ option :parent
11
11
  option :card
12
12
  option :params
13
13
  option :options
@@ -15,7 +15,6 @@ module Avo
15
15
  :dashboards,
16
16
  :menu_editor,
17
17
  :stimulus_js_integration,
18
- :resource_show_controls,
19
18
  :advanced_fields
20
19
  ]
21
20
  end
data/lib/avo/tab.rb CHANGED
@@ -13,7 +13,7 @@ class Avo::Tab
13
13
 
14
14
  def initialize(name: nil, description: nil, view: nil, holds_one_field: false, **args)
15
15
  # Initialize the visibility markers
16
- super
16
+ # super
17
17
 
18
18
  @name = name
19
19
  @description = description
@@ -25,6 +25,8 @@ class Avo::Tab
25
25
  hide_on args[:hide_on] if args[:hide_on].present?
26
26
  only_on args[:only_on] if args[:only_on].present?
27
27
  except_on args[:except_on] if args[:except_on].present?
28
+
29
+ initialize_visibility args
28
30
  end
29
31
 
30
32
  def hydrate(view: nil)
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.11.3.pre.1" unless const_defined?(:VERSION)
2
+ VERSION = "2.11.3.pre.2" 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)
@@ -1,6 +1,6 @@
1
1
  <div class="flex-1 flex p-4">
2
2
  <div class="place-self-end">
3
- Dashboard ID: <%%= @dashboard.id %>
3
+ Parent ID: <%%= @parent.id %>
4
4
  <br />
5
5
  <br />
6
6
  Customize this partial under <code class='p-1 rounded bg-gray-500 text-white text-sm'>app/views/avo/cards/_<%= name.underscore %>.html.erb</code>
@@ -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', color: :primary, style: :primary) do %>
4
+ <%%= a_link('/avo', icon: 'heroicons/solid/academic-cap', 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:)