Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect file path when copying directory|file path in media source #16514

Open
Ruslan-Aleev opened this issue Jan 17, 2024 · 1 comment
Open
Labels
bug The issue in the code or project, which should be addressed. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.
Milestone

Comments

@Ruslan-Aleev
Copy link
Collaborator

Ruslan-Aleev commented Jan 17, 2024

Feature request

Summary

If you copy the path through "Copy Directory Path / Copy File Path" in the tree of your file source, then the copied path will be relative to the "basePath" setting of the source.

But the file browser will show the full path, which is confusing.

It's probably worth copying the path with "basePath", which will be more convenient and consistent.

files_path

In my example, the copied file path would be catalog/grid.jpg and the source's "basePath" setting would be assets/images/path/ accordingly.

It’s also worth adding copying the path in the file browser by clicking on the file path with the icon.

Related issue(s)/PR(s)

N\A

@Ruslan-Aleev Ruslan-Aleev added feature Request about implementing a brand new function or possibility. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript. labels Jan 17, 2024
@Ruslan-Aleev
Copy link
Collaborator Author

Ruslan-Aleev commented Jan 17, 2024

This can be solved this way:
In \manager\assets\modext\widgets\system\modx.tree.directory.js change the copyRelativePath function to:

,copyRelativePath: function(item,e) {
    var node = this.cm.activeNode;
    var path = (node.attributes.type == 'file') ? node.attributes.urlAbsolute : ('/' + node.attributes.pathRelative + '/');

    var dummyRelativePathInput = document.createElement("input");
    document.body.appendChild(dummyRelativePathInput);
    dummyRelativePathInput.setAttribute('value', path);

    dummyRelativePathInput.select();
    document.execCommand("copy");

    document.body.removeChild(dummyRelativePathInput);
}

p.s. The same function is present in the file \manager\assets\modext\widgets\media\modx.browser.js, but I'm not sure if this function is used somewhere in the code.

@rthrash rthrash added this to the v2.8.7 milestone Jan 25, 2024
@rthrash rthrash added bug The issue in the code or project, which should be addressed. and removed feature Request about implementing a brand new function or possibility. labels Jan 25, 2024
@Ruslan-Aleev Ruslan-Aleev modified the milestones: v2.8.7, v3.0.5 Jan 29, 2024
@Ruslan-Aleev Ruslan-Aleev added pr/port-to-3 Pull request has to be ported to 3.x. pr/port-to-2 Pull request has to be ported to 2.x. and removed pr/port-to-3 Pull request has to be ported to 3.x. pr/port-to-2 Pull request has to be ported to 2.x. labels Feb 5, 2024
@opengeek opengeek modified the milestones: v2.8.7, v2.8.8 Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.
Projects
None yet
Development

No branches or pull requests

3 participants