Skip to content

Commit

Permalink
chore(release): 0.8.2 distribution files
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrowhurstram committed Aug 6, 2015
1 parent b1c60f5 commit 5cf51c9
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 44 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<a name="0.8.2"></a>
# 0.8.2 (2015-08-06)


## Bug Fixes

- **NgTableParams:** datasetChanged event fires too early
([9706a60b](https://github.com/esvit/ng-table/commit/9706a60bc77f787afb04f01e9769c896fc63c063))
- **select-filter:** select lists should not display an empty and '-' option
([1ee441be](https://github.com/esvit/ng-table/commit/1ee441bebf3e1f8fac260a38b8b82122714191d2))


## Features

- **NgTableParams:** generatePagesArray can be called without arguments
([25fc82bd](https://github.com/esvit/ng-table/commit/25fc82bd051b07ee9b49f105e453e7a64b462bfc))


<a name="0.8.1"></a>
# 0.8.1 (2015-08-02)

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-table",
"version": "0.8.1",
"version": "0.8.2",
"main": [
"./dist/ng-table.min.js",
"./dist/ng-table.min.css"
Expand Down
52 changes: 30 additions & 22 deletions dist/ng-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,6 @@ app.factory('NgTableParams', ['$q', '$log', 'ngTableDefaults', 'ngTableGetDataBc
//auto-set the total from passed in data
newSettings.total = newSettings.data.length;
}
// note: using != as want null and undefined to be treated the same
if (newSettings.hasOwnProperty('data') && (newSettings.data != settings.data)) {
if (isCommittedDataset){
this.page(1); // reset page as a new dataset has been supplied
}
isCommittedDataset = false;
ngTableEventsChannel.publishDatasetChanged(this, newSettings.data, settings.data);
}

// todo: remove the backwards compatibility shim and the following two if blocks
if (newSettings.getData && newSettings.getData.length > 1){
Expand All @@ -460,7 +452,18 @@ app.factory('NgTableParams', ['$q', '$log', 'ngTableDefaults', 'ngTableGetDataBc
newSettings.getGroupsFnAdaptor = ngTableGetDataBcShim;
}

var originalDataset = settings.data;
settings = angular.extend(settings, newSettings);

// note: using != as want null and undefined to be treated the same
var hasDatasetChanged = newSettings.hasOwnProperty('data') && (newSettings.data != originalDataset);
if (hasDatasetChanged) {
if (isCommittedDataset){
this.page(1); // reset page as a new dataset has been supplied
}
isCommittedDataset = false;
ngTableEventsChannel.publishDatasetChanged(this, newSettings.data, originalDataset);
}
log('ngTable: set settings', settings);
return this;
}
Expand Down Expand Up @@ -619,13 +622,21 @@ app.factory('NgTableParams', ['$q', '$log', 'ngTableDefaults', 'ngTableGetDataBc
* @name NgTableParams#generatePagesArray
* @description Generate array of pages
*
* When no arguments supplied, the current parameter state of this `NgTableParams` instance will be used
*
* @param {boolean} currentPage which page must be active
* @param {boolean} totalItems Total quantity of items
* @param {boolean} pageSize Quantity of items on page
* @param {number} maxBlocks Quantity of blocks for pagination
* @returns {Array} Array of pages
*/
this.generatePagesArray = function(currentPage, totalItems, pageSize, maxBlocks) {
if (!arguments.length){
currentPage = this.page();
totalItems = this.total();
pageSize = this.count();
}

var maxPage, maxPivotPages, minPage, numPages, pages;
maxBlocks = maxBlocks && maxBlocks < 6 ? 6 : maxBlocks;

Expand Down Expand Up @@ -1075,7 +1086,7 @@ function($scope, NgTableParams, $timeout, $parse, $compile, $attrs, $element, ng
data = [];
} else if (angular.isArray(data)) {
data.unshift({
title: '-',
title: '',
id: ''
});
}
Expand Down Expand Up @@ -1442,8 +1453,8 @@ app.directive('ngTableDynamic', ['$parse', function ($parse){
* @module ngTable
* @restrict A
*/
app.directive('ngTablePagination', ['$compile',
function($compile) {
app.directive('ngTablePagination', ['$compile', 'ngTableEventsChannel',
function($compile, ngTableEventsChannel) {
'use strict';

return {
Expand All @@ -1453,22 +1464,19 @@ app.directive('ngTablePagination', ['$compile',
'templateUrl': '='
},
replace: false,
link: function(scope, element, attrs) {
link: function(scope, element/*, attrs*/) {

var settings = scope.params.settings();
settings.$scope.$on('ngTableAfterReloadData', function() {
var page = scope.params.page(),
total = scope.params.total(),
count = scope.params.count(),
maxBlocks = settings.paginationMaxBlocks;
scope.pages = scope.params.generatePagesArray(page, total, count, maxBlocks);
}, true);
ngTableEventsChannel.onAfterReloadData(function(pubParams) {
scope.pages = pubParams.generatePagesArray();
}, scope, function(pubParams){
return pubParams === scope.params;
});

scope.$watch('templateUrl', function(templateUrl) {
if (angular.isUndefined(templateUrl)) {
return;
}
var template = angular.element(document.createElement('div'))
var template = angular.element(document.createElement('div'));
template.attr({
'ng-include': 'templateUrl'
});
Expand All @@ -1483,7 +1491,7 @@ app.directive('ngTablePagination', ['$compile',
angular.module('ngTable').run(['$templateCache', function ($templateCache) {
$templateCache.put('ng-table/filterRow.html', '<tr ng-show="show_filter" class="ng-table-filters"> <th data-title-text="{{$column.titleAlt(this) || $column.title(this)}}" ng-repeat="$column in $columns" ng-if="$column.show(this)" class="filter"> <div ng-repeat="(name, filter) in $column.filter(this)"> <div ng-include="config.getTemplateUrl(filter)"></div> </div> </th> </tr> ');
$templateCache.put('ng-table/filters/select-multiple.html', '<select ng-options="data.id as data.title for data in $column.data" ng-disabled="$filterRow.disabled" multiple ng-multiple="true" ng-model="params.filter()[name]" ng-if="filter==\'select-multiple\'" class="filter filter-select-multiple form-control" name="{{name}}"> </select> ');
$templateCache.put('ng-table/filters/select.html', '<select ng-options="data.id as data.title for data in $column.data" ng-disabled="$filterRow.disabled" ng-model="params.filter()[name]" ng-if="filter==\'select\'" class="filter filter-select form-control" name="{{name}}"> </select> ');
$templateCache.put('ng-table/filters/select.html', '<select ng-options="data.id as data.title for data in $column.data" ng-disabled="$filterRow.disabled" ng-model="params.filter()[name]" ng-if="filter==\'select\'" class="filter filter-select form-control" name="{{name}}"> <option style="display:none" value=""></option> </select> ');
$templateCache.put('ng-table/filters/text.html', '<input type="text" name="{{name}}" ng-disabled="$filterRow.disabled" ng-model="params.filter()[name]" ng-if="filter==\'text\'" class="input-filter form-control"/>');
$templateCache.put('ng-table/header.html', '<ng-table-sorter-row></ng-table-sorter-row> <ng-table-filter-row></ng-table-filter-row> ');
$templateCache.put('ng-table/pager.html', '<div class="ng-cloak ng-table-pager" ng-if="params.data.length"> <div ng-if="params.settings().counts.length" class="ng-table-counts btn-group pull-right"> <button ng-repeat="count in params.settings().counts" type="button" ng-class="{\'active\':params.count()==count}" ng-click="params.count(count)" class="btn btn-default"> <span ng-bind="count"></span> </button> </div> <ul class="pagination ng-table-pagination"> <li ng-class="{\'disabled\': !page.active && !page.current, \'active\': page.current}" ng-repeat="page in pages" ng-switch="page.type"> <a ng-switch-when="prev" ng-click="params.page(page.number)" href="">&laquo;</a> <a ng-switch-when="first" ng-click="params.page(page.number)" href=""><span ng-bind="page.number"></span></a> <a ng-switch-when="page" ng-click="params.page(page.number)" href=""><span ng-bind="page.number"></span></a> <a ng-switch-when="more" ng-click="params.page(page.number)" href="">&#8230;</a> <a ng-switch-when="last" ng-click="params.page(page.number)" href=""><span ng-bind="page.number"></span></a> <a ng-switch-when="next" ng-click="params.page(page.number)" href="">&raquo;</a> </li> </ul> </div> ');
Expand Down
2 changes: 1 addition & 1 deletion dist/ng-table.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/ng-table.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ng-table.min.js.map

Large diffs are not rendered by default.

24 changes: 8 additions & 16 deletions examples/demo6.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h1>AJAX Data Loading</h1>
return !isNaN(parseFloat(n)) && isFinite(n);
}
var app = angular.module('main', ['ngTable', 'ngResource', 'ngMockE2E']).
run(function ($httpBackend, $filter, $log, NgTableParams) {
run(function ($httpBackend, $filter, $log, NgTableParams, ngTableDefaultGetData) {
// emulation of api server
$httpBackend.whenGET(/data.*/).respond(function (method, url, data, headers) {
var query = url.split('?')[1],
Expand Down Expand Up @@ -123,15 +123,11 @@ <h1>AJAX Data Loading</h1>
{name: "Enos", age: 76}];

var params = new NgTableParams(requestParams);
data = params.filter() ? $filter('filter')(data, params.filter()) : data;
data = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;

var total = data.length;
data = data.slice((params.page() - 1) * params.count(), params.page() * params.count());
var results = ngTableDefaultGetData(data, params);

return [200, {
result: data,
total: total
results: results,
inlineCount: params.total()
}];
});
$httpBackend.whenGET(/.*/).passThrough();
Expand Down Expand Up @@ -163,15 +159,11 @@ <h1>AJAX Data Loading</h1>
counts: [5, 10, 15],
paginationMaxBlocks: 9,
total: 0, // length of data
getData: function ($defer, params) {
getData: function (params) {
// ajax request to api
Api.get(params.url(), function (data) {
$timeout(function () {
// update table params
params.total(data.total);
// set new data
$defer.resolve(data.result);
}, 500);
return Api.get(params.url()).$promise.then(function (data) {
params.total(data.inlineCount);
return data.results;
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-table",
"version": "0.8.1",
"version": "0.8.2",
"author": "Vitalii Savchuk <[email protected]>",
"license": "BSD",
"repository": {
Expand Down

0 comments on commit 5cf51c9

Please sign in to comment.