Admin Dashboard Helper Methods
Here you can find a list of helper methods that are available in the Admin Dashboard that you can use in every template.
The list is incomplete.
active_badge
Displays a badge with a color based on the condition.
If the condition is true, it will render
If the condition is false, it will render
You can also pass a custom label to the badge:
Custom text to display in the badge. If not provided, will show “Active”/“Inactive” based on the condition.
active_link_to_with_icon
Same as link_to_with_icon, but it will add the active
class if the current page is the same as the link.
You can also pass a custom active
condition.
currency_select
Available for forms to build a currency select dropdown. Provided via currency_select gem.
Adding data: { controller: 'autocomplete-select' }
will enable the autocomplete feature.
current_currency
Returns the currently selected currency. By default in Admin Dashboard this will be store.default_currency
. This can be changed in the Settings -> Store Defaults
page.
will return
current_store
Returns the current store Spree::Store instance.
current_vendor
Available only in Spree Enterprise Edition.
icon
Displays an icon.
Will render
We use Tabler Icons library for icons.
You can also pass additional options such as:
Add additional CSS classes to the icon
Add additional inline styles to the icon
Set the height of the icon in pixels
will render
local_time
Displays a time in the user’s timezone in a human readable format (based on the browser’s timezone).
Provided by local_time gem.
link_to_with_icon
Creates a link with an icon.
eye
is the icon name.View Order in ERP
is the link text.https://erp.com/orders/#{order.number}
is the link url. For internal links, please usespree.
routes helper, eg.spree.admin_order_path(order)
.btn btn-primary
is the bootstrap class for styling the link
supported_currencies
Returns the list of supported currencies for the current store as an array of strings.
will return
try_spree_current_user
Returns the current user object (class depends on the Spree.admin_user_class
configuration). If the user is not signed in, it will return nil
.
If you want to check if the user is signed in, you can use the following: