avo 2.26.1.pr1584.pre.1 → 2.26.3.pre.pr1601

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.

Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -1
  3. data/Gemfile.lock +15 -10
  4. data/app/assets/stylesheets/css/tags.css +9 -0
  5. data/app/components/avo/base_component.rb +2 -2
  6. data/app/components/avo/field_wrapper_component.rb +2 -1
  7. data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
  8. data/app/components/avo/fields/belongs_to_field/show_component.rb +1 -1
  9. data/app/components/avo/fields/has_one_field/show_component.rb +3 -3
  10. data/app/components/avo/fields/index_component.rb +1 -1
  11. data/app/components/avo/fields/tags_field/edit_component.html.erb +13 -10
  12. data/app/components/avo/index/grid_item_component.rb +1 -1
  13. data/app/components/avo/index/ordering/button_component.rb +1 -1
  14. data/app/components/avo/index/resource_controls_component.rb +2 -2
  15. data/app/components/avo/resource_component.rb +1 -1
  16. data/app/components/avo/views/resource_index_component.rb +6 -4
  17. data/app/controllers/avo/actions_controller.rb +1 -1
  18. data/app/controllers/avo/application_controller.rb +2 -3
  19. data/app/controllers/avo/associations_controller.rb +2 -2
  20. data/app/controllers/avo/base_controller.rb +8 -5
  21. data/app/javascript/js/controllers/fields/tags_field_controller.js +62 -25
  22. data/app/views/avo/associations/new.html.erb +6 -1
  23. data/app/views/avo/partials/_footer.html.erb +1 -1
  24. data/app/views/layouts/avo/application.html.erb +2 -0
  25. data/bin/prod +10 -0
  26. data/lib/avo/base_resource.rb +15 -1
  27. data/lib/avo/concerns/has_fields.rb +4 -0
  28. data/lib/avo/concerns/visible_items.rb +7 -0
  29. data/lib/avo/engine.rb +6 -0
  30. data/lib/avo/fields/tags_field.rb +20 -13
  31. data/lib/avo/services/uri_service.rb +10 -9
  32. data/lib/avo/version.rb +1 -1
  33. data/public/avo-assets/avo.base.css +79 -66
  34. data/public/avo-assets/avo.base.js +161 -161
  35. data/public/avo-assets/avo.base.js.map +3 -3
  36. metadata +3 -2
@@ -264,6 +264,10 @@ module Avo
264
264
  panelfull_items = []
265
265
 
266
266
  items.each do |item|
267
+ if item.respond_to? :hydrate
268
+ item.hydrate(view: view)
269
+ end
270
+
267
271
  # fields and tabs can be hidden on some views
268
272
  if item.respond_to? :visible_on?
269
273
  next unless item.visible_on?(view)
@@ -13,6 +13,13 @@ module Avo
13
13
 
14
14
  def visible_items
15
15
  items
16
+ .map do |item|
17
+ if item.respond_to? :hydrate
18
+ item.hydrate(view: view)
19
+ end
20
+
21
+ item
22
+ end
16
23
  .map do |item|
17
24
  visible(item) ? item : nil
18
25
  end
data/lib/avo/engine.rb CHANGED
@@ -54,6 +54,12 @@ module Avo
54
54
  # app.config.logger = ::Logger.new(STDOUT)
55
55
  end
56
56
 
57
+ initializer "avo.test_buddy" do |app|
58
+ if Avo::IN_DEVELOPMENT
59
+ Rails.autoloaders.main.push_dir Avo::Engine.root.join("spec", "helpers")
60
+ end
61
+ end
62
+
57
63
  config.app_middleware.use(
58
64
  Rack::Static,
59
65
  urls: ["/avo-assets"],
@@ -5,6 +5,7 @@ module Avo
5
5
  attr_reader :close_on_select
6
6
  attr_reader :delimiters
7
7
  attr_reader :enforce_suggestions
8
+ attr_reader :mode
8
9
 
9
10
  def initialize(id, **args, &block)
10
11
  super(id, **args, &block)
@@ -15,6 +16,8 @@ module Avo
15
16
  add_array_prop args, :disallowed
16
17
  add_array_prop args, :delimiters, [","]
17
18
  add_array_prop args, :suggestions
19
+ add_string_prop args, :mode, nil
20
+ add_string_prop args, :fetch_values_from
18
21
  end
19
22
 
20
23
  def field_value
@@ -33,9 +36,16 @@ module Avo
33
36
 
34
37
  def fill_field(model, key, value, params)
35
38
  if acts_as_taggable_on.present?
36
- model.send(act_as_taggable_attribute(key), parsed_value(value))
39
+ model.send(act_as_taggable_attribute(key), value)
37
40
  else
38
- model.send("#{key}=", parsed_value(value))
41
+ val = if value.is_a?(String)
42
+ value.split(",")
43
+ elsif value.is_a?(Array)
44
+ value
45
+ else
46
+ value
47
+ end
48
+ model.send("#{key}=", val)
39
49
  end
40
50
 
41
51
  model
@@ -61,21 +71,18 @@ module Avo
61
71
  []
62
72
  end
63
73
 
64
- private
65
-
66
- def act_as_taggable_attribute(key)
67
- "#{key.singularize}_list="
68
- end
69
-
70
- def parsed_value(value)
71
- JSON.parse(value).pluck("value")
72
- rescue
73
- []
74
+ def fetch_values_from
75
+ if @fetch_values_from.respond_to?(:call)
76
+ Avo::Hosts::ResourceRecordHost.new(block: @fetch_values_from, resource: resource, record: model).handle
77
+ else
78
+ @fetch_values_from
79
+ end
74
80
  end
75
81
 
76
82
  private
77
83
 
78
- def parse_suggestions_from_args(args)
84
+ def act_as_taggable_attribute(key)
85
+ "#{key.singularize}_list="
79
86
  end
80
87
  end
81
88
  end
@@ -3,13 +3,13 @@ module Avo
3
3
  class URIService
4
4
  class << self
5
5
  def parse(path)
6
- self.new path
6
+ new path
7
7
  end
8
8
  end
9
9
 
10
10
  attr_reader :uri
11
11
 
12
- def initialize(path = '')
12
+ def initialize(path = "")
13
13
  @uri = Addressable::URI.parse(path)
14
14
  end
15
15
 
@@ -56,19 +56,20 @@ module Avo
56
56
  private
57
57
 
58
58
  def join_paths(paths)
59
- paths.map do |path|
60
- sanitize_path path
61
- end
62
- .join("/")
59
+ paths
60
+ .map do |path|
61
+ sanitize_path path
62
+ end
63
+ .join("/")
63
64
  end
64
65
 
65
66
  # Removes the forward slash if it's present at the start of the path
66
67
  def sanitize_path(path)
67
- if path.to_s.starts_with? '/'
68
- path = path[1..-1]
68
+ if path.to_s.starts_with? "/"
69
+ path = path[1..]
69
70
  end
70
71
 
71
- path
72
+ ERB::Util.url_encode path
72
73
  end
73
74
  end
74
75
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.26.1.pr1584.pre.1" unless const_defined?(:VERSION)
2
+ VERSION = "2.26.3.pre.pr1601" unless const_defined?(:VERSION)
3
3
  end
@@ -2677,7 +2677,8 @@ body.dark,body[data-theme=dark]{
2677
2677
 
2678
2678
  :root{
2679
2679
  --tagify-dd-color-primary:rgb(53,149,246);
2680
- --tagify-dd-bg-color:white
2680
+ --tagify-dd-bg-color:white;
2681
+ --tagify-dd-item-pad:.3em .5em
2681
2682
  }
2682
2683
 
2683
2684
  .tagify{
@@ -2685,6 +2686,7 @@ body.dark,body[data-theme=dark]{
2685
2686
  --tags-border-color:#DDD;
2686
2687
  --tags-hover-border-color:#CCC;
2687
2688
  --tags-focus-border-color:#3595f6;
2689
+ --tag-border-radius:3px;
2688
2690
  --tag-bg:#E5E5E5;
2689
2691
  --tag-hover:#D3E2E2;
2690
2692
  --tag-text-color:black;
@@ -2705,10 +2707,9 @@ body.dark,body[data-theme=dark]{
2705
2707
  --placeholder-color-focus:rgba(0, 0, 0, 0.25);
2706
2708
  --loader-size:.8em;
2707
2709
  --readonly-striped:1;
2708
- display:flex;
2710
+ display:inline-flex;
2709
2711
  align-items:flex-start;
2710
2712
  flex-wrap:wrap;
2711
- border:1px solid #ddd;
2712
2713
  border:1px solid var(--tags-border-color);
2713
2714
  padding:0;
2714
2715
  line-height:0;
@@ -2731,15 +2732,8 @@ body.dark,body[data-theme=dark]{
2731
2732
  }
2732
2733
  }
2733
2734
 
2734
- .tagify:hover{
2735
- border-color:#ccc;
2736
- border-color:var(--tags-hover-border-color)
2737
- }
2738
-
2739
- .tagify.tagify--focus{
2740
- transition:0s;
2741
- border-color:#3595f6;
2742
- border-color:var(--tags-focus-border-color)
2735
+ .tagify:hover:not(.tagify--focus):not(.tagify--invalid){
2736
+ --tags-border-color:var(--tags-hover-border-color)
2743
2737
  }
2744
2738
 
2745
2739
  .tagify[disabled]{
@@ -2764,7 +2758,6 @@ body.dark,body[data-theme=dark]{
2764
2758
  }
2765
2759
 
2766
2760
  .tagify[disabled]:not(.tagify--mix):not(.tagify--select) .tagify__tag>div,.tagify[readonly]:not(.tagify--mix):not(.tagify--select) .tagify__tag>div{
2767
- padding:.3em .5em;
2768
2761
  padding:var(--tag-pad)
2769
2762
  }
2770
2763
 
@@ -2799,6 +2792,7 @@ body.dark,body[data-theme=dark]{
2799
2792
  height:.7em;
2800
2793
  width:var(--loader-size);
2801
2794
  height:var(--loader-size);
2795
+ min-width:0;
2802
2796
  border:3px solid;
2803
2797
  border-color:#eee #bbb #888 transparent;
2804
2798
  border-radius:50%;
@@ -2833,12 +2827,10 @@ body.dark,body[data-theme=dark]{
2833
2827
  vertical-align:top;
2834
2828
  box-sizing:border-box;
2835
2829
  max-width:100%;
2836
- padding:.3em .5em;
2837
- padding:var(--tag-pad,.3em .5em);
2838
- color:#000;
2839
- color:var(--tag-text-color,#000);
2830
+ padding:var(--tag-pad);
2831
+ color:var(--tag-text-color);
2840
2832
  line-height:inherit;
2841
- border-radius:3px;
2833
+ border-radius:var(--tag-border-radius);
2842
2834
  white-space:nowrap;
2843
2835
  transition:.13s ease-out
2844
2836
  }
@@ -2849,10 +2841,8 @@ body.dark,body[data-theme=dark]{
2849
2841
  text-overflow:ellipsis;
2850
2842
  display:inline-block;
2851
2843
  vertical-align:top;
2852
- min-width:1ch;
2853
- max-width:auto;
2854
- min-width:var(--tag--min-width,1ch);
2855
- max-width:var(--tag--max-width,auto);
2844
+ min-width:var(--tag--min-width);
2845
+ max-width:var(--tag--max-width);
2856
2846
  transition:.8s ease,.1s color
2857
2847
  }
2858
2848
 
@@ -2870,25 +2860,17 @@ body.dark,body[data-theme=dark]{
2870
2860
  content:"";
2871
2861
  position:absolute;
2872
2862
  border-radius:inherit;
2873
- left:0;
2874
- top:0;
2875
- right:0;
2876
- bottom:0;
2863
+ inset:var(--tag-bg-inset,0);
2877
2864
  z-index:-1;
2878
2865
  pointer-events:none;
2879
2866
  transition:120ms ease;
2880
2867
  animation:tags--bump .3s ease-out 1;
2881
- box-shadow:0 0 0 1.1em #e5e5e5 inset;
2882
- box-shadow:0 0 0 var(--tag-inset-shadow-size,1.1em) var(--tag-bg,#e5e5e5) inset
2868
+ box-shadow:0 0 0 var(--tag-inset-shadow-size) var(--tag-bg) inset
2883
2869
  }
2884
2870
 
2885
2871
  .tagify__tag:focus div::before,.tagify__tag:hover:not([readonly]) div::before{
2886
- top:-2px;
2887
- right:-2px;
2888
- bottom:-2px;
2889
- left:-2px;
2890
- box-shadow:0 0 0 1.1em #d3e2e2 inset;
2891
- box-shadow:0 0 0 var(--tag-inset-shadow-size,1.1em) var(--tag-hover,#d3e2e2) inset
2872
+ --tag-bg-inset:-2.5px;
2873
+ --tag-bg:var(--tag-hover)
2892
2874
  }
2893
2875
 
2894
2876
  .tagify__tag--loading{
@@ -2908,6 +2890,7 @@ body.dark,body[data-theme=dark]{
2908
2890
  height:.7em;
2909
2891
  width:var(--loader-size);
2910
2892
  height:var(--loader-size);
2893
+ min-width:0;
2911
2894
  border:3px solid;
2912
2895
  border-color:#eee #bbb #888 transparent;
2913
2896
  border-radius:50%;
@@ -2927,8 +2910,7 @@ body.dark,body[data-theme=dark]{
2927
2910
  margin-right:0;
2928
2911
  opacity:0;
2929
2912
  transform:scale(0);
2930
- transition:.3s;
2931
- transition:var(--tag-hide-transition,.3s);
2913
+ transition:var(--tag-hide-transition);
2932
2914
  pointer-events:none
2933
2915
  }
2934
2916
 
@@ -2945,8 +2927,7 @@ body.dark,body[data-theme=dark]{
2945
2927
  }
2946
2928
 
2947
2929
  .tagify__tag.tagify--notAllowed:not(.tagify__tag--editable) div::before{
2948
- box-shadow:0 0 0 1.1em rgba(211,148,148,.5) inset!important;
2949
- box-shadow:0 0 0 var(--tag-inset-shadow-size,1.1em) var(--tag-invalid-bg,rgba(211,148,148,.5)) inset!important;
2930
+ --tag-bg:var(--tag-invalid-bg);
2950
2931
  transition:.2s
2951
2932
  }
2952
2933
 
@@ -2967,13 +2948,11 @@ body.dark,body[data-theme=dark]{
2967
2948
  }
2968
2949
 
2969
2950
  .tagify__tag--editable>div{
2970
- color:#000;
2971
- color:var(--tag-text-color--edit,#000)
2951
+ color:var(--tag-text-color--edit)
2972
2952
  }
2973
2953
 
2974
2954
  .tagify__tag--editable>div::before{
2975
- box-shadow:0 0 0 2px #d3e2e2 inset!important;
2976
- box-shadow:0 0 0 2px var(--tag-hover,#d3e2e2) inset!important
2955
+ box-shadow:0 0 0 2px var(--tag-hover) inset!important
2977
2956
  }
2978
2957
 
2979
2958
  .tagify__tag--editable>.tagify__tag__removeBtn{
@@ -2986,8 +2965,7 @@ body.dark,body[data-theme=dark]{
2986
2965
  }
2987
2966
 
2988
2967
  .tagify__tag--editable.tagify--invalid>div::before{
2989
- box-shadow:0 0 0 2px #d39494 inset!important;
2990
- box-shadow:0 0 0 2px var(--tag-invalid-color,#d39494) inset!important
2968
+ box-shadow:0 0 0 2px var(--tag-invalid-color) inset!important
2991
2969
  }
2992
2970
 
2993
2971
  .tagify__tag__removeBtn{
@@ -2998,10 +2976,8 @@ body.dark,body[data-theme=dark]{
2998
2976
  border-radius:50px;
2999
2977
  cursor:pointer;
3000
2978
  font:14px/1 Arial;
3001
- background:0 0;
3002
- background:var(--tag-remove-btn-bg,none);
3003
- color:#000;
3004
- color:var(--tag-remove-btn-color,#000);
2979
+ background:var(--tag-remove-btn-bg);
2980
+ color:var(--tag-remove-btn-color);
3005
2981
  width:14px;
3006
2982
  height:14px;
3007
2983
  margin-right:4.6666666667px;
@@ -3017,8 +2993,7 @@ body.dark,body[data-theme=dark]{
3017
2993
 
3018
2994
  .tagify__tag__removeBtn:hover{
3019
2995
  color:#fff;
3020
- background:#c77777;
3021
- background:var(--tag-remove-btn-bg--hover,#c77777)
2996
+ background:var(--tag-remove-btn-bg--hover)
3022
2997
  }
3023
2998
 
3024
2999
  .tagify__tag__removeBtn:hover+div>span{
@@ -3026,8 +3001,7 @@ body.dark,body[data-theme=dark]{
3026
3001
  }
3027
3002
 
3028
3003
  .tagify__tag__removeBtn:hover+div::before{
3029
- box-shadow:0 0 0 1.1em rgba(211,148,148,.3) inset!important;
3030
- box-shadow:0 0 0 var(--tag-inset-shadow-size,1.1em) var(--tag-remove-bg,rgba(211,148,148,.3)) inset!important;
3004
+ box-shadow:0 0 0 var(--tag-inset-shadow-size) var(--tag-remove-bg,rgba(211,148,148,.3)) inset!important;
3031
3005
  transition:box-shadow .2s
3032
3006
  }
3033
3007
 
@@ -3045,16 +3019,18 @@ body.dark,body[data-theme=dark]{
3045
3019
  display:inline-block;
3046
3020
  min-width:110px;
3047
3021
  margin:5px;
3048
- padding:.3em .5em;
3049
- padding:var(--tag-pad,.3em .5em);
3022
+ padding:var(--tag-pad);
3050
3023
  line-height:normal;
3051
3024
  position:relative;
3052
3025
  white-space:pre-wrap;
3053
- color:inherit;
3054
- color:var(--input-color,inherit);
3026
+ color:var(--input-color);
3055
3027
  box-sizing:inherit
3056
3028
  }
3057
3029
 
3030
+ .tagify__input:empty::before{
3031
+ position:static
3032
+ }
3033
+
3058
3034
  .tagify__input:focus{
3059
3035
  outline:0
3060
3036
  }
@@ -3091,7 +3067,6 @@ body.dark,body[data-theme=dark]{
3091
3067
  line-height:1em;
3092
3068
  margin:auto 0;
3093
3069
  z-index:1;
3094
- color:rgba(0,0,0,.4);
3095
3070
  color:var(--placeholder-color);
3096
3071
  white-space:nowrap;
3097
3072
  pointer-events:none;
@@ -3102,8 +3077,13 @@ body.dark,body[data-theme=dark]{
3102
3077
  .tagify__input::after{
3103
3078
  content:attr(data-suggest);
3104
3079
  display:inline-block;
3080
+ vertical-align:middle;
3081
+ position:absolute;
3082
+ min-width:calc(100% - 1.5em);
3083
+ text-overflow:ellipsis;
3084
+ overflow:hidden;
3105
3085
  white-space:pre;
3106
- color:#000;
3086
+ color:var(--tag-text-color);
3107
3087
  opacity:.3;
3108
3088
  pointer-events:none;
3109
3089
  max-width:100px
@@ -3182,6 +3162,11 @@ body.dark,body[data-theme=dark]{
3182
3162
  display:inline-block
3183
3163
  }
3184
3164
 
3165
+ .tagify--focus{
3166
+ --tags-border-color:var(--tags-focus-border-color);
3167
+ transition:0s
3168
+ }
3169
+
3185
3170
  .tagify--invalid{
3186
3171
  --tags-border-color:#D39494
3187
3172
  }
@@ -3215,11 +3200,11 @@ body.dark,body[data-theme=dark]{
3215
3200
  .tagify__dropdown__wrapper{
3216
3201
  max-height:300px;
3217
3202
  overflow:auto;
3218
- background:#fff;
3203
+ overflow-x:hidden;
3219
3204
  background:var(--tagify-dd-bg-color);
3220
- border:1px solid #3595f6;
3205
+ border:1px solid;
3221
3206
  border-color:var(--tagify-dd-color-primary);
3222
- border-bottom-width:1.33px;
3207
+ border-bottom-width:1.5px;
3223
3208
  border-top-width:0;
3224
3209
  box-shadow:0 2px 4px -2px rgba(0,0,0,.2);
3225
3210
  transition:.25s cubic-bezier(0,1,.5,1)
@@ -3232,7 +3217,7 @@ body.dark,body[data-theme=dark]{
3232
3217
  .tagify__dropdown__footer{
3233
3218
  display:inline-block;
3234
3219
  margin-top:.5em;
3235
- padding:.3em .5em;
3220
+ padding:var(--tagify-dd-item-pad);
3236
3221
  font-size:.7em;
3237
3222
  font-style:italic;
3238
3223
  opacity:.5
@@ -3252,17 +3237,18 @@ body.dark,body[data-theme=dark]{
3252
3237
  }
3253
3238
 
3254
3239
  .tagify__dropdown__item{
3255
- box-sizing:inherit;
3256
- padding:.3em .5em;
3240
+ box-sizing:border-box;
3241
+ padding:var(--tagify-dd-item-pad);
3257
3242
  margin:1px;
3258
3243
  cursor:pointer;
3259
3244
  border-radius:2px;
3260
3245
  position:relative;
3261
- outline:0
3246
+ outline:0;
3247
+ max-height:60px;
3248
+ max-width:100%
3262
3249
  }
3263
3250
 
3264
3251
  .tagify__dropdown__item--active{
3265
- background:#3595f6;
3266
3252
  background:var(--tagify-dd-color-primary);
3267
3253
  color:#fff
3268
3254
  }
@@ -3271,6 +3257,22 @@ body.dark,body[data-theme=dark]{
3271
3257
  filter:brightness(105%)
3272
3258
  }
3273
3259
 
3260
+ .tagify__dropdown__item--hidden{
3261
+ padding-top:0;
3262
+ padding-bottom:0;
3263
+ margin:0 1px;
3264
+ pointer-events:none;
3265
+ overflow:hidden;
3266
+ max-height:0;
3267
+ transition:var(--tagify-dd-item--hidden-duration,.3s)!important
3268
+ }
3269
+
3270
+ .tagify__dropdown__item--hidden>*{
3271
+ transform:translateY(-100%);
3272
+ opacity:0;
3273
+ transition:inherit
3274
+ }
3275
+
3274
3276
  /*! tailwindcss v3.0.18 | MIT License | https://tailwindcss.com
3275
3277
  */
3276
3278
 
@@ -4645,6 +4647,11 @@ tags.tagify span.tagify__input{
4645
4647
  margin-bottom:0.25rem
4646
4648
  }
4647
4649
 
4650
+ tags.tagify span.tagify__input:after {
4651
+ /* The loader is not centered by default. This will make it look better. */
4652
+ margin-top: 0.25rem;
4653
+ }
4654
+
4648
4655
  tag.tagify__tag{
4649
4656
  margin-top:0.25rem;
4650
4657
  margin-bottom:0.25rem;
@@ -4653,6 +4660,12 @@ tag.tagify__tag{
4653
4660
  line-height:1.25rem
4654
4661
  }
4655
4662
 
4663
+ /* When the tags field is used to select just one value there's a weird ZeroWidthSpace (\u200B) character that breaks the vertical spacing. */
4664
+
4665
+ [data-tags-field-mode-value="select"] tags.tagify {
4666
+ height: 40px;
4667
+ }
4668
+
4656
4669
  .spinner {
4657
4670
  width: 16px;
4658
4671
  height: 16px;