Skip to content

Commit

Permalink
Copy should work as a function
Browse files Browse the repository at this point in the history
If copy is a function bound to the view, then it needs to be called with
a single object that will be destructed, otherwise the params will
remain undefined.
  • Loading branch information
michaelmalonenz committed Mar 1, 2019
1 parent 4f636a8 commit 7aca9a3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/dragula-and-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class DragulaAndDrop {
isContainer: this._isContainer.bind(this),
moves: this._moves.bind(this),
accepts: this._accepts.bind(this),
invalid: this._invalid.bind(this)
invalid: this._invalid.bind(this),
copy: this._copy.bind(this)
};

this.options = Object.assign(aureliaOptions, boundOptions);
Expand Down Expand Up @@ -132,10 +133,19 @@ export class DragulaAndDrop {
}
}

_copy(item, container) {
if (typeof this.copy === 'function') {
return this.copy({ item, container });
}
if (typeof this.globalOptions.copy === 'function') {
return this.globalOptions.copy({ item, container })
}
return this._convertToBooleanIfRequired(this._getOption('copy'))
}

_setupOptions() {
let result = {
containers: this._getOption('containers'),
copy: this._convertToBooleanIfRequired(this._getOption('copy')),
copySortSource: this._convertToBooleanIfRequired(this._getOption('copySortSource')),
revertOnSpill: this._convertToBooleanIfRequired(this._getOption('revertOnSpill')),
removeOnSpill: this._convertToBooleanIfRequired(this._getOption('removeOnSpill')),
Expand Down

0 comments on commit 7aca9a3

Please sign in to comment.