Skip to content

Commit

Permalink
Adds abililty to disable sort
Browse files Browse the repository at this point in the history
  • Loading branch information
dgavey committed Nov 30, 2015
1 parent be887ef commit e11cb1c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ We now have a basic sorting capabilities in this library. If you wrap the `{{#so
An Example:

```handlebars
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction'}}
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction' enableSort=true}}
{{#each sortableObjectList as |item|}}
{{#draggable-object content=item isSortable=true}}
{{item.name}}
Expand All @@ -166,7 +166,7 @@ An Example:
{{/sortable-objects}}
```

On drop of an item in the list, the sortableObjectList is re-ordered and the sortEndAction is fired. You can check out an example of this is action [here](http://mharris717.github.io/ember-drag-drop/)
On drop of an item in the list, the sortableObjectList is re-ordered and the sortEndAction is fired unless the optional parameter 'enableSort' is false. You can check out an example of this is action [here](http://mharris717.github.io/ember-drag-drop/)

**Note: It's important that you add the isSortable=true to each draggable-object or else that item will be draggable, but will not change the order of any item.**

Expand Down
6 changes: 4 additions & 2 deletions addon/components/sortable-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default Ember.Component.extend( {
return false;
},
drop: function() {
this.set('sortableObjectList', this.get('dragCoordinator').getChangedArray());
this.sendAction('sortEndAction');
if (this.get('enableSort')) {
this.set('sortableObjectList', this.get('dragCoordinator').getChangedArray());
this.sendAction('sortEndAction');
}
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-drag-drop",
"version": "0.2.1",
"version": "0.2.2",
"description": "Addon for Ember CLI to do drag and drop",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit e11cb1c

Please sign in to comment.