From d043d0eee560adb2caf8dd80d650f01e5e7faf2b Mon Sep 17 00:00:00 2001 From: Jeff Tillwick Date: Mon, 30 Jan 2017 14:56:03 -0500 Subject: [PATCH] Fix setDragDisable for multiple grids Change how setDragDisable works to support multiple grids on one page with different drag settings for each grid. --- js/draggable-rows.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/js/draggable-rows.js b/js/draggable-rows.js index 022f7cc..a7bd610 100644 --- a/js/draggable-rows.js +++ b/js/draggable-rows.js @@ -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; } } }; @@ -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); @@ -145,7 +139,7 @@ }, onDragStartEventListener: function(e) { - if (uiGridDraggableRowsSettings.dragDisabled || (hasHandle && !handle)) { + if (this.dragDisabled || (hasHandle && !handle)) { e.preventDefault(); e.stopPropagation();