avo 1.22.1.pre.2 → 1.22.3

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -3
  3. data/app/javascript/js/application.js +1 -1
  4. data/app/javascript/js/controllers/action_controller.js +1 -1
  5. data/app/javascript/js/controllers/actions_picker_controller.js +1 -1
  6. data/app/javascript/js/controllers/alerts_controller.js +1 -1
  7. data/app/javascript/js/controllers/attachments_controller.js +1 -1
  8. data/app/javascript/js/controllers/fields/belongs_to_field_controller.js +1 -1
  9. data/app/javascript/js/controllers/fields/code_field_controller.js +1 -1
  10. data/app/javascript/js/controllers/fields/date_field_controller.js +1 -1
  11. data/app/javascript/js/controllers/fields/key_value_controller.js +3 -3
  12. data/app/javascript/js/controllers/fields/simple_mde_controller.js +1 -1
  13. data/app/javascript/js/controllers/fields/trix_field_controller.js +1 -1
  14. data/app/javascript/js/controllers/filter_controller.js +3 -7
  15. data/app/javascript/js/controllers/hidden_input_controller.js +1 -1
  16. data/app/javascript/js/controllers/item_select_all_controller.js +4 -4
  17. data/app/javascript/js/controllers/item_selector_controller.js +1 -1
  18. data/app/javascript/js/controllers/loading_button_controller.js +1 -1
  19. data/app/javascript/js/controllers/modal_controller.js +1 -1
  20. data/app/javascript/js/controllers/per_page_controller.js +1 -1
  21. data/app/javascript/js/controllers/search_controller.js +1 -1
  22. data/app/javascript/js/controllers/tippy_controller.js +1 -1
  23. data/app/javascript/js/controllers/toggle_panel_controller.js +1 -1
  24. data/db/factories.rb +2 -2
  25. data/lib/avo/base_resource.rb +18 -12
  26. data/lib/avo/fields/belongs_to_field.rb +9 -0
  27. data/lib/avo/version.rb +1 -1
  28. data/public/avo-assets/avo.js +2570 -1938
  29. data/public/avo-assets/avo.js.map +3 -3
  30. metadata +4 -7
  31. data/app/assets/builds/avo.css +0 -8606
  32. data/app/assets/builds/avo.js +0 -87860
  33. data/app/assets/builds/avo.js.map +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f3877093b6d069865155c2f545765fbf70abec721d0795e87894979c80c29a6
4
- data.tar.gz: c7df311af825024a23ee29dadf8e2ee427a7e6ba162ef3e7d29d419164afcc23
3
+ metadata.gz: '0638fa0ab76323be01a732489a1ba96def10bde4897fd4231c7a1f4c41ece424'
4
+ data.tar.gz: 394c86583f0219b3f9c5d2cf1017db4348105ae8bc26cfbac1f5ca56e9ace62a
5
5
  SHA512:
6
- metadata.gz: 94fab6c8ddef7e55d5c2f659c3ffecec573839a25d4171c389355b677b92ff922ad1ffe5d5bd2c907bcabddaaa5b1696572f315588cebc28702a94d844dd959d
7
- data.tar.gz: d813448938980e0f16f62dc5bf9688da849849b8f2e3b141b9fcb27dc098bf0128fabffb8d35faca9b01f6831aca92d0d585e6a69c639d09299f991907ac757d
6
+ metadata.gz: 292f817a4cc4498a4db69268def16be6ac719e5eee1178deb8cad7a26181aacb73ec5cbd9145fea1a0dc627a52f4bc7b9a3e61e5e6099946148239227b313e4d
7
+ data.tar.gz: bad4042ec546cb0c56e209a8c42b59a74a655a5bd8278c7f98baf5025f81d3457b566316fc4f7247d51e68d4add071d6207996e922449106ce3627357e1a2545
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.22.1.pre.2)
4
+ avo (1.22.3)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -230,8 +230,6 @@ GEM
230
230
  nokogiri (1.13.3)
231
231
  mini_portile2 (~> 2.8.0)
232
232
  racc (~> 1.4)
233
- nokogiri (1.13.3-x86_64-linux)
234
- racc (~> 1.4)
235
233
  orm_adapter (0.5.0)
236
234
  pagy (5.10.1)
237
235
  activesupport
@@ -1,4 +1,4 @@
1
- import { Application } from 'stimulus'
1
+ import { Application } from '@hotwired/stimulus'
2
2
 
3
3
  const application = Application.start()
4
4
 
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
  import { castBoolean } from '../helpers/cast_boolean'
3
3
 
4
4
  export default class extends Controller {
@@ -1,5 +1,5 @@
1
1
  import { AttributeObserver } from '@stimulus/mutation-observers'
2
- import { Controller } from 'stimulus'
2
+ import { Controller } from '@hotwired/stimulus'
3
3
 
4
4
  export default class extends Controller {
5
5
  static targets = ['resourceAction', 'standaloneAction']
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['container']
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['form']
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['select', 'type', 'loadAssociationLink'];
@@ -14,7 +14,7 @@ import 'codemirror/mode/vue/vue'
14
14
  import 'codemirror/mode/xml/xml'
15
15
  import 'codemirror/mode/yaml/yaml'
16
16
 
17
- import { Controller } from 'stimulus'
17
+ import { Controller } from '@hotwired/stimulus'
18
18
  import CodeMirror from 'codemirror'
19
19
 
20
20
  import { castBoolean } from '../../helpers/cast_boolean'
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
  import { DateTime } from 'luxon'
3
3
  import flatpickr from 'flatpickr'
4
4
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable max-len */
2
- import { Controller } from 'stimulus'
2
+ import { Controller } from '@hotwired/stimulus'
3
3
  import { castBoolean } from '../../helpers/cast_boolean'
4
4
 
5
5
  export default class extends Controller {
@@ -39,7 +39,7 @@ export default class extends Controller {
39
39
 
40
40
  deleteRow(event) {
41
41
  if (this.options.disable_deleting_rows || !this.options.editable) return
42
- const { index } = event.target.dataset
42
+ const { index } = event.params
43
43
  this.fieldValue.splice(index, 1)
44
44
  this.updateTextareaInput()
45
45
  this.updateKeyValueComponent()
@@ -93,7 +93,7 @@ export default class extends Controller {
93
93
  if (this.options.editable) {
94
94
  result += `<a
95
95
  href="javascript:void(0);"
96
- data-index="${index}"
96
+ data-key-value-index-param="${index}"
97
97
  data-action="click->key-value#deleteRow"
98
98
  title="${this.options.delete_text}"
99
99
  data-tippy="tooltip"
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
  import SimpleMDE from 'simplemde'
3
3
 
4
4
  export default class extends Controller {
@@ -1,5 +1,5 @@
1
1
  import 'trix'
2
- import { Controller } from 'stimulus'
2
+ import { Controller } from '@hotwired/stimulus'
3
3
  import { castBoolean } from '../../helpers/cast_boolean'
4
4
 
5
5
  export default class extends Controller {
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
  import URI from 'urijs'
3
3
 
4
4
  export default class extends Controller {
@@ -26,16 +26,12 @@ export default class extends Controller {
26
26
  // then we convert the percent encodings into raw bytes which
27
27
  // can be fed into btoa.
28
28
  return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
29
- function toSolidBytes(match, p1) {
30
- return String.fromCharCode('0x' + p1);
31
- }));
29
+ (match, p1) => String.fromCharCode(`0x${p1}`)))
32
30
  }
33
31
 
34
32
  b64DecodeUnicode(str) {
35
33
  // Going backwards: from bytestream, to percent-encoding, to original string.
36
- return decodeURIComponent(atob(str).split('').map(function(c) {
37
- return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
38
- }).join(''));
34
+ return decodeURIComponent(atob(str).split('').map((c) => `%${(`00${c.charCodeAt(0).toString(16)}`).slice(-2)}`).join(''))
39
35
  }
40
36
 
41
37
  changeFilter() {
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['content']
@@ -1,20 +1,20 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
- static targets = [ "itemCheckbox", "checkbox" ]
4
+ static targets = ['itemCheckbox', 'checkbox']
5
5
 
6
6
  connect() {
7
7
  this.resourceName = this.element.dataset.resourceName
8
8
  }
9
9
 
10
10
  toggle(event) {
11
- var value = !!event.target.checked
11
+ const value = !!event.target.checked
12
12
  document.querySelectorAll(`[data-controller="item-selector"][data-resource-name="${this.resourceName}"] input[type=checkbox]`)
13
13
  .forEach((checkbox) => checkbox.checked != value && checkbox.click())
14
14
  }
15
15
 
16
16
  update() {
17
- var allSelected = true
17
+ let allSelected = true
18
18
  this.itemCheckboxTargets.forEach((checkbox) => allSelected = allSelected && checkbox.checked)
19
19
  this.checkboxTarget.checked = allSelected
20
20
  }
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['panel'];
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  spinnerMarkup = `<div class="button-spinner">
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['modal']
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['selector']
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
2
  import * as Mousetrap from 'mousetrap'
3
- import { Controller } from 'stimulus'
3
+ import { Controller } from '@hotwired/stimulus'
4
4
  import { Turbo } from '@hotwired/turbo-rails'
5
5
  import { autocomplete } from '@algolia/autocomplete-js'
6
6
  import URI from 'urijs'
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
  import tippy from 'tippy.js'
3
3
 
4
4
  export default class extends Controller {
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
  import { useClickOutside } from 'stimulus-use'
3
3
 
4
4
  export default class extends Controller {
data/db/factories.rb CHANGED
@@ -42,11 +42,11 @@ FactoryBot.define do
42
42
  end
43
43
 
44
44
  factory :comment do
45
- body { Faker::Lorem.paragraphs(number: rand(4...10)) }
45
+ body { Faker::Lorem.paragraphs(number: rand(4...10)).join(' ') }
46
46
  end
47
47
 
48
48
  factory :review do
49
- body { Faker::Lorem.paragraphs(number: rand(4...10)) }
49
+ body { Faker::Lorem.paragraphs(number: rand(4...10)).join(' ') }
50
50
  end
51
51
 
52
52
  factory :person do
@@ -127,23 +127,29 @@ module Avo
127
127
  field.visible?
128
128
  end
129
129
  .select do |field|
130
+ is_valid = true
131
+
130
132
  # Strip out the reflection field in index queries with a parent association.
131
133
  if reflection.present?
132
- if reflection.options.present? &&
133
- field.respond_to?(:polymorphic_as) &&
134
- field.polymorphic_as.to_s == reflection.options[:as].to_s
135
- next
136
- end
137
-
138
- if field.respond_to?(:foreign_key) &&
139
- reflection.respond_to?(:foreign_key) &&
140
- reflection.foreign_key != field.foreign_key &&
141
- @params[:resource_name] == field.resource.model_key
142
- next
134
+ # regular non-polymorphic association
135
+ # we're matching the reflection inverse_of foriegn key with the field's foreign_key
136
+ if field.is_a?(Avo::Fields::BelongsToField)
137
+ if field.respond_to?(:foreign_key) &&
138
+ reflection.inverse_of.foreign_key == field.foreign_key
139
+ is_valid = false
140
+ end
141
+
142
+ # polymorphic association
143
+ if field.respond_to?(:foreign_key) &&
144
+ field.is_polymorphic? &&
145
+ reflection.respond_to?(:polymorphic?) &&
146
+ reflection.inverse_of.foreign_key == field.reflection.foreign_key
147
+ is_valid = false
148
+ end
143
149
  end
144
150
  end
145
151
 
146
- true
152
+ is_valid
147
153
  end
148
154
 
149
155
  if panel.present?
@@ -136,6 +136,8 @@ module Avo
136
136
 
137
137
  def is_polymorphic?
138
138
  polymorphic_as.present?
139
+ rescue
140
+ false
139
141
  end
140
142
 
141
143
  def foreign_key
@@ -154,6 +156,13 @@ module Avo
154
156
  nil
155
157
  end
156
158
 
159
+ # Get the model reflection instance
160
+ def reflection
161
+ reflection_for_key(id)
162
+ rescue
163
+ nil
164
+ end
165
+
157
166
  def relation_model_class
158
167
  @resource.model_class
159
168
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.22.1.pre.2"
2
+ VERSION = "1.22.3"
3
3
  end