From 97359f48fdaa0c302e51cab1ddbedff9afbf3e84 Mon Sep 17 00:00:00 2001 From: Bryan Larson Date: Tue, 12 Sep 2023 12:34:22 -0600 Subject: [PATCH] HYP-300 - Improved and fixed UI updates when completing a sign-up step --- app/projects/api.py | 5 +- app/projects/views.py | 16 +++++-- app/templates/projects/project.html | 23 +++++++-- .../projects/signup/request-access.html | 47 ++++++++++--------- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/app/projects/api.py b/app/projects/api.py index f3f3dd11..8d6c4257 100644 --- a/app/projects/api.py +++ b/app/projects/api.py @@ -15,6 +15,7 @@ from django.http import QueryDict from django.shortcuts import get_object_or_404 from django.shortcuts import redirect +from django.shortcuts import render from dal import autocomplete from contact.views import email_send @@ -774,7 +775,7 @@ def submit_user_permission_request(request): # Check if there are administrators to notify. if project.project_supervisors is None or project.project_supervisors == "": - return HttpResponse(200) + return render(request, 'projects/signup/request-access.html', {"panel": {"additional_context": {"requested_access": True}}}) # Convert the comma separated string of emails into a list. supervisor_emails = project.project_supervisors.split(",") @@ -798,7 +799,7 @@ def submit_user_permission_request(request): except Exception as e: logger.exception(e) - return HttpResponse(200) + return render(request, 'projects/signup/request-access.html', {"panel": {"additional_context": {"requested_access": True}}}) diff --git a/app/projects/views.py b/app/projects/views.py index 0d0a708b..9e652bc5 100644 --- a/app/projects/views.py +++ b/app/projects/views.py @@ -603,19 +603,27 @@ def setup_panel_request_access(self, context): if not self.project.requires_authorization or self.project.has_teams: return - # This step is never completed, it is usually the last step. - step_status = self.get_step_status('request_access', False) - # If the user does not have a participant record, they have not yet requested access. requested_access = self.participant is not None + # Check for a prior current step which is possible even when this step is complete + # due to rejection of signed agreement forms + prior_current_step = next((s for s in context["setup_panels"] if s.status == SIGNUP_STEP_CURRENT_STATUS ), None) + + # This step is never completed, it is usually the last step. + step_status = self.get_step_status('request_access', requested_access and not prior_current_step) + + # Always show expanded when completed, unless a prior step is current + expanded = requested_access and not prior_current_step + panel = DataProjectSignupPanel( title='Request Access', bootstrap_color='default', template='projects/signup/request-access.html', status=step_status, additional_context={ - 'requested_access': requested_access + 'requested_access': requested_access, + 'expanded': expanded, } ) diff --git a/app/templates/projects/project.html b/app/templates/projects/project.html index 5d4327cd..0c7c5762 100644 --- a/app/templates/projects/project.html +++ b/app/templates/projects/project.html @@ -69,7 +69,7 @@

- {% if panel.status == SIGNUP_STEP_CURRENT_STATUS or panel.status == SIGNUP_STEP_PERMANENT_STATUS %} + {% if panel.status == SIGNUP_STEP_CURRENT_STATUS or panel.status == SIGNUP_STEP_PERMANENT_STATUS or panel.additional_context.expanded %}
{% include panel.template %}
@@ -235,8 +235,15 @@ "); + + // Reset button and update to indicate success + $(submit_button).button("reset"); + setTimeout(function() { + // Do this in a timeout since Bootstrap's 'button' function breaks jQuery methods in same iteration + $(submit_button).html("Form Saved  ").prop("disabled", "disabled").toggleClass("btn-primary btn-success"); + }, 0); // Refresh the page so the user does not see this button again setTimeout(function(){ @@ -299,8 +306,16 @@ "); + + // Notify + notify('success', "Agreement form submitted!", 'thumbs-up'); + + // Reset button and update to indicate success + $(submit_button).button("reset"); + setTimeout(function() { + // Do this in a timeout since Bootstrap's 'button' function breaks jQuery methods in same iteration + $(submit_button).html("Form Saved  ").prop("disabled", "disabled").toggleClass("btn-primary btn-success"); + }, 0); // Refresh the page so the user does not see this button again setTimeout(function(){ diff --git a/app/templates/projects/signup/request-access.html b/app/templates/projects/signup/request-access.html index 46e81010..eca58dd5 100644 --- a/app/templates/projects/signup/request-access.html +++ b/app/templates/projects/signup/request-access.html @@ -3,7 +3,10 @@ {% if panel.additional_context.requested_access %} Your request is being reviewed. Please use the 'Contact Us' link for any further questions. {% else %} -
+
@@ -16,9 +19,9 @@
- - -
+
@@ -28,22 +31,22 @@ {% endif %}