Skip to content

Commit

Permalink
Released version 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Aug 12, 2014
1 parent 8a1c039 commit c201748
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 23 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.2.3-rc.1",
"version": "0.2.3",
"homepage": "https://github.com/Zizzamia/ng-tasty",
"authors": [
"@zizzamia"
Expand Down
3 changes: 3 additions & 0 deletions docs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ app.get('/table.json', function(req, res){
];
count = req.query.count;
page = req.query.page;
if (req.query['sort-order'] && !req.query['sort-by']) {
req.query['sort-by'] = 'name';
}
if (req.query['sort-by']) {
sortBy = req.query['sort-by'];
if (req.query['sort-order'] === 'dsc') {
Expand Down
1 change: 1 addition & 0 deletions docs/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ angular.module('myApp.controllers', [])
});
}

$scope.notSortBy = ['sf-location'];
$scope.getResourceOne = function (params) {
$scope.urlApiOne = 'table.json?' + params;
return $http.get($scope.urlApiOne).then(function (response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a href="/" class="head">
<h1>#ngTasty</h1>
</a>
<p class="version">v0.2.2</p>
<p class="version">v0.2.3</p>
<div class="head">
<iframe src="http://ghbtns.com/github-btn.html?user=zizzamia&repo=ng-tasty&type=watch&count=true&size=large"
allowtransparency="true" frameborder="0" scrolling="0" width="220" height="40"></iframe>
Expand Down
2 changes: 1 addition & 1 deletion docs/template/table/example-html-2.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<pre ng-non-bindable><code data-language="html">&lt;div tasty-table resource=&quot;getResource&quot;&gt;
&lt;table class=&quot;table table-striped table-condensed&quot;&gt;
&lt;thead tasty-thead&gt;&lt;/thead&gt;
&lt;thead tasty-thead not-sort-by=&quot;notSortBy&quot;&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr ng-repeat=&quot;row in rows&quot;&gt;
&lt;td&gt;&lbrace;&lbrace; row.name &rbrace;&rbrace;&lt;/td&gt;
Expand Down
4 changes: 3 additions & 1 deletion docs/template/table/example-js-2.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<pre><code data-language="javascript">$scope.getResourceOne = function (params) {
<pre><code data-language="javascript">$scope.notSortBy = ['sf-location'];

$scope.getResourceOne = function (params) {
$scope.urlApiOne = 'table.json?' + params;
return $http.get($scope.urlApiOne).then(function (response) {
return {
Expand Down
10 changes: 9 additions & 1 deletion docs/template/table/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ <h2>Table <small>(ngTasty.table)</small></h2>
: Total number of items in all pages.</p>
</li>
</ul>
<p>Settings can be provided as attributes in the <code>&lt;tasty-thead&gt;</code>.</p>
<ul>
<li>
<p><code>not-sort-by</code><i class="glyphicon glyphicon-eye-open"></i>
: list key columns not want sort
</p>
</li>
</ul>
</div>
<div class="row">
<div class="col-md-12 show-grid">
Expand Down Expand Up @@ -55,7 +63,7 @@ <h4>Table with sorting, pagination and filtering</h4>
<h4>Table only with sorting</h4>
<div tasty-table resource="getResourceOne">
<table class="table table-striped table-condensed">
<thead tasty-thead></thead>
<thead tasty-thead not-sort-by="notSortBy"></thead>
<tbody>
<tr ng-repeat="row in rows">
<td>{{ row.name }}</td>
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-tasty",
"version": "0.2.3-rc.1",
"version": "0.2.3",
"description": "A tasty async AngularJS directives.",
"main": "index.js",
"directories": {
Expand Down
7 changes: 6 additions & 1 deletion src/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ angular.module('ngTasty.table', [
return {
restrict: 'AE',
require: '^tastyTable',
scope: {},
scope: {
'notSortBy': '='
},
templateUrl: 'template/table/head.html',
link: function (scope, element, attrs, tastyTable) {
'use strict';
Expand All @@ -192,6 +194,9 @@ angular.module('ngTasty.table', [
};

scope.sortBy = function (field) {
if (scope.notSortBy && scope.notSortBy.indexOf(field.key) >= 0) {
return false;
}
var fieldName;
fieldName = $filter('cleanFieldName')(field.key);
if (scope.header.sortBy == fieldName) {
Expand Down
40 changes: 24 additions & 16 deletions src/table/test/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,12 @@ describe('Directive', function () {
});
expect(element.scope().rows).toEqual([]);
expect(element.scope().pagination).toEqual({});
expect(element.scope().params).toEqual({
sortBy : undefined,
sortOrder : 'asc',
page : 1,
count : 5,
thead : true,
pagination : true
});
expect(element.scope().params.sortBy).toEqual(undefined);
expect(element.scope().params.sortOrder).toEqual('asc');
expect(element.scope().params.page).toEqual(1);
expect(element.scope().params.count).toEqual(5);
expect(element.scope().params.thead).toEqual(true);
expect(element.scope().params.pagination).toEqual(true);
expect(element.scope().theadDirective).toEqual(true);
expect(element.scope().paginationDirective).toEqual(true);
});
Expand Down Expand Up @@ -137,9 +135,10 @@ describe('Directive', function () {
};
});
};
$scope.notSortBy = ['sf-location'];
element = angular.element(''+
'<table tasty-table resource="getResource">'+
' <thead tasty-thead></thead>'+
' <thead tasty-thead not-sort-by="notSortBy"></thead>'+
' <tbody>'+
' <tr ng-repeat="row in rows">'+
' <td>{{ row.name }}</td>'+
Expand Down Expand Up @@ -199,25 +198,34 @@ describe('Directive', function () {
});

it('should set params.sortBy when scope.sortBy is clicked', function () {
field = {'key': 'sf-location', 'name': 'SF Location'};
field = {'key': 'name', 'name': 'Name'};
tastyThead.isolateScope().sortBy(field);
expect(element.scope().params.sortBy).toEqual('sf-location');
expect(element.scope().params.sortBy).toEqual('name');
field = {'key': 'star', 'name': 'star'};
tastyThead.isolateScope().sortBy(field);
expect(element.scope().params.sortBy).toEqual('star');
});

it('should sorting ascending and descending scope.header.sortBy when scope.sortBy is clicked', function () {
it('should not set params.sortBy when scope.sortBy is one of the notSortBy keys', function () {
field = {'key': 'star', 'name': 'star'};
tastyThead.isolateScope().sortBy(field);
expect(element.scope().params.sortBy).toEqual('star');
field = {'key': 'sf-location', 'name': 'SF Location'};
tastyThead.isolateScope().sortBy(field);
expect(tastyThead.isolateScope().header.sortBy).toEqual('sf-location');
expect(element.scope().params.sortBy).toEqual('star');
});

it('should sorting ascending and descending scope.header.sortBy when scope.sortBy is clicked', function () {
field = {'key': 'star', 'name': 'star'};
tastyThead.isolateScope().sortBy(field);
expect(tastyThead.isolateScope().header.sortBy).toEqual('star');
tastyThead.isolateScope().sortBy(field);
expect(tastyThead.isolateScope().header.sortBy).toEqual('-sf-location');
expect(tastyThead.isolateScope().header.sortBy).toEqual('-star');
});

it('should return true or false to indicate if a specific key is sorted up', function () {
var isSortUp;
field = {'key': 'sf-location', 'name': 'SF Location'};
field = field = {'key': 'star', 'name': 'star'};
tastyThead.isolateScope().sortBy(field);
isSortUp = tastyThead.isolateScope().isSortUp(field);
expect(isSortUp).toEqual(false);
Expand All @@ -228,7 +236,7 @@ describe('Directive', function () {

it('should return true or false to indicate if a specific key is sorted down', function () {
var isSortDown;
field = {'key': 'sf-location', 'name': 'SF Location'};
field = field = {'key': 'star', 'name': 'star'};
tastyThead.isolateScope().sortBy(field);
isSortDown = tastyThead.isolateScope().isSortDown(field);
expect(isSortDown).toEqual(true);
Expand Down

0 comments on commit c201748

Please sign in to comment.