Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set custom template for pagination #218

Merged
merged 2 commits into from
Nov 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smart-table",
"version": "1.4.4",
"version": "1.4.5",
"homepage": "https://github.com/lorenzofox3/Smart-Table",
"authors": [
"lorenzofox3 <laurent34azerty@gmail.com>"
Expand Down
7 changes: 6 additions & 1 deletion dist/smart-table.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,12 @@ ng.module('smart-table')
stItemsByPage: '=?',
stDisplayedPages: '=?'
},
templateUrl: 'template/smart-table/pagination.html',
templateUrl: function(element, attrs) {
if (attrs.stTemplate) {
return attrs.stTemplate;
}
return 'template/smart-table/pagination.html';
},
link: function (scope, element, attrs, ctrl) {

scope.stItemsByPage = scope.stItemsByPage ? +(scope.stItemsByPage) : 10;
Expand Down
2 changes: 1 addition & 1 deletion dist/smart-table.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smart-table",
"version": "1.4.4",
"version": "1.4.5",
"description": "",
"main": "dist/smart-table.debug.js",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion src/stPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ ng.module('smart-table')
stItemsByPage: '=?',
stDisplayedPages: '=?'
},
templateUrl: 'template/smart-table/pagination.html',
templateUrl: function(element, attrs) {
if (attrs.stTemplate) {
return attrs.stTemplate;
}
return 'template/smart-table/pagination.html';
},
link: function (scope, element, attrs, ctrl) {

scope.stItemsByPage = scope.stItemsByPage ? +(scope.stItemsByPage) : 10;
Expand Down
19 changes: 18 additions & 1 deletion test/spec/stPagination.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('stPagination directive', function () {
$controllerProvider.register('stTableController', ControllerMock);
}));

beforeEach(inject(function ($compile, $rootScope) {
beforeEach(inject(function ($compile, $rootScope, $templateCache) {
rootScope = $rootScope;
compile = $compile;

Expand Down Expand Up @@ -74,6 +74,23 @@ describe('stPagination directive', function () {
});
});

describe('template', function () {
var templateCache;
beforeEach(inject(function ($templateCache) {
templateCache = $templateCache;
}));

it('should load custom template from attribute "st-template"', function() {
templateCache.put('custom_template.html', '<div id="custom_id"></div>');

var template = '<table st-table="rowCollection"><tfoot><tr><td id="pagination" st-pagination="" st-template="custom_template.html"></td></tr></tfoot></table>';
element = compile(template)(rootScope);
rootScope.$apply();

expect(angular.element(element.find('div#custom_id')).length).toBe(1);
});
});

describe('draw pages', function () {

it('it should draw the pages based on table state using 5 as default value for displayed pages number and center it on the active page', function () {
Expand Down