Skip to content

Commit

Permalink
Convert sortable-objects sortEndAction to DDAU
Browse files Browse the repository at this point in the history
  • Loading branch information
stopdropandrew committed Mar 4, 2018
1 parent 9db86fb commit 98cb024
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ This only applies if you use the sort capabilities, regular dragging is not vers
An Example:

```handlebars
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction' enableSort=true useSwap=true inPlace=false sortingScope="sortingGroup"}}
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction=(action 'sortEndAction') enableSort=true useSwap=true inPlace=false sortingScope="sortingGroup"}}
{{#each sortableObjectList as |item|}}
{{#draggable-object content=item isSortable=true sortingScope="sortingGroup"}}
{{item.name}}
Expand Down
4 changes: 2 additions & 2 deletions addon/components/sortable-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default Component.extend( {

drop(event) {
event.stopPropagation();
if (this.get('enableSort')) {
this.sendAction('sortEndAction', event);
if (this.get('enableSort') && this.get('sortEndAction')) {
this.get('sortEndAction')(event);
}
}
});
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/horizontal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This demo demonstrates the different between the flag useSwap=true (default) and
<p>{{input type="checkbox" checked=useSwap}} useSwap={{#if useSwap}}true{{else}} false{{/if}}</p>
<p>Typically for a horizontal list, sending in useSwap=false is the right choice. <br>By default (useSwap=true) the box being dragged will be swapped with the item it's over. <br>If useSwap=false the item will be swapped with the one it's over and the items in the list under it will be pushed down the line.</p>
<div class="u-pullLeft">
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction' useSwap=useSwap}}
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction=(action 'sortEndAction') useSwap=useSwap}}
{{#each sortableObjectList as |item|}}
{{#draggable-object content=item overrideClass='sortObject u-pullLeft' isSortable=true}}
{{item.title}}
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/multiple.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p>Drag any item from this block to the block on the right</p>
<p>You can control which blocks can be interacted with by setting the sortingScope </p>
<div class="u-pullLeft">
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction' sortingScope='a' }}
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction=(action 'sortEndAction') sortingScope='a' }}
{{#each sortableObjectList as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true sortingScope='a'}}
{{item.title}}
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/sort.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="u-halfBlock u-pullLeft">
<p>Drag any box to another position and drop to re-sort the list</p>
<div class="u-pullLeft">
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction' sortingScope='a' }}
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction=(action 'sortEndAction') sortingScope='a' }}
{{#each sortableObjectList as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true sortingScope='a'}}
{{item.title}}
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/sortdata.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p>Drag any box to another position and drop to re-sort the list</p>

<div class="u-pullLeft">
{{#sortable-objects sortableObjectList=model.pages sortEndAction='sortEndAction' enableSort=true}}
{{#sortable-objects sortableObjectList=model.pages sortEndAction=(action 'sortEndAction') enableSort=true}}
{{#each model.pages as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true}}
{{item.title}}
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/components/sortable-objects-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test('sortable object renders draggable objects', async function(assert) {
});

this.render(hbs`
{{#sortable-objects sortableObjectList=pojoData sortEndAction='sortEndAction' class='sortContainer' sortingScope='sortable-objects'}}
{{#sortable-objects sortableObjectList=pojoData sortEndAction=(action 'sortEndAction') class='sortContainer' sortingScope='sortable-objects'}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true sortingScope='sortable-objects'}}
{{item.title}}
Expand Down Expand Up @@ -119,7 +119,7 @@ test('sortable object renders draggable objects using shift algorithm', async fu
});

this.render(hbs`
{{#sortable-objects sortableObjectList=pojoData sortEndAction='sortEndAction' class='sortContainer' useSwap=false}}
{{#sortable-objects sortableObjectList=pojoData sortEndAction=(action 'sortEndAction') class='sortContainer' useSwap=false}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true}}
{{item.title}}
Expand Down Expand Up @@ -164,7 +164,7 @@ test('sorting does not happen if off', async function(assert) {
});

this.render(hbs`
{{#sortable-objects sortableObjectList=pojoData sortEndAction='sortEndAction' class='sortContainer' enableSort=false}}
{{#sortable-objects sortableObjectList=pojoData sortEndAction=(action 'sortEndAction') class='sortContainer' enableSort=false}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=false}}
{{item.title}}
Expand Down

0 comments on commit 98cb024

Please sign in to comment.