avo 3.5.1 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9baf34b45ec14d817690a0c2a48fc25132b1cce6b80e8b1542b082325d1af656
4
- data.tar.gz: f49d287883c66fa87c5ef3cc0be4f307c79ffead8737e25e24bc707ce15d3b2c
3
+ metadata.gz: b09b96bd49a61cf405e01532f30b33471437b1b354efad21ccd3c0ad193fdc90
4
+ data.tar.gz: b35e575c1787a34a5b1a2185127f39075b808d833993d3bd8584ea877dc14035
5
5
  SHA512:
6
- metadata.gz: debc97692363a7d08ea51571350fea336c9f5201b343e8d2a15e936dbd99685b7b96fb4b74079348846a650eb177a7a008adb1dbebd61140140bd25acfc54704
7
- data.tar.gz: 150853cce487de3315d29a66d8f09b837263c4277e7b86c32cc09951e12824e3ed67e9e1adb1d851ac47730199b1c7355a3a333465d5d48ee941476f56b66551
6
+ metadata.gz: 87e3e97b4e3e001080341a61565e97674d5e7ba9703a980bae1d769180afb648d5a0dff42d7901b5f42370a2915eb689951bff02cba33cb3183a634faa3c726b
7
+ data.tar.gz: a9841007e4c2226651a0c3b86d5ed25b189f2ad5fceb258bf23f79a8c5931cfcaefa68d8657e895483404c45f6fb8064e5c4b418db5b3282cc2fe7cb2d8e485c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.5.1)
4
+ avo (3.5.2)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -4,7 +4,7 @@
4
4
  <%== item_selector_init @resource %>
5
5
  data-resource-name="<%= @resource.class.to_s %>"
6
6
  data-record-id="<%= @resource.record.id %>"
7
- <%= drag_reorder_item_attributes %>
7
+ <%= try :drag_reorder_item_attributes %>
8
8
  >
9
9
  <%= content_tag :div,
10
10
  class: "relative w-full pb-3/4 rounded-t overflow-hidden #{html(:cover, :classes)}",
@@ -2,7 +2,6 @@
2
2
 
3
3
  class Avo::Index::GridItemComponent < Avo::BaseComponent
4
4
  include Avo::ResourcesHelper
5
- include Avo::Concerns::CanReorderItems
6
5
  include Avo::Fields::Concerns::HasHTMLAttributes
7
6
 
8
7
  attr_reader :parent_resource, :actions
@@ -1,9 +1,4 @@
1
1
  <div class="space-x-2 flex flex-row justify-end w-full">
2
- <% if can_dnd_reorder? %>
3
- <div class="handle">
4
- <%= helpers.svg 'heroicons/outline/bars-3', class: 'text-gray-400 h-6 hover:text-gray-600 cursor-pointer' %>
5
- </div>
6
- <% end %>
7
2
  <% @resource.render_row_controls(item: singular_resource_name).each do |control| %>
8
3
  <%= render_control control %>
9
4
  <% end %>
@@ -2,7 +2,6 @@
2
2
 
3
3
  class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
4
4
  include Avo::ApplicationHelper
5
- include Avo::Concerns::CanReorderItems
6
5
 
7
6
  def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, view_type: :table, actions: nil)
8
7
  @resource = resource
@@ -162,7 +161,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
162
161
  end
163
162
 
164
163
  def render_order_controls(control)
165
- if can_reorder?
164
+ if try(:can_reorder?)
166
165
  render Avo::Pro::Ordering::ButtonsComponent.new resource: @resource, reflection: @reflection, view_type: @view_type
167
166
  end
168
167
  end
@@ -1,7 +1,7 @@
1
1
  <% if @resources.present? %>
2
2
  <turbo-frame id="<%= @resource.model_key %>_list" target="_top" class="relative w-full">
3
3
  <div class="w-full grid grid-cols-1 xs:grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6 mt-8"
4
- <%= drag_reorder_attributes %>
4
+ <%= try :drag_reorder_attributes %>
5
5
  data-component-name="<%= self.class.to_s.underscore %>"
6
6
  data-selected-resources-name="<%= @resource.model_key %>" data-selected-resources="[]">
7
7
  <% @resources.each_with_index do |resource, index| %>
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Index::ResourceGridComponent < Avo::BaseComponent
4
- include Avo::Concerns::CanReorderItems
5
4
  attr_reader :actions
6
5
 
7
6
  def initialize(resources: nil, resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, actions: nil)
@@ -39,7 +39,7 @@
39
39
  <% end %>
40
40
  <table class="w-full px-4 bg-white">
41
41
  <%= render partial: 'avo/partials/table_header', locals: {fields: @resource.get_fields(reflection: @reflection, only_root: true)} %>
42
- <tbody class="divide-y" <%= drag_reorder_attributes %>>
42
+ <tbody class="divide-y" <%= try :drag_reorder_attributes %>>
43
43
  <% @resources.each_with_index do |resource, index| %>
44
44
  <% cache_if Avo.configuration.cache_resources_on_index_view, resource.cache_hash(@parent_record), expires_in: 1.day do %>
45
45
  <%= render Avo::Index::TableRowComponent.new(resource: resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, actions: @actions) %>
@@ -2,7 +2,6 @@
2
2
 
3
3
  class Avo::Index::ResourceTableComponent < Avo::BaseComponent
4
4
  include Avo::ApplicationHelper
5
- include Avo::Concerns::CanReorderItems
6
5
  attr_reader :pagy, :query
7
6
 
8
7
  def initialize(resources: nil, resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, pagy: nil, query: nil, actions: nil)
@@ -5,7 +5,7 @@
5
5
  <%== item_selector_init @resource %>
6
6
  data-resource-name="<%= @resource.class.to_s %>"
7
7
  data-record-id="<%= @resource.record.id %>"
8
- <%= drag_reorder_item_attributes %>
8
+ <%= try :drag_reorder_item_attributes %>
9
9
  >
10
10
  <% if @resource.record_selector %>
11
11
  <td class="w-10">
@@ -2,7 +2,6 @@
2
2
 
3
3
  class Avo::Index::TableRowComponent < Avo::BaseComponent
4
4
  include Avo::ResourcesHelper
5
- include Avo::Concerns::CanReorderItems
6
5
 
7
6
  def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, actions: nil)
8
7
  @resource = resource
@@ -1,4 +1,6 @@
1
1
  class Avo::ResourceComponent < Avo::BaseComponent
2
+ include Avo::Concerns::ChecksAssocAuthorization
3
+
2
4
  attr_reader :fields_by_panel
3
5
  attr_reader :has_one_panels
4
6
  attr_reader :has_many_panels
@@ -7,8 +9,6 @@ class Avo::ResourceComponent < Avo::BaseComponent
7
9
  attr_reader :resource
8
10
  attr_reader :view
9
11
 
10
- include Avo::Concerns::ChecksAssocAuthorization
11
-
12
12
  def can_create?
13
13
  return authorize_association_for(:create) if @reflection.present?
14
14
 
@@ -451,14 +451,14 @@ module Avo
451
451
  def file_hash
452
452
  content_to_be_hashed = ""
453
453
 
454
- # resource file hash
455
- resource_path = Rails.root.join("app", "avo", "resources", "#{self.class.name.underscore}.rb").to_s
454
+ file_name = self.class.underscore_name.tr(" ", "_")
455
+ resource_path = Rails.root.join("app", "avo", "resources", "#{file_name}.rb").to_s
456
456
  if File.file? resource_path
457
457
  content_to_be_hashed += File.read(resource_path)
458
458
  end
459
459
 
460
460
  # policy file hash
461
- policy_path = Rails.root.join("app", "policies", "#{self.class.name.underscore.gsub("_resource", "")}_policy.rb").to_s
461
+ policy_path = Rails.root.join("app", "policies", "#{file_name.gsub("_resource", "")}_policy.rb").to_s
462
462
  if File.file? policy_path
463
463
  content_to_be_hashed += File.read(policy_path)
464
464
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.5.1" unless const_defined?(:VERSION)
2
+ VERSION = "3.5.2" unless const_defined?(:VERSION)
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: 3.5.1
4
+ version: 3.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-03-14 00:00:00.000000000 Z
13
+ date: 2024-03-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -2170,7 +2170,6 @@ files:
2170
2170
  - lib/avo/base_resource_tool.rb
2171
2171
  - lib/avo/concerns/borrow_items_holder.rb
2172
2172
  - lib/avo/concerns/breadcrumbs.rb
2173
- - lib/avo/concerns/can_reorder_items.rb
2174
2173
  - lib/avo/concerns/can_replace_items.rb
2175
2174
  - lib/avo/concerns/checks_assoc_authorization.rb
2176
2175
  - lib/avo/concerns/filters_session_handler.rb
@@ -1,29 +0,0 @@
1
- module Avo
2
- module Concerns
3
- module CanReorderItems
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- if defined? Avo::Pro::Concerns::CanReorderItems
8
- include Avo::Pro::Concerns::CanReorderItems
9
- end
10
- end
11
-
12
- def can_reorder?
13
- false
14
- end
15
-
16
- def can_dnd_reorder?
17
- false
18
- end
19
-
20
- def drag_reorder_attributes
21
- ""
22
- end
23
-
24
- def drag_reorder_item_attributes
25
- ""
26
- end
27
- end
28
- end
29
- end