/* Controllers */
-function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, Organizations, RegistrationState) {
+function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, Organizations, ValidStates) {
$scope.$routeParams = $routeParams;
$scope.$location = $location;
$scope.organizations = data;
$log.info('organizations promise ', $scope.organizations);
});
- $scope.RegistrationState = RegistrationState();
+ $scope.ValidStates = ValidStates();
$scope.info = { message: '', css_class: '' } ; // alert box
$scope.reset();
}
-RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'RegistrationState' ];
+RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'ValidStates' ];
-function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, RegistrationState ) {
+function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidStates ) {
$scope.list = [];
$scope.list_results = 0;
states: true,
pager_numeric: false
};
- $scope.RegistrationState = RegistrationState();
+ $scope.ValidStates = ValidStates();
$scope.create_counts = function( array ) {
$log.info('create_counts', array.length );
}
}
-ListCtrl.$inject = [ '$scope', '$log', 'Registration', 'RegistrationTypes', '$filter', 'RegistrationState' ];
+ListCtrl.$inject = [ '$scope', '$log', 'Registration', 'RegistrationTypes', '$filter', 'ValidStates' ];
+++ /dev/null
-../lib/angular-ui/bootstrap/src/pagination/pagination.js
\ No newline at end of file
--- /dev/null
+angular.module('ui.bootstrap.pagination', [])
+
+.directive('pagination', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ numPages: '=',
+ currentPage: '=',
+ maxSize: '=',
+ hidePagination: '=',
+ onSelectPage: '&'
+ },
+ templateUrl: 'template/pagination/pagination.html',
+ replace: true,
+ link: function(scope) {
+ scope.$watch('numPages + currentPage + maxSize', function() {
+ scope.pages = [];
+
+ //set the default maxSize to numPages
+ var maxSize = ( scope.maxSize && scope.maxSize < scope.numPages ) ? scope.maxSize : scope.numPages;
+ var startPage = scope.currentPage - Math.floor(maxSize/2);
+
+ //adjust the startPage within boundary
+ if(startPage < 1) {
+ startPage = 1;
+ }
+ if ((startPage + maxSize - 1) > scope.numPages) {
+ startPage = startPage - ((startPage + maxSize - 1) - scope.numPages );
+ }
+
+ for(var i=0; i < maxSize && i < scope.numPages ;i++) {
+ scope.pages.push(startPage + i);
+ }
+ if ( scope.currentPage > scope.numPages ) {
+ scope.selectPage(scope.numPages);
+ }
+ });
+ scope.noPrevious = function() {
+ return scope.currentPage === 1;
+ };
+ scope.noNext = function() {
+ return scope.currentPage === scope.numPages;
+ };
+ scope.isActive = function(page) {
+ return scope.currentPage === page;
+ };
+
+ scope.selectPage = function(page) {
+ if ( ! scope.isActive(page) ) {
+ scope.currentPage = page;
+ scope.onSelectPage({ page: page });
+ }
+ };
+
+ scope.selectPrevious = function() {
+ if ( !scope.noPrevious() ) {
+ scope.selectPage(scope.currentPage-1);
+ }
+ };
+ scope.selectNext = function() {
+ if ( !scope.noNext() ) {
+ scope.selectPage(scope.currentPage+1);
+ }
+ };
+ }
+ };
+});
\ No newline at end of file
return $scope.organizations;
}).
/* http://jsfiddle.net/asgoth/7bNAd/ */
- value('RegistrationState', function() {
+ value('ValidStates', function() {
return [ 'draft', 'confirmation', 'verified', 'review' ];
});
</fieldset>
<fieldset ng-show="show.states">
-<button ng-repeat="state in RegistrationState" ng-click="search.$ = state" class="btn {{state}}">
+<button ng-repeat="state in ValidStates" ng-click="search.$ = state" class="btn {{state}}">
<span class="badge">{{Counts['state+'+state]}}</span>
{{state}}
</button>
<select
ng-model="registration.state"
- ng-options="state for state in RegistrationState"
+ ng-options="state for state in ValidStates"
class="my-label-select"
label="<%= locale en => 'State', hr => 'Stanje' %>"
>
expect( scope.ready ).toBe( true );
});
- it('RegistrationState', function() {
+ it('ValidStates', function() {
$httpBackend.flush();
- expect( scope.RegistrationState ).toBeTruthy();
+ expect( scope.ValidStates ).toBeTruthy();
});
});
describe('my-label-select', function() {
beforeEach(module('myApp.services'));
it('div+label+input', function() {
- inject(function($compile, $rootScope, RegistrationState) {
- //dump( RegistrationState() );
- var element = $compile('<div><select class="my-label-select" ng-model="m" label="label" ng-options="value for value in RegistrationState()"></select></div>')($rootScope);
+ inject(function($compile, $rootScope, ValidStates) {
+ //dump( ValidStates() );
+ var element = $compile('<div><select class="my-label-select" ng-model="m" label="label" ng-options="value for value in ValidStates()"></select></div>')($rootScope);
//dump(element.html());
expect(element.html()).toMatch(/div.*label.*label.*div.*select.*select.*div.*div/i);
});
}));
});
- describe('RegistrationState', function() {
- it('have status', inject(function(RegistrationState) {
- expect(RegistrationState().length).toBe(4);
+ describe('ValidStates', function() {
+ it('have status', inject(function(ValidStates) {
+ expect(ValidStates().length).toBe(4);
}));
});