Skip to content

Commit

Permalink
Reload the files in the folder where the move happened
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Oct 8, 2017
1 parent 59e1fbb commit eccaa5d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Modules/Media/Assets/js/components/MediaList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion Modules/Media/Assets/js/components/MoveMediaDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
message: response.data.message,
});
this.dialogFormVisible = false;
this.$events.emit('mediaWasUpdated', response);
this.$events.emit('mediaWasMoved', response);
});
},
closeDialog() {
Expand Down
11 changes: 6 additions & 5 deletions Modules/Media/Http/Controllers/Api/MoveMediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,23 @@ 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);
}
}

return response()->json([
'errors' => false,
'message' => 'Files moved successfully',
'folder_id' => $destination->id,
]);
}

Expand Down
6 changes: 3 additions & 3 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
}
}; //
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit eccaa5d

Please sign in to comment.