avo 2.11.2.pre.3 → 2.11.3.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.lock +1 -1
- data/app/assets/stylesheets/avo.css +1 -0
- data/app/assets/stylesheets/css/scrollbar.css +30 -0
- data/app/components/avo/card_component.html.erb +8 -8
- data/app/components/avo/cards_list_component.html.erb +16 -0
- data/app/components/avo/cards_list_component.rb +13 -0
- data/app/components/avo/paginator_component.html.erb +35 -33
- data/app/components/avo/paginator_component.rb +3 -1
- data/app/components/avo/sidebar_component.html.erb +2 -2
- data/app/components/avo/tab_switcher_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.rb +20 -0
- data/app/components/avo/views/resource_index_component.html.erb +98 -50
- data/app/components/avo/views/resource_show_component.html.erb +11 -5
- data/app/controllers/avo/application_controller.rb +3 -2
- data/app/controllers/avo/associations_controller.rb +1 -1
- data/app/controllers/avo/base_controller.rb +15 -10
- data/app/controllers/avo/cards_controller.rb +18 -5
- data/app/controllers/avo/dashboards_controller.rb +4 -2
- data/app/javascript/avo.js +1 -1
- data/app/javascript/js/controllers/{dashboard_card_controller.js → card_controller.js} +0 -0
- data/app/javascript/js/controllers/fields/date_field_controller.js +7 -3
- data/app/javascript/js/controllers.js +2 -2
- data/app/views/avo/cards/_metric_card.html.erb +2 -2
- data/app/views/avo/dashboards/show.html.erb +2 -19
- data/app/views/layouts/avo/application.html.erb +1 -1
- data/config/routes.rb +3 -0
- data/lib/avo/base_card.rb +40 -21
- data/lib/avo/base_resource.rb +1 -0
- data/lib/avo/concerns/has_cards.rb +88 -0
- data/lib/avo/concerns/styles_cards.rb +48 -0
- data/lib/avo/dashboards/base_dashboard.rb +15 -50
- data/lib/avo/dashboards/base_divider.rb +5 -1
- data/lib/avo/dashboards/chartkick_card.rb +5 -4
- data/lib/avo/fields/base_field.rb +2 -6
- data/lib/avo/fields/date_time_field.rb +2 -2
- data/lib/avo/fields/field_extensions/visible_in_different_views.rb +12 -1
- data/lib/avo/fields/has_base_field.rb +2 -0
- data/lib/avo/hosts/dashboard_card.rb +1 -1
- data/lib/avo/tab.rb +3 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/cards/partial_card_partial.tt +1 -1
- data/public/avo-assets/avo.css +125 -34
- data/public/avo-assets/avo.js +7 -7
- data/public/avo-assets/avo.js.map +3 -3
- metadata +8 -3
@@ -10,9 +10,11 @@ module Avo
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def set_dashboard
|
13
|
-
@
|
13
|
+
@dashboard_class = Avo::App.get_dashboard_by_id params[:id]
|
14
14
|
|
15
|
-
raise ActionController::RoutingError.new("Not Found") if @
|
15
|
+
raise ActionController::RoutingError.new("Not Found") if @dashboard_class.nil? || @dashboard_class.is_hidden?
|
16
|
+
|
17
|
+
@dashboard = @dashboard_class.new.hydrate(params: params) if @dashboard_class.present?
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/app/javascript/avo.js
CHANGED
File without changes
|
@@ -106,13 +106,10 @@ export default class extends Controller {
|
|
106
106
|
|
107
107
|
// enable timezone display
|
108
108
|
if (this.enableTimeValue) {
|
109
|
-
console.log(1)
|
110
109
|
options.defaultDate = this.parsedValue.setZone(this.displayTimezone).toISO()
|
111
110
|
|
112
111
|
options.dateFormat = 'Y-m-d H:i:S'
|
113
112
|
} else {
|
114
|
-
console.log(2)
|
115
|
-
|
116
113
|
// Because the browser treats the date like a timestamp and updates it at 00:00 hour, when on a western timezone the date will be converted with one day offset.
|
117
114
|
// Ex: 2022-01-30 will render as 2022-01-29 on an American timezone
|
118
115
|
options.defaultDate = universalTimestamp(this.initialValue)
|
@@ -124,6 +121,13 @@ export default class extends Controller {
|
|
124
121
|
}
|
125
122
|
|
126
123
|
onChange(selectedDates) {
|
124
|
+
// No date has been selected
|
125
|
+
if (selectedDates.length === 0) {
|
126
|
+
this.updateRealInput('')
|
127
|
+
|
128
|
+
return
|
129
|
+
}
|
130
|
+
|
127
131
|
let time
|
128
132
|
let args = {}
|
129
133
|
|
@@ -5,9 +5,9 @@ import ActionsPickerController from './controllers/actions_picker_controller'
|
|
5
5
|
import AttachmentsController from './controllers/attachments_controller'
|
6
6
|
import BelongsToFieldController from './controllers/fields/belongs_to_field_controller'
|
7
7
|
import BooleanFilterController from './controllers/boolean_filter_controller'
|
8
|
+
import CardController from './controllers/card_controller'
|
8
9
|
import CodeFieldController from './controllers/fields/code_field_controller'
|
9
10
|
import CopyToClipboardController from './controllers/copy_to_clipboard_controller'
|
10
|
-
import DashboardCardController from './controllers/dashboard_card_controller'
|
11
11
|
import DateFieldController from './controllers/fields/date_field_controller'
|
12
12
|
import FilterController from './controllers/filter_controller'
|
13
13
|
import HiddenInputController from './controllers/hidden_input_controller'
|
@@ -38,8 +38,8 @@ application.register('action', ActionController)
|
|
38
38
|
application.register('actions-picker', ActionsPickerController)
|
39
39
|
application.register('attachments', AttachmentsController)
|
40
40
|
application.register('boolean-filter', BooleanFilterController)
|
41
|
+
application.register('card', CardController)
|
41
42
|
application.register('copy-to-clipboard', CopyToClipboardController)
|
42
|
-
application.register('dashboard-card', DashboardCardController)
|
43
43
|
application.register('filter', FilterController)
|
44
44
|
application.register('hidden-input', HiddenInputController)
|
45
45
|
application.register('item-select-all', ItemSelectAllController)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<div class="flex
|
1
|
+
<div class="flex items-end text-gray-800">
|
2
2
|
<span class="text-3xl"><%= @card.prefix %></span>
|
3
|
-
<span class="text-5xl"><%= @card.result_data %></span>
|
3
|
+
<span class="text-5xl font-semibold"><%= @card.result_data %></span>
|
4
4
|
<span class="text-3xl"><%= @card.suffix %></span>
|
5
5
|
</div>
|
@@ -1,24 +1,7 @@
|
|
1
1
|
<%= render Avo::PanelComponent.new(title: @dashboard.name, description: @dashboard.description) do |c| %>
|
2
2
|
<% c.bare_content do %>
|
3
|
-
<% if @dashboard.
|
4
|
-
|
5
|
-
<%= content_tag(:div, class: "grid gap-4 grid-cols-1 #{@dashboard.classes}") do %>
|
6
|
-
<% @dashboard.items.each do |item| %>
|
7
|
-
<% if item.is_divider? %>
|
8
|
-
<%= render Avo::Dashboards::DividerComponent.new(divider: item) %>
|
9
|
-
<% elsif item.is_card? %>
|
10
|
-
<%= content_tag(:div, class: "relative bg-white rounded shadow-panel space-y-2 #{item.card_classes} overflow-hidden") do %>
|
11
|
-
<turbo-frame id="<%= item.turbo_frame %>"
|
12
|
-
src="<%= item.frame_url(enforced_range: @range, params: params) %>"
|
13
|
-
data-card-index="<%= item.index %>"
|
14
|
-
>
|
15
|
-
<%= render(Avo::LoadingComponent.new(title: item.label)) %>
|
16
|
-
</turbo-frame>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
21
|
-
</div>
|
3
|
+
<% if @dashboard.cards.present? %>
|
4
|
+
<%= render Avo::CardsListComponent.new parent: @dashboard %>
|
22
5
|
<% else %>
|
23
6
|
<div class="w-full h-full">
|
24
7
|
<% if Rails.env.development? %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<% end %>
|
19
19
|
<% end %>
|
20
20
|
</head>
|
21
|
-
<body class="bg-
|
21
|
+
<body class="bg-application os-mac">
|
22
22
|
<div class="relative flex flex-1 w-full min-h-full" data-controller="sidebar" data-sidebar-open-value="<%= @sidebar_open %>">
|
23
23
|
<div class="flex-1 flex flex-col max-w-full">
|
24
24
|
<%= render partial: "avo/partials/navbar" %>
|
data/config/routes.rb
CHANGED
@@ -35,6 +35,9 @@ Avo::Engine.routes.draw do
|
|
35
35
|
# resources :posts
|
36
36
|
Avo::DynamicRouter.routes(self)
|
37
37
|
|
38
|
+
# Cards
|
39
|
+
get "/:resource_name/:id/cards/:card_id", to: "cards#show"
|
40
|
+
|
38
41
|
# Associations
|
39
42
|
get "/:resource_name/:id/:related_name/new", to: "associations#new", as: "associations_new"
|
40
43
|
get "/:resource_name/:id/:related_name/", to: "associations#index", as: "associations_index"
|
data/lib/avo/base_card.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Avo
|
2
2
|
class BaseCard
|
3
|
+
include Avo::Concerns::StylesCards
|
4
|
+
include Avo::Fields::FieldExtensions::VisibleInDifferentViews
|
5
|
+
|
3
6
|
class_attribute :id
|
4
7
|
class_attribute :label
|
5
8
|
class_attribute :description
|
6
|
-
class_attribute :cols, default: 1
|
7
|
-
class_attribute :rows, default: 1
|
8
9
|
class_attribute :initial_range
|
9
10
|
class_attribute :ranges, default: []
|
10
11
|
class_attribute :refresh_every
|
@@ -13,7 +14,7 @@ module Avo
|
|
13
14
|
class_attribute :result_data
|
14
15
|
class_attribute :query_block
|
15
16
|
|
16
|
-
attr_accessor :
|
17
|
+
attr_accessor :parent
|
17
18
|
attr_accessor :options
|
18
19
|
attr_accessor :index
|
19
20
|
attr_accessor :params
|
@@ -26,8 +27,8 @@ module Avo
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def initialize(
|
30
|
-
@
|
30
|
+
def initialize(parent:, options: {}, index: 0, cols: nil, rows: nil, label: nil, description: nil, refresh_every: nil, **args)
|
31
|
+
@parent = parent
|
31
32
|
@options = options
|
32
33
|
@index = index
|
33
34
|
@cols = cols
|
@@ -35,6 +36,8 @@ module Avo
|
|
35
36
|
@label = label
|
36
37
|
@refresh_every = refresh_every
|
37
38
|
@description = description
|
39
|
+
|
40
|
+
initialize_visibility args
|
38
41
|
end
|
39
42
|
|
40
43
|
def label
|
@@ -53,13 +56,21 @@ module Avo
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def turbo_frame
|
56
|
-
|
59
|
+
if parent_is_dashboard?
|
60
|
+
"#{parent.id}_#{id}"
|
61
|
+
elsif parent_is_resource?
|
62
|
+
"#{parent.id}_#{parent.model.id}_#{id}"
|
63
|
+
end
|
57
64
|
end
|
58
65
|
|
59
66
|
def frame_url(enforced_range: nil, params: {})
|
60
67
|
enforced_range ||= initial_range || ranges.first
|
61
68
|
|
62
|
-
|
69
|
+
if parent_is_dashboard?
|
70
|
+
Avo::App.view_context.avo.dashboard_card_path(dashboard.id, id, turbo_frame: turbo_frame, index: index, range: enforced_range, **params.permit!.to_h)
|
71
|
+
elsif parent_is_resource?
|
72
|
+
Avo::App.root_path(paths: ["resources", parent.route_key, parent.model.id, "cards", id], query: {**params.permit!.to_h, turbo_frame: turbo_frame, index: index, range: enforced_range})
|
73
|
+
end
|
63
74
|
end
|
64
75
|
|
65
76
|
def card_classes
|
@@ -76,14 +87,13 @@ module Avo
|
|
76
87
|
}
|
77
88
|
|
78
89
|
classes_for_rows = {
|
79
|
-
1 => " h-
|
80
|
-
2 => " h-
|
81
|
-
3 => " h-[
|
82
|
-
4 => " h-[
|
83
|
-
5 => " h-[
|
84
|
-
6 => " h-[
|
90
|
+
1 => " min-h-[8rem] row-span-1",
|
91
|
+
2 => " min-h-[16rem] row-span-2",
|
92
|
+
3 => " min-h-[24rem] row-span-3",
|
93
|
+
4 => " min-h-[32rem] row-span-4",
|
94
|
+
5 => " min-h-[40rem] row-span-5",
|
95
|
+
6 => " min-h-[48rem] row-span-6"
|
85
96
|
}
|
86
|
-
# puts ["cols->", cols, classes_for_cols, classes_for_rows, classes_for_cols[cols.to_i]].inspect
|
87
97
|
|
88
98
|
result += classes_for_cols[cols.to_i] if classes_for_cols[cols.to_i].present?
|
89
99
|
result += classes_for_rows[rows.to_i] if classes_for_rows[rows.to_i].present?
|
@@ -98,15 +108,16 @@ module Avo
|
|
98
108
|
end
|
99
109
|
|
100
110
|
def compute_result
|
101
|
-
Avo::Hosts::DashboardCard.new(card: self,
|
111
|
+
Avo::Hosts::DashboardCard.new(card: self, parent: parent, params: params, context: context, range: range, options: options)
|
102
112
|
.compute_result
|
103
113
|
|
104
114
|
self
|
105
115
|
end
|
106
116
|
|
107
|
-
def hydrate(
|
108
|
-
@
|
117
|
+
def hydrate(parent: nil, params: nil, view: nil)
|
118
|
+
@parent = parent if parent.present?
|
109
119
|
@params = params if params.present?
|
120
|
+
@view = view if view.present?
|
110
121
|
|
111
122
|
self
|
112
123
|
end
|
@@ -135,12 +146,20 @@ module Avo
|
|
135
146
|
|
136
147
|
private
|
137
148
|
|
138
|
-
def
|
139
|
-
|
149
|
+
def parent_is_dashboard?
|
150
|
+
parent.class.superclass == Avo::Dashboards::BaseDashboard
|
151
|
+
end
|
152
|
+
|
153
|
+
def parent_is_resource?
|
154
|
+
parent.class.superclass == Avo::BaseResource
|
155
|
+
end
|
156
|
+
|
157
|
+
def resource
|
158
|
+
parent if parent_is_resource?
|
140
159
|
end
|
141
160
|
|
142
|
-
def
|
143
|
-
|
161
|
+
def dashboard
|
162
|
+
parent if parent_is_dashboard?
|
144
163
|
end
|
145
164
|
end
|
146
165
|
end
|
data/lib/avo/base_resource.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
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
|
@@ -0,0 +1,48 @@
|
|
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
|
@@ -3,63 +3,18 @@ module Avo
|
|
3
3
|
class BaseDashboard
|
4
4
|
extend ActiveSupport::DescendantsTracker
|
5
5
|
|
6
|
+
include Avo::Concerns::HasCards
|
7
|
+
|
6
8
|
class_attribute :id
|
7
9
|
class_attribute :name
|
8
10
|
class_attribute :description
|
9
|
-
class_attribute :items_holder
|
10
|
-
class_attribute :grid_cols, default: 3
|
11
11
|
class_attribute :visible, default: true
|
12
12
|
class_attribute :index, default: 0
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
self.items_holder ||= []
|
17
|
-
|
18
|
-
self.items_holder << klass.new(dashboard: self,
|
19
|
-
label: label,
|
20
|
-
description: description,
|
21
|
-
cols: cols,
|
22
|
-
rows: rows,
|
23
|
-
refresh_every: refresh_every,
|
24
|
-
options: options,
|
25
|
-
index: index
|
26
|
-
)
|
27
|
-
self.index += 1
|
28
|
-
end
|
29
|
-
|
30
|
-
def item_at_index(index)
|
31
|
-
items.find do |item|
|
32
|
-
next if item.index.blank?
|
33
|
-
|
34
|
-
item.index == index
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def divider(**args)
|
39
|
-
self.items_holder ||= []
|
40
|
-
|
41
|
-
self.items_holder << BaseDivider.new(**args)
|
42
|
-
end
|
43
|
-
|
44
|
-
def items
|
45
|
-
self.items_holder
|
46
|
-
end
|
47
|
-
|
48
|
-
def classes
|
49
|
-
case grid_cols
|
50
|
-
when 3
|
51
|
-
"sm:grid-cols-3"
|
52
|
-
when 4
|
53
|
-
"sm:grid-cols-4"
|
54
|
-
when 5
|
55
|
-
"sm:grid-cols-5"
|
56
|
-
when 6
|
57
|
-
"sm:grid-cols-6"
|
58
|
-
else
|
59
|
-
"sm:grid-cols-3"
|
60
|
-
end
|
61
|
-
end
|
14
|
+
attr_reader :view
|
15
|
+
attr_reader :params
|
62
16
|
|
17
|
+
class << self
|
63
18
|
def navigation_label
|
64
19
|
name
|
65
20
|
end
|
@@ -84,6 +39,16 @@ module Avo
|
|
84
39
|
!is_visible?
|
85
40
|
end
|
86
41
|
end
|
42
|
+
|
43
|
+
def initialize
|
44
|
+
@view = :dashboard
|
45
|
+
end
|
46
|
+
|
47
|
+
def hydrate(params:)
|
48
|
+
@params = params
|
49
|
+
|
50
|
+
self
|
51
|
+
end
|
87
52
|
end
|
88
53
|
end
|
89
54
|
end
|
@@ -5,12 +5,16 @@ module Avo
|
|
5
5
|
attr_reader :invisible
|
6
6
|
attr_reader :index
|
7
7
|
|
8
|
+
include Avo::Fields::FieldExtensions::VisibleInDifferentViews
|
9
|
+
|
8
10
|
class_attribute :id
|
9
11
|
|
10
|
-
def initialize(label: nil, invisible: false, index: nil)
|
12
|
+
def initialize(label: nil, invisible: false, index: nil, **args)
|
11
13
|
@label = label
|
12
14
|
@invisible = invisible
|
13
15
|
@index = index
|
16
|
+
|
17
|
+
initialize_visibility args
|
14
18
|
end
|
15
19
|
|
16
20
|
def is_divider?
|
@@ -23,11 +23,12 @@ module Avo
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def chartkick_options
|
26
|
-
card_height =
|
27
|
-
card_heading =
|
26
|
+
card_height = 128
|
27
|
+
card_heading = 32
|
28
28
|
|
29
29
|
default = {
|
30
|
-
# figure our the available height for the chart
|
30
|
+
# figure our the available height for the chart.
|
31
|
+
# It's not ideal to work with magic numbers, I know.
|
31
32
|
height: "#{(rows * card_height) - card_heading}px",
|
32
33
|
colors: %w[#0B8AE2 #34C683 #2AB1EE #34C6A8],
|
33
34
|
library: {
|
@@ -35,7 +36,7 @@ module Avo
|
|
35
36
|
points: false,
|
36
37
|
animation: true
|
37
38
|
},
|
38
|
-
id: "#{
|
39
|
+
id: "#{parent.id}-#{rand(10_000..99_999)}"
|
39
40
|
}
|
40
41
|
|
41
42
|
no_scale_options = {display: false}
|
@@ -54,7 +54,7 @@ module Avo
|
|
54
54
|
class_attribute :item_type, default: :field
|
55
55
|
|
56
56
|
def initialize(id, **args, &block)
|
57
|
-
super(id, **args, &block)
|
57
|
+
# super(id, **args, &block)
|
58
58
|
|
59
59
|
@id = id
|
60
60
|
@name = args[:name]
|
@@ -83,11 +83,7 @@ module Avo
|
|
83
83
|
@computed = block.present?
|
84
84
|
@computed_value = nil
|
85
85
|
|
86
|
-
|
87
|
-
show_on args[:show_on] if args[:show_on].present?
|
88
|
-
hide_on args[:hide_on] if args[:hide_on].present?
|
89
|
-
only_on args[:only_on] if args[:only_on].present?
|
90
|
-
except_on args[:except_on] if args[:except_on].present?
|
86
|
+
initialize_visibility args
|
91
87
|
end
|
92
88
|
|
93
89
|
def hydrate(model: nil, resource: nil, action: nil, view: nil, panel_name: nil, user: nil)
|
@@ -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
|
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
|
@@ -5,6 +5,7 @@ module Avo
|
|
5
5
|
attr_accessor :scope
|
6
6
|
attr_accessor :attach_scope
|
7
7
|
attr_accessor :description
|
8
|
+
attr_accessor :discreet_pagination
|
8
9
|
|
9
10
|
def initialize(id, **args, &block)
|
10
11
|
super(id, **args, &block)
|
@@ -14,6 +15,7 @@ module Avo
|
|
14
15
|
@display = args[:display].present? ? args[:display] : :show
|
15
16
|
@searchable = args[:searchable] == true
|
16
17
|
@description = args[:description]
|
18
|
+
@discreet_pagination = args[:discreet_pagination] || false
|
17
19
|
end
|
18
20
|
|
19
21
|
def searchable
|
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,6 +1,6 @@
|
|
1
1
|
<div class="flex-1 flex p-4">
|
2
2
|
<div class="place-self-end">
|
3
|
-
|
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>
|