From a636be56110d06ca181f27a69c7edb7fbf8dcd00 Mon Sep 17 00:00:00 2001 From: siosTomBeckenhauer Date: Tue, 12 Jan 2016 13:59:23 -0500 Subject: [PATCH 1/3] first column rollover state and default sorting desending https://github.com/siostechcorp/cloud-orchestrator-ui/commit/b17afb3712e6b471da371bf6499237e3aba66034 comment added to default sorting change https://github.com/siostechcorp/cloud-orchestrator-ui/commit/b521d688494c4b37c4df47ee63164e755e13f9e8 --- build/ng-grid.debug.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ng-grid.debug.js b/build/ng-grid.debug.js index 0ad80d364a..1db90ceb0a 100644 --- a/build/ng-grid.debug.js +++ b/build/ng-grid.debug.js @@ -823,7 +823,8 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache if (!self.sortable) { return true; // column sorting is disabled, do nothing } - var dir = self.sortDirection === ASC ? DESC : ASC; + //var dir = self.sortDirection === ASC ? DESC : ASC; + var dir = self.sortDirection === DESC ? ASC : DESC; // To make default sorting by descending order self.sortDirection = dir; config.sortCallback(self, evt); return false; From af33ad0411b6c49f45d08db645be5a8e95e12dcb Mon Sep 17 00:00:00 2001 From: siosTomBeckenhauer Date: Tue, 12 Jan 2016 14:10:08 -0500 Subject: [PATCH 2/3] grid column resize with touch issue fixed https://github.com/siostechcorp/cloud-orchestrator-ui/commit/5a4e4653e406508696800d35c6e79bb2b4a02e1c --- build/ng-grid.debug.js | 45 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/build/ng-grid.debug.js b/build/ng-grid.debug.js index 1db90ceb0a..bf5f8d5ef5 100644 --- a/build/ng-grid.debug.js +++ b/build/ng-grid.debug.js @@ -10,6 +10,7 @@ var EXCESS_ROWS = 6; var SCROLL_THRESHOLD = 4; var ASC = "asc"; + // constant for sorting direction var DESC = "desc"; // constant for sorting direction @@ -23,6 +24,7 @@ var DISPLAY_CELL_TEMPLATE = /DISPLAY_CELL_TEMPLATE/g; var EDITABLE_CELL_TEMPLATE = /EDITABLE_CELL_TEMPLATE/g; var CELL_EDITABLE_CONDITION = /CELL_EDITABLE_CONDITION/g; var TEMPLATE_REGEXP = /<.+>/; +var swipe; window.ngGrid = {}; window.ngGrid.i18n = {}; @@ -843,6 +845,7 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache } }; self.gripOnMouseDown = function(event) { + var ele = angular.element(event.target); $scope.isColumnResizing = true; if (event.ctrlKey && !self.pinned) { self.toggleVisible(); @@ -852,11 +855,17 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache event.target.parentElement.style.cursor = 'col-resize'; self.startMousePosition = event.clientX; self.origWidth = self.width; + + ele.bind('touchstart', function(evt) { + self.onTouchMove(ele); + }); + $(document).mousemove(self.onMouseMove); $(document).mouseup(self.gripOnMouseUp); return false; }; self.onMouseMove = function(event) { + var diff = event.clientX - self.startMousePosition; var newWidth = diff + self.origWidth; self.width = (newWidth < self.minWidth ? self.minWidth : (newWidth > self.maxWidth ? self.maxWidth : newWidth)); @@ -864,8 +873,36 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache domUtilityService.BuildStyles($scope, grid); return false; }; + self.onTouchMove = function(ele){ + var startElement,parent; + var $swipe = swipe; + $swipe.bind(ele, { + 'start' : function(coords) { + self.startMousePosition = coords.x; + }, + 'move' : function(coords) { + + var diff = coords.x - self.startMousePosition; + var newWidth = diff + self.origWidth; + self.width = (newWidth < self.minWidth ? self.minWidth : (newWidth > self.maxWidth ? self.maxWidth : newWidth)); + $scope.hasUserChangedGridColumnWidths = true; + domUtilityService.BuildStyles($scope, grid); + return false; + // ... + }, + 'end' : function(coords) { + // ... + + }, + 'cancel' : function(coords) { + // ... + } + }); + }; self.gripOnMouseUp = function (event) { - $(document).off('mousemove', self.onMouseMove); + + + $(document).off('mousemove', self.onMouseMove); $(document).off('mouseup', self.gripOnMouseUp); event.target.parentElement.style.cursor = 'default'; domUtilityService.digest($scope); @@ -2791,14 +2828,13 @@ var ngSelectionProvider = function (grid, $scope, $parse) { self.lastClickedRow = undefined; self.ignoreSelectedItemChanges = false; // flag to prevent circular event loops keeping single-select var in sync self.pKeyParser = $parse(grid.config.primaryKey); - // function to manage the selection action of a data item (entity) self.ChangeSelection = function (rowItem, evt) { // ctrl-click + shift-click multi-selections // up/down key navigation in multi-selections var charCode = evt.which || evt.keyCode; var isUpDownKeyPress = (charCode === 40 || charCode === 38); - + if (evt && evt.shiftKey && !evt.keyCode && self.multi && grid.config.enableRowSelection) { if (self.lastClickedRow) { var rowsArr; @@ -3203,7 +3239,7 @@ ngGridDirectives.directive('ngGridMenu', ['$compile', '$templateCache', function }; return ngGridMenu; }]); -ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', '$http', '$q', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse, $http, $q) { +ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', '$http', '$q', 'GlobalState','$swipe', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse, $http, $q,GlobalState,$swipe) { var ngGridDirective = { scope: true, compile: function() { @@ -3366,6 +3402,7 @@ ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', ' // the grid Id, entity, scope for convenience options.gridId = grid.gridId; options.ngGrid = grid; + swipe = $swipe options.$gridScope = $scope; options.$gridServices = { SortService: sortService, DomUtilityService: domUtilityService, UtilityService: $utils }; From b1f950612478f4826c09b9798b8758cf2f4edf95 Mon Sep 17 00:00:00 2001 From: siosTomBeckenhauer Date: Tue, 12 Jan 2016 14:16:23 -0500 Subject: [PATCH 3/3] horizontal scroll bar in grid fix https://github.com/siostechcorp/cloud-orchestrator-ui/commit/cceb16cd98b2fa45fe74879ee2a8ef5e054117ad add comment in ng-grid.debug.js https://github.com/siostechcorp/cloud-orchestrator-ui/commit/ae1db7e3f405086a096b328740fb02e5d1a235ed add condition for col.visible in else condition https://github.com/siostechcorp/cloud-orchestrator-ui/commit/9cccce86d7c62ea1a8f8e8baa3aa800bdfee5f7f --- build/ng-grid.debug.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/ng-grid.debug.js b/build/ng-grid.debug.js index bf5f8d5ef5..585501ef30 100644 --- a/build/ng-grid.debug.js +++ b/build/ng-grid.debug.js @@ -333,11 +333,17 @@ angular.module('ngGrid.services').factory('$domUtilityService',['$utilityService for (var i = 0; i < cols.length; i++) { var col = cols[i]; - if (col.visible !== false) { + if (col.visible !== false && i < cols.length-1) { css += "." + gridId + " .col" + i + " { width: " + col.width + "px; left: " + sumWidth + "px; height: " + rowHeight + "px }" + "." + gridId + " .colt" + i + " { width: " + col.width + "px; }"; sumWidth += col.width; } + // for removing horizontal scroll bar on grid during pin unpin + else if(col.visible !== false){ + css += "." + gridId + " .col" + i + " { width: " + (col.width-1) + "px; left: " + sumWidth + "px; height: " + rowHeight + "px }" + + "." + gridId + " .colt" + i + " { width: " + (col.width-1) + "px; }"; + sumWidth += col.width; + } } domUtilityService.setStyleText(grid, css);