{% extends 'registration/base_admin.html' %} {% block title %}Admin - Documenti{% endblock %} {% block breadcrumb %} Admin Documenti {% endblock %} {% block toolbar %} {% endblock %} {% block content %} {% load app_filter %}
{% csrf_token %}
{% endblock %} {%block script%} $(document).ready(function(){ $('.collapsible').collapsible(); $('#modal1').modal(); $('#modal2').modal(); $('#modal3').modal({"dismissible": false}); $('.datepicker').datepicker(options); {% if error %} M.toast({html: '{{ error_text}}', classes: 'orange'}) {% endif %} {% if task_id %} $('#modal3').modal('open'); update(); document.getElementById('progress_bar').className = "determinate"; {% endif %} lazyload(); }); function resetModal() { $('#modal3').modal('close'); document.getElementById('progress_bar').className = "indeterminate"; document.getElementById("modal_close_button").hidden = true; document.getElementById('progress_text').innerHTML = ""; } $('.chips').chips(); $('#chips_type').chips({ placeholder: 'Tipo', secondaryPlaceholder: '+Altro tipo', autocompleteOptions: { data: { {% for t in types %} '{{t.name}}': null, {% endfor %} }, limit: Infinity, minLength: 0 }, data: [ {% for d in chips_type %} {tag: '{{d}}'}, {% endfor %} ] }); $('#chips_owner').chips({ placeholder: 'Utente', secondaryPlaceholder: '+Altro utente', autocompleteOptions: { data: { {% for user in users %} '{{user.user__username}} ({{user.user__first_name}} {{user.user__last_name}})': null, {% endfor %} }, limit: Infinity, minLength: 0 }, data: [ {% for d in chips_owner %} {tag: '{{d}}'}, {% endfor %} ] }); $('#chips_groups').chips({ placeholder: 'Gruppo', secondaryPlaceholder: '+Altro gruppo', autocompleteOptions: { data: { {% for g in groups %} '{{g}}': null, {% endfor %} }, limit: Infinity, minLength: 0 }, data: [ {% for g in chips_groups %} {tag: '{{g}}'}, {% endfor %} ] }); function update() { var box = document.getElementById('progress_text'); var bar = document.getElementById('progress_bar'); {% if task_id %} var url = '{% url "progress" %}' + '?job=' + '{{task_id}}'; {% else %} var url = '{% url "progress" %}'; {% endif %} fetch(url).then(function(response) { response.json().then(function(data) { if (data[0] == data[1]) { if (data[2]) { bar.className = "indeterminate"; url = '{% url "progress" %}' + '?job=' + '{{task_id}}' + '&download=true'; box.innerHTML = "Il download dovrebbe partire automaticamente. Nel caso non succedesse cliccare il seguente link"; document.getElementById("modal_close_button").hidden = false; document.getElementById('downloadLink').click(); } else { bar.style.width = "100%"; box.innerHTML = "Impacchettamento documenti..."; setTimeout(update, 500, url); } } else { box.innerHTML = data[0] + "/" + data[1]; bar.style.width = data[0]/data[1]*100 + "%"; setTimeout(update, 500, url); } }); }); } function send(id) { var form = document.getElementById('selection') var action = document.getElementById('action') var owner = document.getElementById('owner') var type = document.getElementById('type') var groups = document.getElementById('groups') var chips_owner = M.Chips.getInstance(document.getElementById('chips_owner')); var chips_type = M.Chips.getInstance(document.getElementById('chips_type')); var chips_groups = M.Chips.getInstance(document.getElementById('chips_groups')); var type_array = [] var owner_array = [] var groups_array = [] for (i=0; i < chips_owner.chipsData.length; i++) { owner_array.push(chips_owner.chipsData[i].tag) } for (i=0; i < chips_type.chipsData.length; i++) { type_array.push(chips_type.chipsData[i].tag) } for (i=0; i < chips_groups.chipsData.length; i++) { groups_array.push(chips_groups.chipsData[i].tag) } action.setAttribute('value', id); owner.setAttribute('value', owner_array.join("^|")) type.setAttribute('value', type_array.join("^|")) groups.setAttribute('value', groups_array.join("^|")) form.submit() } $('#select-all').click(function(event) { if(this.checked) { // Iterate each checkbox $('.allselect').each(function() { this.checked = true; }); } else { $('.allselect').each(function() { this.checked = false; }); } }); var options = { showClearBtn: true, container: document.getElementById('main'), yearRange:100, format:'dd mmmm yyyy', i18n: { months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ], monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ], weekdays: [ 'domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato' ], weekdaysShort: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ], weekdaysAbbrev: [ 'D', 'L', 'M', 'M', 'G', 'V', 'S' ], today: 'Oggi', clear: 'Cancella', close: 'Chiudi', cancel: 'Annulla', firstDay: 1, format: 'dddd d mmmm yyyy', formatSubmit: 'yyyy/mm/dd', labelMonthNext: 'Mese successivo', labelMonthPrev: 'Mese precedente', labelMonthSelect: 'Seleziona un mese', labelYearSelect: 'Seleziona un anno' } } {% endblock %}