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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1618da266ed143055270d6efe40cbc1672b074977668186ba979dd062e28c296
4
- data.tar.gz: 03600d5cf52bc8cba85970ce6f7c7dceeba01747c17fff374a22ed4137048fc1
3
+ metadata.gz: d5138e11c8508c204270f3b71100905e2046cddba58dc4328459b6f230918b10
4
+ data.tar.gz: 5b63ee835184e1e6b49f4fe6685eb3da91d435a88304917a20c187e88ce8c377
5
5
  SHA512:
6
- metadata.gz: 80856cc4b3c4e164570d5209140e09bfb617c90db0500652b577500a3ed675a96ec14b4944b5e4339849820860fe9f100a971fe414205352e8a37a7983b51bae
7
- data.tar.gz: 3bc19b1c7feb5e06e485648c8ea30f46ddce97ff591c71c69ca0bfef7ac73b384001d202022f5004437a1cffa2c17ec94167160c5136c8e99d977e02df5ef601
6
+ metadata.gz: 8fcb3d6de28e6582d29c80f58d618a4c00676ea9cbd2e9120c6affd3bf3ebe0816ffcb01fdd692584813f928e0977615304cd0768d3c2f88cf72cd54ef4e0101
7
+ data.tar.gz: 8349c52ce5985fdb37c64c7a39a9ecff8b0b7b1985a90904c181655d2a3f01095e2cc66f69e5a0c5e7facc74f9ccc8ecd64d5b1bc010c055f34db5a8bbd014d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.19.1.pre.10)
4
+ avo (1.19.1.pre.11)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -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, scope: @resource.form_scope, url: helpers.resource_path(model: @resource.model, resource: @resource), method: :put, multipart: true do |form| %>
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: @resource.resource_description, body_classes: 'py-4', data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
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' if @actions.present? %>
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, scope: @resource.form_scope, url: helpers.resources_path(resource: @resource, via_relation_class: params[:via_relation_class], via_relation: params[:via_relation], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
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">
@@ -111,7 +111,6 @@ module Avo
111
111
  end
112
112
 
113
113
  def fill_model
114
- puts ['@model_to_fill->', @model_to_fill].inspect
115
114
  @model = @resource.fill_model(@model_to_fill, cast_nullable(model_params))
116
115
  end
117
116
 
@@ -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
@@ -53,4 +53,12 @@ FactoryBot.define do
53
53
  name { "#{Faker::Name.first_name} #{Faker::Name.last_name}" }
54
54
  type { "Spouse" }
55
55
  end
56
+
57
+ factory :course do
58
+ name { Faker::Company.name }
59
+ end
60
+
61
+ factory :link do
62
+ name { Faker::Internet.url }
63
+ end
56
64
  end
@@ -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].present? ? args[:key_label].to_s : I18n.translate('avo.key_value_field.key')
19
- @value_label = args[:value_label].present? ? args[:value_label].to_s : I18n.translate('avo.key_value_field.value')
20
- @action_text = args[:action_text].present? ? args[:action_text].to_s : I18n.translate('avo.key_value_field.add_row')
21
- @delete_text = args[:delete_text].present? ? args[:delete_text].to_s : I18n.translate('avo.key_value_field.delete_row')
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
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.19.1.pre.10"
2
+ VERSION = "1.19.1.pre.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1.pre.10
4
+ version: 1.19.1.pre.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin