Skip to content

Commit

Permalink
Released version 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Jan 2, 2016
1 parent e9510d9 commit dd4ac21
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 42 deletions.
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.6.0",
"version": "0.6.1",
"homepage": "https://github.com/Zizzamia/ng-tasty",
"authors": [
{ "name" : "Leonardo Zizzamia", "homepage" : "https://twitter.com/Zizzamia" }
Expand Down
41 changes: 29 additions & 12 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.6.0 - 2015-12-26
* Version: 0.6.1 - 2016-01-01
* License: MIT
*/
angular.module("ngTasty", ["ngTasty.tpls", "ngTasty.component.table","ngTasty.filter.camelize","ngTasty.filter.cleanFieldName","ngTasty.filter.filterInt","ngTasty.filter.range","ngTasty.filter.slugify","ngTasty.service.bindTo","ngTasty.service.debounce","ngTasty.service.joinObjects","ngTasty.service.setProperty","ngTasty.service.tastyUtil","ngTasty.service.throttle","ngTasty.service.webSocket"]);
Expand Down Expand Up @@ -160,21 +160,21 @@ angular.module('ngTasty.component.table', [
* these values by an isolate optional scope variable,
* more info here https://github.com/angular/angular.js/issues/6404 */
if (!angular.isDefined($attrs.bindResource) && !angular.isDefined($attrs.bindResourceCallback)) {
throw new Error('AngularJS tastyTable directive: need the ' +
throw new Error('Angular tastyTable directive: need the ' +
'bind-resource or bind-resource-callback attribute');
}
if (angular.isDefined($attrs.bindResource)) {
if (!angular.isObject($scope.resource)) {
throw new Error('AngularJS tastyTable directive: the bind-resource ('+
throw new Error('Angular tastyTable directive: the bind-resource ('+
$attrs.bindResource + ') is not an object');
} else if (!$scope.resource.header && !$scope.resource.rows) {
throw new Error('AngularJS tastyTable directive: the bind-resource ('+
throw new Error('Angular tastyTable directive: the bind-resource ('+
$attrs.bindResource + ') has the property header or rows undefined');
}
}
if (angular.isDefined($attrs.bindResourceCallback)) {
if (!angular.isFunction($scope.resourceCallback)) {
throw new Error('AngularJS tastyTable directive: the bind-resource-callback ('+
throw new Error('Angular tastyTable directive: the bind-resource-callback ('+
$attrs.bindResourceCallback + ') is not a function');
}
$scope.clientSide = false;
Expand Down Expand Up @@ -248,10 +248,10 @@ angular.module('ngTasty.component.table', [

setDirectivesValues = function (resource) {
if (!angular.isObject(resource)) {
throw new Error('AngularJS tastyTable directive: the resource response '+
throw new Error('Angular tastyTable directive: the resource response '+
'is not an object');
} else if (!resource.header && !resource.rows) {
throw new Error('AngularJS tastyTable directive: the resource response object '+
throw new Error('Angular tastyTable directive: the resource response object '+
'has the property header or rows undefined');
}
Object.keys(resource).forEach(function(key) {
Expand Down Expand Up @@ -308,11 +308,17 @@ angular.module('ngTasty.component.table', [
if ($scope.theadDirective && $scope.header.columns.length) {
reverse = $scope.header.sortOrder === 'asc' ? false : true;
listSortBy = [function(item) {
return item[$scope.header.sortBy];
return $scope.header.sortBy.split('.')
.reduce(function (previousValue, currentValue) {
return previousValue[currentValue];
}, item);
}];
if ($scope.header.columns[0].key !== $scope.header.sortBy) {
listSortBy.push(function(item) {
return item[$scope.header.columns[0].key];
return $scope.header.columns[0].key.split('.')
.reduce(function (previousValue, currentValue) {
return previousValue[currentValue];
}, item);
});
}
if ($scope.header.sortBy) {
Expand Down Expand Up @@ -557,6 +563,13 @@ angular.module('ngTasty.component.table', [
});
}

function cleanSortBy (sortBy) {
if (sortBy) {
return $filter('cleanFieldName')(sortBy);
}
return undefined;
}

scope.setColumns = function () {
var width, i, active, sortable, sort,
isSorted, isSortedCaret;
Expand Down Expand Up @@ -593,15 +606,19 @@ angular.module('ngTasty.component.table', [
'-' + column.key === scope.header.sortBy) {
active = true;
}
if (!angular.isDefined(column.key)) {
throw new Error('Angular tastyTable directive: need a key value ' +
'each column table header');
}
sort = $filter('cleanFieldName')(column.key);
if (scope.header.sortBy === '-' + sort) {
if (cleanSortBy(scope.header.sortBy) === '-' + sort) {
if (tastyTable.config.bootstrapIcon) {
isSorted = '';
isSortedCaret = 'caret';
} else {
isSorted = scope.iconDown;
}
} else if (scope.header.sortBy === sort) {
} else if (cleanSortBy(scope.header.sortBy) === sort) {
if (tastyTable.config.bootstrapIcon) {
isSorted = 'dropup';
isSortedCaret = 'caret';
Expand Down Expand Up @@ -632,7 +649,7 @@ angular.module('ngTasty.component.table', [
}
var columnName, sortOrder;
columnName = $filter('cleanFieldName')(column.key);
if (scope.header.sortBy === columnName) {
if (cleanSortBy(scope.header.sortBy) === columnName) {
sortOrder = 'dsc';
} else {
sortOrder = 'asc';
Expand Down
4 changes: 2 additions & 2 deletions ng-tasty-tpls.min.js

Large diffs are not rendered by default.

43 changes: 30 additions & 13 deletions ng-tasty.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ng-tasty.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-tasty",
"version": "0.6.0",
"version": "0.6.1",
"description": "A lightweight, flexible, and tasty collection of reusable UI components for AngularJS.",
"main": "ng-tasty-tpls.min.js",
"repository": {
Expand Down
39 changes: 28 additions & 11 deletions src/component/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,21 @@ angular.module('ngTasty.component.table', [
* these values by an isolate optional scope variable,
* more info here https://github.com/angular/angular.js/issues/6404 */
if (!angular.isDefined($attrs.bindResource) && !angular.isDefined($attrs.bindResourceCallback)) {
throw new Error('AngularJS tastyTable directive: need the ' +
throw new Error('Angular tastyTable directive: need the ' +
'bind-resource or bind-resource-callback attribute');
}
if (angular.isDefined($attrs.bindResource)) {
if (!angular.isObject($scope.resource)) {
throw new Error('AngularJS tastyTable directive: the bind-resource ('+
throw new Error('Angular tastyTable directive: the bind-resource ('+
$attrs.bindResource + ') is not an object');
} else if (!$scope.resource.header && !$scope.resource.rows) {
throw new Error('AngularJS tastyTable directive: the bind-resource ('+
throw new Error('Angular tastyTable directive: the bind-resource ('+
$attrs.bindResource + ') has the property header or rows undefined');
}
}
if (angular.isDefined($attrs.bindResourceCallback)) {
if (!angular.isFunction($scope.resourceCallback)) {
throw new Error('AngularJS tastyTable directive: the bind-resource-callback ('+
throw new Error('Angular tastyTable directive: the bind-resource-callback ('+
$attrs.bindResourceCallback + ') is not a function');
}
$scope.clientSide = false;
Expand Down Expand Up @@ -239,10 +239,10 @@ angular.module('ngTasty.component.table', [

setDirectivesValues = function (resource) {
if (!angular.isObject(resource)) {
throw new Error('AngularJS tastyTable directive: the resource response '+
throw new Error('Angular tastyTable directive: the resource response '+
'is not an object');
} else if (!resource.header && !resource.rows) {
throw new Error('AngularJS tastyTable directive: the resource response object '+
throw new Error('Angular tastyTable directive: the resource response object '+
'has the property header or rows undefined');
}
Object.keys(resource).forEach(function(key) {
Expand Down Expand Up @@ -299,11 +299,17 @@ angular.module('ngTasty.component.table', [
if ($scope.theadDirective && $scope.header.columns.length) {
reverse = $scope.header.sortOrder === 'asc' ? false : true;
listSortBy = [function(item) {
return item[$scope.header.sortBy];
return $scope.header.sortBy.split('.')
.reduce(function (previousValue, currentValue) {
return previousValue[currentValue];
}, item);
}];
if ($scope.header.columns[0].key !== $scope.header.sortBy) {
listSortBy.push(function(item) {
return item[$scope.header.columns[0].key];
return $scope.header.columns[0].key.split('.')
.reduce(function (previousValue, currentValue) {
return previousValue[currentValue];
}, item);
});
}
if ($scope.header.sortBy) {
Expand Down Expand Up @@ -548,6 +554,13 @@ angular.module('ngTasty.component.table', [
});
}

function cleanSortBy (sortBy) {
if (sortBy) {
return $filter('cleanFieldName')(sortBy);
}
return undefined;
}

scope.setColumns = function () {
var width, i, active, sortable, sort,
isSorted, isSortedCaret;
Expand Down Expand Up @@ -584,15 +597,19 @@ angular.module('ngTasty.component.table', [
'-' + column.key === scope.header.sortBy) {
active = true;
}
if (!angular.isDefined(column.key)) {
throw new Error('Angular tastyTable directive: need a key value ' +
'each column table header');
}
sort = $filter('cleanFieldName')(column.key);
if (scope.header.sortBy === '-' + sort) {
if (cleanSortBy(scope.header.sortBy) === '-' + sort) {
if (tastyTable.config.bootstrapIcon) {
isSorted = '';
isSortedCaret = 'caret';
} else {
isSorted = scope.iconDown;
}
} else if (scope.header.sortBy === sort) {
} else if (cleanSortBy(scope.header.sortBy) === sort) {
if (tastyTable.config.bootstrapIcon) {
isSorted = 'dropup';
isSortedCaret = 'caret';
Expand Down Expand Up @@ -623,7 +640,7 @@ angular.module('ngTasty.component.table', [
}
var columnName, sortOrder;
columnName = $filter('cleanFieldName')(column.key);
if (scope.header.sortBy === columnName) {
if (cleanSortBy(scope.header.sortBy) === columnName) {
sortOrder = 'dsc';
} else {
sortOrder = 'asc';
Expand Down

0 comments on commit dd4ac21

Please sign in to comment.