Skip to content

Commit

Permalink
Released version 0.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Aug 27, 2014
1 parent 79cd7d3 commit cf5eaed
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 38 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ Inject the `ngTasty` module into your app:
angular.module('myApp', ['ngTasty']);
```

## Changelog

### v0.2.5 (master, released on August 21th 2014)
- Added items-per-page and list-items-per-page settings in table pagination [#15](https://github.com/Zizzamia/ng-tasty/issues/15)
- Added ngTasty.service.tastyUtil [#24](https://github.com/Zizzamia/ng-tasty/issues/24)
- Removed all the Grunt dependence [#23](https://github.com/Zizzamia/ng-tasty/issues/23)
- Fixed table pagination responsive [#18](https://github.com/Zizzamia/ng-tasty/issues/18)

### v0.2.4 (released on August 13th 2014)
- Added a new table that has sorting and pagination client side
- Improved `setDirectivesValues` in `ngTasty.table`
- Fixed issues in `ngTasty.filter.range`
- Fixed issue in `ngTasty.service.setProperty`

## Creator

Designed and built by Leonardo Zizzamia, like grandma used to make.
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-tasty",
"version": "0.2.5",
"version": "0.2.6",
"homepage": "https://github.com/Zizzamia/ng-tasty",
"authors": [
"@zizzamia"
Expand Down
37 changes: 28 additions & 9 deletions ng-tasty-tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-tasty
* https://github.com/Zizzamia/ng-tasty
* Version: 0.2.5 - 2014-08-21
* Version: 0.2.6 - 2014-08-26
* License: MIT
*/
angular.module("ngTasty", ["ngTasty.tpls", "ngTasty.filter","ngTasty.service","ngTasty.table"]);
Expand Down Expand Up @@ -230,13 +230,13 @@ angular.module('ngTasty.table', [
* these values by an isolate optional scope variable,
* more info here https://github.com/angular/angular.js/issues/6404 */
if (angular.isDefined($attrs.query)) {
$scope.query = $scope.$parent.$eval($attrs.query);
$scope.query = $scope.$parent[$attrs.query];
}
if (!angular.isDefined($attrs.resource) && !angular.isDefined($attrs.resourceCallback)) {
throw 'AngularJS tastyTable directive: need the resource or resource-callback attribute';
}
if (angular.isDefined($attrs.resource)) {
$scope.resource = $scope.$parent.$eval($attrs.resource);
$scope.resource = $scope.$parent[$attrs.resource];
if (!angular.isObject($scope.resource)) {
throw 'AngularJS tastyTable directive: the resource ('+
$attrs.resource + ') it\'s not an object';
Expand All @@ -246,7 +246,7 @@ angular.module('ngTasty.table', [
}
}
if (angular.isDefined($attrs.resourceCallback)) {
$scope.resourceCallback = $scope.$parent.$eval($attrs.resourceCallback);
$scope.resourceCallback = $scope.$parent[$attrs.resourceCallback];
if (!angular.isFunction($scope.resourceCallback)) {
throw 'AngularJS tastyTable directive: the resource-callback ('+
$attrs.resourceCallback + ') it\'s not a function';
Expand All @@ -266,23 +266,34 @@ angular.module('ngTasty.table', [
};

$scope.setDirectivesValues = function (resource) {
var sortBy;
if (!resource) {
return false;
}
sortBy = resource.sortBy || $scope.params.sortBy;
sortBy = sortBy || resource.header[0].key;
$scope.header = {
'columns': resource.header,
'sortBy': resource.sortBy || $scope.params.sortBy,
'sortBy': sortBy,
'sortOrder': resource.sortOrder || $scope.params.sortOrder
};
$scope.rows = resource.rows;
$scope.pagination = resource.pagination || $scope.pagination;
};

$scope.buildClientResource = function() {
var fromRow, toRow, rowToShow, reverse;
var fromRow, toRow, rowToShow, reverse, listSortBy;
if ($scope.theadDirective) {
reverse = $scope.header.sortOrder === 'asc' ? false : true;
$scope.rows = $filter('orderBy')($scope.rows, $scope.header.sortBy, reverse);
listSortBy = [function(item) {
return item[$scope.header.sortBy];
}];
if ($scope.header.columns[0].key !== $scope.header.sortBy) {
listSortBy.push(function(item) {
return item[$scope.header.columns[0].key];
});
}
$scope.rows = $filter('orderBy')($scope.rows, listSortBy, reverse);
}
if ($scope.paginationDirective) {
$scope.pagination.page = $scope.params.page;
Expand Down Expand Up @@ -362,6 +373,14 @@ angular.module('ngTasty.table', [
}
}
}, true);
if ($scope.resource) {
$scope.$parent.$watch($attrs.resource, function (newValue, oldValue){
if (newValue !== oldValue) {
$scope.resource = newValue;
$scope.updateClientSideResource();
}
}, true);
}

// Init table
$scope.initTable();
Expand Down Expand Up @@ -482,10 +501,10 @@ angular.module('ngTasty.table', [
*/
.controller('TablePaginationController', ["$scope", "$attrs", "tableConfig", function($scope, $attrs, tableConfig) {
if (angular.isDefined($attrs.itemsPerPage)) {
$scope.itemsPerPage = $scope.$parent.$eval($attrs.itemsPerPage);
$scope.itemsPerPage = $scope.$parent[$attrs.itemsPerPage];
}
if (angular.isDefined($attrs.listItemsPerPage)) {
$scope.listItemsPerPage = $scope.$parent.$eval($attrs.listItemsPerPage);
$scope.listItemsPerPage = $scope.$parent[$attrs.listItemsPerPage];
}
// Default configs
$scope.itemsPerPage = $scope.itemsPerPage || tableConfig.itemsPerPage;
Expand Down
4 changes: 2 additions & 2 deletions ng-tasty-tpls.min.js

Large diffs are not rendered by default.

37 changes: 28 additions & 9 deletions ng-tasty.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-tasty
* https://github.com/Zizzamia/ng-tasty
* Version: 0.2.5 - 2014-08-21
* Version: 0.2.6 - 2014-08-26
* License: MIT
*/
angular.module("ngTasty", ["ngTasty.filter","ngTasty.service","ngTasty.table"]);
Expand Down Expand Up @@ -229,13 +229,13 @@ angular.module('ngTasty.table', [
* these values by an isolate optional scope variable,
* more info here https://github.com/angular/angular.js/issues/6404 */
if (angular.isDefined($attrs.query)) {
$scope.query = $scope.$parent.$eval($attrs.query);
$scope.query = $scope.$parent[$attrs.query];
}
if (!angular.isDefined($attrs.resource) && !angular.isDefined($attrs.resourceCallback)) {
throw 'AngularJS tastyTable directive: need the resource or resource-callback attribute';
}
if (angular.isDefined($attrs.resource)) {
$scope.resource = $scope.$parent.$eval($attrs.resource);
$scope.resource = $scope.$parent[$attrs.resource];
if (!angular.isObject($scope.resource)) {
throw 'AngularJS tastyTable directive: the resource ('+
$attrs.resource + ') it\'s not an object';
Expand All @@ -245,7 +245,7 @@ angular.module('ngTasty.table', [
}
}
if (angular.isDefined($attrs.resourceCallback)) {
$scope.resourceCallback = $scope.$parent.$eval($attrs.resourceCallback);
$scope.resourceCallback = $scope.$parent[$attrs.resourceCallback];
if (!angular.isFunction($scope.resourceCallback)) {
throw 'AngularJS tastyTable directive: the resource-callback ('+
$attrs.resourceCallback + ') it\'s not a function';
Expand All @@ -265,23 +265,34 @@ angular.module('ngTasty.table', [
};

$scope.setDirectivesValues = function (resource) {
var sortBy;
if (!resource) {
return false;
}
sortBy = resource.sortBy || $scope.params.sortBy;
sortBy = sortBy || resource.header[0].key;
$scope.header = {
'columns': resource.header,
'sortBy': resource.sortBy || $scope.params.sortBy,
'sortBy': sortBy,
'sortOrder': resource.sortOrder || $scope.params.sortOrder
};
$scope.rows = resource.rows;
$scope.pagination = resource.pagination || $scope.pagination;
};

$scope.buildClientResource = function() {
var fromRow, toRow, rowToShow, reverse;
var fromRow, toRow, rowToShow, reverse, listSortBy;
if ($scope.theadDirective) {
reverse = $scope.header.sortOrder === 'asc' ? false : true;
$scope.rows = $filter('orderBy')($scope.rows, $scope.header.sortBy, reverse);
listSortBy = [function(item) {
return item[$scope.header.sortBy];
}];
if ($scope.header.columns[0].key !== $scope.header.sortBy) {
listSortBy.push(function(item) {
return item[$scope.header.columns[0].key];
});
}
$scope.rows = $filter('orderBy')($scope.rows, listSortBy, reverse);
}
if ($scope.paginationDirective) {
$scope.pagination.page = $scope.params.page;
Expand Down Expand Up @@ -361,6 +372,14 @@ angular.module('ngTasty.table', [
}
}
}, true);
if ($scope.resource) {
$scope.$parent.$watch($attrs.resource, function (newValue, oldValue){
if (newValue !== oldValue) {
$scope.resource = newValue;
$scope.updateClientSideResource();
}
}, true);
}

// Init table
$scope.initTable();
Expand Down Expand Up @@ -481,10 +500,10 @@ angular.module('ngTasty.table', [
*/
.controller('TablePaginationController', ["$scope", "$attrs", "tableConfig", function($scope, $attrs, tableConfig) {
if (angular.isDefined($attrs.itemsPerPage)) {
$scope.itemsPerPage = $scope.$parent.$eval($attrs.itemsPerPage);
$scope.itemsPerPage = $scope.$parent[$attrs.itemsPerPage];
}
if (angular.isDefined($attrs.listItemsPerPage)) {
$scope.listItemsPerPage = $scope.$parent.$eval($attrs.listItemsPerPage);
$scope.listItemsPerPage = $scope.$parent[$attrs.listItemsPerPage];
}
// Default configs
$scope.itemsPerPage = $scope.itemsPerPage || tableConfig.itemsPerPage;
Expand Down
Loading

0 comments on commit cf5eaed

Please sign in to comment.