-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/form-switching' into combined-br…
…anch-vpat01
- Loading branch information
Showing
5 changed files
with
94 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
document.getElementById('form-shoulder').value = document.querySelectorAll('input[name=selshoulder]')[0].value; | ||
|
||
document.querySelectorAll('input[name="selshoulder"]').forEach(radio => { | ||
radio.addEventListener('change', function () { | ||
var profile; | ||
if(this.value.startsWith('ark')) { | ||
profile = 'erc'; | ||
} else { | ||
profile = 'datacite'; | ||
} | ||
|
||
const form = document.querySelector('#create_form'); | ||
const formData = new FormData(form); | ||
formData.set('current_profile', profile); | ||
|
||
// Convert FormData to a query string | ||
const queryString = new URLSearchParams(formData).toString(); | ||
fetch(`/home/ajax_index_form?${queryString}`, { | ||
headers: { | ||
'X-CSRFToken': document.querySelector('input[name="csrfmiddlewaretoken"]').value, | ||
}, | ||
}) | ||
.then(response => response.text()) | ||
.then(data => { | ||
document.getElementById('form-container').innerHTML = data; // Replace form container HTML | ||
document.getElementById('form-shoulder').value = this.value; // needs to happen after the form is replaced | ||
}); | ||
}); | ||
}); |
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,40 @@ | ||
{% load i18n %} | ||
{% load layout_extras %} | ||
<form id="create_form" action="{% url "ui_home.index" %}" method="post" class="form-horizontal" role="form"> | ||
<input type="hidden" name="current_profile" id="current_profile" value="{{current_profile.name}}"/> | ||
<input type="hidden" name="shoulder" id="form-shoulder" value="{{ shoulder }}"/> | ||
{% csrf_token %} | ||
|
||
<div class="fieldset-stacked fieldset__top-border home__fieldset" role="group" aria-labelledby="fieldset__2"> | ||
|
||
<div id="fieldset__2" aria-label="{% trans "Step 2 - Describe the identified object" %}" | ||
class="fieldset-stacked__legend-number-2"> | ||
{% trans "Describe the identified object" %} | ||
</div> | ||
|
||
<div class="row"> | ||
{{ form.non_field_errors }} | ||
{% for field in form %} | ||
<div class="col-md-5 home__text-field"> | ||
<div class="fcontrol__group-stacked{% if field.errors %}--invalid{% endif %}"> | ||
{% if field|fieldtype == "TextInput" %} | ||
<label for="{{ field.id_for_label }}" class="fcontrol__text-label-hidden">{{ field.label }}</label> | ||
{{ field|add_attributes:"fcontrol__text-field-stacked" }} | ||
{% else %} | ||
<label for="{{ field.id_for_label }}" class="fcontrol__select-label-hidden">{{ field.label }}</label> | ||
{{ field|add_attributes:"fcontrol__select" }} | ||
{% endif %} | ||
{% if field.errors %} | ||
<span class="fcontrol__invalid-flag">{% for error in field.errors %}{{ error|escape }}{% endfor %}</span> | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% endfor %} | ||
|
||
<div class="col-md-2 home__create-button"> | ||
<button class="home__button-primary">{% trans "Create" %}</button> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</form> |
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