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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3eeaf7c4479bd7cd5c0e45ca017ab8527a0d0ddf5fe625bc0bee728d5be654eb
4
- data.tar.gz: 6f8538be2082861d11a2c150cd670733978d8631885aa7693c0d6b9770a97535
3
+ metadata.gz: 38ab852dd9e98b8a3096344f2fd4e3145e937a2cbbef3524adea0fb7339c6949
4
+ data.tar.gz: 5140ed4d3a7075d2ed3c539ea87134026b43eba770d0615ad3ffb1694ed9dc77
5
5
  SHA512:
6
- metadata.gz: 48a019b6179859de05f19839922ae41f391f08112f436c0946a526c5b36bc027855f5220c118c0588c66fecaea0d5ba59978d98803b1311884261f472f267efc
7
- data.tar.gz: a5e00b21b9c62e5825718aec9bff93d8759b67f318edd93ba488a3f2caa2d7af3d7143f25917b6d475557b5d52648dc8f23bdb09d95194bc8278531be653e722
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.45.0)
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.15.4)
272
+ nokogiri (1.16.0)
273
273
  mini_portile2 (~> 2.8.2)
274
274
  racc (~> 1.4)
275
- nokogiri (1.15.4-x86_64-linux)
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.get_stimulus_controllers.split(" ").each do |controller|
87
- attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower)
88
- end
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
  %>
@@ -1,6 +1,7 @@
1
1
  module Avo
2
2
  class BaseAction
3
3
  include Avo::Concerns::HasFields
4
+ include Avo::Concerns::HasActionStimulusControllers
4
5
 
5
6
  class_attribute :name, default: nil
6
7
  class_attribute :message
@@ -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::HasStimulusControllers
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
- add_default_data_attributes attributes, name, element, view
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 add_default_data_attributes(attributes, name, element, view)
51
- if !attributes.nil? && name == :data && element == :input && view.in?([:edit, :new]) && resource.present? && resource.respond_to?(:get_stimulus_controllers)
52
- extra_attributes = resource.get_stimulus_controllers
53
- .split(" ")
54
- .map do |controller|
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
- attributes.merge extra_attributes
60
- else
61
- attributes
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
@@ -1,6 +1,6 @@
1
1
  module Avo
2
2
  module Concerns
3
- module HasStimulusControllers
3
+ module HasResourceStimulusControllers
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
@@ -85,6 +85,7 @@ module Avo
85
85
  @value = args[:value] || nil
86
86
  @stacked = args[:stacked] || nil
87
87
  @resource = args[:resource]
88
+ @action = args[:action]
88
89
 
89
90
  @args = args
90
91
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.45.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.47.0" unless const_defined?(:VERSION)
3
3
  end
@@ -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: هل أنت متأكد أنك تريد فصل هذا الـ٪{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: ربط وربط آخر