avo 1.19.1.pre.10 → 1.19.1.pre.11
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/components/avo/views/resource_edit_component.html.erb +5 -2
- data/app/components/avo/views/resource_index_component.html.erb +2 -2
- data/app/components/avo/views/resource_index_component.rb +8 -0
- data/app/components/avo/views/resource_new_component.html.erb +8 -1
- data/app/controllers/avo/application_controller.rb +0 -1
- data/app/controllers/avo/base_controller.rb +0 -1
- data/db/factories.rb +8 -0
- data/lib/avo/fields/key_value_field.rb +28 -8
- data/lib/avo/services/authorization_service.rb +3 -0
- data/lib/avo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5138e11c8508c204270f3b71100905e2046cddba58dc4328459b6f230918b10
|
4
|
+
data.tar.gz: 5b63ee835184e1e6b49f4fe6685eb3da91d435a88304917a20c187e88ce8c377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fcb3d6de28e6582d29c80f58d618a4c00676ea9cbd2e9120c6affd3bf3ebe0816ffcb01fdd692584813f928e0977615304cd0768d3c2f88cf72cd54ef4e0101
|
7
|
+
data.tar.gz: 8349c52ce5985fdb37c64c7a39a9ecff8b0b7b1985a90904c181655d2a3f01095e2cc66f69e5a0c5e7facc74f9ccc8ecd64d5b1bc010c055f34db5a8bbd014d8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
<div data-model-id="<%= @resource.model.id %>">
|
2
|
-
<%= @resource.form_scope %>
|
3
2
|
<% @resource.panels.each do |resource_panel| %>
|
4
|
-
<%= form_with model: @resource.model,
|
3
|
+
<%= form_with model: @resource.model,
|
4
|
+
scope: @resource.form_scope,
|
5
|
+
url: helpers.resource_path(model: @resource.model, resource: @resource),
|
6
|
+
method: :put,
|
7
|
+
multipart: true do |form| %>
|
5
8
|
<%= hidden_field_tag :referrer, back_path if params[:via_resource_class] %>
|
6
9
|
|
7
10
|
<%= render Avo::PanelComponent.new(title: resource_panel[:name], description: @resource.resource_description, display_breadcrumbs: true) do |c| %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<div>
|
2
|
-
<%= render Avo::PanelComponent.new(title: title, description:
|
2
|
+
<%= render Avo::PanelComponent.new(title: title, description: description, body_classes: 'py-4', data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
|
3
3
|
<% c.tools do %>
|
4
4
|
<% if can_see_the_actions_button? %>
|
5
|
-
<%= render 'actions'
|
5
|
+
<%= render 'actions' %>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<% if can_see_the_create_button? %>
|
@@ -55,6 +55,8 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def can_see_the_actions_button?
|
58
|
+
return false if @actions.blank?
|
59
|
+
|
58
60
|
return authorize_association_for("act_on") if @reflection.present?
|
59
61
|
|
60
62
|
@resource.authorization.authorize_action(:act_on, raise_exception: false) && !has_reflection_and_is_read_only
|
@@ -123,6 +125,12 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
128
|
+
def description
|
129
|
+
return if @reflection.present?
|
130
|
+
|
131
|
+
@resource.resource_description
|
132
|
+
end
|
133
|
+
|
126
134
|
private
|
127
135
|
|
128
136
|
def reflection_model_class
|
@@ -1,6 +1,13 @@
|
|
1
1
|
<div>
|
2
2
|
<% @resource.panels.each do |resource_panel| %>
|
3
|
-
<%= form_with model: @resource.model,
|
3
|
+
<%= form_with model: @resource.model,
|
4
|
+
scope: @resource.form_scope,
|
5
|
+
url: helpers.resources_path(resource: @resource,
|
6
|
+
via_relation_class: params[:via_relation_class],
|
7
|
+
via_relation: params[:via_relation],
|
8
|
+
via_resource_id: params[:via_resource_id]),
|
9
|
+
local: true,
|
10
|
+
multipart: true do |form| %>
|
4
11
|
<%= render Avo::PanelComponent.new(title: resource_panel[:name], description: @resource.resource_description, display_breadcrumbs: true) do |c| %>
|
5
12
|
<% c.tools do %>
|
6
13
|
<div class="flex justify-end space-x-2">
|
@@ -198,7 +198,6 @@ module Avo
|
|
198
198
|
|
199
199
|
request_params = params.require(model_param_key).permit(permitted_params)
|
200
200
|
|
201
|
-
puts ['model_param_key->', model_param_key, params, request_params].inspect
|
202
201
|
if @resource.devise_password_optional && request_params[:password].blank? && request_params[:password_confirmation].blank?
|
203
202
|
request_params.delete(:password_confirmation)
|
204
203
|
request_params.delete(:password)
|
data/db/factories.rb
CHANGED
@@ -3,10 +3,6 @@ require "json"
|
|
3
3
|
module Avo
|
4
4
|
module Fields
|
5
5
|
class KeyValueField < BaseField
|
6
|
-
attr_reader :key_label
|
7
|
-
attr_reader :value_label
|
8
|
-
attr_reader :action_text
|
9
|
-
attr_reader :delete_text
|
10
6
|
attr_reader :disable_editing_keys
|
11
7
|
attr_reader :disable_adding_rows
|
12
8
|
|
@@ -15,10 +11,10 @@ module Avo
|
|
15
11
|
|
16
12
|
hide_on :index
|
17
13
|
|
18
|
-
@key_label = args[:key_label].
|
19
|
-
@value_label = args[:value_label].
|
20
|
-
@action_text = args[:action_text].
|
21
|
-
@delete_text = args[:delete_text].
|
14
|
+
@key_label = args[:key_label].to_s if args[:key_label].present?
|
15
|
+
@value_label = args[:value_label].to_s if args[:value_label].present?
|
16
|
+
@action_text = args[:action_text].to_s if args[:action_text].present?
|
17
|
+
@delete_text = args[:delete_text].to_s if args[:delete_text].present?
|
22
18
|
|
23
19
|
@disable_editing_keys = args[:disable_editing_keys].present? ? args[:disable_editing_keys] : false
|
24
20
|
# disabling editing keys also disables adding rows (doesn't take into account the value of disable_adding_rows)
|
@@ -32,6 +28,30 @@ module Avo
|
|
32
28
|
@disable_deleting_rows = args[:disable_deleting_rows].present? ? args[:disable_deleting_rows] : false
|
33
29
|
end
|
34
30
|
|
31
|
+
def key_label
|
32
|
+
return @key_label if @key_label && !@key_label.empty?
|
33
|
+
|
34
|
+
I18n.translate('avo.key_value_field.key')
|
35
|
+
end
|
36
|
+
|
37
|
+
def value_label
|
38
|
+
return @value_label if @value_label && !@value_label.empty?
|
39
|
+
|
40
|
+
I18n.translate('avo.key_value_field.value')
|
41
|
+
end
|
42
|
+
|
43
|
+
def action_text
|
44
|
+
return @action_text if @action_text && !@action_text.empty?
|
45
|
+
|
46
|
+
I18n.translate('avo.key_value_field.add_row')
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete_text
|
50
|
+
return @delete_text if @delete_text && !@delete_text.empty?
|
51
|
+
|
52
|
+
I18n.translate('avo.key_value_field.delete_row')
|
53
|
+
end
|
54
|
+
|
35
55
|
def to_permitted_param
|
36
56
|
[:"#{id}", "#{id}": {}]
|
37
57
|
end
|
@@ -68,6 +68,9 @@ module Avo
|
|
68
68
|
def authorize_action(user, record, action, **args)
|
69
69
|
action = Avo.configuration.authorization_methods.stringify_keys[action.to_s] || action
|
70
70
|
|
71
|
+
# Add the question mark if it's missing
|
72
|
+
action = "#{action}?" unless action.end_with? '?'
|
73
|
+
|
71
74
|
return true if action.nil?
|
72
75
|
|
73
76
|
authorize user, record, action, **args
|
data/lib/avo/version.rb
CHANGED