forked from ScoDoc/ScoDoc
Merge pull request 'Assiduité : fix bug suppression fichier justif' (#930) from iziram/ScoDoc:hotfix into master
Reviewed-on: ScoDoc/ScoDoc#930
This commit is contained in:
commit
1808e7f5a4
@ -130,7 +130,7 @@ div.submit > input {
|
|||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
{% for filename in filenames %}
|
{% for filename in filenames %}
|
||||||
<li><span data-justif_id="{{justif.id}}" class="suppr_fichier_just"
|
<li><span data-justif_id="{{justif.id}}" data-filename="{{filename}}" class="suppr_fichier_just"
|
||||||
>{{scu.icontag("delete_img", alt="supprimer", title="Supprimer")|safe}}</span>
|
>{{scu.icontag("delete_img", alt="supprimer", title="Supprimer")|safe}}</span>
|
||||||
<a href="{{url_for('apiweb.justif_export',justif_id=justif.justif_id,
|
<a href="{{url_for('apiweb.justif_export',justif_id=justif.justif_id,
|
||||||
filename=filename, scodoc_dept=g.scodoc_dept)}}">{{filename}}</a>
|
filename=filename, scodoc_dept=g.scodoc_dept)}}">{{filename}}</a>
|
||||||
@ -194,27 +194,28 @@ div.submit > input {
|
|||||||
{% include "sco_timepicker.j2" %}
|
{% include "sco_timepicker.j2" %}
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
// Add event listeners to all elements with class 'suppr_fichier_just'
|
// On récupère les boutons de suppression de fichiers
|
||||||
var deleteButtons = document.querySelectorAll('.suppr_fichier_just');
|
const deleteButtons = document.querySelectorAll('.suppr_fichier_just');
|
||||||
|
// On récupère le formulaire
|
||||||
const form = document.getElementById('ajout-justificatif-etud');
|
const form = document.getElementById('ajout-justificatif-etud');
|
||||||
deleteButtons.forEach(function(button) {
|
// Pour chaque bouton, on ajoute une fonction de suppression
|
||||||
button.addEventListener('click', function() {
|
deleteButtons.forEach((btn)=>{
|
||||||
// Get the text content of the next sibling node
|
// Quand le bouton est cliqué, on récupère les infos
|
||||||
var justif_id = this.dataset.justif_id;
|
// et on ajoute un input hidden au formulaire
|
||||||
var fileName = this.nextSibling.nodeValue.trim();
|
// et enfin on supprime l'élement <li> du DOM.
|
||||||
var liElement = this.parentNode; // Get the parent <li> element
|
btn.addEventListener("click",()=>{
|
||||||
|
const filename = btn.getAttribute('data-filename');
|
||||||
|
const justif_id = btn.getAttribute('data-justif_id');
|
||||||
|
|
||||||
// Create a hidden input element to store the file name
|
const input = document.createElement('input');
|
||||||
var input = document.createElement('input');
|
|
||||||
input.type = 'hidden';
|
input.type = 'hidden';
|
||||||
input.name = 'suppr_fichier_just';
|
input.name = 'suppr_fichier_just';
|
||||||
input.value = fileName;
|
input.value = filename;
|
||||||
form.appendChild(input);
|
form.appendChild(input);
|
||||||
|
|
||||||
liElement.remove();
|
btn.parentNode.remove();
|
||||||
|
})
|
||||||
});
|
})
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock scripts %}
|
{% endblock scripts %}
|
||||||
|
Loading…
Reference in New Issue
Block a user