Skip to content

Commit 1d799c5

Browse files
committed
Merge pull request #358 from angular-ui/release-2.0.5
Release version 2.0.5. Changes are in README.md
2 parents 178bd27 + 0d1094e commit 1d799c5

File tree

11 files changed

+783
-665
lines changed

11 files changed

+783
-665
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ There is a task for CI testing with PhantomJS
110110
111111

112112
## Change Log
113-
* __2013-03-29__ - Version 2.0.3 - fixing some more minor bugs.
113+
* __2013-04-23__ - Version 2.0.5 - Moving to $http for external template fetching. Should fix issues with grid rendering before templates are retrieved, as well as fetching the same template multiple times. Also fixed bug that prevented the grid from maintaining row selections post-sort thanks to [sum4me](https://github.com/sum4me).
114+
* __2013-04-08__ - Version 2.0.4 - fixing some more minor bugs.
114115
* __2013-03-29__ - Version 2.0.3 - changed default multiSelect behavior, updating some plugins and making some more minor bugfixes.
115116
* __2013-03-08__ - Version 2.0.2 - minor bugfixes, updating some plugins.
116117
* __2013-03-05__ - Version 2.0.1 - Moved to grunt build system. No more international version; all languages are included by default. Fixed minor grouping display issue. Using $templateCache for templates instead of global namespace.

build/ng-grid.debug.js

Lines changed: 190 additions & 170 deletions
Large diffs are not rendered by default.

build/ng-grid.js

Lines changed: 166 additions & 148 deletions
Large diffs are not rendered by default.

build/ng-grid.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ng-grid-2.0.4.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

ng-grid-2.0.4.debug.js renamed to ng-grid-2.0.5.debug.js

Lines changed: 190 additions & 170 deletions
Large diffs are not rendered by default.

ng-grid-2.0.5.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-grid",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"description": "__Contributors:__",
55
"main": "ng-grid.min.js",
66
"directories": {

src/classes/grid.js

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="footer.js" />
22
/// <reference path="../services/SortService.js" />
33
/// <reference path="../../lib/jquery-1.8.2.min" />
4-
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse) {
4+
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse, $http, $q) {
55
var defaults = {
66
//Define an aggregate template to customize the rows when grouped. See github wiki for more details.
77
aggregateTemplate: undefined,
@@ -215,32 +215,46 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
215215
self.data = [];
216216
self.lateBindColumns = false;
217217
self.filteredRows = [];
218+
219+
self.initTemplates = function() {
220+
var templates = ['rowTemplate', 'aggregateTemplate', 'headerRowTemplate', 'checkboxCellTemplate', 'checkboxHeaderTemplate', 'menuTemplate', 'footerTemplate'];
221+
222+
var promises = [];
223+
templates.forEach(function(template) {
224+
promises.push( self.getTemplate(template) );
225+
});
226+
227+
return $q.all(promises);
228+
};
218229

219230
//Templates
220231
// test templates for urls and get the tempaltes via synchronous ajax calls
221-
var getTemplate = function (key) {
232+
self.getTemplate = function (key) {
222233
var t = self.config[key];
223234
var uKey = self.gridId + key + ".html";
235+
var p = $q.defer();
224236
if (t && !TEMPLATE_REGEXP.test(t)) {
225-
$templateCache.put(uKey, $.ajax({
226-
type: "GET",
227-
url: t,
228-
async: false
229-
}).responseText);
237+
$http.get(t, {
238+
cache: $templateCache
239+
})
240+
.success(function(data){
241+
$templateCache.put(uKey, data);
242+
p.resolve();
243+
})
244+
.error(function(err){
245+
p.reject("Could not load template: " + t);
246+
});
230247
} else if (t) {
231248
$templateCache.put(uKey, t);
249+
p.resolve();
232250
} else {
233251
var dKey = key + ".html";
234252
$templateCache.put(uKey, $templateCache.get(dKey));
253+
p.resolve();
235254
}
255+
256+
return p.promise;
236257
};
237-
getTemplate('rowTemplate');
238-
getTemplate('aggregateTemplate');
239-
getTemplate('headerRowTemplate');
240-
getTemplate('checkboxCellTemplate');
241-
getTemplate('checkboxHeaderTemplate');
242-
getTemplate('menuTemplate');
243-
getTemplate('footerTemplate');
244258

245259
if (typeof self.config.data == "object") {
246260
self.data = self.config.data; // we cannot watch for updates if you don't pass the string name
@@ -442,35 +456,41 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
442456
}
443457
};
444458
self.init = function() {
445-
//factories and services
446-
$scope.selectionProvider = new ngSelectionProvider(self, $scope, $parse);
447-
$scope.domAccessProvider = new ngDomAccessProvider(self);
448-
self.rowFactory = new ngRowFactory(self, $scope, domUtilityService, $templateCache, $utils);
449-
self.searchProvider = new ngSearchProvider($scope, self, $filter);
450-
self.styleProvider = new ngStyleProvider($scope, self);
451-
$scope.$watch('configGroups', function(a) {
452-
var tempArr = [];
453-
angular.forEach(a, function(item) {
454-
tempArr.push(item.field || item);
455-
});
456-
self.config.groups = tempArr;
457-
self.rowFactory.filteredRowsChanged();
458-
$scope.$emit('ngGridEventGroups', a);
459-
}, true);
460-
$scope.$watch('columns', function (a) {
461-
domUtilityService.BuildStyles($scope, self, true);
462-
$scope.$emit('ngGridEventColumns', a);
463-
}, true);
464-
$scope.$watch(function() {
465-
return options.i18n;
466-
}, function(newLang) {
467-
$utils.seti18n($scope, newLang);
459+
return self.initTemplates().then(function(){
460+
//factories and services
461+
$scope.selectionProvider = new ngSelectionProvider(self, $scope, $parse);
462+
$scope.domAccessProvider = new ngDomAccessProvider(self);
463+
self.rowFactory = new ngRowFactory(self, $scope, domUtilityService, $templateCache, $utils);
464+
self.searchProvider = new ngSearchProvider($scope, self, $filter);
465+
self.styleProvider = new ngStyleProvider($scope, self);
466+
$scope.$watch('configGroups', function(a) {
467+
var tempArr = [];
468+
angular.forEach(a, function(item) {
469+
tempArr.push(item.field || item);
470+
});
471+
self.config.groups = tempArr;
472+
self.rowFactory.filteredRowsChanged();
473+
$scope.$emit('ngGridEventGroups', a);
474+
}, true);
475+
$scope.$watch('columns', function (a) {
476+
domUtilityService.BuildStyles($scope, self, true);
477+
$scope.$emit('ngGridEventColumns', a);
478+
}, true);
479+
$scope.$watch(function() {
480+
return options.i18n;
481+
}, function(newLang) {
482+
$utils.seti18n($scope, newLang);
483+
});
484+
self.maxCanvasHt = self.calcMaxCanvasHeight();
485+
if (self.config.sortInfo.fields && self.config.sortInfo.fields.length > 0) {
486+
self.getColsFromFields();
487+
self.sortActual();
488+
}
468489
});
469-
self.maxCanvasHt = self.calcMaxCanvasHeight();
470-
if (self.config.sortInfo.fields && self.config.sortInfo.fields.length > 0) {
471-
self.getColsFromFields();
472-
self.sortActual();
473-
}
490+
491+
// var p = $q.defer();
492+
// p.resolve();
493+
// return p.promise;
474494
};
475495

476496
self.resizeOnData = function(col) {
@@ -565,7 +585,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
565585
angular.forEach(tempData, function(item, i) {
566586
var e = self.rowMap[i];
567587
if (e != undefined) {
568-
var v = self.rowCache[v];
588+
var v = self.rowCache[i];
569589
if(v != undefined) {
570590
item.preSortSelected = v.selected;
571591
item.preSortIndex = i;
@@ -813,6 +833,4 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
813833
}
814834
return newDim;
815835
};
816-
//call init
817-
self.init();
818836
};

0 commit comments

Comments
 (0)