avo 3.9.1 → 3.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
- <div class="relative flex justify-center items-center w-full !border-b-2 border-gray-200 border-solid">
2
- <div class="absolute inset-auto z-20 text-xs font-semibold uppercase leading-none text-gray-500 bg-white px-2">
3
- <%if label.present?%>
4
- <%=label%>
5
- <%end%>
6
- </div>
1
+ <div class="relative flex justify-center items-center w-full !border-b-2 border-gray-200 border-solid" data-component-name="<%= self.class.to_s.underscore %>">
2
+ <% if label.present? %>
3
+ <div class="absolute inset-auto z-20 text-xs font-semibold uppercase leading-none text-gray-500 bg-white px-2 border py-1 rounded">
4
+ <%= label %>
5
+ </div>
6
+ <% end %>
7
7
  </div>
@@ -15,7 +15,6 @@ module Avo
15
15
  protect_from_forgery with: :exception
16
16
  around_action :set_avo_locale
17
17
  around_action :set_force_locale, if: -> { params[:force_locale].present? }
18
- before_action :set_default_locale, if: -> { params[:set_locale].present? }
19
18
  before_action :init_app
20
19
  before_action :set_active_storage_current_host
21
20
  before_action :set_resource_name
@@ -52,10 +51,6 @@ module Avo
52
51
  super
53
52
  end
54
53
 
55
- def hello
56
- puts "Nobody tested me :("
57
- end
58
-
59
54
  private
60
55
 
61
56
  # Get the pluralized resource name for this request
@@ -94,7 +89,7 @@ module Avo
94
89
 
95
90
  return field.use_resource if field&.use_resource.present?
96
91
 
97
- reflection = @record._reflections.with_indifferent_access[params[:for_attribute] || params[:related_name]]
92
+ reflection = @record._reflections.with_indifferent_access[field&.for_attribute || params[:related_name]]
98
93
 
99
94
  reflected_model = reflection.klass
100
95
 
@@ -279,23 +274,21 @@ module Avo
279
274
  @resource.form_scope
280
275
  end
281
276
 
282
- # Sets the locale set in avo.rb initializer
277
+ # Sets the locale set in avo.rb initializer or if to something that the user set using the `?set_locale=pt-BR` param
283
278
  def set_avo_locale(&action)
284
- locale = Avo.configuration.locale || I18n.default_locale
285
- I18n.with_locale(locale, &action)
286
- end
279
+ locale = Avo.configuration.default_locale
287
280
 
288
- # Enable the user to change the default locale with the `?set_locale=pt-BR` param
289
- def set_default_locale
290
- locale = params[:set_locale] || I18n.default_locale
281
+ if params[:set_locale].present?
282
+ locale = params[:set_locale]
283
+ Avo.configuration.locale = locale
284
+ end
291
285
 
292
- I18n.default_locale = locale
286
+ I18n.with_locale(locale, &action)
293
287
  end
294
288
 
295
289
  # Temporary set the locale and reverting at the end of the request.
296
290
  def set_force_locale(&action)
297
- locale = params[:force_locale] || I18n.default_locale
298
- I18n.with_locale(locale, &action)
291
+ I18n.with_locale(params[:force_locale], &action)
299
292
  end
300
293
 
301
294
  def set_sidebar_open
@@ -327,8 +320,6 @@ module Avo
327
320
  end
328
321
  end
329
322
 
330
- private
331
-
332
323
  def choose_layout
333
324
  if turbo_frame_request?
334
325
  "avo/blank"
@@ -78,7 +78,7 @@ module Avo
78
78
  end
79
79
 
80
80
  def destroy
81
- association_name = BaseResource.valid_association_name(@record, params[:related_name])
81
+ association_name = BaseResource.valid_association_name(@record, @field.for_attribute || params[:related_name])
82
82
 
83
83
  if reflection_class == "HasManyReflection"
84
84
  @record.send(association_name).delete @attachment_record
@@ -157,7 +157,7 @@ module Avo
157
157
  end
158
158
 
159
159
  def association_from_params
160
- params[:for_attribute] || params[:related_name]
160
+ @field&.for_attribute || params[:related_name]
161
161
  end
162
162
  end
163
163
  end
@@ -558,7 +558,7 @@ module Avo
558
558
 
559
559
  # Set pagy locale from params or from avo configuration, if both nil locale = "en"
560
560
  def set_pagy_locale
561
- @pagy_locale = locale.to_s || Avo.configuration.locale || "en"
561
+ @pagy_locale = locale.to_s || Avo.configuration.default_locale || "en"
562
562
  end
563
563
 
564
564
  def safe_call(method)
@@ -13,6 +13,9 @@
13
13
  <%= form_with scope: 'fields',
14
14
  url: Avo::Services::URIService.parse(@resource.records_path).append_paths("actions").to_s,
15
15
  local: true,
16
+ html: {
17
+ novalidate: true,
18
+ },
16
19
  data: {
17
20
  action_target: :form,
18
21
  **@action.class.form_data_attributes,
@@ -238,6 +238,10 @@ module Avo
238
238
  def pagination
239
239
  Avo::ExecutionContext.new(target: @pagination).handle
240
240
  end
241
+
242
+ def default_locale
243
+ @locale || I18n.default_locale
244
+ end
241
245
  end
242
246
 
243
247
  def self.configuration
@@ -86,6 +86,7 @@ module Avo
86
86
  @action = args[:action]
87
87
  @components = args[:components] || {}
88
88
  @for_attribute = args[:for_attribute]
89
+ @meta = args[:meta]
89
90
 
90
91
  @args = args
91
92
 
@@ -198,23 +199,25 @@ module Avo
198
199
  key = @for_attribute.to_s if @for_attribute.present?
199
200
  return record unless has_attribute?(record, key)
200
201
 
201
- if @update_using.present?
202
- value = Avo::ExecutionContext.new(
203
- target: @update_using,
204
- record: record,
205
- key: key,
206
- value: value,
207
- resource: resource,
208
- field: self,
209
- include: self.class.included_modules
210
- ).handle
211
- end
212
-
213
- record.public_send(:"#{key}=", value)
202
+ record.public_send(:"#{key}=", apply_update_using(record, key, value, resource))
214
203
 
215
204
  record
216
205
  end
217
206
 
207
+ def apply_update_using(record, key, value, resource)
208
+ return value if @update_using.nil?
209
+
210
+ Avo::ExecutionContext.new(
211
+ target: @update_using,
212
+ record:,
213
+ key:,
214
+ value:,
215
+ resource:,
216
+ field: self,
217
+ include: self.class.included_modules
218
+ ).handle
219
+ end
220
+
218
221
  def has_attribute?(record, attribute)
219
222
  record.methods.include? attribute.to_sym
220
223
  end
@@ -281,6 +284,10 @@ module Avo
281
284
  id
282
285
  end
283
286
 
287
+ def meta
288
+ Avo::ExecutionContext.new(target: @meta, record: record, resource: @resource, view: @view).handle
289
+ end
290
+
284
291
  private
285
292
 
286
293
  def model_or_class(model)
@@ -32,32 +32,39 @@ module Avo
32
32
  end
33
33
 
34
34
  def json_value
35
- value.map do |item|
36
- {
37
- value: item.name
38
- }
39
- end.as_json
35
+ acts_as_taggable_on_values.map { |value| {value:} }.as_json
40
36
  end
41
37
 
42
- def fill_field(model, key, value, params)
43
- return fill_acts_as_taggable(model, key, value, params) if acts_as_taggable_on.present?
38
+ def acts_as_taggable_on_values
39
+ # When record is DB persistent the values are fetched from the DB
40
+ # Else the array values are fetched from the record using the tag_list_on helper
41
+ # values_array examples: ["1", "2"]
42
+ # ["example suggestion","example tag"]
43
+ if record.persisted?
44
+ value.map { |item| item.name }
45
+ else
46
+ record.tag_list_on(acts_as_taggable_on)
47
+ end
48
+ end
44
49
 
45
- val = if value.is_a?(String)
50
+ def fill_field(record, key, value, params)
51
+ return fill_acts_as_taggable(record, key, value, params) if acts_as_taggable_on.present?
52
+
53
+ value = if value.is_a?(String)
46
54
  value.split(",")
47
- elsif value.is_a?(Array)
48
- value
49
55
  else
50
56
  value
51
57
  end
52
- model.send(:"#{key}=", val)
53
58
 
54
- model
59
+ record.send(:"#{key}=", apply_update_using(record, key, value, resource))
60
+
61
+ record
55
62
  end
56
63
 
57
- def fill_acts_as_taggable(model, key, value, params)
58
- model.send(act_as_taggable_attribute(key), value)
64
+ def fill_acts_as_taggable(record, key, value, params)
65
+ record.send(act_as_taggable_attribute(key), value)
59
66
 
60
- model
67
+ record
61
68
  end
62
69
 
63
70
  def suggestions
@@ -2,7 +2,7 @@ module Avo
2
2
  module Resources
3
3
  module Controls
4
4
  class ActionsList < BaseControl
5
- ACTIONS_LIST_DROPDOWN_ICON = "heroicons/outline/arrow-down-circle"
5
+ ACTIONS_LIST_DROPDOWN_ICON = "heroicons/outline/arrow-down-circle" unless defined?(ACTIONS_LIST_DROPDOWN_ICON)
6
6
 
7
7
  attr_reader :color, :exclude, :include, :style, :icon
8
8
 
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.9.1" unless const_defined?(:VERSION)
2
+ VERSION = "3.9.2" unless const_defined?(:VERSION)
3
3
  end
@@ -7302,10 +7302,6 @@ tag.tagify__tag{
7302
7302
  bottom:0.25rem
7303
7303
  }
7304
7304
 
7305
- .bottom-4{
7306
- bottom:1rem
7307
- }
7308
-
7309
7305
  .bottom-full{
7310
7306
  bottom:100%
7311
7307
  }
@@ -7350,10 +7346,6 @@ tag.tagify__tag{
7350
7346
  right:0.75rem
7351
7347
  }
7352
7348
 
7353
- .right-4{
7354
- right:1rem
7355
- }
7356
-
7357
7349
  .start-1{
7358
7350
  inset-inline-start:0.25rem
7359
7351
  }
@@ -7366,10 +7358,6 @@ tag.tagify__tag{
7366
7358
  top:0px
7367
7359
  }
7368
7360
 
7369
- .top-1{
7370
- top:0.25rem
7371
- }
7372
-
7373
7361
  .top-1\/2{
7374
7362
  top:50%
7375
7363
  }
@@ -7438,14 +7426,6 @@ tag.tagify__tag{
7438
7426
  grid-column:span 1 / span 1
7439
7427
  }
7440
7428
 
7441
- .col-span-2{
7442
- grid-column:span 2 / span 2
7443
- }
7444
-
7445
- .col-span-3{
7446
- grid-column:span 3 / span 3
7447
- }
7448
-
7449
7429
  .col-span-4{
7450
7430
  grid-column:span 4 / span 4
7451
7431
  }
@@ -7517,11 +7497,6 @@ tag.tagify__tag{
7517
7497
  margin-right:-0.5rem
7518
7498
  }
7519
7499
 
7520
- .-mx-4{
7521
- margin-left:-1rem;
7522
- margin-right:-1rem
7523
- }
7524
-
7525
7500
  .-mx-6{
7526
7501
  margin-left:-1.5rem;
7527
7502
  margin-right:-1.5rem
@@ -7532,11 +7507,6 @@ tag.tagify__tag{
7532
7507
  margin-bottom:-0.5rem
7533
7508
  }
7534
7509
 
7535
- .-my-4{
7536
- margin-top:-1rem;
7537
- margin-bottom:-1rem
7538
- }
7539
-
7540
7510
  .mx-3{
7541
7511
  margin-left:0.75rem;
7542
7512
  margin-right:0.75rem
@@ -7654,10 +7624,6 @@ tag.tagify__tag{
7654
7624
  margin-left:2.5rem
7655
7625
  }
7656
7626
 
7657
- .ml-12{
7658
- margin-left:3rem
7659
- }
7660
-
7661
7627
  .ml-2{
7662
7628
  margin-left:0.5rem
7663
7629
  }
@@ -7861,10 +7827,6 @@ tag.tagify__tag{
7861
7827
  height:3rem
7862
7828
  }
7863
7829
 
7864
- .h-14{
7865
- height:3.5rem
7866
- }
7867
-
7868
7830
  .h-16{
7869
7831
  height:4rem
7870
7832
  }
@@ -7897,10 +7859,6 @@ tag.tagify__tag{
7897
7859
  height:1.5rem
7898
7860
  }
7899
7861
 
7900
- .h-60{
7901
- height:15rem
7902
- }
7903
-
7904
7862
  .h-64{
7905
7863
  height:16rem
7906
7864
  }
@@ -7929,10 +7887,6 @@ tag.tagify__tag{
7929
7887
  height:100%
7930
7888
  }
7931
7889
 
7932
- .max-h-11{
7933
- max-height:2.75rem
7934
- }
7935
-
7936
7890
  .max-h-11\/12{
7937
7891
  max-height:91.666667%
7938
7892
  }
@@ -7941,10 +7895,6 @@ tag.tagify__tag{
7941
7895
  max-height:100%
7942
7896
  }
7943
7897
 
7944
- .min-h-1{
7945
- min-height:0.25rem
7946
- }
7947
-
7948
7898
  .min-h-1\/4{
7949
7899
  min-height:25%
7950
7900
  }
@@ -7993,18 +7943,10 @@ tag.tagify__tag{
7993
7943
  min-height:8rem
7994
7944
  }
7995
7945
 
7996
- .min-h-dvh{
7997
- min-height:100dvh
7998
- }
7999
-
8000
7946
  .min-h-full{
8001
7947
  min-height:100%
8002
7948
  }
8003
7949
 
8004
- .min-h-inherit{
8005
- min-height:inherit
8006
- }
8007
-
8008
7950
  .min-h-screen{
8009
7951
  min-height:100vh
8010
7952
  }
@@ -8013,10 +7955,6 @@ tag.tagify__tag{
8013
7955
  width:0px
8014
7956
  }
8015
7957
 
8016
- .w-1{
8017
- width:0.25rem
8018
- }
8019
-
8020
7958
  .w-1\/2{
8021
7959
  width:50%
8022
7960
  }
@@ -8029,10 +7967,6 @@ tag.tagify__tag{
8029
7967
  width:83.333333%
8030
7968
  }
8031
7969
 
8032
- .w-11{
8033
- width:2.75rem
8034
- }
8035
-
8036
7970
  .w-11\/12{
8037
7971
  width:91.666667%
8038
7972
  }
@@ -8053,10 +7987,6 @@ tag.tagify__tag{
8053
7987
  width:6rem
8054
7988
  }
8055
7989
 
8056
- .w-3{
8057
- width:0.75rem
8058
- }
8059
-
8060
7990
  .w-4{
8061
7991
  width:1rem
8062
7992
  }
@@ -8205,19 +8135,10 @@ tag.tagify__tag{
8205
8135
  flex-grow:1
8206
8136
  }
8207
8137
 
8208
- .grow-0{
8209
- flex-grow:0
8210
- }
8211
-
8212
8138
  .border-collapse{
8213
8139
  border-collapse:collapse
8214
8140
  }
8215
8141
 
8216
- .-translate-x-1{
8217
- --tw-translate-x:-0.25rem;
8218
- transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
8219
- }
8220
-
8221
8142
  .-translate-x-1\/2{
8222
8143
  --tw-translate-x:-50%;
8223
8144
  transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
@@ -8331,18 +8252,6 @@ tag.tagify__tag{
8331
8252
  grid-template-columns:repeat(2, minmax(0, 1fr))
8332
8253
  }
8333
8254
 
8334
- .grid-cols-3{
8335
- grid-template-columns:repeat(3, minmax(0, 1fr))
8336
- }
8337
-
8338
- .grid-cols-4{
8339
- grid-template-columns:repeat(4, minmax(0, 1fr))
8340
- }
8341
-
8342
- .grid-cols-5{
8343
- grid-template-columns:repeat(5, minmax(0, 1fr))
8344
- }
8345
-
8346
8255
  .grid-cols-6{
8347
8256
  grid-template-columns:repeat(6, minmax(0, 1fr))
8348
8257
  }
@@ -8359,10 +8268,6 @@ tag.tagify__tag{
8359
8268
  flex-direction:column
8360
8269
  }
8361
8270
 
8362
- .flex-col-reverse{
8363
- flex-direction:column-reverse
8364
- }
8365
-
8366
8271
  .flex-wrap{
8367
8272
  flex-wrap:wrap
8368
8273
  }
@@ -8439,12 +8344,6 @@ tag.tagify__tag{
8439
8344
  gap:1.5rem
8440
8345
  }
8441
8346
 
8442
- .space-x-0 > :not([hidden]) ~ :not([hidden]){
8443
- --tw-space-x-reverse:0;
8444
- margin-right:calc(0px * var(--tw-space-x-reverse));
8445
- margin-left:calc(0px * calc(1 - var(--tw-space-x-reverse)))
8446
- }
8447
-
8448
8347
  .space-x-1 > :not([hidden]) ~ :not([hidden]){
8449
8348
  --tw-space-x-reverse:0;
8450
8349
  margin-right:calc(0.25rem * var(--tw-space-x-reverse));
@@ -8469,18 +8368,6 @@ tag.tagify__tag{
8469
8368
  margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))
8470
8369
  }
8471
8370
 
8472
- .space-x-8 > :not([hidden]) ~ :not([hidden]){
8473
- --tw-space-x-reverse:0;
8474
- margin-right:calc(2rem * var(--tw-space-x-reverse));
8475
- margin-left:calc(2rem * calc(1 - var(--tw-space-x-reverse)))
8476
- }
8477
-
8478
- .space-y-0 > :not([hidden]) ~ :not([hidden]){
8479
- --tw-space-y-reverse:0;
8480
- margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));
8481
- margin-bottom:calc(0px * var(--tw-space-y-reverse))
8482
- }
8483
-
8484
8371
  .space-y-1 > :not([hidden]) ~ :not([hidden]){
8485
8372
  --tw-space-y-reverse:0;
8486
8373
  margin-top:calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));
@@ -8947,11 +8834,6 @@ tag.tagify__tag{
8947
8834
  background-color:rgb(227 229 232 / var(--tw-bg-opacity))
8948
8835
  }
8949
8836
 
8950
- .bg-gray-200{
8951
- --tw-bg-opacity:1;
8952
- background-color:rgb(200 203 208 / var(--tw-bg-opacity))
8953
- }
8954
-
8955
8837
  .bg-gray-25{
8956
8838
  --tw-bg-opacity:1;
8957
8839
  background-color:rgb(246 246 247 / var(--tw-bg-opacity))
@@ -9036,10 +8918,6 @@ tag.tagify__tag{
9036
8918
  background-color:rgb(var(--color-primary-100))
9037
8919
  }
9038
8920
 
9039
- .bg-primary-400{
9040
- background-color:rgb(var(--color-primary-400))
9041
- }
9042
-
9043
8921
  .bg-primary-500{
9044
8922
  background-color:rgb(var(--color-primary-500))
9045
8923
  }
@@ -9200,11 +9078,6 @@ tag.tagify__tag{
9200
9078
  padding-right:0.5rem
9201
9079
  }
9202
9080
 
9203
- .px-24{
9204
- padding-left:6rem;
9205
- padding-right:6rem
9206
- }
9207
-
9208
9081
  .px-3{
9209
9082
  padding-left:0.75rem;
9210
9083
  padding-right:0.75rem
@@ -9225,11 +9098,6 @@ tag.tagify__tag{
9225
9098
  padding-right:1.5rem
9226
9099
  }
9227
9100
 
9228
- .px-8{
9229
- padding-left:2rem;
9230
- padding-right:2rem
9231
- }
9232
-
9233
9101
  .py-0{
9234
9102
  padding-top:0px;
9235
9103
  padding-bottom:0px
@@ -9322,10 +9190,6 @@ tag.tagify__tag{
9322
9190
  padding-bottom:2rem
9323
9191
  }
9324
9192
 
9325
- .pe-1{
9326
- padding-inline-end:0.25rem
9327
- }
9328
-
9329
9193
  .pe-64{
9330
9194
  padding-inline-end:16rem
9331
9195
  }
@@ -9354,10 +9218,6 @@ tag.tagify__tag{
9354
9218
  padding-top:0.125rem
9355
9219
  }
9356
9220
 
9357
- .pt-1{
9358
- padding-top:0.25rem
9359
- }
9360
-
9361
9221
  .pt-16{
9362
9222
  padding-top:4rem
9363
9223
  }
@@ -9798,11 +9658,6 @@ tag.tagify__tag{
9798
9658
  filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)
9799
9659
  }
9800
9660
 
9801
- .drop-shadow{
9802
- --tw-drop-shadow:drop-shadow(0 1px 2px rgb(0 0 0 / 0.1)) drop-shadow(0 1px 1px rgb(0 0 0 / 0.06));
9803
- filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)
9804
- }
9805
-
9806
9661
  .grayscale{
9807
9662
  --tw-grayscale:grayscale(100%);
9808
9663
  filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)
@@ -9836,12 +9691,6 @@ tag.tagify__tag{
9836
9691
  transition-duration:150ms
9837
9692
  }
9838
9693
 
9839
- .transition-colors{
9840
- transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;
9841
- transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
9842
- transition-duration:150ms
9843
- }
9844
-
9845
9694
  .transition-opacity{
9846
9695
  transition-property:opacity;
9847
9696
  transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
@@ -9872,10 +9721,6 @@ tag.tagify__tag{
9872
9721
  transition-timing-function:cubic-bezier(0, 0, 0.2, 1)
9873
9722
  }
9874
9723
 
9875
- .will-change-transform{
9876
- will-change:transform
9877
- }
9878
-
9879
9724
  .\[a-zA-Z\:_\]{
9880
9725
  a-z-a--z:
9881
9726
  }
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.9.1
4
+ version: 3.9.2
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: 2024-06-11 00:00:00.000000000 Z
13
+ date: 2024-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -236,6 +236,9 @@ files:
236
236
  - Gemfile.lock
237
237
  - README.md
238
238
  - Rakefile
239
+ - app/assets/builds/avo.base.css
240
+ - app/assets/builds/avo.base.js
241
+ - app/assets/builds/avo.base.js.map
239
242
  - app/assets/config/avo_manifest.js
240
243
  - app/assets/stylesheets/avo.base.css
241
244
  - app/assets/stylesheets/css/active-storage.css