From 2247ac94c892812cceb6e259942059e4c60b593e Mon Sep 17 00:00:00 2001
From: Wes Appler <145372368+wes-otf@users.noreply.github.com>
Date: Fri, 12 Apr 2024 04:27:54 -0400
Subject: [PATCH] Make the open rounds beta filter the default (#3864)

Fixes #3857. Swaps the `Open` & `Closed` tabs in the beta round filter.
This also ensures that the closed tab will be selected if there are no
open rounds.
---
 .../templates/funds/includes/round-block.html |  4 ++--
 .../templates/submissions/submenu/rounds.html | 20 +++++++++++--------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/hypha/apply/funds/templates/funds/includes/round-block.html b/hypha/apply/funds/templates/funds/includes/round-block.html
index 3066e659a..318e7d2bb 100644
--- a/hypha/apply/funds/templates/funds/includes/round-block.html
+++ b/hypha/apply/funds/templates/funds/includes/round-block.html
@@ -1,7 +1,7 @@
 {% load i18n %}
 <div class="wrapper wrapper--bottom-space"
-     x-data="{ activeTab: 'closed-rounds' }"
-     x-init="activeTab = window.location.hash && ['#open-rounds', '#closed-rounds'].includes(window.location.hash) ? window.location.hash.substring(1) : 'closed-rounds'"
+     x-data="{ activeTab: 'open-rounds' }"
+     x-init="activeTab = window.location.hash && ['#open-rounds', '#closed-rounds'].includes(window.location.hash) ? window.location.hash.substring(1) : activeTab"
 >
     <section class="section section--with-options">
         <h4 class="heading heading--normal heading--no-margin">{{ title }}</a></h4>
diff --git a/hypha/apply/funds/templates/submissions/submenu/rounds.html b/hypha/apply/funds/templates/submissions/submenu/rounds.html
index 0f63fdcb6..22924b8e4 100644
--- a/hypha/apply/funds/templates/submissions/submenu/rounds.html
+++ b/hypha/apply/funds/templates/submissions/submenu/rounds.html
@@ -17,23 +17,27 @@
 
         <div
             role="tablist"
-            x-data="{tab: 'closed_rounds'}"
+            {% if open_rounds %}
+                x-data="{tab: 'open_rounds'}"
+            {% else %}
+                x-data="{tab: 'closed_rounds'}"
+            {% endif %}
         >
             <nav class="flex px-3 pt-2" style="box-shadow: inset 0 -1px 0 #e5e7eb">
 
-                {% if closed_rounds %}
-                    <span @click="tab = 'closed_rounds'"
-                          role="tab"
-                          :class="{ 'border-x border-t border-b-transparent': tab === 'closed_rounds' }"
-                          class="text-center bg-white inline-block px-4 py-2 border-b rounded-t-lg cursor-pointer hover:text-gray-900">{% trans "Closed" %}</span>
-                {% endif %}
-
                 {% if open_rounds %}
                     <span @click="tab = 'open_rounds'"
                           role="tab"
                           :class="{ 'border-x border-t border-b-transparent': tab === 'open_rounds' }"
                           class="text-center bg-white inline-block px-4 py-2 border-b rounded-t-lg round cursor-pointer hover:text-gray-900">{% trans "Open" %}</span>
                 {% endif %}
+
+                {% if closed_rounds %}
+                    <span @click="tab = 'closed_rounds'"
+                          role="tab"
+                          :class="{ 'border-x border-t border-b-transparent': tab === 'closed_rounds' }"
+                          class="text-center bg-white inline-block px-4 py-2 border-b rounded-t-lg cursor-pointer hover:text-gray-900">{% trans "Closed" %}</span>
+                {% endif %}
             </nav>
 
             <div data-filter-list>
-- 
GitLab