-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement DatasetWizardView with skippable steps and refactor form ha…
…ndling
- Loading branch information
1 parent
2d408aa
commit 63223bd
Showing
13 changed files
with
316 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
.step-wizard-list { | ||
background: #fff; | ||
color: #333; | ||
list-style-type: none; | ||
border-radius: 10px; | ||
display: flex; | ||
padding: 20px 10px; | ||
position: relative; | ||
z-index: 10; | ||
} | ||
|
||
.step-wizard-item { | ||
padding: 0 20px; | ||
flex-basis: 0; | ||
-webkit-box-flex: 1; | ||
-ms-flex-positive: 1; | ||
flex-grow: 1; | ||
max-width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
text-align: center; | ||
min-width: 170px; | ||
position: relative; | ||
} | ||
|
||
.step-wizard-item + .step-wizard-item:after { | ||
content: ""; | ||
position: absolute; | ||
left: 0; | ||
top: 19px; | ||
background: #023452; | ||
width: 100%; | ||
height: 2px; | ||
transform: translateX(-50%); | ||
z-index: -10; | ||
} | ||
|
||
.progress-count { | ||
height: 40px; | ||
width: 40px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 50%; | ||
font-weight: 600; | ||
margin: 0 auto; | ||
position: relative; | ||
z-index: 10; | ||
color: transparent; | ||
} | ||
|
||
.progress-count:after { | ||
content: ""; | ||
height: 40px; | ||
width: 40px; | ||
background: #023452; | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
border-radius: 50%; | ||
z-index: -10; | ||
} | ||
|
||
.progress-count:before { | ||
content: ""; | ||
height: 10px; | ||
width: 20px; | ||
border-left: 3px solid #fff; | ||
border-bottom: 3px solid #fff; | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -60%) rotate(-45deg); | ||
transform-origin: center center; | ||
} | ||
|
||
.progress-label { | ||
font-size: 14px; | ||
font-weight: 600; | ||
margin-top: 10px; | ||
} | ||
|
||
.current-item .progress-count:before, | ||
.current-item ~ .step-wizard-item .progress-count:before { | ||
display: none; | ||
} | ||
|
||
.current-item ~ .step-wizard-item .progress-count:after { | ||
height: 10px; | ||
width: 10px; | ||
} | ||
|
||
.current-item ~ .step-wizard-item .progress-label { | ||
opacity: 0.5; | ||
} | ||
|
||
.current-item .progress-count:after { | ||
background: #fff; | ||
border: 2px solid #023452; | ||
} | ||
|
||
.current-item .progress-count { | ||
color: #023452; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const skipInput = document.getElementById(skipInputID) | ||
const skipButton = document.getElementById('skipButton') | ||
if (!skipInput) { | ||
skipButton.remove(); | ||
} | ||
if (skipButton) { | ||
skipButton.addEventListener('click', function () { | ||
if (skipInput) { | ||
skipInput.value = 'True'; | ||
document.getElementById('wizard-form').submit(); | ||
} | ||
}); | ||
} | ||
$(document).ready(function () { | ||
$('input[type=radio]').change(function () { | ||
const submit_button = $("#buttons") | ||
$("#sub-form").remove(); | ||
const sub_form = $("<div id='sub-form'>"); | ||
submit_button.before(sub_form); | ||
const declaration_type = this.value; | ||
const forms_url = dataDeclarationsAddSubFormUrl + '?declaration_type=' + declaration_type + '&dataset_id=' + dataset_id; | ||
sub_form.load(forms_url, function () { | ||
sub_form.find('select').select2(); | ||
sub_form.bootstrapMaterialDesign(); | ||
} | ||
) | ||
; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{% extends 'layout.html' %} | ||
{% load static %} | ||
{% block head_end %} | ||
{{ wizard.form.media }} | ||
<link rel="stylesheet" href="{% static 'css/dataset_wizard.css' %}"> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="jumbotron mt-5 py-2 pt-4 px-4 w-100"> | ||
<ul class="step-wizard-list"> | ||
{% for step, step_verbose_name in steps_verbose_data %} | ||
<li class="step-wizard-item {% if wizard.steps.current == step %}current-item{% endif %}"> | ||
<span class="progress-count">{{ forloop.counter }}</span> | ||
<span class="progress-label">{{ step_verbose_name }}</span> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
|
||
<div class="col-md-12 card"> | ||
<div class="d-flex justify-content-between mt-3"> | ||
<a href="{% url 'wizard' %}?reset=true" | ||
class="btn btn-outline-secondary btn-raised float-right"> | ||
<i class="material-icons" style="line-height:1.5;">refresh</i> | ||
</a> | ||
<a type="button" id="skipButton" class="btn btn-outline-secondary btn-raised float-left"> | ||
<i class="material-icons" style="line-height:1.5;">skip_next</i> | ||
</a> | ||
</div> | ||
<form action="" method="post" class="form col-md-12 nice-selects" id="wizard-form"> | ||
{% csrf_token %} | ||
<table> | ||
{{ wizard.management_form }} | ||
{% if wizard.form.forms %} | ||
<!-- If wizard.form.forms is not empty or evaluates to True --> | ||
{{ wizard.form.management_form }} | ||
{% for form in wizard.form.forms %} | ||
<!-- Display form information --> | ||
<div class="jumbotron mt-5 p-4"> | ||
<h1 class="display-4">{{ form.Meta.heading }}</h1> | ||
<p class="text-muted">{{ form.Meta.heading_help }}</p> | ||
</div> | ||
{% include '_includes/forms.html' with form=form %} | ||
{% endfor %} | ||
{% else %} | ||
<!-- If wizard.form.forms is empty or evaluates to False --> | ||
<!-- Display form information --> | ||
<div class="jumbotron mt-5 p-4"> | ||
<h1 class="display-4">{{ form.Meta.heading }}</h1> | ||
<p class="text-muted">{{ form.Meta.heading_help }}</p> | ||
</div> | ||
{% include '_includes/forms.html' with form=wizard.form %} | ||
{% endif %} | ||
</table> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script> | ||
const dataDeclarationsAddSubFormUrl = "{% url 'data_declarations_add_sub_form' %}"; | ||
const dataset_id = '{{ dataset_id }}'; | ||
const stepName = '{{ step_name|safe }}'; | ||
const skipInputID = 'id_' + '{{ step_name|safe }}' + '-skip_wizard'; | ||
</script> | ||
<script src="{% static 'js/data_declaration.js' %}"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.