diff --git a/Modules/Media/Assets/js/components/MediaList.vue b/Modules/Media/Assets/js/components/MediaList.vue index 355fc693b..2b384adf9 100644 --- a/Modules/Media/Assets/js/components/MediaList.vue +++ b/Modules/Media/Assets/js/components/MediaList.vue @@ -316,9 +316,9 @@ this.tableIsLoading = true; this.queryServer({ folder_id: eventData.data.folder_id }); }); - this.$events.listen('mediaWasUpdated', (eventData) => { + this.$events.listen('mediaWasMoved', (eventData) => { this.tableIsLoading = true; - this.queryServer(); + this.queryServer({ folder_id: eventData.data.folder_id }); }); }, }; diff --git a/Modules/Media/Assets/js/components/MoveMediaDialog.vue b/Modules/Media/Assets/js/components/MoveMediaDialog.vue index cc4b58994..794b0bfd2 100644 --- a/Modules/Media/Assets/js/components/MoveMediaDialog.vue +++ b/Modules/Media/Assets/js/components/MoveMediaDialog.vue @@ -58,7 +58,7 @@ message: response.data.message, }); this.dialogFormVisible = false; - this.$events.emit('mediaWasUpdated', response); + this.$events.emit('mediaWasMoved', response); }); }, closeDialog() { diff --git a/Modules/Media/Http/Controllers/Api/MoveMediaController.php b/Modules/Media/Http/Controllers/Api/MoveMediaController.php index 2d4b19a0d..3bcbc9580 100644 --- a/Modules/Media/Http/Controllers/Api/MoveMediaController.php +++ b/Modules/Media/Http/Controllers/Api/MoveMediaController.php @@ -27,15 +27,15 @@ public function __construct(FileRepository $file, FolderRepository $folder) public function __invoke(Request $request) { + $destination = $this->folder->findFolder($request->get('destinationFolder')); + if ($destination === null) { + $destination = $this->makeRootFolder(); + } + foreach ($request->get('files') as $file) { $file = $this->file->find($file['id']); if ($file->is_folder === false) { - $destination = $this->folder->findFolder($request->get('destinationFolder')); - if ($destination === null) { - $destination = $this->makeRootFolder(); - } - $this->file->move($file, $destination); } } @@ -43,6 +43,7 @@ public function __invoke(Request $request) return response()->json([ 'errors' => false, 'message' => 'Files moved successfully', + 'folder_id' => $destination->id, ]); } diff --git a/public/js/app.js b/public/js/app.js index da1b1f359..a52434781 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -103121,9 +103121,9 @@ exports.default = { _this4.tableIsLoading = true; _this4.queryServer({ folder_id: eventData.data.folder_id }); }); - this.$events.listen('mediaWasUpdated', function (eventData) { + this.$events.listen('mediaWasMoved', function (eventData) { _this4.tableIsLoading = true; - _this4.queryServer(); + _this4.queryServer({ folder_id: eventData.data.folder_id }); }); } }; // @@ -104230,7 +104230,7 @@ exports.default = { message: response.data.message }); _this.dialogFormVisible = false; - _this.$events.emit('mediaWasUpdated', response); + _this.$events.emit('mediaWasMoved', response); }); }, closeDialog: function closeDialog() {