avo 2.45.0 → 2.47.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/app/components/avo/field_wrapper_component.rb +14 -3
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
- data/app/javascript/js/controllers/fields/key_value_controller.js +2 -1
- data/app/views/avo/actions/show.html.erb +2 -2
- data/lib/avo/base_action.rb +1 -0
- data/lib/avo/base_resource.rb +1 -1
- data/lib/avo/concerns/has_action_stimulus_controllers.rb +15 -0
- data/lib/avo/concerns/has_html_attributes.rb +27 -12
- data/lib/avo/concerns/{has_stimulus_controllers.rb → has_resource_stimulus_controllers.rb} +1 -1
- data/lib/avo/fields/base_field.rb +1 -0
- data/lib/avo/licensing/h_q.rb +1 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/locales/avo.ar.yml +1 -1
- data/public/avo-assets/avo.base.js +225 -223
- data/public/avo-assets/avo.base.js.map +3 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38ab852dd9e98b8a3096344f2fd4e3145e937a2cbbef3524adea0fb7339c6949
|
4
|
+
data.tar.gz: 5140ed4d3a7075d2ed3c539ea87134026b43eba770d0615ad3ffb1694ed9dc77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 149111feccf530c8da825b8367632a04bb35960e6d9ec3f95c5b2379abcff11a6e1e6e75661c506c9211af56ac4416fe54fb08f0ca9dd849ae934d3e54fa7628
|
7
|
+
data.tar.gz: 5016d7212fa9dac1aa76868e1fa0bd84930e27c4f5e800892c14bc96c1bf5876aca88357bfd77c1a7995300b3aba75dabce0d6d97eafb09090af49e1676e9862
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.
|
4
|
+
avo (2.47.0)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
active_link_to
|
7
7
|
activerecord (>= 6.0)
|
@@ -269,10 +269,10 @@ GEM
|
|
269
269
|
net-smtp (0.3.3)
|
270
270
|
net-protocol
|
271
271
|
nio4r (2.5.9)
|
272
|
-
nokogiri (1.
|
272
|
+
nokogiri (1.16.0)
|
273
273
|
mini_portile2 (~> 2.8.2)
|
274
274
|
racc (~> 1.4)
|
275
|
-
nokogiri (1.
|
275
|
+
nokogiri (1.16.0-x86_64-linux)
|
276
276
|
racc (~> 1.4)
|
277
277
|
orm_adapter (0.5.0)
|
278
278
|
pagy (6.0.4)
|
@@ -35,6 +35,7 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
|
|
35
35
|
@full_width = full_width
|
36
36
|
@label = label
|
37
37
|
@resource = resource
|
38
|
+
@action = field.action
|
38
39
|
@stacked = stacked
|
39
40
|
@style = style
|
40
41
|
@view = view
|
@@ -83,9 +84,11 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
|
|
83
84
|
|
84
85
|
# Add the built-in stimulus integration data tags.
|
85
86
|
if @resource.present?
|
86
|
-
@resource
|
87
|
-
|
88
|
-
|
87
|
+
add_stimulus_attributes_for(@resource, attributes)
|
88
|
+
end
|
89
|
+
|
90
|
+
if @action.present?
|
91
|
+
add_stimulus_attributes_for(@action, attributes)
|
89
92
|
end
|
90
93
|
|
91
94
|
# Fetch the data attributes off the html option
|
@@ -115,4 +118,12 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
|
|
115
118
|
def full_width?
|
116
119
|
@full_width
|
117
120
|
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def add_stimulus_attributes_for(entity, attributes)
|
125
|
+
entity.get_stimulus_controllers.split(" ").each do |controller|
|
126
|
+
attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower)
|
127
|
+
end
|
128
|
+
end
|
118
129
|
end
|
@@ -63,7 +63,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
63
63
|
helpers.new_resource_path(**{
|
64
64
|
via_relation: @field.id.to_s,
|
65
65
|
resource: target_resource || @field.target_resource,
|
66
|
-
via_resource_id: resource.model.to_param,
|
66
|
+
via_resource_id: resource.model.persisted? ? resource.model.to_param : nil,
|
67
67
|
via_belongs_to_resource_class: resource.class.name
|
68
68
|
}.compact)
|
69
69
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
/* eslint-disable max-len */
|
2
|
+
import * as DOMPurify from 'dompurify'
|
2
3
|
import { Controller } from '@hotwired/stimulus'
|
3
4
|
import { castBoolean } from '../../helpers/cast_boolean'
|
4
5
|
|
@@ -80,7 +81,7 @@ export default class extends Controller {
|
|
80
81
|
let index = 0
|
81
82
|
this.fieldValue.forEach((row) => {
|
82
83
|
const [key, value] = row
|
83
|
-
result += this.interpolatedRow(key, value, index)
|
84
|
+
result += this.interpolatedRow(DOMPurify.sanitize(key), DOMPurify.sanitize(value), index)
|
84
85
|
index++
|
85
86
|
})
|
86
87
|
this.rowsTarget.innerHTML = result
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= turbo_frame_tag "actions_show" do %>
|
2
2
|
<div
|
3
|
-
data-controller="action"
|
3
|
+
data-controller="<%= ["action", @action.get_stimulus_controllers].join(" ") %>"
|
4
4
|
data-no-confirmation="<%= @action.no_confirmation %>"
|
5
5
|
data-action-target="controllerDiv"
|
6
6
|
data-resource-name="<%= @resource.model_key %>"
|
@@ -27,7 +27,7 @@
|
|
27
27
|
<div class="my-4 -mx-6">
|
28
28
|
<% @action.get_fields.each_with_index do |field, index| %>
|
29
29
|
<%= render field
|
30
|
-
.hydrate(resource: @resource, model: @resource.model, user: @resource.user, view: @view)
|
30
|
+
.hydrate(resource: @resource, model: @resource.model, user: @resource.user, view: @view, action: @action)
|
31
31
|
.component_for_view(@view)
|
32
32
|
.new(field: field, resource: @resource, index: index, form: form, compact: true)
|
33
33
|
%>
|
data/lib/avo/base_action.rb
CHANGED
data/lib/avo/base_resource.rb
CHANGED
@@ -6,7 +6,7 @@ module Avo
|
|
6
6
|
include Avo::Concerns::HasFields
|
7
7
|
include Avo::Concerns::CanReplaceFields
|
8
8
|
include Avo::Concerns::HasEditableControls
|
9
|
-
include Avo::Concerns::
|
9
|
+
include Avo::Concerns::HasResourceStimulusControllers
|
10
10
|
include Avo::Concerns::ModelClassConstantized
|
11
11
|
include Avo::Concerns::Pagination
|
12
12
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Avo
|
2
|
+
module Concerns
|
3
|
+
module HasActionStimulusControllers
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class_attribute :stimulus_controllers, default: ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_stimulus_controllers
|
11
|
+
self.class.stimulus_controllers
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -27,7 +27,10 @@ module Avo
|
|
27
27
|
default_attribute_value name
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
add_action_data_attributes(attributes, name, element)
|
31
|
+
add_resource_data_attributes(attributes, name, element, view)
|
32
|
+
|
33
|
+
attributes
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
@@ -47,18 +50,17 @@ module Avo
|
|
47
50
|
name == :data ? {} : ""
|
48
51
|
end
|
49
52
|
|
50
|
-
def
|
51
|
-
if
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
[:"#{controller}-target", "#{id.to_s.underscore}_#{type.to_s.underscore}_input".camelize(:lower)]
|
56
|
-
end
|
57
|
-
.to_h
|
53
|
+
def add_action_data_attributes(attributes, name, element)
|
54
|
+
if can_add_stimulus_attributes_for?(action, attributes, name, element)
|
55
|
+
attributes.merge!(stimulus_attributes_for(action))
|
56
|
+
end
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
def add_resource_data_attributes(attributes, name, element, view)
|
60
|
+
if can_add_stimulus_attributes_for?(resource, attributes, name, element) && view.in?([:edit, :new])
|
61
|
+
resource_stimulus_attributes = stimulus_attributes_for(resource)
|
62
|
+
|
63
|
+
attributes.merge!(resource_stimulus_attributes)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
@@ -103,6 +105,19 @@ module Avo
|
|
103
105
|
|
104
106
|
result if result.present?
|
105
107
|
end
|
108
|
+
|
109
|
+
def can_add_stimulus_attributes_for?(entity, attributes, name, element)
|
110
|
+
!attributes.nil? && name == :data && element == :input && entity.present? && entity.respond_to?(:get_stimulus_controllers)
|
111
|
+
end
|
112
|
+
|
113
|
+
def stimulus_attributes_for(entity)
|
114
|
+
entity.get_stimulus_controllers
|
115
|
+
.split(" ")
|
116
|
+
.map do |controller|
|
117
|
+
[:"#{controller}-target", "#{id.to_s.underscore}_#{type.to_s.underscore}_input".camelize(:lower)]
|
118
|
+
end
|
119
|
+
.to_h
|
120
|
+
end
|
106
121
|
end
|
107
122
|
end
|
108
123
|
end
|
data/lib/avo/licensing/h_q.rb
CHANGED
@@ -6,7 +6,7 @@ module Avo
|
|
6
6
|
|
7
7
|
ENDPOINT = "https://avohq.io/api/v1/licenses/check".freeze unless const_defined?(:ENDPOINT)
|
8
8
|
REQUEST_TIMEOUT = 5 unless const_defined?(:REQUEST_TIMEOUT) # seconds
|
9
|
-
CACHE_TIME = 3600 unless const_defined?(:CACHE_TIME) # seconds
|
9
|
+
CACHE_TIME = 3600*12 unless const_defined?(:CACHE_TIME) # seconds
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def cache_key
|
data/lib/avo/version.rb
CHANGED
@@ -5,7 +5,7 @@ ar:
|
|
5
5
|
actions: أوامر
|
6
6
|
and_x_other_resources: و %{count} موارد أخرى
|
7
7
|
are_you_sure: هل أنت متأكد؟
|
8
|
-
are_you_sure_detach_item: هل أنت متأكد أنك تريد فصل هذا
|
8
|
+
are_you_sure_detach_item: هل أنت متأكد أنك تريد فصل هذا الـ%{item}؟
|
9
9
|
are_you_sure_you_want_to_run_this_option: هل أنت متأكد أنك تريد تشغيل هذا الخيار؟
|
10
10
|
attach: ربط
|
11
11
|
attach_and_attach_another: ربط وربط آخر
|