avo 2.4.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/avo/edit/field_wrapper_component.html.erb +2 -2
- data/app/components/avo/edit/field_wrapper_component.rb +6 -1
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +3 -0
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +4 -0
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +26 -27
- data/app/components/avo/filters_component.html.erb +3 -3
- data/app/components/avo/filters_component.rb +2 -1
- data/app/components/avo/paginator_component.html.erb +3 -3
- data/app/components/avo/paginator_component.rb +3 -3
- data/app/components/avo/views/resource_index_component.html.erb +3 -3
- data/app/components/avo/views/resource_index_component.rb +10 -3
- data/app/controllers/avo/associations_controller.rb +6 -1
- data/app/controllers/avo/base_controller.rb +24 -1
- data/app/controllers/avo/search_controller.rb +22 -1
- data/app/helpers/avo/url_helpers.rb +3 -3
- data/app/javascript/js/controllers/filter_controller.js +9 -0
- data/app/javascript/js/controllers/search_controller.js +9 -2
- data/app/views/avo/base/_boolean_filter.html.erb +23 -15
- data/app/views/avo/base/_multiple_select_filter.html.erb +5 -1
- data/app/views/avo/base/_select_filter.html.erb +5 -1
- data/app/views/avo/base/_text_filter.html.erb +5 -1
- data/app/views/avo/base/index.html.erb +1 -0
- data/app/views/avo/partials/_sidebar_extra.html.erb +2 -0
- data/db/factories.rb +5 -3
- data/lib/avo/base_resource.rb +1 -0
- data/lib/avo/fields/belongs_to_field.rb +11 -1
- data/lib/avo/fields/has_base_field.rb +2 -0
- data/lib/avo/filters/base_filter.rb +18 -0
- data/lib/avo/hosts/association_scope_host.rb +8 -0
- data/lib/avo/services/authorization_service.rb +8 -10
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/eject_generator.rb +2 -3
- data/lib/generators/avo/templates/locales/avo.en.yml +2 -1
- data/lib/generators/avo/templates/locales/avo.nb-NO.yml +2 -1
- data/lib/generators/avo/templates/locales/avo.pt-BR.yml +2 -1
- data/lib/generators/avo/templates/locales/avo.ro.yml +2 -1
- data/public/avo-assets/avo.js +22 -22
- data/public/avo-assets/avo.js.map +2 -2
- 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
|
@@ -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
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
@@ -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
|
@@ -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:
|
84
|
+
no_cards_present: Niciun card disponibil
|
85
|
+
no_options_available: Nicio optiune disponibila
|