spree_admin 5.3.1 → 5.3.3
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 +4 -4
- data/app/controllers/spree/admin/addresses_controller.rb +4 -16
- data/app/controllers/spree/admin/policies_controller.rb +5 -0
- data/app/helpers/spree/admin/navigation_helper.rb +94 -4
- data/app/views/layouts/spree/admin.html.erb +1 -1
- data/app/views/spree/admin/addresses/_edit_form.html.erb +13 -0
- data/app/views/spree/admin/addresses/_new_form.html.erb +22 -0
- data/app/views/spree/admin/addresses/create.turbo_stream.erb +21 -0
- data/app/views/spree/admin/addresses/edit.html.erb +1 -12
- data/app/views/spree/admin/addresses/new.html.erb +1 -16
- data/app/views/spree/admin/addresses/update.turbo_stream.erb +26 -0
- data/app/views/spree/admin/tables/_table.html.erb +2 -1
- metadata +9 -7
- data/app/views/spree/admin/shared/_navigation.html.erb +0 -3
- data/app/views/spree/admin/shared/_navigation_item.html.erb +0 -60
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f53aab5bf5de0f40206a80c2a2375cc915973139dec1a0ca669a36f4d98a6469
|
|
4
|
+
data.tar.gz: c3c5c6babf054c33dc7027464c9c38bc5e27eb1fcb41d7ff4891a223291dcde0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30e6161df15f8ba37bfe8b41c7920f63352f344cf7176941a44ce0d43952347ac22aca27d2ddb9209e6423bebb5f089b0b9c9cf51238752ff25552e9ca8440f6
|
|
7
|
+
data.tar.gz: 6a14594a4adf0b59a58f0dcae7607e0e65bc945bd99134895889ba312e26a56702712f25f148879b48d250d2edb27c026f89d9ad2b3824a6aac50930852d9c77
|
|
@@ -15,14 +15,8 @@ module Spree
|
|
|
15
15
|
|
|
16
16
|
@address = @object = result.value
|
|
17
17
|
|
|
18
|
-
if result.success?
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
flash[:success] = flash_message_for(@address, :successfully_created)
|
|
22
|
-
redirect_to location_after_save, status: :see_other
|
|
23
|
-
else
|
|
24
|
-
render action: :edit, status: :unprocessable_entity
|
|
25
|
-
end
|
|
18
|
+
set_current_store if result.success?
|
|
19
|
+
flash.now[:success] = flash_message_for(@address, :successfully_created) if result.success?
|
|
26
20
|
end
|
|
27
21
|
|
|
28
22
|
def update
|
|
@@ -37,14 +31,8 @@ module Spree
|
|
|
37
31
|
|
|
38
32
|
@address = @object = result.value
|
|
39
33
|
|
|
40
|
-
if result.success?
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
flash[:success] = flash_message_for(@address, :successfully_updated)
|
|
44
|
-
redirect_to location_after_save, status: :see_other
|
|
45
|
-
else
|
|
46
|
-
render action: :edit, status: :unprocessable_entity
|
|
47
|
-
end
|
|
34
|
+
set_current_store if result.success?
|
|
35
|
+
flash.now[:success] = flash_message_for(@address, :successfully_updated) if result.success?
|
|
48
36
|
end
|
|
49
37
|
|
|
50
38
|
private
|
|
@@ -27,6 +27,11 @@ module Spree
|
|
|
27
27
|
target = object || @object
|
|
28
28
|
spree.admin_policy_url(target&.id, options)
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
def edit_object_url(object = nil, options = {})
|
|
32
|
+
target = object || @object
|
|
33
|
+
spree.edit_admin_policy_url(target&.id, options)
|
|
34
|
+
end
|
|
30
35
|
end
|
|
31
36
|
end
|
|
32
37
|
end
|
|
@@ -323,10 +323,7 @@ module Spree
|
|
|
323
323
|
items = navigation_items(context)
|
|
324
324
|
return '' if items.empty?
|
|
325
325
|
|
|
326
|
-
|
|
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="
|
|
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" %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%= turbo_frame_tag "edit_address_#{params[:type]}" do %>
|
|
2
|
+
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @address } %>
|
|
3
|
+
|
|
4
|
+
<%= form_for [:admin, @address], as: :address, url: spree.admin_address_path(@address), method: :put do |f| %>
|
|
5
|
+
<%= render 'spree/addresses/form',
|
|
6
|
+
address_name: 'address',
|
|
7
|
+
address_form: f,
|
|
8
|
+
address_type: 'shipping',
|
|
9
|
+
address: @address %>
|
|
10
|
+
<%= hidden_field_tag :type, params[:type] %>
|
|
11
|
+
<%= render 'spree/admin/shared/edit_resource_links', f: f %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<% frame_id = local_assigns.fetch(:frame_id, "new_address_#{params[:type]}") %>
|
|
2
|
+
<% user_id_value = local_assigns.fetch(:user_id, params[:user_id]) %>
|
|
3
|
+
<% default_shipping_value = local_assigns.fetch(:default_shipping, params[:default_shipping]) %>
|
|
4
|
+
<% default_billing_value = local_assigns.fetch(:default_billing, params[:default_billing]) %>
|
|
5
|
+
|
|
6
|
+
<%= turbo_frame_tag frame_id do %>
|
|
7
|
+
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @address } %>
|
|
8
|
+
|
|
9
|
+
<%= form_for [:admin, @address], as: :address, url: spree.admin_addresses_path, method: :post do |f| %>
|
|
10
|
+
<%= render 'spree/addresses/form',
|
|
11
|
+
address_name: 'address',
|
|
12
|
+
address_form: f,
|
|
13
|
+
address_type: 'shipping',
|
|
14
|
+
address: @address %>
|
|
15
|
+
<%= hidden_field_tag :user_id, user_id_value %>
|
|
16
|
+
<%= hidden_field_tag :default_shipping, default_shipping_value %>
|
|
17
|
+
<%= hidden_field_tag :default_billing, default_billing_value %>
|
|
18
|
+
<%= hidden_field_tag :type, params[:type] %>
|
|
19
|
+
|
|
20
|
+
<%= render 'spree/admin/shared/new_resource_links', f: f %>
|
|
21
|
+
<% end %>
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% @user = @address.user %>
|
|
2
|
+
|
|
3
|
+
<% if @address.valid? %>
|
|
4
|
+
<%= turbo_render_alerts %>
|
|
5
|
+
|
|
6
|
+
<% if params[:default_shipping].to_b %>
|
|
7
|
+
<%= turbo_stream.replace 'user-ship-address' do %>
|
|
8
|
+
<%= render 'spree/admin/users/shipping' %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<% if params[:default_billing].to_b %>
|
|
13
|
+
<%= turbo_stream.replace 'user-bill-address' do %>
|
|
14
|
+
<%= render 'spree/admin/users/billing' %>
|
|
15
|
+
<% end %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% else %>
|
|
18
|
+
<%= turbo_stream.replace "new_address_#{params[:type]}" do %>
|
|
19
|
+
<%= render 'spree/admin/addresses/new_form' %>
|
|
20
|
+
<% end %>
|
|
21
|
+
<% end %>
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
<%=
|
|
2
|
-
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @address } %>
|
|
3
|
-
|
|
4
|
-
<%= form_for [:admin, @address], as: :address, url: spree.admin_address_path(@address), method: :put, data: { turbo_frame: '_top' } do |f| %>
|
|
5
|
-
<%= render 'spree/addresses/form',
|
|
6
|
-
address_name: 'address',
|
|
7
|
-
address_form: f,
|
|
8
|
-
address_type: 'shipping',
|
|
9
|
-
address: @address %>
|
|
10
|
-
<%= render 'spree/admin/shared/edit_resource_links', f: f, turbo_frame: '_top' %>
|
|
11
|
-
<% end %>
|
|
12
|
-
<% end %>
|
|
1
|
+
<%= render 'spree/admin/addresses/edit_form' %>
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
<%=
|
|
2
|
-
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @address } %>
|
|
3
|
-
|
|
4
|
-
<%= form_for [:admin, @address], as: :address, url: spree.admin_addresses_path, method: :post, data: { turbo_frame: '_top' } do |f| %>
|
|
5
|
-
<%= render 'spree/addresses/form',
|
|
6
|
-
address_name: 'address',
|
|
7
|
-
address_form: f,
|
|
8
|
-
address_type: 'shipping',
|
|
9
|
-
address: @address %>
|
|
10
|
-
<%= hidden_field_tag :user_id, params[:user_id] %>
|
|
11
|
-
<%= hidden_field_tag :default_shipping, params[:default_shipping] %>
|
|
12
|
-
<%= hidden_field_tag :default_billing, params[:default_billing] %>
|
|
13
|
-
|
|
14
|
-
<%= render 'spree/admin/shared/new_resource_links', f: f %>
|
|
15
|
-
<% end %>
|
|
16
|
-
<% end %>
|
|
1
|
+
<%= render 'spree/admin/addresses/new_form' %>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<% @user = @address.user %>
|
|
2
|
+
|
|
3
|
+
<% if @address.valid? %>
|
|
4
|
+
<%= turbo_render_alerts %>
|
|
5
|
+
|
|
6
|
+
<%= turbo_stream.replace 'user-ship-address' do %>
|
|
7
|
+
<%= render 'spree/admin/users/shipping' %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<%= turbo_stream.replace 'user-bill-address' do %>
|
|
11
|
+
<%= render 'spree/admin/users/billing' %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% else %>
|
|
14
|
+
<%# Update service may return a new address without ID when original isn't editable %>
|
|
15
|
+
<%= turbo_stream.replace "edit_address_#{params[:type]}" do %>
|
|
16
|
+
<% if @address.persisted? %>
|
|
17
|
+
<%= render 'spree/admin/addresses/edit_form' %>
|
|
18
|
+
<% else %>
|
|
19
|
+
<%= render 'spree/admin/addresses/new_form',
|
|
20
|
+
frame_id: "edit_address_#{params[:type]}",
|
|
21
|
+
user_id: @user&.id,
|
|
22
|
+
default_shipping: params[:type] == 'shipping',
|
|
23
|
+
default_billing: params[:type] == 'billing' %>
|
|
24
|
+
<% end %>
|
|
25
|
+
<% end %>
|
|
26
|
+
<% end %>
|
|
@@ -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
|
-
|
|
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.
|
|
4
|
+
version: 5.3.3
|
|
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.
|
|
18
|
+
version: 5.3.3
|
|
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.
|
|
25
|
+
version: 5.3.3
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: active_link_to
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -506,8 +506,12 @@ files:
|
|
|
506
506
|
- app/views/layouts/spree/admin_settings.html.erb
|
|
507
507
|
- app/views/layouts/spree/admin_wizard.html.erb
|
|
508
508
|
- app/views/layouts/spree/minimal.html.erb
|
|
509
|
+
- app/views/spree/admin/addresses/_edit_form.html.erb
|
|
510
|
+
- app/views/spree/admin/addresses/_new_form.html.erb
|
|
511
|
+
- app/views/spree/admin/addresses/create.turbo_stream.erb
|
|
509
512
|
- app/views/spree/admin/addresses/edit.html.erb
|
|
510
513
|
- app/views/spree/admin/addresses/new.html.erb
|
|
514
|
+
- app/views/spree/admin/addresses/update.turbo_stream.erb
|
|
511
515
|
- app/views/spree/admin/admin_users/_admin_user.html.erb
|
|
512
516
|
- app/views/spree/admin/admin_users/_audit_log.html.erb
|
|
513
517
|
- app/views/spree/admin/admin_users/_form.html.erb
|
|
@@ -937,8 +941,6 @@ files:
|
|
|
937
941
|
- app/views/spree/admin/shared/_media_form.html.erb
|
|
938
942
|
- app/views/spree/admin/shared/_modal.html.erb
|
|
939
943
|
- 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
944
|
- app/views/spree/admin/shared/_new_item_dropdown.html.erb
|
|
943
945
|
- app/views/spree/admin/shared/_new_resource.html.erb
|
|
944
946
|
- app/views/spree/admin/shared/_new_resource_links.html.erb
|
|
@@ -1255,9 +1257,9 @@ licenses:
|
|
|
1255
1257
|
- AGPL-3.0-or-later
|
|
1256
1258
|
metadata:
|
|
1257
1259
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
1258
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.
|
|
1260
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.3
|
|
1259
1261
|
documentation_uri: https://docs.spreecommerce.org/
|
|
1260
|
-
source_code_uri: https://github.com/spree/spree/tree/v5.3.
|
|
1262
|
+
source_code_uri: https://github.com/spree/spree/tree/v5.3.3
|
|
1261
1263
|
rdoc_options: []
|
|
1262
1264
|
require_paths:
|
|
1263
1265
|
- lib
|
|
@@ -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 %>
|