@@ -128,6 +128,59 @@ describe('uiSortable', function() {
128
128
} ) ;
129
129
} ) ;
130
130
131
+ it ( 'should update model when sorting between drectly nested sortables' , function ( ) {
132
+ inject ( function ( $compile , $rootScope ) {
133
+ var elementTree , li1 , li2 ;
134
+
135
+ elementTree = $compile ( '' . concat (
136
+ '<div ui-sortable="sortableOptions" ng-model="items" class="nested-sortable outterList" style="float: left;margin-left: 10px;padding-bottom: 10px;">' ,
137
+ '<div ui-sortable="innerSortableOptions" ng-model="item.items" class="nested-sortable innerList" ng-repeat="item in items">' ,
138
+ '<div class="itemContent lvl1ItemContent">{{item.text}}</div>' ,
139
+ '<div ng-repeat="i in item.items" style="margin-left: 10px;padding-bottom: 10px;">' ,
140
+ '<div class="itemContent lvl2ItemContent">{{i.text}}</div>' ,
141
+ '</div>' ,
142
+ '</div>' ,
143
+ '</div>' ,
144
+ '<div style="clear: both;"></div>' ) ) ( $rootScope ) ;
145
+
146
+ $rootScope . $apply ( function ( ) {
147
+ $rootScope . items = [
148
+ {
149
+ text : 'Item 1' ,
150
+ items : [
151
+ { text : 'Item 1.1' , items : [ ] } ,
152
+ { text : 'Item 1.2' , items : [ ] }
153
+ ]
154
+ } ,
155
+ {
156
+ text : 'Item 2' ,
157
+ items : [
158
+ { text : 'Item 2.1' , items : [ ] } ,
159
+ { text : 'Item 2.2' , items : [ ] }
160
+ ]
161
+ }
162
+ ] ;
163
+
164
+ $rootScope . sortableOptions = { } ;
165
+ $rootScope . innerSortableOptions = {
166
+ connectWith : '.nested-sortable'
167
+ } ;
168
+ } ) ;
169
+
170
+ host . append ( elementTree ) ;
171
+
172
+ li1 = elementTree . find ( '.innerList:last' ) ;
173
+ li2 = elementTree . find ( '.innerList:first' ) ;
174
+ simulateElementDrag ( li1 , li2 , { place : 'above' , extradx : - 10 , extrady : - 6 } ) ;
175
+ expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
176
+ . toEqual ( [ 'Item 2' , 'Item 1' ] ) ;
177
+ expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
178
+ . toEqual ( listInnerContent ( elementTree , '.lvl1ItemContent' ) ) ;
179
+
180
+ $ ( elementTree ) . remove ( ) ;
181
+ } ) ;
182
+ } ) ;
183
+
131
184
} ) ;
132
185
133
186
} ) ;
0 commit comments