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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/svgs/triangle-up.svg +1 -1
- data/app/components/avo/index/field_wrapper_component.rb +0 -12
- data/app/controllers/avo/search_controller.rb +4 -4
- data/app/views/avo/partials/_table_header.html.erb +0 -8
- data/lib/avo/base_action.rb +0 -6
- data/lib/avo/base_resource.rb +4 -6
- data/lib/avo/fields/base_field.rb +19 -4
- data/lib/avo/filters/base_filter.rb +3 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/resource_generator.rb +1 -1
- data/lib/generators/avo/templates/action.tt +6 -4
- data/lib/generators/avo/templates/dashboards/dashboard.tt +4 -2
- data/lib/generators/avo/templates/resource/resource.tt +4 -3
- data/lib/generators/avo/templates/standalone_action.tt +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe5b6765044687c412c2fd89cf479e3e1fe775f6eb0519824cc63c7bd3a651b2
|
4
|
+
data.tar.gz: f65add1a904af96f6464e22bd1c86464111c4a46f03e9a8375452fffd6afce5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d6fe1f910683c701cbdc253c879f2415de5f9744237a496a6abc0237cce464f609f4c6c598870e7f119bf1e71f19f817e223973dc4881d3527f8559030c0f3
|
7
|
+
data.tar.gz: 731535291627256c234a5eeded5ad7854f89a25a399a201b5f76a94d9c74d87793cfb0dd25f44f31ae1b7f590203f3393b28089c080b2fdaca8a8282b2b790e7
|
data/Gemfile.lock
CHANGED
@@ -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="#
|
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
|
-
|
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
|
-
|
104
|
+
query = parent.send(association_name)
|
105
105
|
|
106
|
-
Avo::ExecutionContext.new(target: @resource.search_query, params: params,
|
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)
|
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",
|
data/lib/avo/base_action.rb
CHANGED
@@ -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
|
|
data/lib/avo/base_resource.rb
CHANGED
@@ -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
|
-
|
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,
|
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,
|
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
|
-
|
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 =
|
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
|
-
|
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
@@ -4,11 +4,13 @@ class Avo::Actions::<%= class_name.camelize %> < Avo::BaseAction
|
|
4
4
|
# true
|
5
5
|
# end
|
6
6
|
|
7
|
-
def
|
8
|
-
|
7
|
+
# def fields
|
8
|
+
# # Add Action fields here
|
9
|
+
# end
|
9
10
|
|
10
|
-
|
11
|
-
|
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
|
@@ -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
|
-
#
|
5
|
+
# query.ransack(id_eq: params[:q], m: "or").result(distinct: false)
|
6
6
|
# end
|
7
7
|
|
8
|
-
|
9
|
-
|
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
|
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.
|
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-
|
12
|
+
date: 2023-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|