avo 2.27.1 → 2.27.2.pre.pr1606

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aac3092349f067eb4327e5b3ccf5bce819d29365bb6a5d8157382cf863b6e14a
4
- data.tar.gz: 3d475ef799448ee4189642e279448b8f73b15e3a321e4a9c1e225a7d0f988d8e
3
+ metadata.gz: 161deecc8d313c1254a3be834d954d88d6a20b5d9d9ba68f17b38eed7eb05de7
4
+ data.tar.gz: 9f78a084bf9129ed2789c412ed9836d940f372563d8a0ae715df52e3edce0874
5
5
  SHA512:
6
- metadata.gz: 9852e6779654ff6dd30309e5966d4476c10da02ac3dfc34c4696c0cd82dce28aca92ffbfb8e0567ddc3c5ab9b7fc1094f13dbd3daec0f3c7e140d05b9f120c38
7
- data.tar.gz: dda61e467b8f6e907b9711695d6ea940ffddfe9b8dc9b27a3d192d9914b35d700ecd6785ff6fa1db5bbddf99e257f9adb828ad3aad3402021ff127942841431c
6
+ metadata.gz: 3dd2b783c45b8d836c0715e8677dbcd253d94ac9f59ef3ee9f230464564915bc2730b35e77e2a60626db2fe0131fdbb9f9b467205e66528926392bc5e6376b73
7
+ data.tar.gz: 4cc9d8b35be4eebec0323721dce5573ba74e5a2dc2bbbbf16d0a2c0634ecc21b1b20f9ef3e272a3eaf50733694c62437905d94fdd0578cef2032df087474152f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.27.1)
4
+ avo (2.27.2.pre.pr1606)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
data/config/master.key ADDED
@@ -0,0 +1 @@
1
+ 2aeb23d82b909d9c6b5abb62f7058c2a
data/lib/avo/base_card.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Avo
2
2
  class BaseCard
3
+ include Avo::Concerns::VisibleInDashboard
4
+
3
5
  class_attribute :id
4
6
  class_attribute :label
5
7
  class_attribute :description
@@ -31,7 +33,7 @@ module Avo
31
33
  end
32
34
  end
33
35
 
34
- def initialize(dashboard:, options: {}, arguments: {}, index: 0, cols: nil, rows: nil, label: nil, description: nil, refresh_every: nil)
36
+ def initialize(dashboard:, options: {}, arguments: {}, index: 0, cols: nil, rows: nil, label: nil, description: nil, refresh_every: nil, visible: nil)
35
37
  @dashboard = dashboard
36
38
  @options = options
37
39
  @arguments = arguments
@@ -41,6 +43,7 @@ module Avo
41
43
  @label = label
42
44
  @refresh_every = refresh_every
43
45
  @description = description
46
+ @visible = visible
44
47
  end
45
48
 
46
49
  def label
@@ -137,6 +140,14 @@ module Avo
137
140
  false
138
141
  end
139
142
 
143
+ def visible
144
+ @visible || self.class.visible
145
+ end
146
+
147
+ def call_block
148
+ ::Avo::Hosts::CardVisibility.new(block: visible, card: self, parent: dashboard).handle
149
+ end
150
+
140
151
  private
141
152
 
142
153
  def cols
@@ -0,0 +1,31 @@
1
+ module Avo
2
+ module Concerns
3
+ module VisibleInDashboard
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ class_attribute :visible, default: true
8
+ end
9
+
10
+ def is_visible?
11
+ # Default is true
12
+ return true if visible == true
13
+
14
+ # Hide if false
15
+ return false if visible == false
16
+
17
+ if visible.respond_to? :call
18
+ call_block
19
+ end
20
+ end
21
+
22
+ def is_hidden?
23
+ !is_visible?
24
+ end
25
+
26
+ def call_block
27
+ ::Avo::Hosts::DashboardVisibility.new(block: visible, dashboard: self).handle
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,6 +1,8 @@
1
1
  module Avo
2
2
  module Dashboards
3
3
  class BaseDashboard
4
+ # TODO: convert the dashboards from classes to instances.
5
+ extend Avo::Concerns::VisibleInDashboard
4
6
  extend ActiveSupport::DescendantsTracker
5
7
 
6
8
  class_attribute :id
@@ -8,6 +10,7 @@ module Avo
8
10
  class_attribute :description
9
11
  class_attribute :items_holder
10
12
  class_attribute :grid_cols, default: 3
13
+ # TODO: remove this when you make the conversion.
11
14
  class_attribute :visible, default: true
12
15
  class_attribute :index, default: 0
13
16
  class_attribute :authorize, default: -> { true }
@@ -17,11 +20,12 @@ module Avo
17
20
  Rails.logger.warn "DEPRECATION WARNING: Card options parameter is deprecated in favor of arguments parameter and will be removed from Avo version 3.0.0"
18
21
  end
19
22
 
20
- def card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {})
23
+ def card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}, visible: nil)
21
24
  options_deprecation_message if options.present?
22
25
  self.items_holder ||= []
23
26
 
24
- self.items_holder << klass.new(dashboard: self,
27
+ self.items_holder << klass.new(
28
+ dashboard: self,
25
29
  label: label,
26
30
  description: description,
27
31
  cols: cols,
@@ -29,7 +33,8 @@ module Avo
29
33
  refresh_every: refresh_every,
30
34
  options: options,
31
35
  arguments: arguments,
32
- index: index
36
+ index: index,
37
+ visible: visible
33
38
  )
34
39
  self.index += 1
35
40
  end
@@ -45,11 +50,15 @@ module Avo
45
50
  def divider(**args)
46
51
  self.items_holder ||= []
47
52
 
48
- self.items_holder << BaseDivider.new(**args)
53
+ self.items_holder << BaseDivider.new(dashboard: self, **args)
49
54
  end
50
55
 
51
56
  def items
52
- self.items_holder
57
+ items = self.items_holder || []
58
+
59
+ items.filter do |item|
60
+ item.is_visible?
61
+ end
53
62
  end
54
63
 
55
64
  def classes
@@ -74,22 +83,6 @@ module Avo
74
83
  def navigation_path
75
84
  Avo::App.view_context.avo.dashboard_path id
76
85
  end
77
-
78
- def is_visible?
79
- # Default is true
80
- return true if visible == true
81
-
82
- # Hide if false
83
- return false if visible == false
84
-
85
- if visible.respond_to? :call
86
- ::Avo::Hosts::DashboardVisibility.new(block: visible, dashboard: self).handle
87
- end
88
- end
89
-
90
- def is_hidden?
91
- !is_visible?
92
- end
93
86
  end
94
87
  end
95
88
  end
@@ -1,16 +1,22 @@
1
1
  module Avo
2
2
  module Dashboards
3
3
  class BaseDivider
4
+ include Avo::Concerns::VisibleInDashboard
5
+
6
+ attr_reader :dashboard
4
7
  attr_reader :label
5
8
  attr_reader :invisible
6
9
  attr_reader :index
10
+ attr_reader :visible
7
11
 
8
12
  class_attribute :id
9
13
 
10
- def initialize(label: nil, invisible: false, index: nil)
14
+ def initialize(dashboard: nil, label: nil, invisible: false, index: nil, visible: nil)
15
+ @dashboard = dashboard
11
16
  @label = label
12
17
  @invisible = invisible
13
18
  @index = index
19
+ @visible = visible
14
20
  end
15
21
 
16
22
  def is_divider?
@@ -20,6 +26,10 @@ module Avo
20
26
  def is_card?
21
27
  false
22
28
  end
29
+
30
+ def call_block
31
+ ::Avo::Hosts::CardVisibility.new(block: visible, card: self, parent: dashboard).handle
32
+ end
23
33
  end
24
34
  end
25
35
  end
@@ -0,0 +1,20 @@
1
+ require "dry-initializer"
2
+
3
+ module Avo
4
+ module Hosts
5
+ class CardVisibility
6
+ extend Dry::Initializer
7
+
8
+ option :block, default: proc { proc {} }
9
+ option :current_user, default: proc { ::Avo::App.current_user }
10
+ option :context, default: proc { ::Avo::App.context }
11
+ option :parent
12
+ option :card
13
+ option :params, default: proc { ::Avo::App.params }
14
+
15
+ def handle
16
+ instance_exec(&block)
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.27.1" unless const_defined?(:VERSION)
2
+ VERSION = "2.27.2.pre.pr1606" unless const_defined?(:VERSION)
3
3
  end
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.27.1
4
+ version: 2.27.2.pre.pr1606
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: 2023-02-28 00:00:00.000000000 Z
12
+ date: 2023-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -1696,6 +1696,7 @@ files:
1696
1696
  - config/credentials.yml.enc
1697
1697
  - config/i18n-tasks.yml
1698
1698
  - config/initializers/pagy.rb
1699
+ - config/master.key
1699
1700
  - config/routes.rb
1700
1701
  - config/spring.rb
1701
1702
  - db/factories.rb
@@ -1717,6 +1718,7 @@ files:
1717
1718
  - lib/avo/concerns/has_stimulus_controllers.rb
1718
1719
  - lib/avo/concerns/is_resource_item.rb
1719
1720
  - lib/avo/concerns/model_class_constantized.rb
1721
+ - lib/avo/concerns/visible_in_dashboard.rb
1720
1722
  - lib/avo/concerns/visible_items.rb
1721
1723
  - lib/avo/configuration.rb
1722
1724
  - lib/avo/configuration/branding.rb
@@ -1781,6 +1783,7 @@ files:
1781
1783
  - lib/avo/grid_fields/title_field.rb
1782
1784
  - lib/avo/hosts/association_scope_host.rb
1783
1785
  - lib/avo/hosts/base_host.rb
1786
+ - lib/avo/hosts/card_visibility.rb
1784
1787
  - lib/avo/hosts/dashboard_card.rb
1785
1788
  - lib/avo/hosts/dashboard_visibility.rb
1786
1789
  - lib/avo/hosts/ordering.rb
@@ -1951,9 +1954,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1951
1954
  version: 2.6.0
1952
1955
  required_rubygems_version: !ruby/object:Gem::Requirement
1953
1956
  requirements:
1954
- - - ">="
1957
+ - - ">"
1955
1958
  - !ruby/object:Gem::Version
1956
- version: '0'
1959
+ version: 1.3.1
1957
1960
  requirements: []
1958
1961
  rubygems_version: 3.3.3
1959
1962
  signing_key: