Skip to content

Commit

Permalink
chore(release): 0.8.0 distribution files
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrowhurstram committed Jul 25, 2015
1 parent 032f6ff commit 6e5acd0
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 23 deletions.
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
<a name="0.8.0"></a>
# 0.8.0 (2015-07-25)


## Bug Fixes

- **ngTableController:** don't trigger reload whilst a reload is already in-flight
([97d09ca4](https://github.com/esvit/ng-table/commit/97d09ca43501ea97a30e1afcd04f6ed81df4f97d))


## Features

- **ngTableFilterConfig:** allow template urls for filters to be customized
([032f6ff6](https://github.com/esvit/ng-table/commit/032f6ff6aec0fcad7c4d84976aee8dc317c67a6c))


## Breaking Changes

- **header.html:** due to [47460d67](https://github.com/esvit/ng-table/commit/47460d67acb518a402a42329e6108a4e86e436d6),


The sortBy function previously declared by `ngTableController` has been moved to the new controller
- `ngTableSorterRowController`.

- **ngTableController:** due to [97d09ca4](https://github.com/esvit/ng-table/commit/97d09ca43501ea97a30e1afcd04f6ed81df4f97d),


Calls to `NgTableParams.filter`, `NgTableParams.sorting` (etc) made in the `then` method of
the promise returned by `NgTableParams.reload` will NOT trigger a subsequent call to `NgTableParams.reload`;
the call to `NgTableParams.reload` must now be explicitly be made.

Previously:

```js
tableParams.reload().then(function(){
if (!tableParams.total() && _.size(tableParams.filter()) > 0) {
tableParams.filter({});
}
});
```

Now:

```js
tableParams.reload().then(function(){
if (!tableParams.total() && _.size(tableParams.filter()) > 0) {
tableParams.filter({});
return tableParams.reload();
}
});
```


<a name="0.7.1"></a>
# 0.7.1 (2015-07-20)

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.7.1",
"version": "0.8.0",
"main": [
"./dist/ng-table.min.js",
"./dist/ng-table.min.css"
Expand Down
181 changes: 164 additions & 17 deletions dist/ng-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,65 @@ app.value('ngTableDefaults', {
settings: {}
});

(function(){
'use strict';

angular.module('ngTable')
.provider('ngTableFilterConfig', ngTableFilterConfigProvider);

ngTableFilterConfigProvider.$inject = [];

function ngTableFilterConfigProvider(){
var defaultConfig = {
defaultBaseUrl: 'ng-table/filters/',
defaultExt: '.html',
aliasUrls: {}
};
var config = defaultConfig;

this.$get = ngTableFilterConfig;
this.setConfig = setConfig;

/////////

function setConfig(customConfig){
config = angular.extend({}, defaultConfig, customConfig);
config.aliasUrls = angular.extend({}, defaultConfig.aliasUrls, config.aliasUrls);
}

/////////

ngTableFilterConfig.$inject = [];

function ngTableFilterConfig(){

var publicConfig = angular.copy(config);

var service = {
config: publicConfig,
getTemplateUrl: getTemplateUrl,
getUrlForAlias: getUrlForAlias
};
return service;

/////////

function getTemplateUrl(filterValue, filterKey){
if (filterValue.indexOf('/') !== -1){
return filterValue;
}

return service.getUrlForAlias(filterValue, filterKey);
}

function getUrlForAlias(aliasName/*, filterKey*/){
return config.aliasUrls[aliasName] || config.defaultBaseUrl + aliasName + config.defaultExt;
}
}
}
})();


/**
* @ngdoc service
* @name NgTableParams
Expand Down Expand Up @@ -543,7 +602,23 @@ function($scope, NgTableParams, $timeout, $parse, $compile, $attrs, $element, ng

$scope.$watch('params.$params', function(newParams, oldParams) {

if (newParams === oldParams) {
// We don't want to watch for changes to $params whilst the NgTableParams.reload function is executing
// (ie $loading === true).
// This is important for cases where you have a want to *chain* a subsequent call to reload.
// Take the following code example:
//
// tableParams.reload().then(function(){
// if (!tableParams.total() && _.size(tableParams.filter()) > 0) {
// tableParams.filter({});
// return tableParams.reload();
// }
// });
//
// In the code above, you're checking whether to remove the table filter. When removing the filter
// you want the second reload to execute in the *same promise chain* initiated by the first call
// to reload; you do NOT want the second reload to trigger sometime later because of a $watch
// seeing the change to the filter.
if (newParams === oldParams || $scope.params.settings().$loading) {
return;
}

Expand Down Expand Up @@ -669,21 +744,6 @@ function($scope, NgTableParams, $timeout, $parse, $compile, $attrs, $element, ng
});
}
};

$scope.sortBy = function($column, event) {
var parsedSortable = $column.sortable && $column.sortable();
if (!parsedSortable) {
return;
}
var defaultSort = $scope.params.settings().defaultSort;
var inverseSort = (defaultSort === 'asc' ? 'desc' : 'asc');
var sorting = $scope.params.sorting() && $scope.params.sorting()[parsedSortable] && ($scope.params.sorting()[parsedSortable] === defaultSort);
var sortingParams = (event.ctrlKey || event.metaKey) ? $scope.params.sorting() : {};
sortingParams[parsedSortable] = (sorting ? inverseSort : defaultSort);
$scope.params.parameters({
sorting: sortingParams
});
};
}]);


Expand Down Expand Up @@ -755,6 +815,51 @@ app.factory('ngTableColumn', [function () {
};
}]);

(function(){
'use strict';

angular.module('ngTable')
.controller('ngTableSorterRowController', ngTableSorterRowController);

ngTableSorterRowController.$inject = ['$scope'];

function ngTableSorterRowController($scope){

$scope.sortBy = sortBy;

///////////

function sortBy($column, event) {
var parsedSortable = $column.sortable && $column.sortable();
if (!parsedSortable) {
return;
}
var defaultSort = $scope.params.settings().defaultSort;
var inverseSort = (defaultSort === 'asc' ? 'desc' : 'asc');
var sorting = $scope.params.sorting() && $scope.params.sorting()[parsedSortable] && ($scope.params.sorting()[parsedSortable] === defaultSort);
var sortingParams = (event.ctrlKey || event.metaKey) ? $scope.params.sorting() : {};
sortingParams[parsedSortable] = (sorting ? inverseSort : defaultSort);
$scope.params.parameters({
sorting: sortingParams
});
}
}
})();

(function(){
'use strict';

angular.module('ngTable')
.controller('ngTableFilterRowController', ngTableFilterRowController);

ngTableFilterRowController.$inject = ['$scope', 'ngTableFilterConfig'];

function ngTableFilterRowController($scope, ngTableFilterConfig){

$scope.config = ngTableFilterConfig;
}
})();

/**
* ngTable: Table + Angular JS
*
Expand Down Expand Up @@ -913,6 +1018,46 @@ app.directive('ngTableDynamic', ['$parse', function ($parse){
};
}]);

(function(){
'use strict';

angular.module('ngTable')
.directive('ngTableFilterRow', ngTableFilterRow);

ngTableFilterRow.$inject = [];

function ngTableFilterRow(){
var directive = {
restrict: 'E',
replace: true,
templateUrl: 'ng-table/filterRow.html',
scope: true,
controller: 'ngTableFilterRowController'
};
return directive;
}
})();

(function(){
'use strict';

angular.module('ngTable')
.directive('ngTableSorterRow', ngTableSorterRow);

ngTableSorterRow.$inject = [];

function ngTableSorterRow(){
var directive = {
restrict: 'E',
replace: true,
templateUrl: 'ng-table/sorterRow.html',
scope: true,
controller: 'ngTableSorterRowController'
};
return directive;
}
})();

/**
* ngTable: Table + Angular JS
*
Expand Down Expand Up @@ -966,11 +1111,13 @@ 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/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', '<tr> <th title="{{$column.headerTitle(this)}}" ng-repeat="$column in $columns" ng-class="{ \'sortable\': $column.sortable(this), \'sort-asc\': params.sorting()[$column.sortable(this)]==\'asc\', \'sort-desc\': params.sorting()[$column.sortable(this)]==\'desc\' }" ng-click="sortBy($column, $event)" ng-if="$column.show(this)" ng-init="template=$column.headerTemplateURL(this)" class="header {{$column.class(this)}}"> <div ng-if="!template" class="ng-table-header" ng-class="{\'sort-indicator\': params.settings().sortingIndicator==\'div\'}"> <span ng-bind="$column.title(this)" ng-class="{\'sort-indicator\': params.settings().sortingIndicator==\'span\'}"></span> </div> <div ng-if="template" ng-include="template"></div> </th> </tr> <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-if="filter.indexOf(\'/\') !==-1" ng-include="filter"></div> <div ng-if="filter.indexOf(\'/\')===-1" ng-include="\'ng-table/filters/\' + filter + \'.html\'"></div> </div> </th> </tr> ');
$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> ');
$templateCache.put('ng-table/sorterRow.html', '<tr> <th title="{{$column.headerTitle(this)}}" ng-repeat="$column in $columns" ng-class="{ \'sortable\': $column.sortable(this), \'sort-asc\': params.sorting()[$column.sortable(this)]==\'asc\', \'sort-desc\': params.sorting()[$column.sortable(this)]==\'desc\' }" ng-click="sortBy($column, $event)" ng-if="$column.show(this)" ng-init="template=$column.headerTemplateURL(this)" class="header {{$column.class(this)}}"> <div ng-if="!template" class="ng-table-header" ng-class="{\'sort-indicator\': params.settings().sortingIndicator==\'div\'}"> <span ng-bind="$column.title(this)" ng-class="{\'sort-indicator\': params.settings().sortingIndicator==\'span\'}"></span> </div> <div ng-if="template" ng-include="template"></div> </th> </tr> ');
}]);
return app;
}));
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.

0 comments on commit 6e5acd0

Please sign in to comment.