From d118ab71e6aa4f300ba6e42663d13a63a2323122 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 21 Dec 2020 21:37:10 +0000 Subject: files_ng: implement directory and bulk file download --- view/js/mod_cloud.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index cbd9c2a08..736dec471 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -56,6 +56,24 @@ $(document).ready(function () { close_and_deactivate_all_panels(); }); + $('.cloud-tool-dir-download-btn').on('click', function (e) { + e.preventDefault(); + close_and_deactivate_all_panels() + + let id = $(this).data('id'); + if(! id) { + return false; + } + + close_and_deactivate_all_panels(); + + // some trickery to trigger download action via ajax + let form = $('
').attr('action', 'attach').attr('method', 'post'); + form.append($("").attr('type', 'hidden').attr('name', 'channel_id').attr('value', channelId)); + form.append($("").attr('type', 'hidden').attr('name', 'attach_ids[]').attr('value', id)); + form.appendTo('body').submit().remove(); + }); + $('.cloud-tool-delete-btn').on('click', function (e) { e.preventDefault(); let id = $(this).data('id'); @@ -255,14 +273,37 @@ $(document).ready(function () { $('#cloud-multi-tool-submit, #cloud-multi-tool-categories').show(); }); + $('#cloud-multi-tool-download-btn').on('click', function (e) { + e.preventDefault(); + + let post_data = $('.cloud-multi-tool-checkbox:checked'); + + if(! post_data.length) { + return false; + } + + close_and_deactivate_all_panels(); + + // some trickery to trigger download action via ajax + var form = $('
').attr('action', 'attach').attr('method', 'post'); + form.append($("").attr('type', 'hidden').attr('name', 'channel_id').attr('value', channelId)); + post_data.each(function () { + form.append($("").attr('type', 'hidden').attr('name', 'attach_ids[]').attr('value', this.value)); + }); + form.appendTo('body').submit().remove(); + }); + $('#cloud-multi-tool-delete-btn').on('click', function (e) { e.preventDefault(); - let post_data = $('.cloud-multi-tool-checkbox').serializeArray(); + close_and_deactivate_all_panels(); + + let post_data = $('.cloud-multi-tool-checkbox:checked').serializeArray(); if(! post_data.length) { return false; } + let confirm = confirmDelete(); if (confirm) { $('body').css('cursor', 'wait'); -- cgit v1.2.3