avo 3.0.0.pre6 → 3.0.0.pre7

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: 648d67d19be6d7475617bcc3534cb4a3a534b02cf16b2178d145c31e3ffc9747
4
- data.tar.gz: e64cb4bbdd4863c112a61a002a593954ee9794542c46402fb63bb036bc875918
3
+ metadata.gz: fe5b6765044687c412c2fd89cf479e3e1fe775f6eb0519824cc63c7bd3a651b2
4
+ data.tar.gz: f65add1a904af96f6464e22bd1c86464111c4a46f03e9a8375452fffd6afce5e
5
5
  SHA512:
6
- metadata.gz: e3486bc36e7c7bda0997ff00b28b69fbdc100e32e568e34e3e5b230d5fe5e8d13bb45fe815f336d133ac3c797b61fd55bcc38084f260482baa3ea480370ff018
7
- data.tar.gz: 71d11d5cd259929fd45283e4b32356a58529b07bf9edddfa95a051eb628ec7adfe087c8b2cc3ee0c2d29b4aeb892113e86f7abb4b4471f42ad14d0ded94af85a
6
+ metadata.gz: 47d6fe1f910683c701cbdc253c879f2415de5f9744237a496a6abc0237cce464f609f4c6c598870e7f119bf1e71f19f817e223973dc4881d3527f8559030c0f3
7
+ data.tar.gz: 731535291627256c234a5eeded5ad7854f89a25a399a201b5f76a94d9c74d87793cfb0dd25f44f31ae1b7f590203f3393b28089c080b2fdaca8a8282b2b790e7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.0.0.pre6)
4
+ avo (3.0.0.pre7)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="21" height="9" role="presentation"><g fill="none" fill-rule="evenodd"><path fill="#8898AA" fill-opacity="0.1" d="M1 9.092h19l-6.402-6.74c-1.717-1.806-4.485-1.8-6.196 0L1 9.093zM20.342 8l-6.02-6.336c-2.108-2.22-5.538-2.218-7.645 0L.658 8h19.684z"></path><path fill="currentcolor" d="M7.402 2.353c1.711-1.801 4.48-1.807 6.196 0L20 9.093H1l6.402-6.74z"></path></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="21" height="9" role="presentation"><g fill="none" fill-rule="evenodd"><path fill="#C9CBCF" fill-opacity="1" d="M1 9.092h19l-6.402-6.74c-1.717-1.806-4.485-1.8-6.196 0L1 9.093zM20.342 8l-6.02-6.336c-2.108-2.22-5.538-2.218-7.645 0L.658 8h19.684z"></path><path fill="currentcolor" d="M7.402 2.353c1.711-1.801 4.48-1.807 6.196 0L20 9.093H1l6.402-6.74z"></path></g></svg>
@@ -21,7 +21,6 @@ class Avo::Index::FieldWrapperComponent < ViewComponent::Base
21
21
  result += " py-3"
22
22
  end
23
23
 
24
- result += " #{text_align_classes}"
25
24
  result += " #{@field.get_html(:classes, view: view, element: :wrapper)}"
26
25
 
27
26
  result
@@ -45,15 +44,4 @@ class Avo::Index::FieldWrapperComponent < ViewComponent::Base
45
44
 
46
45
  attributes
47
46
  end
48
-
49
- private
50
-
51
- def text_align_classes
52
- case @field.index_text_align.to_sym
53
- when :right
54
- "text-right"
55
- when :center
56
- "text-center"
57
- end
58
- end
59
47
  end
@@ -37,7 +37,7 @@ module Avo
37
37
  query = Avo::ExecutionContext.new(
38
38
  target: resource.search_query,
39
39
  params: params,
40
- scope: resource.class.scope
40
+ query: resource.class.scope
41
41
  ).handle
42
42
 
43
43
  # Get the count
@@ -101,16 +101,16 @@ module Avo
101
101
  # This scope is applied if the search is being performed on a has_many association
102
102
  def apply_has_many_scope
103
103
  association_name = BaseResource.valid_association_name(parent, params[:via_association_id])
104
- scope = parent.send(association_name)
104
+ query = parent.send(association_name)
105
105
 
106
- Avo::ExecutionContext.new(target: @resource.search_query, params: params, scope: scope).handle
106
+ Avo::ExecutionContext.new(target: @resource.search_query, params: params, query: query).handle
107
107
  end
108
108
 
109
109
  def apply_search_metadata(records, avo_resource)
110
110
  records.map do |record|
111
111
  # TODO: refactor this
112
112
  # resource = avo_resource.dup.hydrate(record: record).hydrate_fields
113
- resource = avo_resource.dup.hydrate(record: record).hydrate_fields
113
+ resource = avo_resource.dup.hydrate(record: record)
114
114
 
115
115
  fetch_result_information record, resource
116
116
  end
@@ -37,14 +37,6 @@
37
37
  sort_direction = 'desc'
38
38
  end
39
39
  classes = "text-gray-500 tracking-tight leading-tight text-xs font-semibold"
40
- classes += case field.index_text_align.to_sym
41
- when :right
42
- " text-right"
43
- when :center
44
- " text-center"
45
- else
46
- ""
47
- end
48
40
  %>
49
41
  <%= content_tag :th,
50
42
  class: "text-left uppercase px-3 py-3 whitespace-nowrap rounded-l",
@@ -158,12 +158,6 @@ module Avo
158
158
  self
159
159
  end
160
160
 
161
- def fail(text)
162
- Rails.logger.warn "DEPRECATION WARNING: Action fail method is deprecated in favor of error method and will be removed from Avo version 3.0.0"
163
-
164
- error text
165
- end
166
-
167
161
  def error(text)
168
162
  add_message text, :error
169
163
 
@@ -57,7 +57,7 @@ module Avo
57
57
  class_attribute :resolve_find_scope
58
58
  # TODO: refactor this into a Host without args
59
59
  class_attribute :find_record_method, default: -> {
60
- model_class.find id
60
+ query.find id
61
61
  }
62
62
  class_attribute :hide_from_global_search, default: false
63
63
  class_attribute :after_create_path, default: :show
@@ -112,7 +112,7 @@ module Avo
112
112
  # This resolves the scope when doing "where" queries (not find queries)
113
113
  def query_scope
114
114
  final_scope = if resolve_index_query.present?
115
- Avo::ExecutionContext.new(target: resolve_index_query, model_class: model_class).handle
115
+ Avo::ExecutionContext.new(target: resolve_index_query, query: model_class).handle
116
116
  else
117
117
  model_class
118
118
  end
@@ -123,7 +123,7 @@ module Avo
123
123
  # This resolves the scope when finding records (not "where" queries)
124
124
  def find_scope
125
125
  final_scope = if resolve_find_scope.present?
126
- Avo::ExecutionContext.new(target: resolve_find_scope, model_class: model_class).handle
126
+ Avo::ExecutionContext.new(target: resolve_find_scope, query: model_class).handle
127
127
  else
128
128
  model_class
129
129
  end
@@ -536,11 +536,9 @@ module Avo
536
536
  end
537
537
 
538
538
  def find_record(id, query: nil, params: nil)
539
- query ||= self.class.find_scope
540
-
541
539
  Avo::ExecutionContext.new(
542
540
  target: self.class.find_record_method,
543
- model_class: query,
541
+ query: query || self.class.find_scope,
544
542
  id: id,
545
543
  params: params
546
544
  ).handle
@@ -38,7 +38,6 @@ module Avo
38
38
  attr_reader :as_label
39
39
  attr_reader :as_avatar
40
40
  attr_reader :as_description
41
- attr_reader :index_text_align
42
41
  attr_reader :stacked
43
42
  attr_reader :for_presentation_only
44
43
 
@@ -75,7 +74,6 @@ module Avo
75
74
  @as_label = args[:as_label] || false
76
75
  @as_avatar = args[:as_avatar] || false
77
76
  @as_description = args[:as_description] || false
78
- @index_text_align = args[:index_text_align] || :left
79
77
  @html = args[:html] || nil
80
78
  @view = args[:view] || nil
81
79
  @value = args[:value] || nil
@@ -160,11 +158,28 @@ module Avo
160
158
 
161
159
  # Run computable callback block if present
162
160
  if computable && block.present?
163
- final_value = instance_exec(record, @resource, @view, self, &block)
161
+ final_value = Avo::ExecutionContext.new(
162
+ target: block,
163
+ record: record,
164
+ resource: @resource,
165
+ view: @view,
166
+ field: self,
167
+ include: self.class.included_modules
168
+ ).handle
164
169
  end
165
170
 
166
171
  # Run the value through resolver if present
167
- final_value = instance_exec(final_value, &@format_using) if @format_using.present?
172
+ if format_using.present?
173
+ final_value = Avo::ExecutionContext.new(
174
+ target: format_using,
175
+ value: final_value,
176
+ record: record,
177
+ resource: @resource,
178
+ view: @view,
179
+ field: self,
180
+ include: self.class.included_modules
181
+ ).handle
182
+ end
168
183
 
169
184
  final_value
170
185
  end
@@ -13,6 +13,9 @@ module Avo
13
13
  attr_reader :arguments
14
14
 
15
15
  delegate :params, to: Avo::Current
16
+ delegate :request, to: Avo::Current
17
+ delegate :view_context, to: Avo::Current
18
+ delegate :current_user, to: Avo::Current
16
19
 
17
20
  class << self
18
21
  def decode_filters(filter_params)
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.0.0.pre6" unless const_defined?(:VERSION)
2
+ VERSION = "3.0.0.pre7" unless const_defined?(:VERSION)
3
3
  end
@@ -132,7 +132,7 @@ module Generators
132
132
  def generated_fields_template
133
133
  return if fields.blank?
134
134
 
135
- fields_string = "\n # Fields generated from the model"
135
+ fields_string = ""
136
136
 
137
137
  fields.each do |field_name, field_options|
138
138
  options = ""
@@ -4,11 +4,13 @@ class Avo::Actions::<%= class_name.camelize %> < Avo::BaseAction
4
4
  # true
5
5
  # end
6
6
 
7
- def handle(**args)
8
- models, fields, current_user, resource = args.values_at(:models, :fields, :current_user, :resource)
7
+ # def fields
8
+ # # Add Action fields here
9
+ # end
9
10
 
10
- models.each do |model|
11
- # Do something with your models.
11
+ def handle(records:, fields:, current_user:, resource:)
12
+ records.each do |model|
13
+ # Do something with your records.
12
14
  end
13
15
  end
14
16
  end
@@ -7,6 +7,8 @@ class Avo::Dashboards::<%= class_name.camelize %> < AvoDashboards::BaseDashboard
7
7
  # true
8
8
  # end
9
9
 
10
- # cards go here
11
- # card UsersCount
10
+ def cards
11
+ # cards go here
12
+ # card UsersCount
13
+ end
12
14
  end
@@ -2,9 +2,10 @@ class Avo::Resources::<%= resource_class %> < Avo::BaseResource
2
2
  self.title = :id
3
3
  self.includes = []<%= model_class_from_args %>
4
4
  # self.search_query = -> do
5
- # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
5
+ # query.ransack(id_eq: params[:q], m: "or").result(distinct: false)
6
6
  # end
7
7
 
8
- field :id, as: :id<%= generate_fields %>
9
- # add fields here
8
+ def fields
9
+ field :id, as: :id<%= generate_fields %>
10
+ end
10
11
  end
@@ -1,8 +1,15 @@
1
1
  class Avo::Actions::<%= class_name.camelize %> < Avo::BaseAction
2
2
  self.name = "<%= name.underscore.humanize %>"
3
3
  self.standalone = true
4
+ # self.visible = -> do
5
+ # true
6
+ # end
4
7
 
5
- def handle(fields:)
8
+ # def fields
9
+ # # Add Action fields here
10
+ # end
11
+
12
+ def handle(fields:, current_user:, resource:)
6
13
  # Do something here
7
14
  end
8
15
  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: 3.0.0.pre6
4
+ version: 3.0.0.pre7
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-05-05 00:00:00.000000000 Z
12
+ date: 2023-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord