avo 0.5.0.beta9 → 0.5.0.beta10

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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +47 -48
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +14 -14
  5. data/app/components/avo/common/multiple_file_viewer_component.rb +1 -1
  6. data/app/components/avo/common/single_file_viewer_component.rb +1 -1
  7. data/app/components/avo/edit/field_wrapper_component.rb +3 -3
  8. data/app/components/avo/index/field_wrapper_component.rb +1 -1
  9. data/app/components/avo/index/grid_item_component.rb +10 -9
  10. data/app/components/avo/index/resource_controls_component.rb +2 -2
  11. data/app/components/avo/panel_component.rb +7 -6
  12. data/app/components/avo/resource_component.rb +4 -3
  13. data/app/components/avo/show/field_wrapper_component.rb +3 -3
  14. data/app/components/avo/views/resource_edit_component.rb +4 -3
  15. data/app/components/avo/views/resource_index_component.rb +8 -7
  16. data/app/components/avo/views/resource_new_component.rb +4 -3
  17. data/app/components/avo/views/resource_show_component.rb +21 -21
  18. data/app/controllers/avo/actions_controller.rb +30 -29
  19. data/app/controllers/avo/application_controller.rb +113 -126
  20. data/app/controllers/avo/attachments_controller.rb +3 -3
  21. data/app/controllers/avo/base_controller.rb +81 -80
  22. data/app/controllers/avo/home_controller.rb +2 -2
  23. data/app/controllers/avo/relations_controller.rb +29 -28
  24. data/app/controllers/avo/resources_controller.rb +1 -1
  25. data/app/controllers/avo/search_controller.rb +20 -19
  26. data/app/helpers/avo/application_helper.rb +48 -42
  27. data/app/helpers/avo/resources_helper.rb +11 -11
  28. data/app/mailers/avo/application_mailer.rb +2 -2
  29. data/app/packs/entrypoints/application.js +9 -7
  30. data/app/packs/js/controllers/fields/code_field_controller.js +14 -14
  31. data/app/packs/js/controllers/filter_controller.js +9 -8
  32. data/app/packs/js/toastr.js +1 -0
  33. data/avo.gemspec +31 -31
  34. data/config/initializers/inline_svg.rb +1 -1
  35. data/config/initializers/pagy.rb +1 -1
  36. data/config/routes.rb +12 -12
  37. data/config/spring.rb +5 -5
  38. data/db/factories.rb +3 -5
  39. data/lib/avo.rb +6 -6
  40. data/lib/avo/app.rb +18 -18
  41. data/lib/avo/base_action.rb +20 -20
  42. data/lib/avo/base_resource.rb +41 -45
  43. data/lib/avo/configuration.rb +16 -18
  44. data/lib/avo/engine.rb +18 -18
  45. data/lib/avo/fields/badge_field.rb +2 -2
  46. data/lib/avo/fields/base_field.rb +24 -25
  47. data/lib/avo/fields/belongs_to_field.rb +13 -12
  48. data/lib/avo/fields/boolean_field.rb +4 -4
  49. data/lib/avo/fields/boolean_group_field.rb +3 -3
  50. data/lib/avo/fields/code_field.rb +4 -4
  51. data/lib/avo/fields/country_field.rb +2 -2
  52. data/lib/avo/fields/currency_field.rb +3 -3
  53. data/lib/avo/fields/date_field.rb +3 -3
  54. data/lib/avo/fields/date_time_field.rb +2 -2
  55. data/lib/avo/fields/external_image_field.rb +2 -2
  56. data/lib/avo/fields/field_extensions/has_field_name.rb +2 -2
  57. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +34 -33
  58. data/lib/avo/fields/file_field.rb +1 -1
  59. data/lib/avo/fields/files_field.rb +2 -2
  60. data/lib/avo/fields/gravatar_field.rb +9 -9
  61. data/lib/avo/fields/has_and_belongs_to_many_field.rb +1 -1
  62. data/lib/avo/fields/has_many_field.rb +1 -1
  63. data/lib/avo/fields/has_one_field.rb +2 -2
  64. data/lib/avo/fields/heading_field.rb +2 -2
  65. data/lib/avo/fields/hidden_field.rb +1 -1
  66. data/lib/avo/fields/id_field.rb +3 -3
  67. data/lib/avo/fields/key_value_field.rb +12 -12
  68. data/lib/avo/fields/markdown_field.rb +2 -2
  69. data/lib/avo/fields/number_field.rb +3 -3
  70. data/lib/avo/fields/password_field.rb +1 -1
  71. data/lib/avo/fields/select_field.rb +8 -12
  72. data/lib/avo/fields/status_field.rb +4 -4
  73. data/lib/avo/fields/text_field.rb +2 -2
  74. data/lib/avo/fields/textarea_field.rb +2 -2
  75. data/lib/avo/fields/trix_field.rb +1 -1
  76. data/lib/avo/fields_collector.rb +4 -5
  77. data/lib/avo/filters/base_filter.rb +6 -6
  78. data/lib/avo/filters/boolean_filter.rb +1 -1
  79. data/lib/avo/filters/select_filter.rb +1 -1
  80. data/lib/avo/licensing/h_q.rb +56 -55
  81. data/lib/avo/licensing/license.rb +5 -5
  82. data/lib/avo/licensing/license_manager.rb +4 -4
  83. data/lib/avo/licensing/null_license.rb +2 -2
  84. data/lib/avo/licensing/pro_license.rb +1 -1
  85. data/lib/avo/loaders/fields_loader.rb +4 -4
  86. data/lib/avo/services/authorization_service.rb +2 -2
  87. data/lib/avo/services/panel_service.rb +4 -4
  88. data/lib/avo/version.rb +1 -1
  89. data/lib/generators/avo/action_generator.rb +4 -4
  90. data/lib/generators/avo/controller_generator.rb +4 -4
  91. data/lib/generators/avo/filter_generator.rb +5 -5
  92. data/lib/generators/avo/install_generator.rb +8 -8
  93. data/lib/generators/avo/locales_generator.rb +5 -5
  94. data/lib/generators/avo/partials_generator.rb +4 -4
  95. data/lib/generators/avo/resource_generator.rb +5 -5
  96. data/lib/tasks/avo_tasks.rake +52 -53
  97. data/public/avo-packs/css/{application-38e7e91b.css → application-4e16d6a6.css} +4 -4
  98. data/public/avo-packs/css/application-4e16d6a6.css.br +0 -0
  99. data/public/avo-packs/css/{application-38e7e91b.css.gz → application-4e16d6a6.css.gz} +0 -0
  100. data/public/avo-packs/css/{application-38e7e91b.css.map → application-4e16d6a6.css.map} +1 -1
  101. data/public/avo-packs/css/application-4e16d6a6.css.map.br +0 -0
  102. data/public/avo-packs/css/application-4e16d6a6.css.map.gz +0 -0
  103. data/public/avo-packs/js/{application-2b90fe889f7d6df1ad92.js → application-8eb130a4688f2c667703.js} +4 -4
  104. data/public/avo-packs/js/{application-2b90fe889f7d6df1ad92.js.LICENSE.txt → application-8eb130a4688f2c667703.js.LICENSE.txt} +0 -0
  105. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.br +0 -0
  106. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.gz +0 -0
  107. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map +1 -0
  108. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.br +0 -0
  109. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.gz +0 -0
  110. data/public/avo-packs/manifest.json +15 -15
  111. metadata +15 -15
  112. data/public/avo-packs/css/application-38e7e91b.css.br +0 -0
  113. data/public/avo-packs/css/application-38e7e91b.css.map.br +0 -0
  114. data/public/avo-packs/css/application-38e7e91b.css.map.gz +0 -0
  115. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.br +0 -0
  116. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.gz +0 -0
  117. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map +0 -1
  118. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.br +0 -0
  119. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.gz +0 -0
@@ -3,13 +3,13 @@ module Avo
3
3
  class BelongsToField < BaseField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
- partial_name: 'belongs-to-field',
7
- placeholder: I18n.t('avo.choose_an_option')
6
+ partial_name: "belongs-to-field",
7
+ placeholder: I18n.t("avo.choose_an_option")
8
8
  }
9
9
 
10
10
  super(name, **args, &block)
11
11
 
12
- @meta[:searchable] = args[:searchable] == true ? true : false
12
+ @meta[:searchable] = args[:searchable] == true
13
13
  @meta[:relation_method] = name.to_s.parameterize.underscore
14
14
  end
15
15
 
@@ -28,7 +28,7 @@ module Avo
28
28
 
29
29
  def foreign_key
30
30
  if @model.present?
31
- if @model.class == Class
31
+ if @model.instance_of?(Class)
32
32
  @model.reflections[@meta[:relation_method]].foreign_key
33
33
  else
34
34
  @model.class.reflections[@meta[:relation_method]].foreign_key
@@ -51,15 +51,16 @@ module Avo
51
51
  end
52
52
 
53
53
  private
54
- def target_resource
55
- if @model._reflections[id.to_s].klass.present?
56
- App.get_resource_by_model_name @model._reflections[id.to_s].klass.to_s
57
- elsif @model._reflections[id.to_s].options[:class_name].present?
58
- App.get_resource_by_model_name @model._reflections[id.to_s].options[:class_name]
59
- else
60
- App.get_resource_by_name id.to_s
61
- end
54
+
55
+ def target_resource
56
+ if @model._reflections[id.to_s].klass.present?
57
+ App.get_resource_by_model_name @model._reflections[id.to_s].klass.to_s
58
+ elsif @model._reflections[id.to_s].options[:class_name].present?
59
+ App.get_resource_by_model_name @model._reflections[id.to_s].options[:class_name]
60
+ else
61
+ App.get_resource_by_name id.to_s
62
62
  end
63
+ end
63
64
  end
64
65
  end
65
66
  end
@@ -6,8 +6,8 @@ module Avo
6
6
 
7
7
  def initialize(name, **args, &block)
8
8
  @defaults = {
9
- partial_name: 'boolean-field',
10
- computable: true,
9
+ partial_name: "boolean-field",
10
+ computable: true
11
11
  }
12
12
 
13
13
  super(name, **args, &block)
@@ -25,11 +25,11 @@ module Avo
25
25
  end
26
26
 
27
27
  def truthy_values
28
- ['true', '1', @true_value]
28
+ ["true", "1", @true_value]
29
29
  end
30
30
 
31
31
  def falsy_values
32
- ['false', '0', @false_value]
32
+ ["false", "0", @false_value]
33
33
  end
34
34
  end
35
35
  end
@@ -5,8 +5,8 @@ module Avo
5
5
 
6
6
  def initialize(name, **args, &block)
7
7
  @defaults = {
8
- partial_name: 'boolean-group-field',
9
- computable: true,
8
+ partial_name: "boolean-group-field",
9
+ computable: true
10
10
  }
11
11
 
12
12
  super(name, **args, &block)
@@ -15,7 +15,7 @@ module Avo
15
15
  end
16
16
 
17
17
  def to_permitted_param
18
- ["#{id}": [] ]
18
+ ["#{id}": []]
19
19
  end
20
20
 
21
21
  def fill_field(model, key, value)
@@ -10,16 +10,16 @@ module Avo
10
10
 
11
11
  def initialize(name, **args, &block)
12
12
  @defaults = {
13
- partial_name: 'code-field',
13
+ partial_name: "code-field"
14
14
  }
15
15
 
16
16
  hide_on :index
17
17
 
18
18
  super(name, **args, &block)
19
19
 
20
- @language = args[:language].present? ? args[:language].to_s : 'javascript'
21
- @theme = args[:theme].present? ? args[:theme].to_s : 'material-darker'
22
- @height = args[:height].present? ? args[:height].to_s : 'auto'
20
+ @language = args[:language].present? ? args[:language].to_s : "javascript"
21
+ @theme = args[:theme].present? ? args[:theme].to_s : "material-darker"
22
+ @height = args[:height].present? ? args[:height].to_s : "auto"
23
23
  @tab_size = args[:tab_size].present? ? args[:tab_size] : 2
24
24
  @indent_with_tabs = args[:indent_with_tabs].present? ? args[:indent_with_tabs] : false
25
25
  @line_wrapping = args[:line_wrapping].present? ? args[:line_wrapping] : true
@@ -6,8 +6,8 @@ module Avo
6
6
 
7
7
  def initialize(name, **args, &block)
8
8
  @defaults = {
9
- partial_name: 'country-field',
10
- placeholder: I18n.t('avo.choose_a_country'),
9
+ partial_name: "country-field",
10
+ placeholder: I18n.t("avo.choose_a_country")
11
11
  }
12
12
 
13
13
  super(name, **args, &block)
@@ -3,8 +3,8 @@ module Avo
3
3
  class CurrencyField < BaseField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
- partial_name: 'currency-field',
7
- computable: true,
6
+ partial_name: "currency-field",
7
+ computable: true
8
8
  }
9
9
 
10
10
  super(name, **args, &block)
@@ -16,7 +16,7 @@ module Avo
16
16
  def hydrate_field(fields, model, resource, view)
17
17
  {
18
18
  currency: @currency,
19
- locale: @locale,
19
+ locale: @locale
20
20
  }
21
21
  end
22
22
  end
@@ -9,15 +9,15 @@ module Avo
9
9
 
10
10
  def initialize(name, **args, &block)
11
11
  @defaults = {
12
- partial_name: 'date-field',
12
+ partial_name: "date-field"
13
13
  }
14
14
 
15
15
  super(name, **args, &block)
16
16
 
17
17
  @first_day_of_week = args[:first_day_of_week].present? ? args[:first_day_of_week].to_i : 0
18
- @picker_format = args[:picker_format].present? ? args[:picker_format] : 'Y-m-d'
18
+ @picker_format = args[:picker_format].present? ? args[:picker_format] : "Y-m-d"
19
19
  @format = args[:format].present? ? args[:format] : :long
20
- @placeholder = args[:placeholder].present? ? args[:placeholder] : ''
20
+ @placeholder = args[:placeholder].present? ? args[:placeholder] : ""
21
21
  @relative = args[:relative].present? ? args[:relative] : false
22
22
  end
23
23
 
@@ -8,8 +8,8 @@ module Avo
8
8
  def initialize(name, **args, &block)
9
9
  super(name, **args, &block)
10
10
 
11
- @partial_name = 'date-time-field'
12
- @picker_format = args[:picker_format].present? ? args[:picker_format] : 'Y-m-d H:i:S'
11
+ @partial_name = "date-time-field"
12
+ @picker_format = args[:picker_format].present? ? args[:picker_format] : "Y-m-d H:i:S"
13
13
  @time_24hr = args[:time_24hr].present? ? args[:time_24hr] : false
14
14
  @timezone = args[:timezone].present? ? args[:timezone] : Rails.application.config.time_zone
15
15
  end
@@ -7,8 +7,8 @@ module Avo
7
7
 
8
8
  def initialize(name, **args, &block)
9
9
  @defaults = {
10
- partial_name: 'external-image-field',
11
- computable: true,
10
+ partial_name: "external-image-field",
11
+ computable: true
12
12
  }.merge(@defaults || {})
13
13
 
14
14
  super(name, **args, &block)
@@ -9,9 +9,9 @@ module Avo
9
9
 
10
10
  # Get the field name
11
11
  def get_field_name
12
- return self.field_name_attribute if self.field_name_attribute.present?
12
+ return field_name_attribute if field_name_attribute.present?
13
13
 
14
- self.to_s.demodulize.underscore.gsub '_field', ''
14
+ to_s.demodulize.underscore.gsub "_field", ""
15
15
  end
16
16
  end
17
17
  end
@@ -45,48 +45,49 @@ module Avo
45
45
  end
46
46
 
47
47
  private
48
- def show_on_view(view)
49
- self.send("show_on_#{view.to_s}=", true)
50
- end
51
48
 
52
- def hide_on_view(view)
53
- self.send("show_on_#{view.to_s}=", false)
54
- end
49
+ def show_on_view(view)
50
+ send("show_on_#{view}=", true)
51
+ end
55
52
 
56
- def only_on_view(view)
57
- hide_on_all
58
- show_on_view view
59
- end
53
+ def hide_on_view(view)
54
+ send("show_on_#{view}=", false)
55
+ end
60
56
 
61
- def except_on_view(view)
62
- show_on_all
63
- hide_on_view view
64
- end
57
+ def only_on_view(view)
58
+ hide_on_all
59
+ show_on_view view
60
+ end
65
61
 
66
- def show_on_all
67
- @show_on_index = true
68
- @show_on_show = true
69
- @show_on_edit = true
70
- @show_on_new = true
71
- end
62
+ def except_on_view(view)
63
+ show_on_all
64
+ hide_on_view view
65
+ end
72
66
 
73
- def hide_on_all
74
- @show_on_index = false
75
- @show_on_show = false
76
- @show_on_edit = false
77
- @show_on_new = false
78
- end
67
+ def show_on_all
68
+ @show_on_index = true
69
+ @show_on_show = true
70
+ @show_on_edit = true
71
+ @show_on_new = true
72
+ end
79
73
 
80
- def normalize_views(*views_and_groups)
81
- forms = views_and_groups.flatten! & [:forms]
74
+ def hide_on_all
75
+ @show_on_index = false
76
+ @show_on_show = false
77
+ @show_on_edit = false
78
+ @show_on_new = false
79
+ end
82
80
 
83
- if forms.present?
84
- views_and_groups = views_and_groups - forms
85
- views_and_groups = views_and_groups + [:new, :edit]
86
- end
81
+ def normalize_views(*views_and_groups)
82
+ forms = views_and_groups.flatten! & [:forms]
87
83
 
88
- views_and_groups.flatten.uniq
84
+ if forms.present?
85
+ views_and_groups -= forms
86
+ views_and_groups += [:new, :edit]
89
87
  end
88
+
89
+ views_and_groups.flatten.uniq
90
+ end
90
91
  end
91
92
  end
92
93
  end
@@ -6,7 +6,7 @@ module Avo
6
6
 
7
7
  def initialize(name, **args, &block)
8
8
  @defaults = {
9
- partial_name: 'file-field',
9
+ partial_name: "file-field"
10
10
  }.merge(@defaults || {})
11
11
 
12
12
  super(name, **args, &block)
@@ -5,7 +5,7 @@ module Avo
5
5
 
6
6
  def initialize(name, **args, &block)
7
7
  @defaults = {
8
- partial_name: 'files-field',
8
+ partial_name: "files-field"
9
9
  }.merge(@defaults || {})
10
10
 
11
11
  super(name, **args, &block)
@@ -16,7 +16,7 @@ module Avo
16
16
  end
17
17
 
18
18
  def to_permitted_param
19
- { "#{id}": [] }
19
+ {"#{id}": []}
20
20
  end
21
21
 
22
22
  def fill_field(model, key, value)
@@ -1,5 +1,5 @@
1
- require 'digest'
2
- require 'erb'
1
+ require "digest"
2
+ require "erb"
3
3
 
4
4
  module Avo
5
5
  module Fields
@@ -10,9 +10,9 @@ module Avo
10
10
 
11
11
  def initialize(name, **args, &block)
12
12
  @defaults = {
13
- partial_name: 'gravatar-field',
14
- name: 'Avatar',
15
- id: args[:id].present? ? args[:id] : 'email',
13
+ partial_name: "gravatar-field",
14
+ name: "Avatar",
15
+ id: args[:id].present? ? args[:id] : "email"
16
16
  }
17
17
 
18
18
  super(name, **args, &block)
@@ -21,7 +21,7 @@ module Avo
21
21
 
22
22
  @rounded = args[:rounded].present? ? args[:rounded] : true
23
23
  @size = args[:size].present? ? args[:size].to_i : 40
24
- @default = args[:default].present? ? ERB::Util.url_encode(args[:default]).to_s : ''
24
+ @default = args[:default].present? ? ERB::Util.url_encode(args[:default]).to_s : ""
25
25
  @link_to_resource = args[:link_to_resource].present? ? args[:link_to_resource] : false
26
26
  end
27
27
 
@@ -33,11 +33,11 @@ module Avo
33
33
 
34
34
  def to_image
35
35
  options = {
36
- default: '',
37
- size: 340,
36
+ default: "",
37
+ size: 340
38
38
  }
39
39
 
40
- query = options.map { |key, value| "#{key}=#{value}" }.join('&')
40
+ query = options.map { |key, value| "#{key}=#{value}" }.join("&")
41
41
 
42
42
  URI::HTTPS.build(host: "www.gravatar.com", path: "/avatar/#{md5}", query: query).to_s
43
43
  end
@@ -4,7 +4,7 @@ module Avo
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
6
  updatable: false,
7
- partial_name: 'has-many-field'
7
+ partial_name: "has-many-field"
8
8
  }
9
9
 
10
10
  super(name, **args, &block)
@@ -4,7 +4,7 @@ module Avo
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
6
  updatable: false,
7
- partial_name: 'has-many-field'
7
+ partial_name: "has-many-field"
8
8
  }
9
9
  @through = args[:through]
10
10
 
@@ -7,14 +7,14 @@ module Avo
7
7
  def initialize(name, **args, &block)
8
8
  @defaults = {
9
9
  updatable: true,
10
- partial_name: 'has-one-field',
10
+ partial_name: "has-one-field"
11
11
  }
12
12
 
13
13
  super(name, **args, &block)
14
14
 
15
15
  hide_on :new, :edit
16
16
 
17
- @placeholder = I18n.t 'avo.choose_an_option'
17
+ @placeholder = I18n.t "avo.choose_an_option"
18
18
 
19
19
  @relation_method = name.to_s.parameterize.underscore
20
20
  @display = args[:display].present? ? args[:display] : :show
@@ -4,8 +4,8 @@ module Avo
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
6
  updatable: false,
7
- partial_name: 'heading-field',
8
- id: 'heading_' + name.to_s.parameterize.underscore,
7
+ partial_name: "heading-field",
8
+ id: "heading_" + name.to_s.parameterize.underscore
9
9
  }
10
10
 
11
11
  super(name, **args, &block)
@@ -3,7 +3,7 @@ module Avo
3
3
  class HiddenField < TextField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
- partial_name: 'hidden-field',
6
+ partial_name: "hidden-field"
7
7
  }
8
8
 
9
9
  super(name, **args, &block)
@@ -2,11 +2,11 @@ module Avo
2
2
  module Fields
3
3
  class IdField < BaseField
4
4
  def initialize(name, **args, &block)
5
- default_value = 'id'
5
+ default_value = "id"
6
6
 
7
7
  if name.nil?
8
8
  @name = name = default_value
9
- elsif !name.is_a? String and !name.is_a? Symbol
9
+ elsif !name.is_a?(String) && !name.is_a?(Symbol)
10
10
  args_copy = name
11
11
  @name = name = default_value
12
12
  args = args_copy
@@ -16,7 +16,7 @@ module Avo
16
16
  id: name.to_sym,
17
17
  readonly: true,
18
18
  sortable: true,
19
- partial_name: 'id-field'
19
+ partial_name: "id-field"
20
20
  }
21
21
 
22
22
  hide_on [:edit, :new]