diff --git a/public/js/script.js b/public/js/script.js index fd527de4..bd681f0e 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -266,6 +266,9 @@ function performLfmRequest(url, parameter, type) { }); } + $('#notify').modal('hide'); + $('#dialog').modal('hide'); + return $.ajax({ type: 'GET', beforeSend: function(request) { @@ -284,7 +287,7 @@ function performLfmRequest(url, parameter, type) { } function displayErrorResponse(jqXHR) { - var message = JSON.parse(jqXHR.responseText) + var message = JSON.parse(jqXHR.responseText) ?? '' if (Array.isArray(message)) { message = message.join('
') } @@ -799,13 +802,17 @@ function notImp() { } function notify(body) { + $('#notify').find('.btn-primary').off('click').hide(); $('#notify').modal('show').find('.modal-body').html(body); + if (!$('#notify').hasClass('show')) { + $('#notify').modal('show'); + } } function confirm(body, callback) { - $('#confirm').find('.btn-primary').toggle(callback !== undefined); - $('#confirm').find('.btn-primary').click(callback); - $('#confirm').modal('show').find('.modal-body').html(body); + $('#notify').find('.btn-primary').toggle(callback !== undefined); + $('#notify').find('.btn-primary').on('click', callback); + $('#notify').modal('show').find('.modal-body').html(body); } function dialog(title, value, callback) { @@ -813,7 +820,7 @@ function dialog(title, value, callback) { $('#dialog').on('shown.bs.modal', function () { $('#dialog').find('input').focus(); }); - $('#dialog').find('.btn-primary').unbind().click(function (e) { + $('#dialog').find('.btn-primary').off('click').on('click', function (e) { callback($('#dialog').find('input').val()); }); $('#dialog').modal('show').find('.modal-title').text(title); diff --git a/src/Controllers/DeleteController.php b/src/Controllers/DeleteController.php index ad0e4882..54b6c4af 100644 --- a/src/Controllers/DeleteController.php +++ b/src/Controllers/DeleteController.php @@ -50,7 +50,7 @@ public function getDelete() } if ($this->lfm->setName($name_to_delete)->isDirectory()) { - if (! $this->lfm->setName($name_to_delete)->directoryIsEmpty()) { + if ($this->config->get('lfm.allow_delete_folder') === false && !$this->lfm->setName($name_to_delete)->directoryIsEmpty()) { array_push($errors, parent::error('delete-folder')); continue; } diff --git a/src/config/lfm.php b/src/config/lfm.php index 70e7fd3f..28b6d687 100644 --- a/src/config/lfm.php +++ b/src/config/lfm.php @@ -36,6 +36,7 @@ 'private_folder_name' => UniSharp\LaravelFilemanager\Handlers\ConfigHandler::class, 'allow_shared_folder' => true, + 'allow_delete_folder' => true, 'shared_folder_name' => 'shares', diff --git a/src/views/index.blade.php b/src/views/index.blade.php index dbcb83b0..36187934 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -107,7 +107,7 @@
-