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

Allow item with nested sortable to be moved to another item's nested sortable #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions angular-legacy-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@
evt.from.insertBefore(nextSibling, evt.item.nextSibling);
}
}

scope.$apply();
}

function _destroy() {
Expand Down Expand Up @@ -175,7 +173,6 @@
onAdd: function (/**Event*/evt) {
_sync(evt);
_emitEvent(evt, removed);
scope.$apply();
},
onUpdate: function (/**Event*/evt) {
_sync(evt);
Expand Down
2 changes: 1 addition & 1 deletion e2e/conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['./basic-drag-drop.e2e.js'],
specs: ['./basic-drag-drop.e2e.js', './nested-drag-drop.e2e.js'],
}
11 changes: 11 additions & 0 deletions e2e/nested-drag-drop.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('nested drag and drop', () => {

it('should allow list with nested list to be dropped in a nested list', () => {
browser.get('http://localhost:8080/nested.html')
browser.executeAsyncScript('var done = arguments[0]; window.onerror = done; $("#item2").simulate("drag-n-drop", { dragTarget: $("#subitem1"), interpolation: {stepWidth: 2, stepDelay: 30}}); setTimeout(done, 1000)').then(response =>{
expect(response).toBeFalsy()
})
browser.sleep(1000)
})
})

18 changes: 18 additions & 0 deletions example/nested.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>
<head>
<script src="vendor/jquery.min.js"></script>
<script src="vendor/jquery.simulate.js"></script>
<script src="vendor/jquery.simulate.ext.js"></script>
<script src="vendor/jquery.simulate.drag-n-drop.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.6.0/Sortable.min.js"></script>
<script src="./angular-legacy-sortable.js"></script>

<script src="nestedApp.js"></script>
</head>

<body ng-app="nestedApp">
<nested-drag-and-drop-example></nested-drag-and-drop-example>
</body>
</html>
53 changes: 53 additions & 0 deletions example/nestedApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
angular.module('nestedApp', ['ng-sortable'])
.component('nestedDragAndDropExample', {
template: `<ul id='main-list' ng-sortable="$ctrl.sortableConf">
<li ng-repeat="item in $ctrl.items" >
<span id={{item.name}}> {{ item.name }} </span>
<div ng-if="item.items">
<ul class='nested-list' ng-sortable="$ctrl.nestedSortableConf">
<li ng-repeat="subitem in item.items" >
<span id={{subitem.name}}> {{ subitem.name }} </span>
</li>
</ul>
</div>
</li>
</ul>`,
controller: class ExampleAppController {
constructor() {
var _this = this;
this.items = [{
name: 'item1',
items: [
{
name: 'subitem1',
}
]
},
{
name: 'item2',
items: [
{
name: 'subitem2',
}
]
},
{
name: 'item3'
}]
this.onEnd = function(event) {
_this.lastDragged = event.model;
}

this.sortableConf = {
group: 'all',
forceFallback: true,
onEnd: this.onEnd
}
this.nestedSortableConf = {
group: 'all',
forceFallback: true,
onEnd: this.onEnd
}
}
},
})