-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract breadcrumbs helpers to concern
- Loading branch information
Showing
2 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
backend/app/controllers/concerns/spree/admin/breadcrumbs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
module Admin | ||
module Breadcrumbs | ||
def add_breadcrumb(name, path = nil) | ||
@admin_breadcrumbs ||= [] | ||
@admin_breadcrumbs << [name, path] | ||
end | ||
|
||
# Shared breadcrumbs | ||
|
||
def set_user_breadcrumbs | ||
add_breadcrumb plural_resource_name(Spree::LegacyUser), spree.admin_users_path | ||
add_breadcrumb @user.email, edit_admin_user_url(@user) if @user && !@user.new_record? | ||
end | ||
|
||
def set_order_breadcrumbs | ||
add_breadcrumb plural_resource_name(Spree::Order), spree.admin_orders_path | ||
add_breadcrumb "##{@order.number}", spree.edit_admin_order_path(@order) if @order && !@order.new_record? | ||
end | ||
|
||
def set_product_breadcrumbs | ||
add_breadcrumb plural_resource_name(Spree::Product), spree.admin_products_path | ||
add_breadcrumb @product.name, spree.admin_product_path(@product) if @product && !@product.new_record? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters