From 872788148ec01ae09491ceb76e93351983aca648 Mon Sep 17 00:00:00 2001 From: TreyWW <73353716+TreyWW@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:13:42 +0000 Subject: [PATCH 1/5] added basic dropdown content --- backend/core/api/base/global_search.py | 67 ++++++++++ backend/core/api/base/urls.py | 7 +- .../base/topbar/_search_dropdown.html | 66 ++++++++++ frontend/templates/base/topbar/_topbar.html | 118 ++++++++++-------- 4 files changed, 202 insertions(+), 56 deletions(-) create mode 100644 backend/core/api/base/global_search.py create mode 100644 frontend/templates/base/topbar/_search_dropdown.html diff --git a/backend/core/api/base/global_search.py b/backend/core/api/base/global_search.py new file mode 100644 index 000000000..d7a4ec7a8 --- /dev/null +++ b/backend/core/api/base/global_search.py @@ -0,0 +1,67 @@ +from django.shortcuts import render +from django.urls import reverse + +from backend.core.types.requests import WebRequest + + +def global_search_endpoint(request: WebRequest): + services = { + "invoices": { + "description": "Simplify your billing for customers", + "icon": "fa-file-invoice", + "url": reverse("finance:invoices:single:dashboard"), + "features": { + "Single": reverse("finance:invoices:single:dashboard"), + "Recurring": reverse("finance:invoices:recurring:dashboard") + } + }, + "clients": { + "description": "Simplified customer information storage", + "icon": "fa-users", + "url": reverse("clients:dashboard"), + "features": { + "View All": reverse("clients:dashboard"), + "Create new customer": reverse("clients:create") + } + } + } + + resources = { + "invoice": [ + { + "name": "#23", + "details": { + "Due Date": "12/11/2024", + "Total Amount": "£1,333" + } + }, + { + "name": "#24", + "details": { + "Due Date": "23/11/2024", + "Total Amount": "£433.20" + } + } + ], + "client": [ + { + "name": "Bob Smith (#21)", + "details": { + } + }, + { + "name": "Jeff Smith (#22)", + "details": { + } + } + ] + } + + return render( + request, "base/topbar/_search_dropdown.html", { + "services": services, + "resources": resources, + "resource_count": sum(len(v) for v in resources.values()), + "search": request.GET.get("search") + } + ) diff --git a/backend/core/api/base/urls.py b/backend/core/api/base/urls.py index 539b0c64d..1bbd57f8a 100644 --- a/backend/core/api/base/urls.py +++ b/backend/core/api/base/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from . import modal, notifications, breadcrumbs +from . import modal, notifications, breadcrumbs, global_search urlpatterns = [ path( @@ -24,6 +24,11 @@ name="notifications delete", ), path("breadcrumbs/refetch/", breadcrumbs.update_breadcrumbs_endpoint, name="breadcrumbs refetch"), + path( + "global_search", + global_search.global_search_endpoint, + name="global_search" + ) ] app_name = "base" diff --git a/frontend/templates/base/topbar/_search_dropdown.html b/frontend/templates/base/topbar/_search_dropdown.html new file mode 100644 index 000000000..faeb6c471 --- /dev/null +++ b/frontend/templates/base/topbar/_search_dropdown.html @@ -0,0 +1,66 @@ +