Skip to content

Commit

Permalink
Version 2.0.12 release
Browse files Browse the repository at this point in the history
  • Loading branch information
c0bra committed Aug 4, 2014
1 parent 5b19134 commit cb2f0eb
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 111 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="2.0.11"></a>
## 2.0.12 *(2014-08-04)*

* Merged all outstanding 2.x PRs in advance of 3.0 beta release.

<a name="2.0.11"></a>
## 2.0.11 *(2014-04-29)*

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Dependencies: jQuery & angular.js. (JqueryUi draggable for non-HTML5 compliant b
## About
__ng-grid__ Originally built on knockout we wanted to port it to angular.

version 2.0.11
version 2.0.12

[nuGet](https://nuget.org/packages/ng-grid)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-grid",
"version": "2.0.11",
"version": "2.0.12",
"homepage": "https://github.com/angular-ui/ng-grid",
"description": "Angular data grid",
"keywords": [
Expand Down
122 changes: 87 additions & 35 deletions build/ng-grid.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 04/29/2014 10:21
* Compiled At: 08/04/2014 16:09
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -43,7 +43,9 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
lastInRow = false,
firstInRow = false,
rowIndex = $scope.selectionProvider.lastClickedRow === undefined ? 1 : $scope.selectionProvider.lastClickedRow.rowIndex,
visibleCols = $scope.columns.filter(function(c) { return c.visible; }),
visibleCols = $scope.columns.filter(function(c) {
return c.visible && c.width > 0;
}),
pinnedCols = $scope.columns.filter(function(c) { return c.pinned; });

if ($scope.col) {
Expand All @@ -59,9 +61,9 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
evt.preventDefault();
}

var focusedOnFirstColumn = $scope.showSelectionCheckbox ? $scope.col.index === 1 : $scope.col.index === 0;
var focusedOnFirstVisibleColumns = $scope.$index === 1 || $scope.$index === 0;
var focusedOnLastVisibleColumns = $scope.$index === ($scope.renderedColumns.length - 1) || $scope.$index === ($scope.renderedColumns.length - 2);
var focusedOnFirstColumn = $scope.showSelectionCheckbox ? newColumnIndex === 1 : newColumnIndex === 0;
var focusedOnFirstVisibleColumns = newColumnIndex === 1 || newColumnIndex === 0;
var focusedOnLastVisibleColumns = newColumnIndex === (visibleCols.length - 1) || newColumnIndex === (visibleCols.length - 2);
var focusedOnLastColumn = visibleCols.indexOf($scope.col) === (visibleCols.length - 1);
var focusedOnLastPinnedColumn = pinnedCols.indexOf($scope.col) === (pinnedCols.length - 1);

Expand Down Expand Up @@ -252,16 +254,18 @@ angular.module('ngGrid.services').factory('$domUtilityService',['$utilityService

$scope.$on('$destroy', function() {
// Remove all references to DOM elements, otherwise we get memory leaks
$(grid.$root.parent()).off('resize.nggrid');
if(grid.$root) {
$(grid.$root.parent()).off('resize.nggrid');

grid.$root = null;
grid.$topPanel = null;
// grid.$groupPanel = null;
grid.$headerContainer = null;
// grid.$headerScroller = null;
grid.$headers = null;
grid.$canvas = null;
grid.$footerPanel = null;
grid.$root = null;
grid.$topPanel = null;
// grid.$groupPanel = null;
grid.$headerContainer = null;
// grid.$headerScroller = null;
grid.$headers = null;
grid.$canvas = null;
grid.$footerPanel = null;
}

scopeDereg();
});
Expand Down Expand Up @@ -492,15 +496,15 @@ angular.module('ngGrid.services').factory('$sortService', ['$parse', function($p
tem = direction === ASC ? res : 0 - res;
} else {
// we want to allow zero values to be evaluated in the sort function
if ((!propA && propA !== 0) || (!propB && propB !== 0)) {
if (propA == null || propB == null) {
// we want to force nulls and such to the bottom when we sort... which effectively is "greater than"
if (!propB && !propA) {
if (propB == null && propA == null) {
tem = 0;
}
else if (!propA) {
else if (propA == null) {
tem = 1;
}
else if (!propB) {
else if (propB == null) {
tem = -1;
}
}
Expand Down Expand Up @@ -670,6 +674,9 @@ ngAggregate.prototype.toggleExpand = function () {
};
ngAggregate.prototype.setExpand = function (state) {
this.collapsed = state;
if (this.orig) {
this.orig.collapsed = state;
}
this.notifyChildren();
};
ngAggregate.prototype.notifyChildren = function () {
Expand Down Expand Up @@ -718,6 +725,7 @@ ngAggregate.prototype.copy = function () {
ret.orig = this;
return ret;
};

var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache, $utils) {
var self = this,
colDef = config.colDef,
Expand Down Expand Up @@ -1454,6 +1462,9 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
//all of the items selected in the grid. In single select mode there will only be one item in the array.
selectedItems: [],

//Width of row selection checkbox column
selectionCheckboxColumnWidth: 25,

//Disable row selections by clicking on the row and only when the checkbox is clicked.
selectWithCheckboxOnly: false,

Expand Down Expand Up @@ -1585,8 +1596,8 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
self.elementDims = {
scrollW: 0,
scrollH: 0,
rowIndexCellW: 25,
rowSelectedCellW: 25,
rowIndexCellW: self.config.selectionCheckboxColumnWidth,
rowSelectedCellW: self.config.selectionCheckboxColumnWidth,
rootMaxW: 0,
rootMaxH: 0
};
Expand Down Expand Up @@ -1716,12 +1727,14 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
if (self.config.showSelectionCheckbox) {
//if visible, takes up 25 pixels
if(ngCol.originalIndex === 0 && ngCol.visible){
totalWidth += 25;
totalWidth += self.config.selectionCheckboxColumnWidth;
}
// The originalIndex will be offset 1 when including the selection column
origIndex--;
}
indexMap[origIndex] = i;
} else if (ngCol.isAggCol && ngCol.visible){ // aggregate columns are 25px in length.
totalWidth+=25;
}
});

Expand All @@ -1740,8 +1753,10 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
t = isPercent ? colDef.width : parseInt(colDef.width, 10);
}

// has bug for resize event causing NaN for all column width after another http.get
// if (isNaN(t) && !$scope.hasUserChangedGridColumnWidths) {
// check if it is a number
if (isNaN(t) && !$scope.hasUserChangedGridColumnWidths) {
if (isNaN(t)) {
t = colDef.width;
// figure out if the width is defined or if we need to calculate it
if (t === 'auto') { // set it for now until we have data and subscribe when it changes so we can set the width.
Expand Down Expand Up @@ -1829,6 +1844,9 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
// Get the ngColumn that matches the current column from columnDefs
var ngColumn = $scope.columns[indexMap[colDef.index]];
ngColumn.width = asteriskVal * colDef.width.length;
if (ngColumn.width < ngColumn.minWidth) {
ngColumn.width = ngColumn.minWidth;
}
if (ngColumn.visible !== false) {
totalWidth += ngColumn.width;
}
Expand All @@ -1851,7 +1869,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
$scope.selectionProvider = new ngSelectionProvider(self, $scope, $parse);
$scope.domAccessProvider = new ngDomAccessProvider(self);
self.rowFactory = new ngRowFactory(self, $scope, domUtilityService, $templateCache, $utils);
self.searchProvider = new ngSearchProvider($scope, self, $filter);
self.searchProvider = new ngSearchProvider($scope, self, $filter, $utils);
self.styleProvider = new ngStyleProvider($scope, self);
$scope.$on('$destroy', $scope.$watch('configGroups', function(a) {
var tempArr = [];
Expand Down Expand Up @@ -1928,6 +1946,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
} else {
self.config.sortInfo.directions[indx] = col.sortDirection;
}
$scope.$emit('ngGridEventSorted', self.config.sortInfo);
} else if (!self.config.useExternalSorting || (self.config.useExternalSorting && self.config.sortInfo )) {
var isArr = $.isArray(col);
self.config.sortInfo.columns.length = 0;
Expand Down Expand Up @@ -2510,7 +2529,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
var col = filterCols(cols, group)[0];

var val = $utils.evalProperty(model, group);
val = val ? val.toString() : 'null';
val = (val === '' || val === null) ? 'null' : val.toString();
if (!ptr[val]) {
ptr[val] = {};
}
Expand Down Expand Up @@ -2565,7 +2584,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
self.getGrouping(grid.config.groups);
}
};
var ngSearchProvider = function ($scope, grid, $filter) {
var ngSearchProvider = function ($scope, grid, $filter, $utils) {
var self = this,
searchConditions = [];

Expand All @@ -2585,14 +2604,25 @@ var ngSearchProvider = function ($scope, grid, $filter) {
return fieldMap;
};

var getAllPrimitiveValues = function(value) {
if(typeof value === "object") {
var arr = [];
for(var prop in value) {
arr = arr.concat(getAllPrimitiveValues(value[prop]));
}

return arr;
}
else {
return [value];
}
};

var searchEntireRow = function(condition, item, fieldMap){
var result;
for (var prop in item) {
if (item.hasOwnProperty(prop)) {
var c = fieldMap[prop.toLowerCase()];
if (!c) {
continue;
}
var pVal = item[prop];
if(typeof pVal === 'object' && !(pVal instanceof Date)) {
var objectFieldMap = convertToFieldMap(c);
Expand All @@ -2610,7 +2640,7 @@ var ngSearchProvider = function ($scope, grid, $filter) {
if (pVal !== null && pVal !== undefined) {
if (typeof f === "function") {
// Have to slice off the quotes the parser would have removed
var filterRes = f(pVal, s[1].slice(1,-1)).toString();
var filterRes = f(pVal, s[1] ? s[1].slice(1,-1) : "").toString();
result = condition.regex.test(filterRes);
} else {
result = condition.regex.test(pVal.toString());
Expand All @@ -2633,7 +2663,7 @@ var ngSearchProvider = function ($scope, grid, $filter) {
}
var sp = col.cellFilter.split(':');
var filter = col.cellFilter ? $filter(sp[0]) : null;
var value = item[condition.column] || item[col.field.split('.')[0]];
var value = item[condition.column] || item[col.field.split('.')[0]] || $utils.evalProperty(item, col.field);
if (value === null || value === undefined) {
return false;
}
Expand All @@ -2642,7 +2672,10 @@ var ngSearchProvider = function ($scope, grid, $filter) {
result = condition.regex.test(filterResults);
}
else {
result = condition.regex.test(typeof value === "object" ? evalObject(value, col.field).toString() : value.toString());
var primitiveValues = getAllPrimitiveValues(evalObject(value, col.field));
for(var prop in primitiveValues) {
result |= condition.regex.test(primValues[prop]);
}
}
if (result) {
return true;
Expand Down Expand Up @@ -2925,19 +2958,24 @@ var ngSelectionProvider = function (grid, $scope, $parse) {
// @return - boolean indicating if all items are selected or not
// @val - boolean indicating whether to select all/de-select all
self.toggleSelectAll = function (checkAll, bypass, selectFiltered) {
var rows = selectFiltered ? grid.filteredRows : grid.rowCache;
var rows = selectFiltered ? grid.filteredRows : grid.rowCache, wasSelected, index;
if (bypass || grid.config.beforeSelectionChange(rows, checkAll)) {
var selectedlength = self.selectedItems.length;
if (selectedlength > 0) {
if (!selectFiltered && self.selectedItems.length > 0) {
self.selectedItems.length = 0;
}
for (var i = 0; i < rows.length; i++) {
wasSelected = rows[i].selected;
rows[i].selected = checkAll;
if (rows[i].clone) {
rows[i].clone.selected = checkAll;
}
if (checkAll) {
if (!wasSelected && checkAll) {
self.selectedItems.push(rows[i].entity);
} else if (wasSelected && !checkAll) {
index = self.selectedItems.indexOf(rows[i].entity);
if (index > -1) {
self.selectedItems.splice(index, 1);
}
}
}
if (!bypass) {
Expand Down Expand Up @@ -3699,6 +3737,20 @@ window.ngGrid.i18n['pt-br'] = {
ngPagerLastTitle: 'Última Página'
};

window.ngGrid.i18n['ru'] = {
ngAggregateLabel: 'записи',
ngGroupPanelDescription: 'Перетащите сюда заголовок колонки для группировки по этой колонке.',
ngSearchPlaceHolder: 'Искать...',
ngMenuText: 'Выберите столбцы:',
ngShowingItemsLabel: 'Показаны записи:',
ngTotalItemsLabel: 'Всего записей:',
ngSelectedItemsLabel: 'Выбранные записи:',
ngPageSizeLabel: 'Строк на странице:',
ngPagerFirstTitle: 'Первая страница',
ngPagerNextTitle: 'Следующая страница',
ngPagerPrevTitle: 'Предыдущая страница',
ngPagerLastTitle: 'Последняя страница'
};
window.ngGrid.i18n['zh-cn'] = {
ngAggregateLabel: '条目',
ngGroupPanelDescription: '拖曳表头到此处以进行分组',
Expand Down
Loading

0 comments on commit cb2f0eb

Please sign in to comment.