Add compact searchable consultant client list
This commit is contained in:
@@ -27,6 +27,7 @@ from app.modules.consultants.service import (
|
||||
approve_managed_client_conversion,
|
||||
consultant_can_add_managed_client,
|
||||
consultant_dashboard_payload,
|
||||
consultant_linked_clients_page,
|
||||
create_consultant_service_request,
|
||||
create_or_update_consultant,
|
||||
create_or_update_managed_client,
|
||||
@@ -1349,6 +1350,12 @@ def _consultant_empty_payload() -> dict:
|
||||
return {
|
||||
"links": [],
|
||||
"active_links": [],
|
||||
"linked_clients_page": {
|
||||
"rows": [],
|
||||
"groups": [],
|
||||
"meta": {"total": 0, "page": 1, "per_page": 25, "pages": 1},
|
||||
"filters": {"q": "", "client_group_id": None, "status": "active", "sort_by": "client_name", "sort_order": "asc"},
|
||||
},
|
||||
"comments": [],
|
||||
"recent_firm_messages": [],
|
||||
"recent_consultant_replies": [],
|
||||
@@ -1390,8 +1397,30 @@ def _consultant_empty_payload() -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _build_consultant_portal_payload(db, consultant) -> dict:
|
||||
def _build_consultant_portal_payload(
|
||||
db,
|
||||
consultant,
|
||||
*,
|
||||
linked_q: str = "",
|
||||
linked_group_id: int | None = None,
|
||||
linked_status: str = "active",
|
||||
linked_page: int = 1,
|
||||
linked_per_page: int = 25,
|
||||
linked_sort_by: str = "client_name",
|
||||
linked_sort_order: str = "asc",
|
||||
) -> dict:
|
||||
payload = consultant_dashboard_payload(db, consultant=consultant)
|
||||
payload["linked_clients_page"] = consultant_linked_clients_page(
|
||||
db,
|
||||
consultant=consultant,
|
||||
q=linked_q,
|
||||
client_group_id=linked_group_id,
|
||||
status=linked_status,
|
||||
page=linked_page,
|
||||
per_page=linked_per_page,
|
||||
sort_by=linked_sort_by,
|
||||
sort_order=linked_sort_order,
|
||||
)
|
||||
try:
|
||||
payload["work_board"] = get_consultant_work_board(db, consultant=consultant)
|
||||
except Exception:
|
||||
@@ -1405,7 +1434,17 @@ def _build_consultant_portal_payload(db, consultant) -> dict:
|
||||
|
||||
|
||||
@portal_router.get("/dashboard")
|
||||
def consultant_dashboard(request: Request, tab: str = "overview"):
|
||||
def consultant_dashboard(
|
||||
request: Request,
|
||||
tab: str = "overview",
|
||||
linked_q: str = "",
|
||||
linked_group_id: int | None = None,
|
||||
linked_status: str = "active",
|
||||
linked_page: int = 1,
|
||||
linked_per_page: int = 25,
|
||||
linked_sort_by: str = "client_name",
|
||||
linked_sort_order: str = "asc",
|
||||
):
|
||||
db = CommonSessionLocal()
|
||||
try:
|
||||
user = get_current_user(request, db=db)
|
||||
@@ -1416,7 +1455,17 @@ def consultant_dashboard(request: Request, tab: str = "overview"):
|
||||
tenant_id = int(getattr(user, "tenant_id", 0) or 0)
|
||||
consultant = get_consultant_by_user(db, tenant_id=tenant_id, user_id=user.id)
|
||||
active_tab = tab if tab in CONSULTANT_PORTAL_TABS else "overview"
|
||||
payload = _build_consultant_portal_payload(db, consultant) if consultant else _consultant_empty_payload()
|
||||
payload = _build_consultant_portal_payload(
|
||||
db,
|
||||
consultant,
|
||||
linked_q=linked_q,
|
||||
linked_group_id=linked_group_id,
|
||||
linked_status=linked_status,
|
||||
linked_page=linked_page,
|
||||
linked_per_page=linked_per_page,
|
||||
linked_sort_by=linked_sort_by,
|
||||
linked_sort_order=linked_sort_order,
|
||||
) if consultant else _consultant_empty_payload()
|
||||
return _render(
|
||||
request,
|
||||
"modules/consultants/templates/consultants/portal_dashboard.html",
|
||||
@@ -1432,7 +1481,17 @@ def consultant_dashboard(request: Request, tab: str = "overview"):
|
||||
|
||||
|
||||
@portal_router.get("/dashboard/tab/{tab_name}")
|
||||
def consultant_dashboard_tab(request: Request, tab_name: str):
|
||||
def consultant_dashboard_tab(
|
||||
request: Request,
|
||||
tab_name: str,
|
||||
linked_q: str = "",
|
||||
linked_group_id: int | None = None,
|
||||
linked_status: str = "active",
|
||||
linked_page: int = 1,
|
||||
linked_per_page: int = 25,
|
||||
linked_sort_by: str = "client_name",
|
||||
linked_sort_order: str = "asc",
|
||||
):
|
||||
db = CommonSessionLocal()
|
||||
try:
|
||||
user = get_current_user(request, db=db)
|
||||
@@ -1443,7 +1502,17 @@ def consultant_dashboard_tab(request: Request, tab_name: str):
|
||||
tenant_id = int(getattr(user, "tenant_id", 0) or 0)
|
||||
consultant = get_consultant_by_user(db, tenant_id=tenant_id, user_id=user.id)
|
||||
active_tab = tab_name if tab_name in CONSULTANT_PORTAL_TABS else "overview"
|
||||
payload = _build_consultant_portal_payload(db, consultant) if consultant else _consultant_empty_payload()
|
||||
payload = _build_consultant_portal_payload(
|
||||
db,
|
||||
consultant,
|
||||
linked_q=linked_q,
|
||||
linked_group_id=linked_group_id,
|
||||
linked_status=linked_status,
|
||||
linked_page=linked_page,
|
||||
linked_per_page=linked_per_page,
|
||||
linked_sort_by=linked_sort_by,
|
||||
linked_sort_order=linked_sort_order,
|
||||
) if consultant else _consultant_empty_payload()
|
||||
return _render(
|
||||
request,
|
||||
CONSULTANT_PORTAL_TABS[active_tab],
|
||||
|
||||
Reference in New Issue
Block a user