Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setDragDisable for multiple grids #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions js/draggable-rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,11 @@
};
}])

.factory('uiGridDraggableRowsSettings', [function() {
return {
dragDisabled: false
};
}])

.service('uiGridDraggableRowsService', ['uiGridDraggableRowsConstants', 'uiGridDraggableRowsCommon' , 'uiGridDraggableRowsSettings', function(uiGridDraggableRowsConstants, uiGridDraggableRowsCommon, uiGridDraggableRowsSettings) {
.service('uiGridDraggableRowsService', ['uiGridDraggableRowsConstants', 'uiGridDraggableRowsCommon' , function(uiGridDraggableRowsConstants, uiGridDraggableRowsCommon) {
var publicMethods = {
dragndrop: {
setDragDisabled: function setDragDisabled(status) {
uiGridDraggableRowsSettings.dragDisabled = ~~status;
this.dragDisabled = ~~status;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this in this place is single grid object, but in my opinion, it's better to keep dragDisabled state inside the plugin instead of performing modification in main grid itself

}
}
};
Expand All @@ -70,7 +64,7 @@
};
}])

.service('uiGridDraggableRowService', ['uiGridDraggableRowsConstants', 'uiGridDraggableRowsCommon', 'uiGridDraggableRowsSettings', '$parse', function(uiGridDraggableRowsConstants, uiGridDraggableRowsCommon, uiGridDraggableRowsSettings, $parse) {
.service('uiGridDraggableRowService', ['uiGridDraggableRowsConstants', 'uiGridDraggableRowsCommon', '$parse', function(uiGridDraggableRowsConstants, uiGridDraggableRowsCommon, $parse) {
var move = function(from, to, grid) {
grid.api.draggableRows.raise.beforeRowMove(from, to, this);

Expand Down Expand Up @@ -145,7 +139,7 @@
},

onDragStartEventListener: function(e) {
if (uiGridDraggableRowsSettings.dragDisabled || (hasHandle && !handle)) {
if (this.dragDisabled || (hasHandle && !handle)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this in this place is DOM node

e.preventDefault();
e.stopPropagation();

Expand Down