avo 1.16.2 → 1.17.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/avo/actions_controller.rb +3 -1
- data/app/packs/js/controllers/filter_controller.js +19 -2
- data/app/views/avo/partials/_profile_dropdown.html.erb +1 -1
- data/app/views/avo/sidebar/_sidebar.html.erb +2 -2
- data/lib/avo/base_action.rb +4 -2
- data/lib/avo/base_resource.rb +20 -5
- data/lib/avo/fields/base_field.rb +19 -5
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/action.tt +3 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +1 -0
- data/lib/generators/avo/templates/locales/avo.nb-NO.yml +1 -0
- data/lib/generators/avo/templates/locales/avo.pt-BR.yml +1 -0
- data/lib/generators/avo/templates/locales/avo.ro.yml +1 -0
- data/public/avo-packs/css/application-2b4685ca.css.map +1 -1
- data/public/avo-packs/css/application-2b4685ca.css.map.br +0 -0
- data/public/avo-packs/css/application-2b4685ca.css.map.gz +0 -0
- data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js +26 -0
- data/public/avo-packs/js/{application-124d087ff9491dbf3511.js.LICENSE.txt → application-1f1c66b45a54b2d06bfe.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.br +0 -0
- data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.gz +0 -0
- data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.map +1 -0
- data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.map.br +0 -0
- data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +8 -8
- metadata +9 -9
- data/public/avo-packs/js/application-124d087ff9491dbf3511.js +0 -26
- data/public/avo-packs/js/application-124d087ff9491dbf3511.js.br +0 -0
- data/public/avo-packs/js/application-124d087ff9491dbf3511.js.gz +0 -0
- data/public/avo-packs/js/application-124d087ff9491dbf3511.js.map +0 -1
- data/public/avo-packs/js/application-124d087ff9491dbf3511.js.map.br +0 -0
- data/public/avo-packs/js/application-124d087ff9491dbf3511.js.map.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f979b13adfa02e58a8d2b3b4f6463d0fcef9200cdc4a4dee76b268ebc5a5e8b0
|
4
|
+
data.tar.gz: acdddcbb5516ffd36f1538877472f4f8a4ec5f2423a4ddea69b7eed5b156c308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '050786326a44c661a9c3467cf9f5b3ed5df27a8b713040a9126be15f96b3fcf553b8cd7c7f23fe01339665eac1f41d2a203fca4c3c671676c28b9c6efaf18cb9'
|
7
|
+
data.tar.gz: 417a94817cdad9255904bbff41dc5aa911b2dfa02c31ac2f1d2deb46c6038e7a563d802ad0d2b4533e6001e06d455b2fd9cf48a47c2556539e143f48b95ff6ee
|
data/Gemfile.lock
CHANGED
@@ -21,6 +21,23 @@ export default class extends Controller {
|
|
21
21
|
return param
|
22
22
|
}
|
23
23
|
|
24
|
+
b64EncodeUnicode(str) {
|
25
|
+
// first we use encodeURIComponent to get percent-encoded UTF-8,
|
26
|
+
// then we convert the percent encodings into raw bytes which
|
27
|
+
// can be fed into btoa.
|
28
|
+
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
29
|
+
function toSolidBytes(match, p1) {
|
30
|
+
return String.fromCharCode('0x' + p1);
|
31
|
+
}));
|
32
|
+
}
|
33
|
+
|
34
|
+
b64DecodeUnicode(str) {
|
35
|
+
// 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(''));
|
39
|
+
}
|
40
|
+
|
24
41
|
changeFilter() {
|
25
42
|
const value = this.getFilterValue()
|
26
43
|
const filterClass = this.getFilterClass()
|
@@ -28,7 +45,7 @@ export default class extends Controller {
|
|
28
45
|
let filters = this.uriParams()[this.uriParam('filters')]
|
29
46
|
|
30
47
|
if (filters) {
|
31
|
-
filters = JSON.parse(
|
48
|
+
filters = JSON.parse(this.b64DecodeUnicode(filters))
|
32
49
|
} else {
|
33
50
|
filters = {}
|
34
51
|
}
|
@@ -46,7 +63,7 @@ export default class extends Controller {
|
|
46
63
|
let encodedFilters
|
47
64
|
|
48
65
|
if (filtered && Object.keys(filtered).length > 0) {
|
49
|
-
encodedFilters =
|
66
|
+
encodedFilters = this.b64EncodeUnicode(JSON.stringify(filtered))
|
50
67
|
}
|
51
68
|
|
52
69
|
const url = new URI(this.urlRedirectTarget.href)
|
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
<% if main_app.respond_to?(:destroy_user_session_path) %>
|
19
19
|
<div class="hidden absolute inset-auto inset-auto right-0 mr-6 mt-0 py-4 bg-white rounded-xl min-w-[200px] shadow-context" data-toggle-panel-target="panel">
|
20
|
-
<%= button_to
|
20
|
+
<%= button_to t('avo.sign_out'), main_app.destroy_user_session_path, method: :delete, form: { "data-turbo" => "false" }, class: "appearance-none bg-white text-left cursor-pointer text-green-600 font-semibold hover:text-white hover:bg-green-500 block px-4 py-1 w-full" %>
|
21
21
|
</div>
|
22
22
|
<% end %>
|
23
23
|
</div>
|
@@ -11,8 +11,8 @@
|
|
11
11
|
<%= render Avo::NavigationHeadingComponent.new label: t('avo.resources') %>
|
12
12
|
|
13
13
|
<div class="w-full">
|
14
|
-
<% Avo::App.resources_navigation(_current_user).each do |resource| %>
|
15
|
-
<%= render Avo::NavigationLinkComponent.new label: resource.
|
14
|
+
<% Avo::App.resources_navigation(_current_user).sort_by { |r| r.navigation_label }.each do |resource| %>
|
15
|
+
<%= render Avo::NavigationLinkComponent.new label: resource.navigation_label, path: resources_path(resource.model_class) %>
|
16
16
|
<% end %>
|
17
17
|
|
18
18
|
<% sidebar_partials = Avo::App.get_sidebar_partials %>
|
data/lib/avo/base_action.rb
CHANGED
@@ -70,7 +70,7 @@ module Avo
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def handle_action(**args)
|
73
|
-
models, fields = args.values_at(:models, :fields)
|
73
|
+
models, fields, current_user, resource = args.values_at(:models, :fields, :current_user, :resource)
|
74
74
|
avo_fields = get_fields.map { |field| [field.id, field] }.to_h
|
75
75
|
|
76
76
|
if fields.present?
|
@@ -84,7 +84,9 @@ module Avo
|
|
84
84
|
end
|
85
85
|
|
86
86
|
args = {
|
87
|
-
fields: processed_fields
|
87
|
+
fields: processed_fields,
|
88
|
+
current_user: current_user,
|
89
|
+
resource: resource,
|
88
90
|
}
|
89
91
|
|
90
92
|
args[:models] = models unless standalone
|
data/lib/avo/base_resource.rb
CHANGED
@@ -16,6 +16,7 @@ module Avo
|
|
16
16
|
class_attribute :includes, default: []
|
17
17
|
class_attribute :model_class
|
18
18
|
class_attribute :translation_key
|
19
|
+
class_attribute :translation_enabled
|
19
20
|
class_attribute :default_view_type, default: :table
|
20
21
|
class_attribute :devise_password_optional, default: false
|
21
22
|
class_attribute :actions_loader
|
@@ -94,7 +95,7 @@ module Avo
|
|
94
95
|
return [] if self.class.fields.blank?
|
95
96
|
|
96
97
|
fields = self.class.fields.map do |field|
|
97
|
-
field.hydrate(resource: self, panel_name: default_panel_name, user: user)
|
98
|
+
field.hydrate(resource: self, panel_name: default_panel_name, user: user, translation_enabled: translation_enabled)
|
98
99
|
end
|
99
100
|
|
100
101
|
if Avo::App.license.lacks_with_trial(:custom_fields)
|
@@ -192,12 +193,16 @@ module Avo
|
|
192
193
|
]
|
193
194
|
end
|
194
195
|
|
196
|
+
def class_name_without_resource
|
197
|
+
self.class.name.demodulize.chomp("Resource")
|
198
|
+
end
|
199
|
+
|
195
200
|
def model_class
|
196
201
|
return self.class.model_class if self.class.model_class.present?
|
197
202
|
|
198
203
|
return @model.class if @model.present?
|
199
204
|
|
200
|
-
|
205
|
+
class_name_without_resource.safe_constantize
|
201
206
|
end
|
202
207
|
|
203
208
|
def model_title
|
@@ -206,12 +211,18 @@ module Avo
|
|
206
211
|
name
|
207
212
|
end
|
208
213
|
|
214
|
+
def translation_key
|
215
|
+
return "avo.resource_translations.#{class_name_without_resource.underscore}" if self.class.translation_enabled
|
216
|
+
|
217
|
+
self.class.translation_key
|
218
|
+
end
|
219
|
+
|
209
220
|
def name
|
210
221
|
return @name if @name.present?
|
211
222
|
|
212
|
-
return I18n.t(
|
223
|
+
return I18n.t(translation_key, count: 1).capitalize if translation_key
|
213
224
|
|
214
|
-
|
225
|
+
class_name_without_resource.titlecase
|
215
226
|
end
|
216
227
|
|
217
228
|
def singular_name
|
@@ -219,7 +230,7 @@ module Avo
|
|
219
230
|
end
|
220
231
|
|
221
232
|
def plural_name
|
222
|
-
return I18n.t(
|
233
|
+
return I18n.t(translation_key, count: 2).capitalize if translation_key
|
223
234
|
|
224
235
|
name.pluralize
|
225
236
|
end
|
@@ -230,6 +241,10 @@ module Avo
|
|
230
241
|
self.class.name.demodulize.underscore
|
231
242
|
end
|
232
243
|
|
244
|
+
def navigation_label
|
245
|
+
plural_name.humanize
|
246
|
+
end
|
247
|
+
|
233
248
|
def available_view_types
|
234
249
|
view_types = [:table]
|
235
250
|
|
@@ -6,8 +6,6 @@ module Avo
|
|
6
6
|
include Avo::Fields::FieldExtensions::VisibleInDifferentViews
|
7
7
|
|
8
8
|
attr_reader :id
|
9
|
-
attr_reader :name
|
10
|
-
attr_reader :translation_key
|
11
9
|
attr_reader :block
|
12
10
|
attr_reader :required
|
13
11
|
attr_reader :readonly
|
@@ -43,8 +41,9 @@ module Avo
|
|
43
41
|
super(id, **args, &block)
|
44
42
|
|
45
43
|
@id = id
|
46
|
-
@name = args[:name]
|
44
|
+
@name = args[:name]
|
47
45
|
@translation_key = args[:translation_key]
|
46
|
+
@translation_enabled = false
|
48
47
|
@block = block
|
49
48
|
@required = args[:required] || false
|
50
49
|
@readonly = args[:readonly] || false
|
@@ -72,20 +71,35 @@ module Avo
|
|
72
71
|
except_on args[:except_on] if args[:except_on].present?
|
73
72
|
end
|
74
73
|
|
75
|
-
def hydrate(model: nil, resource: nil, action: nil, view: nil, panel_name: nil, user: nil)
|
74
|
+
def hydrate(model: nil, resource: nil, action: nil, view: nil, panel_name: nil, user: nil, translation_enabled: nil)
|
76
75
|
@model = model if model.present?
|
77
76
|
@view = view if view.present?
|
78
77
|
@resource = resource if resource.present?
|
79
78
|
@action = action if action.present?
|
80
79
|
@user = user if user.present?
|
81
80
|
@panel_name = panel_name if panel_name.present?
|
81
|
+
@translation_enabled = translation_enabled if translation_enabled.present?
|
82
82
|
|
83
83
|
self
|
84
84
|
end
|
85
85
|
|
86
|
+
def translation_key
|
87
|
+
return "avo.field_translations.#{@id}" if @translation_enabled
|
88
|
+
|
89
|
+
@translation_key
|
90
|
+
end
|
91
|
+
|
92
|
+
def name
|
93
|
+
return @name if @name.present?
|
94
|
+
|
95
|
+
return I18n.t(translation_key, count: 1).capitalize if translation_key
|
96
|
+
|
97
|
+
@id.to_s.humanize(keep_id_suffix: true)
|
98
|
+
end
|
99
|
+
|
86
100
|
def visible?
|
87
101
|
if visible.present? && visible.respond_to?(:call)
|
88
|
-
visible.call resource: resource
|
102
|
+
visible.call resource: @resource
|
89
103
|
else
|
90
104
|
visible
|
91
105
|
end
|
data/lib/avo/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
class <%= class_name.camelize %> < Avo::BaseAction
|
2
2
|
self.name = '<%= name.underscore.humanize %>'
|
3
3
|
|
4
|
-
def handle(
|
4
|
+
def handle(**args)
|
5
|
+
models, fields, current_user, resource = args.values_at(:models, :fields, :current_user, :resource)
|
6
|
+
|
5
7
|
models.each do |model|
|
6
8
|
# Do something with your models.
|
7
9
|
end
|