diff --git a/slapp/explorer/urls.py b/slapp/explorer/urls.py index a126bce..e8e0428 100644 --- a/slapp/explorer/urls.py +++ b/slapp/explorer/urls.py @@ -10,7 +10,7 @@ path("map/", views.MapGLView.as_view(), name="map"), path("details/", views.details_list, name="details"), path("details/csv/", views.details_csv, name="details-csv"), - path("esm_mode//", views.choose_esm_mode, name="esm_mode"), + path("esm_mode/", views.choose_esm_mode, name="esm_mode"), path("parameters_variation/", views.optimization_parameters, name="parameters_variation"), path("results_variation/", views.optimization_results, name="results_variation"), path("results_robustness/", views.robustness, name="results_robustness"), @@ -18,8 +18,6 @@ path("added_value/", views.added_value, name="added_value"), ] -htmx_urlpatterns = [ - path("search-municipality/", views.search_municipality, name="search-municipality"), -] +htmx_urlpatterns = [] urlpatterns += htmx_urlpatterns diff --git a/slapp/explorer/views.py b/slapp/explorer/views.py index 0265b51..e52c2e3 100644 --- a/slapp/explorer/views.py +++ b/slapp/explorer/views.py @@ -29,11 +29,13 @@ def start_page(request: HttpRequest) -> HttpResponse: next_url = reverse("explorer:map") prev_url = None active_tab = "step_1_start" + sidepanel = False context = { "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/home.html", context) @@ -45,10 +47,12 @@ class MapGLView(TemplateView, views.MapEngineMixin): next_url = reverse_lazy("explorer:details") prev_url = reverse_lazy("explorer:home") active_tab = "step_2_today" + sidepanel = True extra_context = { "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } def get_context_data(self, **kwargs) -> dict[str, Any]: @@ -99,38 +103,22 @@ def details_list(request: HttpRequest) -> HttpResponse: else: municipalities = None - next_url = reverse("explorer:esm_mode", args=[0]) + next_url = reverse("explorer:esm_mode") prev_url = reverse("explorer:map") active_tab = "step_3_details" + sidepanel = True context = { "municipalities": municipalities, "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/details.html", context) -def search_municipality(request: HttpRequest) -> HttpResponse: - """Return list of municipalities for given search text.""" - search_text = request.POST.get("search") - param_string = request.POST.get("param_string") - - first_item = param_string in ["/explorer/details/", "/explorer/parameters_variation/"] - - new_param_string = param_string + "?id=" if first_item else param_string + "&id=" - - # look up all municipalities that contain the text - results = Municipality.objects.filter(name__icontains=search_text) - return render( - request, - "pages/partials/search-results.html", - {"results": results, "new_param_string": new_param_string}, - ) - - def details_csv(request: HttpRequest) -> HttpResponse: """Return details as CSV for given municipalities.""" ids = request.GET.getlist("id") @@ -157,21 +145,31 @@ def details_csv(request: HttpRequest) -> HttpResponse: return response -def choose_esm_mode(request: HttpRequest, robustness: int) -> HttpResponse: +def choose_esm_mode(request: HttpRequest) -> HttpResponse: """Render page for choosing esm mode (robust or variation).""" - next_url = reverse("explorer:parameters_variation") + next_url = None prev_url = reverse("explorer:details") active_tab = "step_4_mode" - - if robustness == 1: + sidepanel = True + render_template = "pages/esm_mode.html" + radio_button_value = int(request.GET.get("esm_choice_radio", 0)) + variation_chosen = 1 + robustness_chosen = 2 + + if radio_button_value == variation_chosen: + next_url = reverse("explorer:parameters_variation") + render_template = "pages/partials/next_wizard.html" + if radio_button_value == robustness_chosen: next_url = reverse("explorer:parameters_robustness") + render_template = "pages/partials/next_wizard.html" context = { "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } - return render(request, "pages/esm_mode.html", context) + return render(request, render_template, context) def optimization_parameters(request: HttpRequest) -> HttpResponse: @@ -186,14 +184,16 @@ def optimization_parameters(request: HttpRequest) -> HttpResponse: municipalities = None next_url = reverse("explorer:results_variation") - prev_url = reverse("explorer:esm_mode", args=[0]) + prev_url = reverse("explorer:esm_mode") active_tab = "step_5_parameters" + sidepanel = True context = { "municipalities": municipalities, "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/parameters_variation.html", context) @@ -237,6 +237,7 @@ def optimization_results(request: HttpRequest) -> HttpResponse: next_url = reverse("explorer:added_value") prev_url = reverse("explorer:parameters_variation") active_tab = "step_6_results" + sidepanel = True request.session["prev_before_added_value"] = "variation" context = { @@ -244,6 +245,7 @@ def optimization_results(request: HttpRequest) -> HttpResponse: "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/results_variation.html", context) @@ -252,13 +254,15 @@ def optimization_results(request: HttpRequest) -> HttpResponse: def robustness_parameters(request: HttpRequest) -> HttpResponse: """Render page for robustness parameters.""" next_url = reverse("explorer:results_robustness") - prev_url = reverse("explorer:esm_mode", args=[1]) + prev_url = reverse("explorer:esm_mode") active_tab = "step_5_parameters" + sidepanel = True context = { "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/parameters_robustness.html", context) @@ -321,6 +325,7 @@ def robustness(request: HttpRequest) -> HttpResponse: next_url = reverse("explorer:added_value") prev_url = reverse("explorer:parameters_robustness") active_tab = "step_6_results" + sidepanel = True request.session["prev_before_added_value"] = "robustness" context = { @@ -328,6 +333,7 @@ def robustness(request: HttpRequest) -> HttpResponse: "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/results_robustness.html", context) @@ -338,6 +344,7 @@ def added_value(request: HttpRequest) -> HttpResponse: next_url = None prev_url = reverse("explorer:results_variation") active_tab = "step_7_added_value" + sidepanel = True if request.session.get("prev_before_added_value") == "robustness": prev_url = reverse("explorer:results_robustness") @@ -346,5 +353,6 @@ def added_value(request: HttpRequest) -> HttpResponse: "next_url": next_url, "prev_url": prev_url, "active_tab": active_tab, + "has_sidepanel": sidepanel, } return render(request, "pages/added_value.html", context) diff --git a/slapp/static/scss/app.scss b/slapp/static/scss/app.scss index 2dab9a2..97dea0c 100644 --- a/slapp/static/scss/app.scss +++ b/slapp/static/scss/app.scss @@ -3,6 +3,7 @@ @import "../vendors/bootstrap/scss/bootstrap"; +@import 'components/navbar.scss'; @import 'components/link_buttons'; @import 'components/sliders'; @import 'components/wizard'; diff --git a/slapp/static/scss/components/_navbar.scss b/slapp/static/scss/components/_navbar.scss new file mode 100644 index 0000000..15b14c1 --- /dev/null +++ b/slapp/static/scss/components/_navbar.scss @@ -0,0 +1,14 @@ +.navbar { + + &__wrap { + @extend .container-fluid; + @extend .w-100; + @extend .position-fixed; + @extend .bg-white; + top: 0px; + height: 3.75rem; + box-shadow: $box-shadow-sm; + z-index: 1000; + } + +} diff --git a/slapp/static/scss/components/_wizard.scss b/slapp/static/scss/components/_wizard.scss index e584d53..7c860c3 100644 --- a/slapp/static/scss/components/_wizard.scss +++ b/slapp/static/scss/components/_wizard.scss @@ -1,15 +1,19 @@ .wizard { - @extend .w-100; - @extend .position-relative; - height: 3.75rem; - box-shadow: $box-shadow-sm; - z-index: 1000; + padding-top: 7.5rem; &__wrap { @extend .container-fluid; @extend .d-flex; @extend .flex-row; @extend .justify-content-between; + @extend .bg-white; + @extend .position-fixed; + @extend .w-100; + + height: 3.75rem; + box-shadow: $box-shadow-sm; + z-index: 1000; + top: 56px; } &__back, diff --git a/slapp/templates/base.html b/slapp/templates/base.html index 9eeb23f..e479542 100644 --- a/slapp/templates/base.html +++ b/slapp/templates/base.html @@ -51,7 +51,7 @@ hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>