Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Template tag for dashboard sorting headers
Anna Siwik58090ba5c762
diff --git a/saleor/core/templatetags/shop.py b/saleor/core/templatetags/shop.pyindex c14d1bafe4..56fe2c3883 100644--- a/saleor/core/templatetags/shop.py+++ b/saleor/core/templatetags/shop.py@@ -16,11 +16,10 @@ def get_sort_by_url(context, field, descending=False):return '%s?%s' % (request.path, urlencode(request_get))[email protected]_tag(takes_context=True)-def get_sort_by_toggle(context, field):- '''- This templatetag returns data needed for sorting querysets by links toggle.- '''[email protected]_tag(+ 'dashboard/includes/_sorting_header.html', takes_context=True)+def render_sorting_header(context, field, label):+ """This template tag renders table sorting header."""request = context['request']request_get = request.GET.copy()sort_by = request_get.get('sort_by')@@ -51,4 +50,4 @@ def get_sort_by_toggle(context, field):request_get['sort_by'] = new_sort_byreturn {'url': '%s?%s' % (request.path, request_get.urlencode()),- 'is_active': is_active, 'sorting_icon': sorting_icon}+ 'is_active': is_active, 'sorting_icon': sorting_icon, 'label': label}diff --git a/templates/dashboard/group/list.html b/templates/dashboard/group/list.htmlindex 58ba11892a..f808901ebb 100644--- a/templates/dashboard/group/list.html+++ b/templates/dashboard/group/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -43,13 +43,8 @@<table class="bordered highlight data-table data-table-description"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Dashboard groups list table header name" %}- </a>- </th>+ {% trans "Name" context "Dashboard groups list table header name" as label %}+ {% render_sorting_header 'name' label %}<th>{% trans "Permissions" context "Dashboard groups list table header permissions" %}</th>diff --git a/templates/dashboard/includes/_sorting_header.html b/templates/dashboard/includes/_sorting_header.htmlnew file mode 100644index 0000000000..0787ac57f2--- /dev/null+++ b/templates/dashboard/includes/_sorting_header.html@@ -0,0 +1,6 @@+<th class="{% if is_active %}active{% endif %}">+ <a href="{{ url }}">+ <svg data-src="{{ sorting_icon }}" />+ {{ label }}+ </a>+</th>