diff --git a/amadeus/static/js/topics.js b/amadeus/static/js/topics.js new file mode 100644 index 0000000..9433204 --- /dev/null +++ b/amadeus/static/js/topics.js @@ -0,0 +1,37 @@ +// utilizado para fazer a re-organização dos tópicos +$("#topics-accordion").sortable({ + delay: 100, + distance: 5, + handler: 'i.fa-arrows', + update: function( event, ui ) { + var cont = 1; + var data = []; + + $("#topics-accordion").find('.order_inp').each(function () { + $(this).val(cont++); + + data.push({ + 'topic_id': $(this).parent().find('.id_inp').val(), + 'topic_order': $(this).val() + }); + }); + + data = JSON.stringify(data); + + sendUpdate(data); + }, +}); + +function sendUpdate(data) { + $.ajax({ + url: $('.url_order').val(), + dataType: 'json', + data: {'data': data}, + success: function(response) { + console.log(response); + }, + error: function(response) { + console.log(response); + } + }); +} \ No newline at end of file diff --git a/topics/templates/topics/list.html b/topics/templates/topics/list.html index ff55f77..6f7a543 100644 --- a/topics/templates/topics/list.html +++ b/topics/templates/topics/list.html @@ -4,6 +4,7 @@ {% subject_permissions request.user subject as has_subject_permissions %}