avo 2.11.3.pre.3 → 2.12.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -3
  3. data/app/components/avo/card_component.html.erb +8 -8
  4. data/app/components/avo/index/ordering/buttons_component.html.erb +1 -1
  5. data/app/components/avo/index/resource_controls_component.rb +1 -1
  6. data/app/components/avo/sidebar_component.html.erb +1 -1
  7. data/app/components/avo/views/resource_edit_component.rb +0 -20
  8. data/app/components/avo/views/resource_index_component.html.erb +49 -97
  9. data/app/components/avo/views/resource_index_component.rb +2 -0
  10. data/app/components/avo/views/resource_show_component.html.erb +0 -5
  11. data/app/controllers/avo/application_controller.rb +7 -3
  12. data/app/controllers/avo/associations_controller.rb +2 -2
  13. data/app/controllers/avo/base_controller.rb +3 -7
  14. data/app/controllers/avo/cards_controller.rb +5 -18
  15. data/app/controllers/avo/dashboards_controller.rb +2 -4
  16. data/app/javascript/js/controllers/{card_controller.js → dashboard_card_controller.js} +0 -0
  17. data/app/javascript/js/controllers.js +2 -2
  18. data/app/views/avo/cards/_metric_card.html.erb +2 -2
  19. data/app/views/avo/dashboards/show.html.erb +19 -2
  20. data/app/views/layouts/avo/application.html.erb +1 -1
  21. data/config/routes.rb +0 -3
  22. data/lib/avo/base_card.rb +21 -40
  23. data/lib/avo/base_resource.rb +0 -1
  24. data/lib/avo/dashboards/base_dashboard.rb +50 -15
  25. data/lib/avo/dashboards/base_divider.rb +1 -5
  26. data/lib/avo/dashboards/chartkick_card.rb +4 -5
  27. data/lib/avo/fields/base_field.rb +12 -6
  28. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +1 -12
  29. data/lib/avo/fields/has_base_field.rb +16 -1
  30. data/lib/avo/hosts/dashboard_card.rb +1 -1
  31. data/lib/avo/tab.rb +1 -3
  32. data/lib/avo/version.rb +1 -1
  33. data/lib/generators/avo/templates/cards/partial_card_partial.tt +1 -1
  34. data/public/avo-assets/avo.css +34 -86
  35. data/public/avo-assets/avo.js +6 -6
  36. data/public/avo-assets/avo.js.map +3 -3
  37. metadata +5 -9
  38. data/app/components/avo/cards_list_component.html.erb +0 -16
  39. data/app/components/avo/cards_list_component.rb +0 -13
  40. data/lib/avo/concerns/has_cards.rb +0 -88
  41. data/lib/avo/concerns/styles_cards.rb +0 -48
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.3.pre.3
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-01 00:00:00.000000000 Z
12
+ date: 2022-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -805,8 +805,6 @@ files:
805
805
  - app/components/avo/button_component.rb
806
806
  - app/components/avo/card_component.html.erb
807
807
  - app/components/avo/card_component.rb
808
- - app/components/avo/cards_list_component.html.erb
809
- - app/components/avo/cards_list_component.rb
810
808
  - app/components/avo/common_field_wrapper_component.html.erb
811
809
  - app/components/avo/common_field_wrapper_component.rb
812
810
  - app/components/avo/dashboards/divider_component.html.erb
@@ -1073,8 +1071,8 @@ files:
1073
1071
  - app/javascript/js/controllers/attachments_controller.js
1074
1072
  - app/javascript/js/controllers/base_controller.js
1075
1073
  - app/javascript/js/controllers/boolean_filter_controller.js
1076
- - app/javascript/js/controllers/card_controller.js
1077
1074
  - app/javascript/js/controllers/copy_to_clipboard_controller.js
1075
+ - app/javascript/js/controllers/dashboard_card_controller.js
1078
1076
  - app/javascript/js/controllers/fields/belongs_to_field_controller.js
1079
1077
  - app/javascript/js/controllers/fields/code_field_controller.js
1080
1078
  - app/javascript/js/controllers/fields/date_field_controller.js
@@ -1178,14 +1176,12 @@ files:
1178
1176
  - lib/avo/base_resource_tool.rb
1179
1177
  - lib/avo/concerns/fetches_things.rb
1180
1178
  - lib/avo/concerns/handles_field_args.rb
1181
- - lib/avo/concerns/has_cards.rb
1182
1179
  - lib/avo/concerns/has_fields.rb
1183
1180
  - lib/avo/concerns/has_html_attributes.rb
1184
1181
  - lib/avo/concerns/has_model.rb
1185
1182
  - lib/avo/concerns/has_stimulus_controllers.rb
1186
1183
  - lib/avo/concerns/is_resource_item.rb
1187
1184
  - lib/avo/concerns/model_class_constantized.rb
1188
- - lib/avo/concerns/styles_cards.rb
1189
1185
  - lib/avo/configuration.rb
1190
1186
  - lib/avo/configuration/resource_configuration.rb
1191
1187
  - lib/avo/dashboards/base_dashboard.rb
@@ -1379,9 +1375,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1379
1375
  version: 2.4.0
1380
1376
  required_rubygems_version: !ruby/object:Gem::Requirement
1381
1377
  requirements:
1382
- - - ">"
1378
+ - - ">="
1383
1379
  - !ruby/object:Gem::Version
1384
- version: 1.3.1
1380
+ version: '0'
1385
1381
  requirements: []
1386
1382
  rubygems_version: 3.3.3
1387
1383
  signing_key:
@@ -1,16 +0,0 @@
1
- <%= content_tag(:div, class: "grid gap-4 grid-cols-1 #{parent.class.cards_classes}") do %>
2
- <% parent.cards.each do |card| %>
3
- <% if card.is_divider? %>
4
- <%= render Avo::Dashboards::DividerComponent.new(divider: card) %>
5
- <% elsif card.is_card? %>
6
- <%= content_tag(:div, class: "relative bg-white rounded shadow-panel space-y-2 overflow-hidden h-full #{card.card_classes}") do %>
7
- <turbo-frame id="<%= card.turbo_frame %>"
8
- src="<%= card.frame_url(enforced_range: @range, params: params) %>"
9
- data-card-index="<%= card.index %>"
10
- >
11
- <%= render(Avo::LoadingComponent.new(title: card.label)) %>
12
- </turbo-frame>
13
- <% end %>
14
- <% end %>
15
- <% end %>
16
- <% end %>
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::CardsListComponent < ViewComponent::Base
4
- attr_reader :parent
5
-
6
- def initialize(parent: nil)
7
- @parent = parent
8
- end
9
-
10
- def render?
11
- parent.cards.present?
12
- end
13
- end
@@ -1,88 +0,0 @@
1
- module Avo
2
- module Concerns
3
- module HasCards
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- class_attribute :cards_holder
8
- class_attribute :cards_index, default: 0
9
- class_attribute :grid_cols, default: 3
10
-
11
- delegate :item_at_index, to: :class
12
-
13
- def cards
14
- return [] if self.class.cards.blank?
15
-
16
- view = self&.view
17
-
18
- self.class.cards
19
- .map do |card|
20
- # Try to hydrate the card
21
- card.hydrate(parent: self, params: params, view: view) if card.is_card?
22
-
23
- card
24
- end
25
- .select do |card|
26
- # If we don't get a view return all cards
27
- return true if view.nil?
28
-
29
- card.send("show_on_#{view}")
30
- end
31
- end
32
- end
33
-
34
- class_methods do
35
- def card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, visible_on: nil, **args)
36
- self.cards_holder ||= []
37
-
38
- self.cards_holder << klass.new(
39
- parent: self,
40
- options: options,
41
- index: cards_index,
42
- label: label,
43
- description: description,
44
- cols: cols,
45
- rows: rows,
46
- refresh_every: refresh_every,
47
- **args
48
- )
49
- self.cards_index += 1
50
- end
51
-
52
- def item_at_index(index)
53
- cards.find do |item|
54
- next if item.index.blank?
55
-
56
- item.index == index
57
- end
58
- end
59
-
60
- def divider(**args)
61
- self.cards_holder ||= []
62
-
63
- self.cards_holder << Avo::Dashboards::BaseDivider.new(**args)
64
- self.cards_index += 1
65
- end
66
-
67
- def cards
68
- self.cards_holder
69
- end
70
-
71
- def cards_classes
72
- case grid_cols
73
- when 3
74
- "sm:grid-cols-3"
75
- when 4
76
- "sm:grid-cols-4"
77
- when 5
78
- "sm:grid-cols-5"
79
- when 6
80
- "sm:grid-cols-6"
81
- else
82
- "sm:grid-cols-3"
83
- end
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,48 +0,0 @@
1
- module Avo
2
- module Concerns
3
- module StylesCards
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- class_attribute :cols, default: 1
8
- class_attribute :rows, default: 1
9
-
10
- def card_classes
11
- result = ""
12
-
13
- # Writing down the classes so TailwindCSS knows not to purge them
14
- classes_for_cols = {
15
- 1 => " sm:col-span-1",
16
- 2 => " sm:col-span-2",
17
- 3 => " sm:col-span-3",
18
- 4 => " sm:col-span-4",
19
- 5 => " sm:col-span-5",
20
- 6 => " sm:col-span-6"
21
- }
22
-
23
- classes_for_rows = {
24
- 1 => " sm:row-span-1 min-h-[8rem]",
25
- 2 => " sm:row-span-2 min-h-[16rem]",
26
- 3 => " sm:row-span-3 min-h-[24rem]",
27
- 4 => " sm:row-span-4 min-h-[32rem]",
28
- 5 => " sm:row-span-5 min-h-[40rem]",
29
- 6 => " sm:row-span-6 min-h-[48rem]",
30
- }
31
-
32
- result += classes_for_cols[cols.to_i] if classes_for_cols[cols.to_i].present?
33
- result += classes_for_rows[rows.to_i] if classes_for_rows[rows.to_i].present?
34
-
35
- result
36
- end
37
-
38
- def cols
39
- @cols || self.class.cols
40
- end
41
-
42
- def rows
43
- @rows || self.class.rows
44
- end
45
- end
46
- end
47
- end
48
- end