spree_admin 5.3.1 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e5563fe644b860f13ec2dbbe7f1becacbbdc98c0155fc96613df511ad5210c6
4
- data.tar.gz: b1d9bab21c05510f2c8a2a3a82c1c97e90b92853a91f46abbae29980428d32d9
3
+ metadata.gz: 4946aeaa86aa1e2c96735cda6cce989be4b24ae48ee0da8fb818a2ecc6629ab6
4
+ data.tar.gz: 3ad2307712a9587dcf81f83fb6c315bca28cb157a7be773a45b7a39b2b611566
5
5
  SHA512:
6
- metadata.gz: 5cee25a742f215c4f66aefeec9ae5402ffd46cbb91715a90cbed7dcfaff2970719fae39f81a9dcfcfcd9ee63cceca906549ace8fc26a76080f3f7734615d391e
7
- data.tar.gz: 1098481f56d76418a17dfff7806e4b64527ef2be597e11800992ad4393617aa66c6a5f54cae85d329315d3cd2f92af414ffe86c165ae2a4f6fc9c8c03f8bec6f
6
+ metadata.gz: 6ec39dcde0b0523fd504293103e50e34010d6c3046056bb89764740f38eee913bdc40a569992327475987e45dcba66ef37d8c08e442bd3421d4ecc68f3e10d27
7
+ data.tar.gz: bd648240f8c15a8b119df6e267772df73cbe6db8ddfeddce1da6861bc2d745271ac8c1fe9663be19e75188c87ed278c7aff31f3f92ef9f12e99eb498a72ef6bb
@@ -323,10 +323,7 @@ module Spree
323
323
  items = navigation_items(context)
324
324
  return '' if items.empty?
325
325
 
326
- render 'spree/admin/shared/navigation',
327
- items: items,
328
- context: context,
329
- **options
326
+ render_navigation_items(items, context)
330
327
  end
331
328
 
332
329
  # Get navigation items for the given context
@@ -337,6 +334,51 @@ module Spree
337
334
  Spree.admin.navigation.send(context)&.visible_items(self) || []
338
335
  end
339
336
 
337
+ # Renders navigation items as an unordered list
338
+ # @param items [Array<Spree::Admin::Navigation::Item>] navigation items to render
339
+ # @param context [Symbol] the navigation context
340
+ # @return [SafeBuffer] the rendered HTML
341
+ def render_navigation_items(items, context)
342
+ return ''.html_safe if items.empty?
343
+
344
+ content_tag :ul, class: 'nav flex-col' do
345
+ safe_join(items.map { |item| render_navigation_item(item, context) })
346
+ end
347
+ end
348
+
349
+ # Renders a single navigation item
350
+ # @param item [Spree::Admin::Navigation::Item] the navigation item
351
+ # @param context [Symbol] the navigation context
352
+ # @return [SafeBuffer] the rendered HTML
353
+ def render_navigation_item(item, context)
354
+ return render_nav_section_header(item) if item.section?
355
+
356
+ item_url = item.resolve_url(self)
357
+ item_label = item.resolve_label
358
+ badge_value = item.badge_value(self)
359
+ is_active = item.active?(request.path, self)
360
+ has_children = item.children.present?
361
+ tooltip_text = item.tooltip
362
+
363
+ # Build data attributes
364
+ data_attrs = item.data_attributes.dup
365
+ data_attrs[:controller] = 'tooltip' if tooltip_text.present?
366
+
367
+ # Build HTML options
368
+ html_options = {}
369
+ html_options[:target] = item.target if item.target.present?
370
+ html_options[:id] = "nav-link-#{item.key}" if item.key.present?
371
+
372
+ # Build complete label with badge and tooltip
373
+ complete_label = build_nav_label(item_label, badge_value, item.badge_class, tooltip_text)
374
+
375
+ if has_children
376
+ render_nav_item_with_children(item, complete_label, item_url, item_label, is_active, data_attrs, html_options, context)
377
+ else
378
+ nav_item(complete_label, item_url, icon: item.icon, active: is_active, data: data_attrs, **html_options)
379
+ end
380
+ end
381
+
340
382
  # Renders page tab navigation for the given context
341
383
  # @param context [Symbol] the navigation context (:tax_tabs, :shipping_tabs, etc.)
342
384
  # @param options [Hash] additional options for rendering
@@ -355,6 +397,54 @@ module Spree
355
397
  end.join.html_safe
356
398
  end
357
399
  end
400
+
401
+ private
402
+
403
+ # Builds navigation label with optional badge and tooltip
404
+ # @return [SafeBuffer] the label HTML
405
+ def build_nav_label(label, badge_value, badge_class, tooltip_text)
406
+ result = label.to_s
407
+ if badge_value.present?
408
+ css_class = badge_class.presence || 'badge-light'
409
+ result += content_tag(:span, badge_value, class: "badge ml-auto #{css_class}")
410
+ end
411
+ if tooltip_text.present?
412
+ result += tooltip(tooltip_text)
413
+ end
414
+ result.html_safe
415
+ end
416
+
417
+ # Renders a section header
418
+ # @return [SafeBuffer] the section header HTML
419
+ def render_nav_section_header(item)
420
+ content_tag :li, class: 'nav-item nav-section-header mt-4 border-t pt-4 pl-2' do
421
+ content_tag :span, item.section_label, class: 'text-gray-600 uppercase font-light text-sm'
422
+ end
423
+ end
424
+
425
+ # Renders a nav item that has children (with submenu)
426
+ # @return [SafeBuffer] the nav item with submenu HTML
427
+ def render_nav_item_with_children(item, complete_label, item_url, item_label, is_active, data_attrs, html_options, context)
428
+ visible_children = item.children.select { |child| child.visible?(self) }
429
+
430
+ # Main nav item
431
+ main_item = nav_item(complete_label, item_url, icon: item.icon, active: is_active, data: data_attrs, **html_options)
432
+
433
+ # Submenu for expanded sidebar (only shown when active)
434
+ submenu = content_tag :ul, class: "nav-submenu#{' hidden' unless is_active}", id: "nav-submenu-#{item.key}" do
435
+ safe_join(visible_children.map { |child| render_navigation_item(child, context) })
436
+ end
437
+
438
+ # Dropdown submenu for collapsed sidebar (shown on hover)
439
+ dropdown = content_tag :ul, class: 'nav-submenu-dropdown hidden dropdown-container', id: "nav-submenu-dropdown-#{item.key}" do
440
+ # Parent item as first dropdown item
441
+ parent_link = nav_item(item_label, item_url, icon: nil)
442
+ children_items = safe_join(visible_children.map { |child| render_navigation_item(child, context) })
443
+ parent_link + children_items
444
+ end
445
+
446
+ main_item + submenu + dropdown
447
+ end
358
448
  end
359
449
  end
360
450
  end
@@ -13,7 +13,7 @@
13
13
 
14
14
  <%= render "spree/admin/shared/header" %>
15
15
  <%= render "spree/admin/shared/sidebar" %>
16
- <main id="content" data-controller=" export-dialog">
16
+ <main id="content" data-controller="export-dialog">
17
17
  <%= render "spree/admin/shared/content_header" %>
18
18
  <%= render "spree/admin/shared/page_tabs" %>
19
19
  <%= render "spree/admin/shared/page_alerts" %>
@@ -22,7 +22,8 @@
22
22
  params.dig(:q, search_param),
23
23
  class: "outline-none border-0 h-full focus:border-0 focus:ring-0 p-0 text-base w-full",
24
24
  placeholder: search_placeholder,
25
- data: { action: 'input->auto-submit#submit input->search-clear#toggleClearButton search->auto-submit#submit', search_clear_target: 'input' } %>
25
+ id: "#{frame_name}-table-search-input",
26
+ data: { "turbo-permanent": true, action: 'input->auto-submit#submit input->search-clear#toggleClearButton search->auto-submit#submit', search_clear_target: 'input' } %>
26
27
  <button type="button" class="<%= 'hidden' if params.dig(:q, search_param).blank? %> p-1 text-gray-400 hover:text-gray-600 shrink-0" data-search-clear-target="clear" data-action="search-clear#clear">
27
28
  <%= icon 'x', class: 'w-4 h-4' %>
28
29
  </button>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.1
4
+ version: 5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vendo Connect Inc.
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 5.3.1
18
+ version: 5.3.2
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 5.3.1
25
+ version: 5.3.2
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: active_link_to
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -937,8 +937,6 @@ files:
937
937
  - app/views/spree/admin/shared/_media_form.html.erb
938
938
  - app/views/spree/admin/shared/_modal.html.erb
939
939
  - app/views/spree/admin/shared/_multi_product_picker.html.erb
940
- - app/views/spree/admin/shared/_navigation.html.erb
941
- - app/views/spree/admin/shared/_navigation_item.html.erb
942
940
  - app/views/spree/admin/shared/_new_item_dropdown.html.erb
943
941
  - app/views/spree/admin/shared/_new_resource.html.erb
944
942
  - app/views/spree/admin/shared/_new_resource_links.html.erb
@@ -1255,9 +1253,9 @@ licenses:
1255
1253
  - AGPL-3.0-or-later
1256
1254
  metadata:
1257
1255
  bug_tracker_uri: https://github.com/spree/spree/issues
1258
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.1
1256
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.2
1259
1257
  documentation_uri: https://docs.spreecommerce.org/
1260
- source_code_uri: https://github.com/spree/spree/tree/v5.3.1
1258
+ source_code_uri: https://github.com/spree/spree/tree/v5.3.2
1261
1259
  rdoc_options: []
1262
1260
  require_paths:
1263
1261
  - lib
@@ -1,3 +0,0 @@
1
- <ul class="nav flex-col">
2
- <%= render collection: items, partial: 'spree/admin/shared/navigation_item', as: :item, locals: { context: context } %>
3
- </ul>
@@ -1,60 +0,0 @@
1
- <%
2
- # Resolve item properties (pass self as context for route helpers)
3
- item_url = item.resolve_url(self)
4
- item_label = item.resolve_label
5
- badge_value = item.badge_value(self)
6
- is_active = item.active?(request.path, self)
7
- has_children = item.children.present?
8
- tooltip_text = item.tooltip
9
-
10
- # Build data attributes - only add tooltip controller if tooltip is present
11
- data_attrs = item.data_attributes.dup
12
- if tooltip_text.present?
13
- data_attrs[:controller] = 'tooltip'
14
- end
15
-
16
- # Build additional HTML options (like target)
17
- html_options = {}
18
- html_options[:target] = item.target if item.target.present?
19
- html_options[:id] = "nav-link-#{item.key}" if item.key.present?
20
-
21
- # Build complete label with badge (like old menu pattern)
22
- complete_label = item_label
23
- if badge_value.present?
24
- badge_class = item.badge_class.presence || 'badge-light'
25
- complete_label += content_tag(:span, badge_value, class: "badge ml-auto #{badge_class}")
26
- end
27
- # Add tooltip if present
28
- if tooltip_text.present?
29
- complete_label += tooltip(tooltip_text)
30
- end
31
- complete_label = complete_label&.html_safe
32
- %>
33
-
34
- <% if item.section? %>
35
- <%# Section header %>
36
- <li class="nav-item nav-section-header mt-4 border-t pt-4 pl-2">
37
- <span class="text-gray-600 uppercase font-light text-sm"><%= item.section_label %></span>
38
- </li>
39
- <% else %>
40
- <% if has_children %>
41
- <%# Item with children (submenu shows when parent is active) %>
42
- <%= nav_item(complete_label, item_url, icon: item.icon, active: is_active, data: data_attrs, **html_options) %>
43
-
44
- <%# Submenu for expanded sidebar (only shown when active) %>
45
- <ul class="nav-submenu <% unless is_active %>hidden<% end %>" id="nav-submenu-<%= item.key %>">
46
- <%= render collection: item.children.select { |child| child.visible?(self) }, partial: 'spree/admin/shared/navigation_item', as: :item, locals: { context: context } %>
47
- </ul>
48
-
49
- <%# Submenu dropdown for collapsed sidebar (always rendered, shown on hover) %>
50
- <ul class="nav-submenu-dropdown hidden dropdown-container" id="nav-submenu-dropdown-<%= item.key %>">
51
- <%# Add parent item as first item in dropdown %>
52
- <%= nav_item(item_label, item_url, icon: nil) %>
53
-
54
- <%= render collection: item.children.select { |child| child.visible?(self) }, partial: 'spree/admin/shared/navigation_item', as: :item, locals: { context: context } %>
55
- </ul>
56
- <% else %>
57
- <%# Regular item without children %>
58
- <%= nav_item(complete_label, item_url, icon: item.icon, active: is_active, data: data_attrs, **html_options) %>
59
- <% end %>
60
- <% end %>