Skip to content
Snippets Groups Projects
Commit a93470da authored by Benoit Alessandroni's avatar Benoit Alessandroni
Browse files

Improve resource creation and account completion scripts

parent 5d541aaa
No related branches found
No related tags found
1 merge request!168Bugfix/improve resource creation edition script
Pipeline #5964 failed with stage
in 1 hour
......@@ -122,15 +122,14 @@ async function refreshUser(formId, listId) {
if (list) {
let listProxy = await list.component.resource;
let account = await listProxy['account'];
// Refresh du cache sur le User
listProxy.clearCache();
list.dataset.src = list.dataset.src;
let account = await listProxy['account'];
// Refresh du cache sur le account du user
if (account) {
account.clearCache();
}
list.dataset.src = list.dataset.src;
}
});
}
......@@ -667,6 +666,22 @@ function listenToInputChangeOnResourceCreation(originalForm) {
}
}
function listenToInputChangeOnMentorAccountCompletion(originalForm) {
let submitInput = originalForm.querySelectorAll('input[type=submit]')[0];
if (originalForm.querySelectorAll('input[name="first_name"]')[0].value != "" &&
originalForm.querySelectorAll('input[name="last_name"]')[0].value != "" &&
originalForm.querySelectorAll('input[name="mentorProfile.city"]')[0].value != "" &&
originalForm.querySelectorAll('select[name="mentorProfile.languages"]')[0].value != "" &&
originalForm.querySelectorAll('select[name="mentorProfile.fields"]')[0].value != "" &&
originalForm.querySelectorAll('select[name="mentorProfile.country"]')[0].value != "") {
submitInput.disabled = false;
submitInput.classList.remove('disabled');
} else {
submitInput.disabled = true;
submitInput.classList.add('disabled');
}
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXX ON LOAD XXXXXXXXXXXXXXXXXXXXXXX
......@@ -689,36 +704,11 @@ jQuery(document).ready(function($) {
submitInput.classList.add('disabled');
const inputsList = mentorCreationForm.querySelectorAll('input[type="text"]' + ',select');
inputsList.forEach(function(input) {
input.addEventListener('focusout', (() => {
let submitInput = mentorCreationForm.querySelectorAll('input[type=submit]')[0];
if (mentorCreationForm.querySelectorAll('input[name="first_name"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('input[name="last_name"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('input[name="mentorProfile.city"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('select[name="mentorProfile.languages"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('select[name="mentorProfile.fields"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('select[name="mentorProfile.country"]')[0].value != "") {
submitInput.disabled = false;
submitInput.classList.remove('disabled');
} else {
submitInput.disabled = true;
submitInput.classList.add('disabled');
}
}));
input.addEventListener('change', (() => {
let submitInput = mentorCreationForm.querySelectorAll('input[type=submit]')[0];
if (mentorCreationForm.querySelectorAll('input[name="first_name"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('input[name="last_name"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('input[name="mentorProfile.city"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('select[name="mentorProfile.languages"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('select[name="mentorProfile.fields"]')[0].value != "" &&
mentorCreationForm.querySelectorAll('select[name="mentorProfile.country"]')[0].value != "") {
submitInput.disabled = false;
submitInput.classList.remove('disabled');
} else {
submitInput.disabled = true;
submitInput.classList.add('disabled');
}
listenToInputChangeOnMentorAccountCompletion(mentorCreationForm);
}));
input.addEventListener('input', (() => {
listenToInputChangeOnMentorAccountCompletion(mentorCreationForm);
}));
});
});
......@@ -730,10 +720,10 @@ jQuery(document).ready(function($) {
submitInput.classList.add('disabled');
let inputs = mentorResourceCreationForm.querySelectorAll('input[type="text"]' + ',select' + ',textarea');
inputs.forEach(function(input) {
input.addEventListener('focusout', (() => {
input.addEventListener('change', (() => {
listenToInputChangeOnResourceCreation(mentorResourceCreationForm);
}));
input.addEventListener('change', (() => {
input.addEventListener('input', (() => {
listenToInputChangeOnResourceCreation(mentorResourceCreationForm);
}));
});
......@@ -746,7 +736,7 @@ jQuery(document).ready(function($) {
submitInput.classList.add('disabled');
let inputs = mentorResourceEditionForm.querySelectorAll('input[type="text"]' + ',select' + ',textarea');
inputs.forEach(function(input) {
input.addEventListener('focusout', (() => {
input.addEventListener('input', (() => {
listenToInputChangeOnResourceCreation(mentorResourceEditionForm);
}));
input.addEventListener('change', (() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment