Skip to content

Commit 81fed6d

Browse files
authored
feat(backoffice): improve the organizations_v2 ui (#7623)
* feat: improve the ui * fix: lint * fix: sort by status and column
1 parent e440f3b commit 81fed6d

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

server/polar/backoffice/organizations/endpoints.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,17 @@ async def get(
14251425
hx_target="#modal",
14261426
):
14271427
text("Edit")
1428+
with tag.a(
1429+
classes="btn",
1430+
href=str(
1431+
request.url_for(
1432+
"organizations-v2:detail",
1433+
organization_id=organization.id,
1434+
)
1435+
),
1436+
title="Switch to new view",
1437+
):
1438+
text("View V2")
14281439
with tag.div(classes="grid grid-cols-1 lg:grid-cols-2 gap-4"):
14291440
with description_list.DescriptionList[Organization](
14301441
description_list.DescriptionListAttrItem(

server/polar/backoffice/organizations_v2/views/list_view.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def sortable_header(
7676
current_sort: str,
7777
current_direction: str,
7878
align: str = "left",
79+
status_filter: OrganizationStatus | None = None,
7980
) -> Generator[None]:
8081
"""Render a sortable table header with direction indicator."""
8182
is_active = current_sort == sort_key
@@ -94,11 +95,20 @@ def sortable_header(
9495
"right": "text-right",
9596
}.get(align, "")
9697

98+
# Build hx-vals with status filter if present
99+
hx_vals_dict = {"sort": sort_key, "direction": next_direction}
100+
if status_filter is not None:
101+
hx_vals_dict["status"] = status_filter.value
102+
103+
import json
104+
105+
hx_vals = json.dumps(hx_vals_dict)
106+
97107
with tag.th(
98108
classes=f"cursor-pointer hover:bg-base-300 {align_class}",
99109
**{
100110
"hx-get": str(request.url_for("organizations-v2:list")),
101-
"hx-vals": f'{{"sort": "{sort_key}", "direction": "{next_direction}"}}',
111+
"hx-vals": hx_vals,
102112
"hx-target": "#org-list",
103113
"hx-include": "#filter-form",
104114
},
@@ -508,6 +518,7 @@ def render(
508518
"name",
509519
current_sort,
510520
current_direction,
521+
status_filter=status_filter,
511522
):
512523
pass
513524

@@ -520,6 +531,7 @@ def render(
520531
"country",
521532
current_sort,
522533
current_direction,
534+
status_filter=status_filter,
523535
):
524536
pass
525537

@@ -529,6 +541,7 @@ def render(
529541
"created",
530542
current_sort,
531543
current_direction,
544+
status_filter=status_filter,
532545
):
533546
pass
534547

@@ -539,6 +552,7 @@ def render(
539552
current_sort,
540553
current_direction,
541554
"center",
555+
status_filter=status_filter,
542556
):
543557
pass
544558

@@ -549,6 +563,7 @@ def render(
549563
current_sort,
550564
current_direction,
551565
"center",
566+
status_filter=status_filter,
552567
):
553568
pass
554569

@@ -559,6 +574,7 @@ def render(
559574
current_sort,
560575
current_direction,
561576
"right",
577+
status_filter=status_filter,
562578
):
563579
pass
564580

@@ -587,6 +603,7 @@ def render(
587603
"name",
588604
current_sort,
589605
current_direction,
606+
status_filter=status_filter,
590607
):
591608
pass
592609

@@ -599,6 +616,7 @@ def render(
599616
"country",
600617
current_sort,
601618
current_direction,
619+
status_filter=status_filter,
602620
):
603621
pass
604622

@@ -608,6 +626,7 @@ def render(
608626
"created",
609627
current_sort,
610628
current_direction,
629+
status_filter=status_filter,
611630
):
612631
pass
613632

@@ -618,6 +637,7 @@ def render(
618637
current_sort,
619638
current_direction,
620639
"center",
640+
status_filter=status_filter,
621641
):
622642
pass
623643

@@ -628,6 +648,7 @@ def render(
628648
current_sort,
629649
current_direction,
630650
"center",
651+
status_filter=status_filter,
631652
):
632653
pass
633654

@@ -638,6 +659,7 @@ def render(
638659
current_sort,
639660
current_direction,
640661
"right",
662+
status_filter=status_filter,
641663
):
642664
pass
643665

@@ -716,6 +738,7 @@ def render_table_only(
716738
"name",
717739
current_sort,
718740
current_direction,
741+
status_filter=status_filter,
719742
):
720743
pass
721744

@@ -728,6 +751,7 @@ def render_table_only(
728751
"country",
729752
current_sort,
730753
current_direction,
754+
status_filter=status_filter,
731755
):
732756
pass
733757

@@ -737,6 +761,7 @@ def render_table_only(
737761
"created",
738762
current_sort,
739763
current_direction,
764+
status_filter=status_filter,
740765
):
741766
pass
742767

@@ -747,6 +772,7 @@ def render_table_only(
747772
current_sort,
748773
current_direction,
749774
"center",
775+
status_filter=status_filter,
750776
):
751777
pass
752778

@@ -757,6 +783,7 @@ def render_table_only(
757783
current_sort,
758784
current_direction,
759785
"center",
786+
status_filter=status_filter,
760787
):
761788
pass
762789

@@ -767,6 +794,7 @@ def render_table_only(
767794
current_sort,
768795
current_direction,
769796
"right",
797+
status_filter=status_filter,
770798
):
771799
pass
772800

@@ -795,6 +823,7 @@ def render_table_only(
795823
"name",
796824
current_sort,
797825
current_direction,
826+
status_filter=status_filter,
798827
):
799828
pass
800829

@@ -807,6 +836,7 @@ def render_table_only(
807836
"country",
808837
current_sort,
809838
current_direction,
839+
status_filter=status_filter,
810840
):
811841
pass
812842

@@ -816,6 +846,7 @@ def render_table_only(
816846
"created",
817847
current_sort,
818848
current_direction,
849+
status_filter=status_filter,
819850
):
820851
pass
821852

@@ -826,6 +857,7 @@ def render_table_only(
826857
current_sort,
827858
current_direction,
828859
"center",
860+
status_filter=status_filter,
829861
):
830862
pass
831863

@@ -836,6 +868,7 @@ def render_table_only(
836868
current_sort,
837869
current_direction,
838870
"center",
871+
status_filter=status_filter,
839872
):
840873
pass
841874

@@ -846,6 +879,7 @@ def render_table_only(
846879
current_sort,
847880
current_direction,
848881
"right",
882+
status_filter=status_filter,
849883
):
850884
pass
851885

0 commit comments

Comments
 (0)