Skip to content

Commit

Permalink
Fixed file directory on close
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaucht committed Aug 12, 2020
1 parent 1d2c02c commit 60a545f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions build/media_source/com_media/js/edit-images.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,7 @@ Joomla.MediaManager = Joomla.MediaManager || {};

forUpload[options.csrfToken] = '1';

let fileDirectory = uploadPath.split('/');
fileDirectory.pop();
fileDirectory = fileDirectory.join('/');

// If we are in root add a backslash
if (fileDirectory.endsWith(':')) {
fileDirectory = `${fileDirectory}/`;
}
const fileDirectory = Joomla.MediaManager.GetDirectory(uploadPath);
switch (task) {
case 'apply':
Joomla.UploadFile.exec(name, JSON.stringify(forUpload), uploadPath, url, type);
Expand Down Expand Up @@ -196,6 +189,16 @@ Joomla.MediaManager = Joomla.MediaManager || {};
// The upload object
Joomla.UploadFile = {};

Joomla.MediaManager.GetDirectory = (path) => {
let fileDirectory = path.split('/');
fileDirectory.pop();
fileDirectory = fileDirectory.join('/');
// If we are in root add a backslash
if (fileDirectory.endsWith(':')) {
fileDirectory = `${fileDirectory}/`;
}
return fileDirectory;
}
/**
* @TODO Extend Joomla.request and drop this code!!!!
*/
Expand All @@ -218,6 +221,8 @@ Joomla.MediaManager = Joomla.MediaManager || {};
if (resp.success === true) {
Joomla.MediaManager.Edit.removeProgressBar();
if (resp.data.isClose) {
const fileDirectory = Joomla.MediaManager.GetDirectory(resp.data.file.path);
const pathName = window.location.pathname.replace(/&view=file.*/g, '');
window.location = `${pathName}?option=com_media&path=${fileDirectory}`;
}
if (resp.data.isCopy) {
Expand Down

0 comments on commit 60a545f

Please sign in to comment.