From 1d3a96aae7ae85f2dc431a2471f19017e92dcaf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Wed, 3 Apr 2024 18:42:56 +0200 Subject: [PATCH] Filter job seeker job applications with HTMX Instead of reloading the page, use HTMX to reload the content. --- itou/static/js/job_applications_filters.js | 6 - .../apply/includes/list_job_applications.html | 25 ++- itou/templates/apply/list_for_job_seeker.html | 72 +------- itou/www/apply/views/list_views.py | 6 +- tests/www/apply/__snapshots__/test_list.ambr | 155 ++++++++++-------- tests/www/apply/test_list.py | 19 +++ 6 files changed, 144 insertions(+), 139 deletions(-) diff --git a/itou/static/js/job_applications_filters.js b/itou/static/js/job_applications_filters.js index 7c775b5cc7..ce0b787a84 100644 --- a/itou/static/js/job_applications_filters.js +++ b/itou/static/js/job_applications_filters.js @@ -1,7 +1 @@ -function submitFiltersForm() { - $("#js-job-applications-filters-form").submit(); -} -$("#js-job-applications-filters-form :input").change(submitFiltersForm); -$("#js-job-applications-filters-form duet-date-picker").on("duetChange", submitFiltersForm); - $("#js-job-applications-filters-apply-button").hide(); diff --git a/itou/templates/apply/includes/list_job_applications.html b/itou/templates/apply/includes/list_job_applications.html index 5e57f62527..7e439b7467 100644 --- a/itou/templates/apply/includes/list_job_applications.html +++ b/itou/templates/apply/includes/list_job_applications.html @@ -12,7 +12,8 @@

{% include "apply/includes/job_applications_export_button.html" %} {% if filters_counter > 0 %} - + Réinitialiser les filtres ({{ filters_counter }}) @@ -24,7 +25,7 @@

- {% if request.user.is_prescriber %} + {% if request.user.is_prescriber or request.user.is_job_seeker %} Aucune candidature pour le moment {% elif request.user.is_employer %} {% if pending_states_job_applications_count == 0 %} @@ -45,6 +46,10 @@

Pour recevoir des candidatures, vérifiez que les postes ouverts
dans votre structure sont bien à jour. + {% elif request.user.is_job_seeker %} + Vous trouverez ici vos candidatures, émises par un prescripteur +
+ ou par vous même. {% endif %}

@@ -58,6 +63,11 @@

Gérer les métiers et recrutements + {% elif request.user.is_job_seeker %} + + + Rechercher un emploi inclusif + {% endif %}

{% if request.user.is_employer %} @@ -66,7 +76,11 @@

{% else %} {% for job_application in job_applications_page %} @@ -100,5 +43,6 @@

{% block script %} {{ block.super }} + {% endblock %} diff --git a/itou/www/apply/views/list_views.py b/itou/www/apply/views/list_views.py index cbd5370b12..4eadf5de7c 100644 --- a/itou/www/apply/views/list_views.py +++ b/itou/www/apply/views/list_views.py @@ -91,7 +91,11 @@ def list_for_job_seeker(request, template_name="apply/list_for_job_seeker.html") "filters_form": filters_form, "filters_counter": filters_counter, } - return render(request, template_name, context) + return render( + request, + "apply/includes/list_job_applications.html" if request.htmx else template_name, + context, + ) @login_required diff --git a/tests/www/apply/__snapshots__/test_list.ambr b/tests/www/apply/__snapshots__/test_list.ambr index dc93808192..e9170e803d 100644 --- a/tests/www/apply/__snapshots__/test_list.ambr +++ b/tests/www/apply/__snapshots__/test_list.ambr @@ -824,24 +824,24 @@ # --- # name: TestListForSiae.test_warns_about_long_awaiting_applications[JOB SEEKER - no warnings] ''' -
-
-

- - 3 résultats - -

-
- - - -
-
+
+
+

+ + 3 résultats + +

+
+ - - - +
+ + + - -
- - + + + - - - - + + + - - - - - + + + + + + - -
+ +
''' # --- # name: TestListForSiae.test_warns_about_long_awaiting_applications[PRESCRIBER - warnings for 2222 and 3333] @@ -1060,6 +1073,7 @@ +