avo 2.34.0 → 2.34.2

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: dce48ff1282bab4437a07c321a0099ce1755e92c96d0b82a29e2d91577b33da4
4
- data.tar.gz: de4b93b760c5177e9631c51957eda7915f817b3ab60ed8a24c8fe9be739e19f8
3
+ metadata.gz: 7b1b2bdba8e863c5c01a069056bf4fd5ac98fd45ebfb8ed9e70c3f5a9da05380
4
+ data.tar.gz: cb6e887b63ea5992da6233b8323df13427478f37e0805945903d1d52c2302342
5
5
  SHA512:
6
- metadata.gz: 50614474a512b8b8f22eb0a10c2c225fbe13b122bd7719109a842af0e82beccbe7d3f1977f966cd5a1316f31a08d894467afb1cf9dbd9e99745b7bf21560a281
7
- data.tar.gz: 7331125c451330a2926e980b51e8dba2e6b9072b97965aa40a1a2b7afb6367c1822185088749e55c011e0666ce4d50c95a111b51e5f1ddf175e95c8caaca5a7a
6
+ metadata.gz: 86d3aa5189e477e66095b2d648010fbbe9ee5b7d5cc4b38c1c5b10b709a139dff14a60bb9a1cab97ceea62edc5c37d48bb40c657fc6f774412911cc00474d098
7
+ data.tar.gz: 64b9694b95826f77faf2a1e56023522809923c9aedcf646f2622db44da537403bcadded775d3935bb91226d1eb5868c8c6f967195c4957ad18f95e1efdba95e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.34.0)
4
+ avo (2.34.2)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -1,3 +1,18 @@
1
- <%= link_to path, class: "flex-1 flex items-center justify-center bg-white text-left cursor-pointer text-gray-800 font-semibold hover:bg-primary-100 block px-4 py-1 w-full py-3 text-center rounded w-full", target: target, title: title do %>
2
- <%= helpers.svg(icon, class: 'h-4 mr-1') if icon.present? %> <%= label %>
1
+ <% if method.present? %>
2
+ <%= button_to path,
3
+ form_class: "flex-1 flex",
4
+ class: button_classes,
5
+ target: target,
6
+ title: title,
7
+ method: method,
8
+ params: params do %>
9
+ <%= helpers.svg(icon, class: 'h-4 mr-1') if icon.present? %> <%= label %>
10
+ <% end %>
11
+ <% else %>
12
+ <%= link_to path,
13
+ class: button_classes,
14
+ target: target,
15
+ title: title do %>
16
+ <%= helpers.svg(icon, class: 'h-4 mr-1') if icon.present? %> <%= label %>
17
+ <% end %>
3
18
  <% end %>
@@ -6,17 +6,29 @@ class Avo::ProfileItemComponent < ViewComponent::Base
6
6
  attr_reader :path
7
7
  attr_reader :active
8
8
  attr_reader :target
9
+ attr_reader :method
10
+ attr_reader :params
11
+ attr_reader :classes
9
12
 
10
- def initialize(label: nil, icon: nil, path: nil, active: :inclusive, target: nil, title: nil)
13
+ def initialize(label: nil, icon: nil, path: nil, active: :inclusive, target: nil, title: nil, method: nil, params: {}, classes: "")
11
14
  @label = label
12
15
  @icon = icon
13
16
  @path = path
14
17
  @active = active
15
18
  @target = target
16
19
  @title = title
20
+ @method = method
21
+ @params = params
22
+ @classes = classes
17
23
  end
18
24
 
19
25
  def title
20
26
  @title || @label
21
27
  end
28
+
29
+ private
30
+
31
+ def button_classes
32
+ "flex-1 flex items-center justify-center bg-white text-left cursor-pointer text-gray-800 font-semibold hover:bg-primary-100 block px-4 py-1 w-full py-3 text-center rounded w-full"
33
+ end
22
34
  end
@@ -16,26 +16,25 @@
16
16
  <% end %>
17
17
  </div>
18
18
  </div>
19
- <% if can_destroy_user? %>
20
- <div class="relative" data-controller="toggle-panel">
21
- <a class="flex items-center h-full cursor-pointer" data-control="profile-dots" data-action="click->toggle-panel#togglePanel">
22
- <%= helpers.svg 'three-dots', class: 'h-4' %>
23
- </a>
24
- <div
25
- class="hidden absolute flex flex-col inset-auto right-0 -mt-12 bg-white rounded min-w-[200px] shadow-context -translate-y-full z-40"
26
- data-toggle-panel-target="panel"
27
- >
28
- <% if Avo::App.has_profile_menu? %>
29
- <div class="text-black space-y-4">
30
- <% Avo::App.profile_menu.items.each do |item| %>
31
- <% if item.is_a? Avo::Menu::Link %>
32
- <%= render Avo::ProfileItemComponent.new label: item.name, path: item.path, icon: item.icon %>
33
- <% end %>
19
+ <div class="relative" data-controller="toggle-panel">
20
+ <a class="flex items-center h-full cursor-pointer" data-control="profile-dots" data-action="click->toggle-panel#togglePanel">
21
+ <%= helpers.svg 'three-dots', class: 'h-4' %>
22
+ </a>
23
+ <div
24
+ class="hidden absolute flex flex-col inset-auto right-0 -mt-12 bg-white rounded min-w-[200px] shadow-context -translate-y-full z-40"
25
+ data-toggle-panel-target="panel"
26
+ >
27
+ <% if Avo::App.has_profile_menu? %>
28
+ <div class="text-black">
29
+ <% Avo::App.profile_menu.items.each do |item| %>
30
+ <% if item.is_a? Avo::Menu::Link %>
31
+ <%= render Avo::ProfileItemComponent.new label: item.name, path: item.path, icon: item.icon, method: item.method, params: item.params %>
34
32
  <% end %>
35
- </div>
36
- <% end %>
37
- <%# Example link below %>
38
- <%#= render Avo::ProfileItemComponent.new label: 'Profile', path: '/profile', icon: 'user-circle' %>
33
+ <% end %>
34
+ </div>
35
+ <% end %>
36
+ <%= render "avo/partials/profile_menu_extra" %>
37
+ <% if can_destroy_user? %>
39
38
  <%= button_to helpers.main_app.send(destroy_user_session_path),
40
39
  form: { "data-turbo" => "false" },
41
40
  method: :delete,
@@ -46,7 +45,7 @@
46
45
  form_class: 'flex-1' do %>
47
46
  <%= helpers.svg 'logout', class: 'h-4 mr-1' %> <%= t('avo.sign_out') %>
48
47
  <% end %>
49
- </div>
48
+ <% end %>
50
49
  </div>
51
- <% end %>
50
+ </div>
52
51
  </div>
@@ -0,0 +1,2 @@
1
+ <%# Example link below %>
2
+ <%#= render Avo::ProfileItemComponent.new label: 'Profile', path: '/profile', icon: 'user-circle' %>
@@ -199,9 +199,9 @@ module Avo
199
199
  def fill_field(model, key, value, params)
200
200
  return model unless model.methods.include? key.to_sym
201
201
 
202
- valid_model_class = valid_polymorphic_class params["#{polymorphic_as}_type"]
203
-
204
202
  if polymorphic_as.present?
203
+ valid_model_class = valid_polymorphic_class params["#{polymorphic_as}_type"]
204
+
205
205
  model.send("#{polymorphic_as}_type=", valid_model_class)
206
206
 
207
207
  # If the type is blank, reset the id too.
data/lib/avo/menu/link.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  class Avo::Menu::Link < Avo::Menu::BaseItem
2
2
  option :path, default: proc { "" }
3
3
  option :target, optional: true
4
+ option :method, optional: true
5
+ option :params, optional: true
4
6
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.34.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.34.2" unless const_defined?(:VERSION)
3
3
  end
@@ -17,6 +17,7 @@ module Generators
17
17
  pre_head: "app/views/avo/partials/_pre_head.html.erb",
18
18
  scripts: "app/views/avo/partials/_scripts.html.erb",
19
19
  sidebar_extra: "app/views/avo/partials/_sidebar_extra.html.erb",
20
+ profile_menu_extra: "app/views/avo/partials/_profile_menu_extra.html.erb",
20
21
  }
21
22
 
22
23
  def handle
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: 2.34.0
4
+ version: 2.34.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-06-06 00:00:00.000000000 Z
12
+ date: 2023-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -1687,6 +1687,7 @@ files:
1687
1687
  - app/views/avo/partials/_logo.html.erb
1688
1688
  - app/views/avo/partials/_navbar.html.erb
1689
1689
  - app/views/avo/partials/_pre_head.html.erb
1690
+ - app/views/avo/partials/_profile_menu_extra.html.erb
1690
1691
  - app/views/avo/partials/_resource_search.html.erb
1691
1692
  - app/views/avo/partials/_scripts.html.erb
1692
1693
  - app/views/avo/partials/_sidebar_extra.html.erb