nineskeletor/templates/Child/upload.html.twig

80 lines
2.5 KiB
Twig
Raw Normal View History

2023-02-16 17:03:53 +01:00
{% extends 'base.html.twig' %}
{% block encoretags %}
{{ encore_entry_link_tags('dropzone') }}
{% endblock %}
{% block body %}
<h1 class="page-header">
Upload child{% if typeupload!="all" %} = {{ typeupload }}{%endif%}
</h1>
{% if idchild is defined %}
<a href="{{path("app_child_update",{catparent:catparent,idparent:idparent,idchild:idchild})}}" class="btn btn-secondary">Annuler</a>
{% else %}
<a href="{{path("app_child",{catparent:catparent,idparent:idparent})}}" class="btn btn-secondary">Annuler</a>
{% endif %}
<form
action="{{ oneup_uploader_endpoint('child') }}"
class="dropzone"
id="mydropzone"
{%if typeupload=="image" %}
data-acceptedFiles: 'image/*',
{%elseif typeupload=="video" %}
data-acceptedFiles: 'video/*',
data-timeout: 900000,
{%endif%}
{% if idchild is defined %}
data-maxFiles=1
{% else %}
data-maxFiles="0"
{%endif%}
style="margin-top:10px">
</form>
{% endblock %}
{% block localscript %}
{{ encore_entry_script_tags('dropzone') }}
<script>
function dropzoneinit( elmt ) {
var totalFiles = 0;
var completeFiles = 0;
elmt.on("sending", function(file, xhr, formData) {
formData.append("type", "{{ type }}");
formData.append("catparent", "{{ catparent }}");
formData.append("idparent", "{{ idparent }}");
formData.append("idchildtype", "{{ idchildtype }}");
formData.append("typeupload", "{{ typeupload }}");
{% if idchild is defined %}
formData.append("idchild", "{{ idchild }}");
{% else %}
formData.append("idchild", "-99999");
{% endif %}
});
elmt.on("addedfile", function (file) {
totalFiles += 1;
});
elmt.on("removed file", function (file) {
totalFiles -= 1;
});
elmt.on("complete", function (file) {
completeFiles += 1;
if (completeFiles === totalFiles) {
{% if idchild is defined %}
window.location="{{path("app_child_update",{catparent:catparent,idparent:idparent,idchild:idchild})}}";
{% else %}
window.location="{{path("app_child",{catparent:catparent,idparent:idparent})}}";
{% endif %}
}
});
}
function dropzonesuccess( file, response ) {
}
</script>
{% endblock %}