Skip to content

Commit

Permalink
[BUGFIX release]: Added check for target column is droppable (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-kr authored and alexander-alvarez committed Oct 18, 2017
1 parent 494f4d0 commit daa657e
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions addon/mixins/draggable-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,31 @@ export default Mixin.create({
drop(e) {
this._super(...arguments);

let table = this.get('table');
let targetColumn = this.get('column');
let columns = this.get('dragColumnGroup');
if (targetColumn.droppable) {
let table = this.get('table');
let columns = this.get('dragColumnGroup');

let _columns = columns.toArray();
let targetColumnIdx = _columns.indexOf(targetColumn);
let _columns = columns.toArray();
let targetColumnIdx = _columns.indexOf(targetColumn);

e.dataTransfer.dropEffect = 'move';
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'move';
e.preventDefault();
e.stopPropagation();

table.propertyWillChange('columns');
table.propertyWillChange('columns');

_columns.removeObject(sourceColumn);
_columns.insertAt(targetColumnIdx, sourceColumn);
columns.setObjects(_columns);
_columns.removeObject(sourceColumn);
_columns.insertAt(targetColumnIdx, sourceColumn);
columns.setObjects(_columns);

table.propertyDidChange('columns');
table.propertyDidChange('columns');

this.setProperties({ isDragTarget: false, isDragging: false });
this.setProperties({ isDragTarget: false, isDragging: false });

this.sendAction('onColumnDrop', sourceColumn, true, ...arguments);
sourceColumn = null;
this.sendAction('onColumnDrop', sourceColumn, true, ...arguments);
sourceColumn = null;
}
},

destroy() {
Expand Down

0 comments on commit daa657e

Please sign in to comment.