Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Show new dashboard search results
Jakub Draganekd7139bf3dea1
diff --git a/saleor/search/backends/elasticsearch_dashboard.py b/saleor/search/backends/elasticsearch_dashboard.pyindex 9265abf24b..7d0643ba10 100644--- a/saleor/search/backends/elasticsearch_dashboard.py+++ b/saleor/search/backends/elasticsearch_dashboard.py@@ -15,8 +15,8 @@ def get_search_query(phrase):fields=['user_email', 'status', 'discount_name'], query=phrase)orders = OrderDocument.search().query(order_query).source(False)- return products, users, orders+ return {'products': products, 'users': users, 'orders': orders}def search(phrase):- return [s.to_queryset() for s in get_search_query(phrase)]+ return {k: s.to_queryset() for k, s in get_search_query(phrase).items()}diff --git a/templates/dashboard/search/results.html b/templates/dashboard/search/results.htmlindex 8b52ffcbce..be8a589167 100644--- a/templates/dashboard/search/results.html+++ b/templates/dashboard/search/results.html@@ -33,10 +33,10 @@</div>{% if results %}<ul class="collection list">- {% for result in results %}+ {% for result_type, result_items in results.items %}<li class="collection-item avatar list-item">- {% if result.content_type == 'product_product' %}- {% with product=result %}+ {% if result_type == 'products' %}+ {% for product in result_items %}<a href="{% url 'dashboard:product-detail' pk=product.pk %}"><img src="{% product_first_image product size="60x60" method="crop" %}"srcset="{% product_first_image product size="60x60" method="crop" %} 1x, {% product_first_image product size="120x120" method="crop" %} 2x"@@ -50,9 +50,10 @@</small></p></a>- {% endwith %}- {% elif result.content_type == 'order_order' %}- <a href="{% url 'dashboard:order-details' order_pk=result.pk %}">+ {% endfor %}+ {% elif result_type == 'orders' %}+ {% for order in result_items %}+ <a href="{% url 'dashboard:order-details' order_pk=order.pk %}"><i class="small material-icons circle">payment</i><span class="list-item-name">{% blocktrans trimmed with order_number=result.pk context "Dashboard order" %}@@ -61,22 +62,24 @@</span><p class="list-item-price"><small>- {% blocktrans trimmed context "Dashboard customer" with email=result.user_email %}+ {% blocktrans trimmed context "Dashboard customer" with email=order.user_email %}Customer: {{ email }}{% endblocktrans %}</small><small>- {% blocktrans trimmed with placed=result.created context "Dashboard order info" %}+ {% blocktrans trimmed with placed=order.created context "Dashboard order info" %}Placed on: {{ placed }}{% endblocktrans %}</small></p></a>- {% elif result.content_type == 'userprofile_user' %}- <a href="{% url 'dashboard:customer-details' pk=result.pk %}">+ {% endfor %}+ {% elif result_type == 'users' %}+ {% for user in result_items %}+ <a href="{% url 'dashboard:customer-details' pk=user.pk %}"><i class="small material-icons circle">perm_identity</i><span class="list-item-name">- {% blocktrans trimmed with full_name=result.get_full_name context "Dashboard user" %}+ {% blocktrans trimmed with full_name=user.get_full_name context "Dashboard user" %}User {{ full_name }}{% endblocktrans %}</span>@@ -86,6 +89,7 @@</small></p></a>+ {% endfor %}{% endif %}</li>{% endfor %}