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

Add drag and drop capabilities #1

Open
rubenheymans opened this issue Mar 4, 2015 · 4 comments
Open

Add drag and drop capabilities #1

rubenheymans opened this issue Mar 4, 2015 · 4 comments

Comments

@rubenheymans
Copy link

rubenheymans commented Mar 4, 2015

Thanks for this awesome module!

Is it possible to add drag and drop, use a script like this one: https://github.com/RamonSmit/Nestable
use an arrow icon as drag handler


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@kartik-v
Copy link
Owner

kartik-v commented Mar 5, 2015

Probably for later. Wanted to minimize amount of javascript used - yet make it configurable for most use cases. These maybe embedded as optional plugins later.

Note that sorting/reordering is currently possible through the arrow keys (up, down, left, and right).

@arogachev
Copy link

What's with this feature? It's hard to manage tree without drag-and-drop.

@kartik-v
Copy link
Owner

kartik-v commented May 4, 2015

Limited by time and may not be able to focus on this immediately.

Its lower in my priority currently - because of the additional overhead to both PHP & JS code - as well as the complex DB queries needed to achieve this and the performance.

Please feel free to submit a PR for this if you want it faster or find a better approach to do this.

@attybean
Copy link

attybean commented Mar 26, 2018

Here is my simple solution: https://stackoverflow.com/questions/49487557/javascript-add-form-model-name-to-formdata

`<script>
function allowDrop(event) {
event.preventDefault();
}

function drop(event) {
    event.preventDefault();
    var dropFiles = event.dataTransfer.files;
    event.target.click();
        setTimeout(function(){
            var formData = new FormData();
            $.each(dropFiles, function(i, file){  
                formData.append('Files[files][]',file);  
            });                  

            $.ajax({
                   url : '/files/upload-files',
                   type : 'POST',
                   data : formData,
                   processData: false,  // tell jQuery not to process the data
                   contentType: false,  // tell jQuery not to set contentType
                   success : function(data) {
                       // console.log(data);
                   }
            });
        }, 1000);
}

function highlightToggle(event) {
    event.preventDefault();
    event.target.classList.toggle("highlightDrop");
}

</script>`

to use this I just added the following to the 'options' of the widget:


'nodeLabel' => function($node) {
                                                return '<span id = '.$node->file_id.' ondragenter="highlightToggle(event)" ondragleave="highlightToggle(event)">'.$node->name.'</span>';
                                            },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants