avo 3.19.2 → 3.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/avo/engine.rb CHANGED
@@ -70,7 +70,7 @@ module Avo
70
70
 
71
71
  scope at do
72
72
  Avo.plugin_manager.engines.each do |engine|
73
- mount engine[:klass], **engine[:options]
73
+ mount engine[:klass], **engine[:options].dup
74
74
  end
75
75
  end
76
76
  end
@@ -70,18 +70,19 @@ module Avo
70
70
  @summarizable = args[:summarizable] || false
71
71
  @nullable = args[:nullable] || false
72
72
  @null_values = args[:null_values] || [nil, ""]
73
- @format_using = args[:format_using] || nil
74
- @update_using = args[:update_using] || nil
73
+ @format_using = args[:format_using]
74
+ @update_using = args[:update_using]
75
+ @decorate = args[:decorate]
75
76
  @placeholder = args[:placeholder]
76
- @autocomplete = args[:autocomplete] || nil
77
- @help = args[:help] || nil
78
- @default = args[:default] || nil
77
+ @autocomplete = args[:autocomplete]
78
+ @help = args[:help]
79
+ @default = args[:default]
79
80
  @visible = args[:visible]
80
81
  @as_avatar = args[:as_avatar] || false
81
- @html = args[:html] || nil
82
- @view = Avo::ViewInquirer.new(args[:view]) || nil
83
- @value = args[:value] || nil
84
- @stacked = args[:stacked] || nil
82
+ @html = args[:html]
83
+ @view = Avo::ViewInquirer.new(args[:view])
84
+ @value = args[:value]
85
+ @stacked = args[:stacked]
85
86
  @for_presentation_only = args[:for_presentation_only] || false
86
87
  @resource = args[:resource]
87
88
  @action = args[:action]
@@ -154,45 +155,42 @@ module Avo
154
155
  def value(property = nil)
155
156
  return @value if @value.present?
156
157
 
157
- property ||= @for_attribute || id
158
+ property ||= @for_attribute || @id
158
159
 
159
160
  # Get record value
160
- final_value = record.send(property) if is_model?(record) && record.respond_to?(property)
161
+ final_value = @record.send(property) if is_model?(@record) && @record.respond_to?(property)
161
162
 
162
163
  # On new views and actions modals we need to prefill the fields with the default value if value is nil
163
- if final_value.nil? && should_fill_with_default_value? && default.present?
164
+ if final_value.nil? && should_fill_with_default_value? && @default.present?
164
165
  final_value = computed_default_value
165
166
  end
166
167
 
167
168
  # Run computable callback block if present
168
- if computable && block.present?
169
- final_value = execute_block
169
+ if computable && @block.present?
170
+ final_value = execute_context(@block)
170
171
  end
171
172
 
172
173
  # Run the value through resolver if present
173
- if format_using.present?
174
- final_value = Avo::ExecutionContext.new(
175
- target: format_using,
176
- value: final_value,
177
- record: record,
178
- resource: resource,
179
- view: view,
180
- field: self,
181
- include: self.class.included_modules
182
- ).handle
174
+ if @format_using.present?
175
+ final_value = execute_context(@format_using, value: final_value)
176
+ end
177
+
178
+ if @decorate.present? && @view.display?
179
+ final_value = execute_context(@decorate, value: final_value)
183
180
  end
184
181
 
185
182
  final_value
186
183
  end
187
184
 
188
- def execute_block
185
+ def execute_context(target, **extra_args)
189
186
  Avo::ExecutionContext.new(
190
- target: block,
191
- record: record,
192
- resource: resource,
193
- view: view,
187
+ target:,
188
+ record: @record,
189
+ resource: @resource,
190
+ view: @view,
194
191
  field: self,
195
- include: self.class.included_modules
192
+ include: self.class.included_modules,
193
+ **extra_args
196
194
  ).handle
197
195
  end
198
196
 
@@ -24,7 +24,7 @@ module Avo
24
24
  end
25
25
 
26
26
  def value
27
- block.present? ? execute_block : @label
27
+ @block.present? ? execute_context(@block) : @label
28
28
  end
29
29
  end
30
30
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.19.2" unless const_defined?(:VERSION)
2
+ VERSION = "3.19.3" 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: 3.19.2
4
+ version: 3.19.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-04-07 00:00:00.000000000 Z
13
+ date: 2025-04-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord