Commit 9bd371423a951761f51e7d5a8aab396fccef8c59
Exists in
master
Merge branch 'master' into 'master'
Implementación angular ladda See merge request modulos-npm/foca-modal-vendedores!10
Showing
6 changed files
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const concat = require('gulp-concat'); | 2 | const concat = require('gulp-concat'); |
3 | const htmlmin = require('gulp-htmlmin'); | 3 | const htmlmin = require('gulp-htmlmin'); |
4 | const rename = require('gulp-rename'); | 4 | const rename = require('gulp-rename'); |
5 | const uglify = require('gulp-uglify'); | 5 | const uglify = require('gulp-uglify'); |
6 | const gulp = require('gulp'); | 6 | const gulp = require('gulp'); |
7 | const pump = require('pump'); | 7 | const pump = require('pump'); |
8 | const jshint = require('gulp-jshint'); | 8 | const jshint = require('gulp-jshint'); |
9 | const replace = require('gulp-replace'); | 9 | const replace = require('gulp-replace'); |
10 | const connect = require('gulp-connect'); | 10 | const connect = require('gulp-connect'); |
11 | const clean = require('gulp-clean'); | 11 | const clean = require('gulp-clean'); |
12 | 12 | ||
13 | var paths = { | 13 | var paths = { |
14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
16 | tmp: 'tmp', | 16 | tmp: 'tmp', |
17 | dist: 'dist/' | 17 | dist: 'dist/' |
18 | }; | 18 | }; |
19 | 19 | ||
20 | gulp.task('templates', function() { | 20 | gulp.task('templates', function() { |
21 | return pump( | 21 | return pump( |
22 | [ | 22 | [ |
23 | gulp.src(paths.srcViews), | 23 | gulp.src(paths.srcViews), |
24 | replace('views/', ''), | 24 | replace('views/', ''), |
25 | htmlmin(), | 25 | htmlmin(), |
26 | templateCache('views.js', { | 26 | templateCache('views.js', { |
27 | module: 'focaModalVendedores', | 27 | module: 'focaModalVendedores', |
28 | root: '' | 28 | root: '' |
29 | }), | 29 | }), |
30 | gulp.dest(paths.tmp) | 30 | gulp.dest(paths.tmp) |
31 | ] | 31 | ] |
32 | ); | 32 | ); |
33 | }); | 33 | }); |
34 | 34 | ||
35 | gulp.task('uglify', ['templates'], function() { | 35 | gulp.task('uglify', ['templates'], function() { |
36 | return pump( | 36 | return pump( |
37 | [ | 37 | [ |
38 | gulp.src([ | 38 | gulp.src([ |
39 | paths.srcJS, | 39 | paths.srcJS, |
40 | 'tmp/views.js' | 40 | 'tmp/views.js' |
41 | ]), | 41 | ]), |
42 | concat('foca-modal-vendedores.js'), | 42 | concat('foca-modal-vendedores.js'), |
43 | replace('src/views/', ''), | 43 | replace('src/views/', ''), |
44 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | 44 | replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), |
45 | gulp.dest(paths.tmp), | 45 | gulp.dest(paths.tmp), |
46 | rename('foca-modal-vendedores.min.js'), | 46 | rename('foca-modal-vendedores.min.js'), |
47 | uglify(), | 47 | uglify(), |
48 | gulp.dest(paths.dist) | 48 | gulp.dest(paths.dist) |
49 | ] | 49 | ] |
50 | ); | 50 | ); |
51 | }); | 51 | }); |
52 | 52 | ||
53 | gulp.task('pre-commit', function() { | 53 | gulp.task('pre-commit', function() { |
54 | return pump( | 54 | return pump( |
55 | [ | 55 | [ |
56 | gulp.src(paths.srcJS), | 56 | gulp.src(paths.srcJS), |
57 | jshint('.jshintrc'), | 57 | jshint('.jshintrc'), |
58 | jshint.reporter('default'), | 58 | jshint.reporter('default'), |
59 | jshint.reporter('fail') | 59 | jshint.reporter('fail') |
60 | ] | 60 | ] |
61 | ); | 61 | ); |
62 | 62 | ||
63 | gulp.start('uglify'); | 63 | gulp.start('uglify'); |
64 | }); | 64 | }); |
65 | 65 | ||
66 | gulp.task('webserver', function() { | 66 | gulp.task('webserver', function() { |
67 | pump [ | 67 | pump [ |
68 | connect.server({port: 3000}) | 68 | connect.server({port: 3000}) |
69 | ] | 69 | ] |
70 | }); | 70 | }); |
71 | 71 | ||
72 | gulp.task('clean-post-install', function(){ | 72 | gulp.task('clean-post-install', function(){ |
73 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 73 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
74 | 'index.html'], {read: false}) | 74 | 'index.html'], {read: false}) |
75 | .pipe(clean()); | 75 | .pipe(clean()); |
76 | }); | 76 | }); |
77 | 77 | ||
78 | gulp.task('default', ['webserver']); | 78 | gulp.task('default', ['webserver']); |
79 | 79 | ||
80 | gulp.task('watch', function() { | 80 | gulp.task('watch', function() { |
81 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | 81 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) |
82 | }); | 82 | }); |
83 | 83 |
index.html
1 | <html ng-app="focaModalVendedores"> | 1 | <html ng-app="focaModalVendedores"> |
2 | 2 | ||
3 | <head> | 3 | <head> |
4 | <meta charset="UTF-8" /> | 4 | <meta charset="UTF-8" /> |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
6 | 6 | ||
7 | <!--CSS--> | 7 | <!--CSS--> |
8 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" /> | 8 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" /> |
9 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" /> | 9 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" /> |
10 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> | ||
10 | 11 | ||
11 | <!--VENDOR JS--> | 12 | <!--VENDOR JS--> |
12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 13 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 14 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
14 | <script src="node_modules/angular/angular.min.js"></script> | 15 | <script src="node_modules/angular/angular.min.js"></script> |
15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
16 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 17 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
18 | <script src="node_modules/ladda/dist/spin.min.js"></script> | ||
19 | <script src="node_modules/ladda/dist/ladda.min.js"></script> | ||
20 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> | ||
17 | 21 | ||
18 | <!-- BUILD --> | 22 | <!-- BUILD --> |
19 | <script src="src/js/app.js"></script> | 23 | <script src="src/js/app.js"></script> |
20 | <script src="src/js/controller.js"></script> | 24 | <script src="src/js/controller.js"></script> |
21 | <script src="src/js/service.js"></script> | 25 | <script src="src/js/service.js"></script> |
22 | 26 | ||
23 | <!-- /BUILD --> | 27 | <!-- /BUILD --> |
24 | 28 | ||
25 | <!-- CONFIG PARA DEVELOP --> | 29 | <!-- CONFIG PARA DEVELOP --> |
26 | <script type="text/javascript"> | 30 | <script type="text/javascript"> |
27 | angular.module('focaModalVendedores') | 31 | angular.module('focaModalVendedores') |
28 | .controller('controller', ['$uibModal', '$timeout', function($uibModal, $timeout) { | 32 | .controller('controller', ['$uibModal', '$timeout', function($uibModal, $timeout) { |
29 | openModal(); | 33 | openModal(); |
30 | 34 | ||
31 | function openModal() { | 35 | function openModal() { |
32 | var modalInstance = $uibModal.open( | 36 | var modalInstance = $uibModal.open( |
33 | { | 37 | { |
34 | ariaLabelledBy: 'Busqueda de Vendedores', | 38 | ariaLabelledBy: 'Busqueda de Vendedores', |
35 | templateUrl: 'src/views/modal-vendedores.html', | 39 | templateUrl: 'src/views/modal-vendedores.html', |
36 | controller: 'modalVendedoresCtrl', | 40 | controller: 'modalVendedoresCtrl', |
37 | size: 'lg' | 41 | size: 'lg' |
38 | } | 42 | } |
39 | ); | 43 | ); |
40 | 44 | ||
41 | modalInstance.result.then( | 45 | modalInstance.result.then( |
42 | function (selectedItem) { | 46 | function (selectedItem) { |
43 | console.info(selectedItem); | 47 | console.info(selectedItem); |
44 | $timeout(openModal, 500); | 48 | $timeout(openModal, 500); |
45 | }, function () { | 49 | }, function () { |
46 | console.info('modal-component dismissed at: ' + new Date()); | 50 | console.info('modal-component dismissed at: ' + new Date()); |
47 | $timeout(openModal, 500); | 51 | $timeout(openModal, 500); |
48 | } | 52 | } |
49 | ); | 53 | ); |
50 | } | 54 | } |
51 | }]); | 55 | }]); |
52 | </script> | 56 | </script> |
53 | 57 | ||
54 | <script src="src/etc/develop.js"></script> | 58 | <script src="src/etc/develop.js"></script> |
55 | </head> | 59 | </head> |
56 | 60 | ||
57 | <body ng-controller="controller"> | 61 | <body ng-controller="controller"> |
58 | <style> | 62 | <style> |
59 | .p-5 { | 63 | .p-5 { |
60 | padding: 5px !important; | 64 | padding: 5px !important; |
61 | } | 65 | } |
62 | </style> | 66 | </style> |
63 | </body> | 67 | </body> |
64 | 68 | ||
65 | </html> | 69 | </html> |
package.json
1 | { | 1 | { |
2 | "name": "foca-modal-vendedores", | 2 | "name": "foca-modal-vendedores", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Modal para seleccionar vendedores", | 4 | "description": "Modal para seleccionar vendedores", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "gulp-pre-commit": "gulp pre-commit", | 8 | "gulp-pre-commit": "gulp pre-commit", |
9 | "compile": "gulp uglify", | 9 | "compile": "gulp uglify", |
10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
11 | "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-clean gulp-replace gulp-uglify jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas" | 11 | "install-dev": "npm install -D angular angular-ladda ladda@1.0.6 bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-clean gulp-replace gulp-uglify jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas" |
12 | }, | 12 | }, |
13 | "pre-commit": [ | 13 | "pre-commit": [ |
14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
15 | ], | 15 | ], |
16 | "repository": { | 16 | "repository": { |
17 | "type": "git", | 17 | "type": "git", |
18 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-vendedores" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-vendedores" |
19 | }, | 19 | }, |
20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
21 | "license": "ISC", | 21 | "license": "ISC", |
22 | "peerDependencies": { | 22 | "peerDependencies": { |
23 | "angular": "^1.7.4", | 23 | "angular": "^1.7.4", |
24 | "bootstrap": "^4.1.3", | 24 | "bootstrap": "^4.1.3", |
25 | "font-awesome": "^4.7.0", | 25 | "font-awesome": "^4.7.0", |
26 | "ui-bootstrap4": "^3.0.4", | 26 | "ui-bootstrap4": "^3.0.4", |
27 | "gulp": "^3.9.1", | 27 | "gulp": "^3.9.1", |
28 | "gulp-angular-templatecache": "^2.2.1", | 28 | "gulp-angular-templatecache": "^2.2.1", |
29 | "gulp-concat": "^2.6.1", | 29 | "gulp-concat": "^2.6.1", |
30 | "gulp-connect": "^5.6.1", | 30 | "gulp-connect": "^5.6.1", |
31 | "gulp-htmlmin": "^5.0.1", | 31 | "gulp-htmlmin": "^5.0.1", |
32 | "gulp-rename": "^1.4.0", | 32 | "gulp-rename": "^1.4.0", |
33 | "gulp-replace": "^1.0.0", | 33 | "gulp-replace": "^1.0.0", |
34 | "gulp-uglify": "^3.0.1", | 34 | "gulp-uglify": "^3.0.1", |
35 | "jquery": "^3.3.1", | 35 | "jquery": "^3.3.1", |
36 | "pump": "^3.0.0", | 36 | "pump": "^3.0.0", |
37 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas" | 37 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas" |
38 | }, | 38 | }, |
39 | "devDependencies": { | 39 | "devDependencies": { |
40 | "angular": "^1.7.5", | 40 | "angular": "^1.7.5", |
41 | "angular-ladda": "^0.4.3", | ||
41 | "bootstrap": "^4.1.3", | 42 | "bootstrap": "^4.1.3", |
42 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", | 43 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", |
43 | "font-awesome": "^4.7.0", | 44 | "font-awesome": "^4.7.0", |
44 | "gulp": "^3.9.1", | 45 | "gulp": "^3.9.1", |
45 | "gulp-angular-templatecache": "^2.2.3", | 46 | "gulp-angular-templatecache": "^2.2.3", |
46 | "gulp-clean": "^0.4.0", | 47 | "gulp-clean": "^0.4.0", |
47 | "gulp-concat": "^2.6.1", | 48 | "gulp-concat": "^2.6.1", |
48 | "gulp-connect": "^5.6.1", | 49 | "gulp-connect": "^5.6.1", |
49 | "gulp-htmlmin": "^5.0.1", | 50 | "gulp-htmlmin": "^5.0.1", |
50 | "gulp-jshint": "^2.1.0", | 51 | "gulp-jshint": "^2.1.0", |
51 | "gulp-rename": "^1.4.0", | 52 | "gulp-rename": "^1.4.0", |
52 | "gulp-replace": "^1.0.0", | 53 | "gulp-replace": "^1.0.0", |
53 | "gulp-uglify": "^3.0.1", | 54 | "gulp-uglify": "^3.0.1", |
54 | "jasmine-core": "^3.3.0", | 55 | "jasmine-core": "^3.3.0", |
55 | "jquery": "^3.3.1", | 56 | "jquery": "^3.3.1", |
56 | "jshint": "^2.9.6", | 57 | "jshint": "^2.9.6", |
58 | "ladda": "1.0.6", | ||
57 | "pre-commit": "^1.2.2", | 59 | "pre-commit": "^1.2.2", |
58 | "pump": "^3.0.0", | 60 | "pump": "^3.0.0", |
59 | "ui-bootstrap4": "^3.0.5" | 61 | "ui-bootstrap4": "^3.0.5" |
60 | } | 62 | } |
61 | } | 63 | } |
62 | 64 |
src/js/app.js
1 | angular.module('focaModalVendedores', ['ui.bootstrap', 'focaDirectivas']); | 1 | angular.module('focaModalVendedores', ['ui.bootstrap', 'focaDirectivas', 'angular-ladda']); |
2 | 2 |
src/js/controller.js
1 | angular.module('focaModalVendedores') | 1 | angular.module('focaModalVendedores') |
2 | .controller('modalVendedoresCtrl', [ | 2 | .controller('modalVendedoresCtrl', [ |
3 | '$filter', | 3 | '$filter', |
4 | '$scope', | 4 | '$scope', |
5 | '$uibModalInstance', | 5 | '$uibModalInstance', |
6 | 'focaVendedoresService', | 6 | 'focaVendedoresService', |
7 | function($filter, $scope, $uibModalInstance, focaVendedoresService) { | 7 | function($filter, $scope, $uibModalInstance, focaVendedoresService) { |
8 | 8 | ||
9 | $scope.filters = ''; | 9 | $scope.filters = ''; |
10 | $scope.vendedores = []; | 10 | $scope.vendedores = []; |
11 | $scope.primerBusqueda = false; | 11 | $scope.primerBusqueda = false; |
12 | $scope.searchLoading = false; | ||
12 | // pagination | 13 | // pagination |
13 | $scope.numPerPage = 10; | 14 | $scope.numPerPage = 10; |
14 | $scope.currentPage = 1; | 15 | $scope.currentPage = 1; |
15 | $scope.filteredVendedores = []; | 16 | $scope.filteredVendedores = []; |
16 | $scope.currentPageVendedores = []; | 17 | $scope.currentPageVendedores = []; |
17 | $scope.selectedVendedor = -1; | 18 | $scope.selectedVendedor = -1; |
18 | 19 | ||
19 | $scope.busquedaPress = function(key) { | 20 | $scope.busquedaPress = function(key) { |
20 | if (key === 13) { | 21 | if (key === 13) { |
22 | $scope.searchLoading = true; | ||
21 | focaVendedoresService.getVendedores($scope.filters).then( | 23 | focaVendedoresService.getVendedores($scope.filters).then( |
22 | function(res) { | 24 | function(res) { |
25 | $scope.searchLoading = false; | ||
23 | $scope.primerBusqueda = true; | 26 | $scope.primerBusqueda = true; |
24 | $scope.vendedores = res.data; | 27 | $scope.vendedores = res.data; |
25 | $scope.search(); | 28 | $scope.search(); |
26 | primera(); | 29 | primera(); |
27 | } | 30 | } |
28 | ); | 31 | ); |
29 | } | 32 | } |
30 | }; | 33 | }; |
31 | 34 | ||
32 | $scope.search = function() { | 35 | $scope.search = function() { |
33 | if($scope.vendedores.length > 0) { | 36 | if($scope.vendedores.length > 0) { |
34 | $scope.filteredVendedores = $filter('filter')( | 37 | $scope.filteredVendedores = $filter('filter')( |
35 | $scope.vendedores, { $: $scope.filters } | 38 | $scope.vendedores, { $: $scope.filters } |
36 | ); | 39 | ); |
37 | $scope.lastPage = Math.ceil( | 40 | $scope.lastPage = Math.ceil( |
38 | $scope.filteredVendedores.length / $scope.numPerPage | 41 | $scope.filteredVendedores.length / $scope.numPerPage |
39 | ); | 42 | ); |
40 | $scope.resetPage(); | 43 | $scope.resetPage(); |
41 | } | 44 | } |
42 | }; | 45 | }; |
43 | 46 | ||
44 | $scope.resetPage = function() { | 47 | $scope.resetPage = function() { |
45 | $scope.currentPage = 1; | 48 | $scope.currentPage = 1; |
46 | $scope.selectPage(1); | 49 | $scope.selectPage(1); |
47 | }; | 50 | }; |
48 | 51 | ||
49 | $scope.selectPage = function(page) { | 52 | $scope.selectPage = function(page) { |
50 | var start = (page - 1) * $scope.numPerPage; | 53 | var start = (page - 1) * $scope.numPerPage; |
51 | var end = start + $scope.numPerPage; | 54 | var end = start + $scope.numPerPage; |
52 | $scope.paginas = []; | 55 | $scope.paginas = []; |
53 | $scope.paginas = calcularPages(page); | 56 | $scope.paginas = calcularPages(page); |
54 | $scope.currentPageVendedores = $scope.filteredVendedores.slice(start, end); | 57 | $scope.currentPageVendedores = $scope.filteredVendedores.slice(start, end); |
55 | $scope.currentPage = page; | 58 | $scope.currentPage = page; |
56 | }; | 59 | }; |
57 | 60 | ||
58 | $scope.select = function(vendedor) { | 61 | $scope.select = function(vendedor) { |
59 | $uibModalInstance.close(vendedor); | 62 | $uibModalInstance.close(vendedor); |
60 | }; | 63 | }; |
61 | 64 | ||
62 | $scope.cancel = function() { | 65 | $scope.cancel = function() { |
63 | $uibModalInstance.dismiss('cancel'); | 66 | $uibModalInstance.dismiss('cancel'); |
64 | }; | 67 | }; |
65 | 68 | ||
66 | $scope.busquedaDown = function(key) { | 69 | $scope.busquedaDown = function(key) { |
67 | if (key === 40) { | 70 | if (key === 40) { |
68 | primera(key); | 71 | primera(key); |
69 | } | 72 | } |
70 | }; | 73 | }; |
71 | 74 | ||
72 | $scope.itemVendedor = function(key) { | 75 | $scope.itemVendedor = function(key) { |
73 | if (key === 38) { | 76 | if (key === 38) { |
74 | anterior(key); | 77 | anterior(key); |
75 | } | 78 | } |
76 | 79 | ||
77 | if (key === 40) { | 80 | if (key === 40) { |
78 | siguiente(key); | 81 | siguiente(key); |
79 | } | 82 | } |
80 | 83 | ||
81 | if (key === 37) { | 84 | if (key === 37) { |
82 | retrocederPagina(); | 85 | retrocederPagina(); |
83 | } | 86 | } |
84 | 87 | ||
85 | if (key === 39) { | 88 | if (key === 39) { |
86 | avanzarPagina(); | 89 | avanzarPagina(); |
87 | } | 90 | } |
88 | }; | 91 | }; |
89 | 92 | ||
90 | function calcularPages(paginaActual) { | 93 | function calcularPages(paginaActual) { |
91 | var paginas = []; | 94 | var paginas = []; |
92 | paginas.push(paginaActual); | 95 | paginas.push(paginaActual); |
93 | 96 | ||
94 | if (paginaActual - 1 > 1) { | 97 | if (paginaActual - 1 > 1) { |
95 | 98 | ||
96 | paginas.unshift(paginaActual - 1); | 99 | paginas.unshift(paginaActual - 1); |
97 | if (paginaActual - 2 > 1) { | 100 | if (paginaActual - 2 > 1) { |
98 | paginas.unshift(paginaActual - 2); | 101 | paginas.unshift(paginaActual - 2); |
99 | } | 102 | } |
100 | } | 103 | } |
101 | 104 | ||
102 | if (paginaActual + 1 < $scope.lastPage) { | 105 | if (paginaActual + 1 < $scope.lastPage) { |
103 | paginas.push(paginaActual + 1); | 106 | paginas.push(paginaActual + 1); |
104 | if (paginaActual + 2 < $scope.lastPage) { | 107 | if (paginaActual + 2 < $scope.lastPage) { |
105 | paginas.push(paginaActual + 2); | 108 | paginas.push(paginaActual + 2); |
106 | } | 109 | } |
107 | } | 110 | } |
108 | 111 | ||
109 | if (paginaActual !== 1) { | 112 | if (paginaActual !== 1) { |
110 | paginas.unshift(1); | 113 | paginas.unshift(1); |
111 | } | 114 | } |
112 | 115 | ||
113 | if (paginaActual !== $scope.lastPage) { | 116 | if (paginaActual !== $scope.lastPage) { |
114 | paginas.push($scope.lastPage); | 117 | paginas.push($scope.lastPage); |
115 | } | 118 | } |
116 | 119 | ||
117 | return paginas; | 120 | return paginas; |
118 | } | 121 | } |
119 | 122 | ||
120 | function primera() { | 123 | function primera() { |
121 | $scope.selectedVendedor = 0; | 124 | $scope.selectedVendedor = 0; |
122 | } | 125 | } |
123 | 126 | ||
124 | function anterior() { | 127 | function anterior() { |
125 | if ($scope.selectedVendedor === 0 && $scope.currentPage > 1) { | 128 | if ($scope.selectedVendedor === 0 && $scope.currentPage > 1) { |
126 | retrocederPagina(); | 129 | retrocederPagina(); |
127 | } else { | 130 | } else { |
128 | $scope.selectedVendedor--; | 131 | $scope.selectedVendedor--; |
129 | } | 132 | } |
130 | } | 133 | } |
131 | 134 | ||
132 | function siguiente() { | 135 | function siguiente() { |
133 | if ($scope.selectedVendedor < $scope.currentPageVendedores.length - 1) { | 136 | if ($scope.selectedVendedor < $scope.currentPageVendedores.length - 1) { |
134 | $scope.selectedVendedor++; | 137 | $scope.selectedVendedor++; |
135 | } else { | 138 | } else { |
136 | avanzarPagina(); | 139 | avanzarPagina(); |
137 | } | 140 | } |
138 | } | 141 | } |
139 | 142 | ||
140 | function retrocederPagina() { | 143 | function retrocederPagina() { |
141 | if ($scope.currentPage > 1) { | 144 | if ($scope.currentPage > 1) { |
142 | $scope.selectPage($scope.currentPage - 1); | 145 | $scope.selectPage($scope.currentPage - 1); |
143 | $scope.selectedVendedor = $scope.numPerPage - 1; | 146 | $scope.selectedVendedor = $scope.numPerPage - 1; |
144 | } | 147 | } |
145 | } | 148 | } |
146 | 149 | ||
147 | function avanzarPagina() { | 150 | function avanzarPagina() { |
148 | if ($scope.currentPage < $scope.lastPage) { | 151 | if ($scope.currentPage < $scope.lastPage) { |
149 | $scope.selectPage($scope.currentPage + 1); | 152 | $scope.selectPage($scope.currentPage + 1); |
150 | $scope.selectedVendedor = 0; | 153 | $scope.selectedVendedor = 0; |
151 | } | 154 | } |
152 | } | 155 | } |
153 | }] | 156 | }] |
154 | ); | 157 | ); |
155 | 158 |
src/views/modal-vendedores.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <h5 class="modal-title">Búsqueda de vendedores</h5> | 2 | <h5 class="modal-title">Búsqueda de vendedores</h5> |
3 | </div> | 3 | </div> |
4 | <div class="modal-body" id="modal-body"> | 4 | <div class="modal-body" id="modal-body"> |
5 | <div class="input-group"> | 5 | <div class="input-group"> |
6 | <input | 6 | <input |
7 | ladda="searchLoading" | ||
7 | type="text" | 8 | type="text" |
8 | class="form-control form-control-sm" | 9 | class="form-control form-control-sm" |
9 | placeholder="Busqueda" | 10 | placeholder="Busqueda" |
10 | ng-model="filters" | 11 | ng-model="filters" |
11 | ng-change="search()" | 12 | ng-change="search()" |
12 | ng-keydown="busquedaDown($event.keyCode)" | 13 | ng-keydown="busquedaDown($event.keyCode)" |
13 | ng-keypress="busquedaPress($event.keyCode)" | 14 | ng-keypress="busquedaPress($event.keyCode)" |
14 | foca-focus="selectedVendedor == -1" | 15 | foca-focus="selectedVendedor == -1" |
15 | ng-focus="selectedVendedor = -1" | 16 | ng-focus="selectedVendedor = -1" |
16 | > | 17 | > |
17 | <div class="input-group-append"> | 18 | <div class="input-group-append"> |
18 | <button class="btn btn-outline-secondary" type="button" ng-click="busquedaPress(13)"> | 19 | <button |
20 | ladda="searchLoading" | ||
21 | class="btn btn-outline-secondary" | ||
22 | type="button" | ||
23 | ng-click="busquedaPress(13)" | ||
24 | > | ||
19 | <i class="fa fa-search" aria-hidden="true"></i> | 25 | <i class="fa fa-search" aria-hidden="true"></i> |
20 | </button> | 26 | </button> |
21 | </div> | 27 | </div> |
22 | </div> | 28 | </div> |
23 | <table ng-show="primerBusqueda" class="table table-striped table-sm col-12"> | 29 | <table ng-show="primerBusqueda" class="table table-striped table-sm col-12"> |
24 | <thead> | 30 | <thead> |
25 | <tr> | 31 | <tr> |
26 | <th>Código</th> | 32 | <th>Código</th> |
27 | <th>Nombre</th> | 33 | <th>Nombre</th> |
28 | <th></th> | 34 | <th></th> |
29 | </tr> | 35 | </tr> |
30 | </thead> | 36 | </thead> |
31 | <tbody> | 37 | <tbody> |
32 | <tr ng-show="currentPageVendedores.length == 0 && primerBusqueda"> | 38 | <tr ng-show="currentPageVendedores.length == 0 && primerBusqueda"> |
33 | <td colspan="3"> | 39 | <td colspan="3"> |
34 | No se encontraron resultados. | 40 | No se encontraron resultados. |
35 | </td> | 41 | </td> |
36 | </tr> | 42 | </tr> |
37 | <tr class="selected" | 43 | <tr class="selected" |
38 | ng-repeat="(key, vendedor) in currentPageVendedores" | 44 | ng-repeat="(key, vendedor) in currentPageVendedores" |
39 | ng-click="select(vendedor)" | 45 | ng-click="select(vendedor)" |
40 | > | 46 | > |
41 | <td ng-bind="vendedor.CodVen"></td> | 47 | <td ng-bind="vendedor.CodVen"></td> |
42 | <td ng-bind="vendedor.NomVen"></td> | 48 | <td ng-bind="vendedor.NomVen"></td> |
43 | <td> | 49 | <td> |
44 | <button | 50 | <button |
45 | type="button" | 51 | type="button" |
46 | class="btn btn-xs p-1 float-right" | 52 | class="btn btn-xs p-1 float-right" |
47 | ng-class="{ | 53 | ng-class="{ |
48 | 'btn-secondary': selectedVendedor != key, | 54 | 'btn-secondary': selectedVendedor != key, |
49 | 'btn-primary': selectedVendedor == key | 55 | 'btn-primary': selectedVendedor == key |
50 | }" | 56 | }" |
51 | foca-focus="selectedVendedor == {{key}}" | 57 | foca-focus="selectedVendedor == {{key}}" |
52 | ng-keydown="itemVendedor($event.keyCode)"> | 58 | ng-keydown="itemVendedor($event.keyCode)"> |
53 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | 59 | <i class="fa fa-arrow-right" aria-hidden="true"></i> |
54 | </button> | 60 | </button> |
55 | </td> | 61 | </td> |
56 | </tr> | 62 | </tr> |
57 | </tbody> | 63 | </tbody> |
58 | </table> | 64 | </table> |
59 | <nav ng-show="currentPageVendedores.length > 0 && primerBusqueda"> | 65 | <nav ng-show="currentPageVendedores.length > 0 && primerBusqueda"> |
60 | <ul class="pagination pagination-sm justify-content mb-0"> | 66 | <ul class="pagination pagination-sm justify-content mb-0"> |
61 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | 67 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
62 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | 68 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> |
63 | <span aria-hidden="true">«</span> | 69 | <span aria-hidden="true">«</span> |
64 | <span class="sr-only">Anterior</span> | 70 | <span class="sr-only">Anterior</span> |
65 | </a> | 71 | </a> |
66 | </li> | 72 | </li> |
67 | <li | 73 | <li |
68 | class="page-item" | 74 | class="page-item" |
69 | ng-repeat="pagina in paginas" | 75 | ng-repeat="pagina in paginas" |
70 | ng-class="{'active': pagina == currentPage}" | 76 | ng-class="{'active': pagina == currentPage}" |
71 | > | 77 | > |
72 | <a | 78 | <a |
73 | class="page-link" | 79 | class="page-link" |
74 | href="#" | 80 | href="#" |
75 | ng-click="selectPage(pagina)" | 81 | ng-click="selectPage(pagina)" |
76 | ng-bind="pagina" | 82 | ng-bind="pagina" |
77 | ></a> | 83 | ></a> |
78 | </li> | 84 | </li> |
79 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | 85 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> |
80 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | 86 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> |
81 | <span aria-hidden="true">»</span> | 87 | <span aria-hidden="true">»</span> |
82 | <span class="sr-only">Siguiente</span> | 88 | <span class="sr-only">Siguiente</span> |
83 | </a> | 89 | </a> |
84 | </li> | 90 | </li> |
85 | </ul> | 91 | </ul> |
86 | </nav> | 92 | </nav> |
87 | </div> | 93 | </div> |
88 | <div class="modal-footer py-1"> | 94 | <div class="modal-footer py-1"> |
89 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | 95 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
90 | </div> | 96 | </div> |
91 | 97 |