avo 2.4.1 → 2.5.0

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/components/avo/edit/field_wrapper_component.html.erb +2 -2
  4. data/app/components/avo/edit/field_wrapper_component.rb +6 -1
  5. data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +3 -0
  6. data/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +4 -0
  7. data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +26 -27
  8. data/app/components/avo/filters_component.html.erb +3 -3
  9. data/app/components/avo/filters_component.rb +2 -1
  10. data/app/components/avo/paginator_component.html.erb +3 -3
  11. data/app/components/avo/paginator_component.rb +3 -3
  12. data/app/components/avo/views/resource_index_component.html.erb +3 -3
  13. data/app/components/avo/views/resource_index_component.rb +10 -3
  14. data/app/controllers/avo/associations_controller.rb +6 -1
  15. data/app/controllers/avo/base_controller.rb +24 -1
  16. data/app/controllers/avo/search_controller.rb +22 -1
  17. data/app/helpers/avo/url_helpers.rb +3 -3
  18. data/app/javascript/js/controllers/filter_controller.js +9 -0
  19. data/app/javascript/js/controllers/search_controller.js +9 -2
  20. data/app/views/avo/base/_boolean_filter.html.erb +23 -15
  21. data/app/views/avo/base/_multiple_select_filter.html.erb +5 -1
  22. data/app/views/avo/base/_select_filter.html.erb +5 -1
  23. data/app/views/avo/base/_text_filter.html.erb +5 -1
  24. data/app/views/avo/base/index.html.erb +1 -0
  25. data/app/views/avo/partials/_sidebar_extra.html.erb +2 -0
  26. data/db/factories.rb +5 -3
  27. data/lib/avo/base_resource.rb +1 -0
  28. data/lib/avo/fields/belongs_to_field.rb +11 -1
  29. data/lib/avo/fields/has_base_field.rb +2 -0
  30. data/lib/avo/filters/base_filter.rb +18 -0
  31. data/lib/avo/hosts/association_scope_host.rb +8 -0
  32. data/lib/avo/services/authorization_service.rb +8 -10
  33. data/lib/avo/version.rb +1 -1
  34. data/lib/generators/avo/eject_generator.rb +2 -3
  35. data/lib/generators/avo/templates/locales/avo.en.yml +2 -1
  36. data/lib/generators/avo/templates/locales/avo.nb-NO.yml +2 -1
  37. data/lib/generators/avo/templates/locales/avo.pt-BR.yml +2 -1
  38. data/lib/generators/avo/templates/locales/avo.ro.yml +2 -1
  39. data/public/avo-assets/avo.js +22 -22
  40. data/public/avo-assets/avo.js.map +2 -2
  41. metadata +3 -2
@@ -3,6 +3,7 @@ module Avo
3
3
  class HasBaseField < BaseField
4
4
  attr_accessor :display
5
5
  attr_accessor :scope
6
+ attr_accessor :description
6
7
 
7
8
  def initialize(id, **args, &block)
8
9
  super(id, **args, &block)
@@ -10,6 +11,7 @@ module Avo
10
11
  @scope = args[:scope].present? ? args[:scope] : nil
11
12
  @display = args[:display].present? ? args[:display] : :show
12
13
  @searchable = args[:searchable] == true
14
+ @description = args[:description]
13
15
  end
14
16
 
15
17
  def searchable
@@ -1,10 +1,23 @@
1
1
  module Avo
2
2
  module Filters
3
3
  class BaseFilter
4
+ PARAM_KEY = :filters unless const_defined?(:PARAM_KEY)
5
+
4
6
  class_attribute :name, default: "Filter"
5
7
  class_attribute :component, default: "boolean-filter"
6
8
  class_attribute :default, default: nil
7
9
  class_attribute :template, default: "avo/base/select_filter"
10
+ class_attribute :empty_message, default: I18n.t("avo.no_options_available")
11
+
12
+ delegate :params, to: Avo::App
13
+
14
+ class << self
15
+ def decode_filters(filter_params)
16
+ JSON.parse(Base64.decode64(filter_params))
17
+ rescue
18
+ {}
19
+ end
20
+ end
8
21
 
9
22
  def apply_query(request, query, value)
10
23
  value.stringify_keys! if value.is_a? Hash
@@ -30,6 +43,11 @@ module Avo
30
43
  rescue
31
44
  default
32
45
  end
46
+
47
+ # Fetch the applied filters from the params
48
+ def applied_filters
49
+ self.class.decode_filters params[PARAM_KEY]
50
+ end
33
51
  end
34
52
  end
35
53
  end
@@ -0,0 +1,8 @@
1
+ module Avo
2
+ module Hosts
3
+ class AssociationScopeHost < BaseHost
4
+ option :parent
5
+ option :query
6
+ end
7
+ end
8
+ end
@@ -71,13 +71,13 @@ module Avo
71
71
  # If no action passed we should raise error if the user wants that.
72
72
  # If not, just allow it.
73
73
  if action.nil?
74
- raise Pundit::NotDefinedError.new 'Policy method is missing' if Avo.configuration.raise_error_on_missing_policy
74
+ raise Pundit::NotDefinedError.new "Policy method is missing" if Avo.configuration.raise_error_on_missing_policy
75
75
 
76
76
  return true
77
77
  end
78
78
 
79
79
  # Add the question mark if it's missing
80
- action = "#{action}?" unless action.end_with? '?'
80
+ action = "#{action}?" unless action.end_with? "?"
81
81
 
82
82
  authorize user, record, action, **args
83
83
  end
@@ -110,14 +110,12 @@ module Avo
110
110
  end
111
111
 
112
112
  def defined_methods(user, record, **args)
113
- begin
114
- Pundit.policy!(user, record).methods
115
- rescue => error
116
- if args[:raise_exception] == false
117
- []
118
- else
119
- raise error
120
- end
113
+ Pundit.policy!(user, record).methods
114
+ rescue => error
115
+ if args[:raise_exception] == false
116
+ []
117
+ else
118
+ raise error
121
119
  end
122
120
  end
123
121
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.4.1" unless const_defined?(:VERSION)
2
+ VERSION = "2.5.0" unless const_defined?(:VERSION)
3
3
  end
@@ -11,13 +11,12 @@ module Generators
11
11
  namespace "avo:eject"
12
12
 
13
13
  TEMPLATES = {
14
- sidebar: "app/views/avo/sidebar/_sidebar.html.erb",
15
14
  logo: "app/views/avo/partials/_logo.html.erb",
16
15
  head: "app/views/avo/partials/_head.html.erb",
17
16
  header: "app/views/avo/partials/_header.html.erb",
18
- profile_dropdown: "app/views/avo/partials/_profile_dropdown.html.erb",
19
17
  footer: "app/views/avo/partials/_footer.html.erb",
20
- scripts: "app/views/avo/partials/_scripts.html.erb"
18
+ scripts: "app/views/avo/partials/_scripts.html.erb",
19
+ sidebar_extra: "app/views/avo/partials/_sidebar_extra.html.erb",
21
20
  }
22
21
 
23
22
  def handle
@@ -107,4 +107,5 @@ en:
107
107
  to_top: Move record to top
108
108
  to_bottom: Move record to bottom
109
109
  empty_dashboard_message: Add cards to this dashboard
110
- no_cards_present: 'No cards present'
110
+ no_cards_present: No cards present
111
+ no_options_available: No options available
@@ -83,5 +83,6 @@ nb-NO:
83
83
  sign_out: 'Logg ut'
84
84
  tools: Redskapene
85
85
  empty_dashboard_message: Legg til kort i dette dashbordet
86
- no_cards_present: 'Ingen kort til stede'
86
+ no_cards_present: Ingen kort til stede
87
+ no_options_available: Ingen tilgjengelige alternativer
87
88
 
@@ -85,4 +85,5 @@ pt-BR:
85
85
  sign_out: 'sair'
86
86
  tools: Ferramentas
87
87
  empty_dashboard_message: Adicionar cartões a este painel
88
- no_cards_present: 'Nenhum cartão presente'
88
+ no_cards_present: Nenhum cartão presente
89
+ no_options_available: Nenhuma opção disponível
@@ -81,4 +81,5 @@ ro:
81
81
  was_successfully_updated: 'a fost actualizat'
82
82
  tools: Instrumente
83
83
  empty_dashboard_message: Adauga carduri in acest dashboard
84
- no_cards_present: 'Niciun card disponibil'
84
+ no_cards_present: Niciun card disponibil
85
+ no_options_available: Nicio optiune disponibila