forked from SortableJS/angular-legacy-sortablejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
describe('nested drag and drop', () => { | ||
it('should have correct model after moving between lists', () => { | ||
browser.get('http://localhost:8080/nested.html') | ||
browser.executeScript('$("#item2").simulate("drag-n-drop", { dragTarget: $("#item3"), interpolation: {stepWidth: 2, stepDelay: 30}});') | ||
browser.sleep(1000) | ||
element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ | ||
expect(value).toBe('item2'); | ||
}) | ||
browser.executeScript('$("#item3").simulate("drag-n-drop", { dragTarget: $("#subitem1"), interpolation: {stepWidth: 2, stepDelay: 30}});') | ||
browser.sleep(1000) | ||
element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ | ||
expect(value).toBe('item3'); | ||
}) | ||
browser.executeScript('$("#item1").simulate("drag-n-drop", { dragTarget: $("#item2"), interpolation: {stepWidth: 2, stepDelay: 30}});') | ||
browser.sleep(1000) | ||
element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ | ||
expect(value).toBe('item1'); | ||
}) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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', | ||
}, | ||
{ | ||
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 | ||
} | ||
} | ||
}, | ||
}) |