Commit ddbe0e5c3f2e10d0e5524b68b39290d437cebfa1
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request modulos-npm/foca-modal-proveedor!7
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('clean', function() { | 20 | gulp.task('clean', function() { |
21 | return gulp.src(['tmp', 'dist'], {read: false}) | 21 | return gulp.src(['tmp', 'dist'], {read: false}) |
22 | .pipe(clean()); | 22 | .pipe(clean()); |
23 | }); | 23 | }); |
24 | 24 | ||
25 | gulp.task('templates', ['clean'], function() { | 25 | gulp.task('templates', ['clean'], function() { |
26 | return pump( | 26 | return pump( |
27 | [ | 27 | [ |
28 | gulp.src(paths.srcViews), | 28 | gulp.src(paths.srcViews), |
29 | replace('views/', ''), | 29 | replace('views/', ''), |
30 | htmlmin(), | 30 | htmlmin(), |
31 | templateCache('views.js', { | 31 | templateCache('views.js', { |
32 | module: 'focaModalProveedor', | 32 | module: 'focaModalProveedor', |
33 | root: '' | 33 | root: '' |
34 | }), | 34 | }), |
35 | gulp.dest(paths.tmp) | 35 | gulp.dest(paths.tmp) |
36 | ] | 36 | ] |
37 | ); | 37 | ); |
38 | }); | 38 | }); |
39 | 39 | ||
40 | gulp.task('uglify', ['templates'], function() { | 40 | gulp.task('uglify', ['templates'], function() { |
41 | return pump( | 41 | return pump( |
42 | [ | 42 | [ |
43 | gulp.src([ | 43 | gulp.src([ |
44 | paths.srcJS, | 44 | paths.srcJS, |
45 | 'tmp/views.js' | 45 | 'tmp/views.js' |
46 | ]), | 46 | ]), |
47 | concat('foca-modal-proveedor.js'), | 47 | concat('foca-modal-proveedor.js'), |
48 | replace('src/views/', ''), | 48 | replace('src/views/', ''), |
49 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | 49 | replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), |
50 | gulp.dest(paths.tmp), | 50 | gulp.dest(paths.tmp), |
51 | rename('foca-modal-proveedor.min.js'), | 51 | rename('foca-modal-proveedor.min.js'), |
52 | uglify(), | 52 | uglify(), |
53 | gulp.dest(paths.dist) | 53 | gulp.dest(paths.dist) |
54 | ] | 54 | ] |
55 | ); | 55 | ); |
56 | }); | 56 | }); |
57 | 57 | ||
58 | gulp.task('pre-commit', function() { | 58 | gulp.task('pre-commit', function() { |
59 | return pump( | 59 | return pump( |
60 | [ | 60 | [ |
61 | gulp.src(paths.srcJS), | 61 | gulp.src(paths.srcJS), |
62 | jshint('.jshintrc'), | 62 | jshint('.jshintrc'), |
63 | jshint.reporter('default'), | 63 | jshint.reporter('default'), |
64 | jshint.reporter('fail') | 64 | jshint.reporter('fail') |
65 | ] | 65 | ] |
66 | ); | 66 | ); |
67 | 67 | ||
68 | gulp.start('uglify'); | 68 | gulp.start('uglify'); |
69 | }); | 69 | }); |
70 | 70 | ||
71 | gulp.task('webserver', function() { | 71 | gulp.task('webserver', function() { |
72 | pump [ | 72 | pump [ |
73 | connect.server({port: 3000}) | 73 | connect.server({port: 3000}) |
74 | ] | 74 | ] |
75 | }); | 75 | }); |
76 | 76 | ||
77 | gulp.task('clean-post-install', function() { | 77 | gulp.task('clean-post-install', function() { |
78 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 78 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
79 | 'index.html'], {read: false}) | 79 | 'index.html'], {read: false}) |
80 | .pipe(clean()); | 80 | .pipe(clean()); |
81 | }); | 81 | }); |
82 | 82 | ||
83 | gulp.task('default', ['webserver']); | 83 | gulp.task('default', ['webserver']); |
84 | 84 | ||
85 | gulp.task('watch', function() { | 85 | gulp.task('watch', function() { |
86 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | 86 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) |
87 | }); | 87 | }); |
88 | 88 |
index.html
1 | <html ng-app="focaModalProveedores"> | 1 | <html ng-app="focaModalProveedor"> |
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 src="src/etc/develop.js"></script> | 30 | <script src="src/etc/develop.js"></script> |
27 | 31 | ||
28 | <script type="text/javascript"> | 32 | <script type="text/javascript"> |
29 | angular.module('focaModalProveedor') | 33 | angular.module('focaModalProveedor') |
30 | .controller('controller', ['$uibModal', '$timeout', function ($uibModal, $timeout) { | 34 | .controller('controller', ['$uibModal', '$timeout', function ($uibModal, $timeout) { |
31 | openModal(); | 35 | openModal(); |
32 | 36 | ||
33 | function openModal() { | 37 | function openModal() { |
34 | var modalInstance = $uibModal.open( | 38 | var modalInstance = $uibModal.open( |
35 | { | 39 | { |
36 | ariaLabelledBy: 'Busqueda de Proveedores', | 40 | ariaLabelledBy: 'Busqueda de Proveedores', |
37 | templateUrl: 'src/views/modal-proveedor.html', | 41 | templateUrl: 'src/views/modal-proveedor.html', |
38 | controller: 'focaModalProveedorCtrl', | 42 | controller: 'focaModalProveedorCtrl', |
39 | size: 'lg' | 43 | size: 'lg' |
40 | } | 44 | } |
41 | ); | 45 | ); |
42 | 46 | ||
43 | modalInstance.result.then( | 47 | modalInstance.result.then( |
44 | function (selectedItem) { | 48 | function (selectedItem) { |
45 | console.info(selectedItem); | 49 | console.info(selectedItem); |
46 | $timeout(openModal, 500); | 50 | $timeout(openModal, 500); |
47 | }, function () { | 51 | }, function () { |
48 | console.info('modal-component dismissed at: ' + new Date()); | 52 | console.info('modal-component dismissed at: ' + new Date()); |
49 | $timeout(openModal, 500); | 53 | $timeout(openModal, 500); |
50 | } | 54 | } |
51 | ); | 55 | ); |
52 | } | 56 | } |
53 | }]); | 57 | }]); |
54 | </script> | 58 | </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-proveedor", | 2 | "name": "foca-modal-proveedor", |
3 | "version": "0.0.2", | 3 | "version": "0.0.2", |
4 | "description": "Modal para seleccionar proveedores", | 4 | "description": "Modal para seleccionar proveedores", |
5 | "scripts": { | 5 | "scripts": { |
6 | "test": "echo \"Error: no test specified\" && exit 1", | 6 | "test": "echo \"Error: no test specified\" && exit 1", |
7 | "gulp-pre-commit": "gulp pre-commit", | 7 | "gulp-pre-commit": "gulp pre-commit", |
8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
9 | "postinstall": "npm run compile && gulp clean-post-install", | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | "install-dev": "npm install angular bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean jshint pump gulp-connect gulp-uglify jasmine-core pre-commit gulp-angular-templatecache ui-bootstrap4 git+https://debo.suite.repo/modulos-npm/foca-directivas" | 10 | "install-dev": "npm install -D angular angular-ladda ladda@1.0.6 bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean jshint pump gulp-connect gulp-uglify jasmine-core pre-commit gulp-angular-templatecache ui-bootstrap4 gulp-htmlmin git+https://debo.suite.repo/modulos-npm/foca-directivas" |
11 | }, | 11 | }, |
12 | "pre-commit": [ | 12 | "pre-commit": [ |
13 | "gulp-pre-commit" | 13 | "gulp-pre-commit" |
14 | ], | 14 | ], |
15 | "repository": { | 15 | "repository": { |
16 | "type": "git", | 16 | "type": "git", |
17 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-proveedor" | 17 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-proveedor" |
18 | }, | 18 | }, |
19 | "author": "Nicolás Guarnieri", | 19 | "author": "Nicolás Guarnieri", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "peerDependencies": { | 21 | "peerDependencies": { |
22 | "angular": "^1.7.4", | 22 | "angular": "^1.7.4", |
23 | "bootstrap": "^4.1.3", | 23 | "bootstrap": "^4.1.3", |
24 | "font-awesome": "^4.7.0", | 24 | "font-awesome": "^4.7.0", |
25 | "ui-bootstrap4": "^3.0.4", | 25 | "ui-bootstrap4": "^3.0.4", |
26 | "gulp": "^3.9.1", | 26 | "gulp": "^3.9.1", |
27 | "gulp-angular-templatecache": "^2.2.1", | 27 | "gulp-angular-templatecache": "^2.2.1", |
28 | "gulp-clean": "^0.4.0", | 28 | "gulp-clean": "^0.4.0", |
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.1", | 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.2.1", | 55 | "gulp-uglify-es": "^1.0.4", |
56 | "jasmine-core": "^3.3.0", | ||
55 | "jquery": "^3.3.1", | 57 | "jquery": "^3.3.1", |
56 | "jshint": "^2.9.6", | 58 | "jshint": "^2.9.6", |
59 | "ladda": "1.0.6", | ||
57 | "pre-commit": "^1.2.2", | 60 | "pre-commit": "^1.2.2", |
58 | "pump": "^3.0.0", | 61 | "pump": "^3.0.0", |
59 | "ui-bootstrap4": "^3.0.5" | 62 | "ui-bootstrap4": "^3.0.5" |
60 | } | 63 | } |
61 | } | 64 | } |
62 | 65 |
src/js/app.js
1 | angular.module('focaModalProveedor', ['ui.bootstrap', 'focaDirectivas']); | 1 | angular.module('focaModalProveedor', ['ui.bootstrap', 'focaDirectivas', 'angular-ladda']); |
2 | 2 |
src/js/controller.js
1 | angular.module('focaModalProveedor') | 1 | angular.module('focaModalProveedor') |
2 | .controller('focaModalProveedorCtrl', [ | 2 | .controller('focaModalProveedorCtrl', [ |
3 | '$filter', | 3 | '$filter', |
4 | '$scope', | 4 | '$scope', |
5 | '$uibModalInstance', | 5 | '$uibModalInstance', |
6 | 'focaModalProveedorService', | 6 | 'focaModalProveedorService', |
7 | function ($filter, $scope, $uibModalInstance, focaModalProveedorService) { | 7 | function ($filter, $scope, $uibModalInstance, focaModalProveedorService) { |
8 | var json = {razonCuitCod: ''}; | ||
9 | |||
10 | focaModalProveedorService.getProveedores(json).then( | ||
11 | function (res) { | ||
12 | for (var i = res.data.length - 1; i >= 0; i--) { | ||
13 | if (res.data[i].COD === 0) { | ||
14 | delete res.data[i]; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | $scope.proveedores = res.data; | ||
19 | $scope.search(); | ||
20 | }); | ||
21 | 8 | ||
9 | $scope.filters = ''; | ||
10 | $scope.primerBusqueda = false; | ||
22 | // pagination | 11 | // pagination |
23 | $scope.numPerPage = 10; | 12 | $scope.numPerPage = 10; |
24 | $scope.currentPage = 1; | 13 | $scope.currentPage = 1; |
25 | $scope.filteredProveedores = []; | 14 | $scope.filteredProveedores = []; |
26 | $scope.currentPageProveedores = []; | 15 | $scope.currentPageProveedores = []; |
27 | $scope.selectedProveedores = -1; | 16 | $scope.selectedProveedores = -1; |
28 | 17 | ||
18 | $scope.busquedaPress = function(key) { | ||
19 | if (key === 13) { | ||
20 | $scope.searchLoading = true; | ||
21 | var json = { | ||
22 | razonCuitCod: $scope.filters | ||
23 | }; | ||
24 | focaModalProveedorService.getProveedores(json).then( | ||
25 | function(res) { | ||
26 | for (var i = res.data.length - 1; i >= 0; i--) { | ||
27 | if (res.data[i].COD === 0) { | ||
28 | delete res.data[i]; | ||
29 | } | ||
30 | } | ||
31 | $scope.primerBusqueda = true; | ||
32 | $scope.proveedores = res.data; | ||
33 | $scope.search(); | ||
34 | primera(); | ||
35 | $scope.searchLoading = false; | ||
36 | }); | ||
37 | } | ||
38 | }; | ||
39 | |||
29 | $scope.search = function () { | 40 | $scope.search = function () { |
30 | $scope.filteredProveedores = $filter('filter')( | 41 | $scope.filteredProveedores = $filter('filter')( |
31 | $scope.proveedores, {$: $scope.filters} | 42 | $scope.proveedores, {$: $scope.filters} |
32 | ); | 43 | ); |
33 | 44 | ||
34 | $scope.lastPage = Math.ceil( | 45 | $scope.lastPage = Math.ceil( |
35 | $scope.filteredProveedores.length / $scope.numPerPage | 46 | $scope.filteredProveedores.length / $scope.numPerPage |
36 | ); | 47 | ); |
37 | 48 | ||
38 | $scope.resetPage(); | 49 | $scope.resetPage(); |
39 | }; | 50 | }; |
40 | 51 | ||
41 | $scope.resetPage = function () { | 52 | $scope.resetPage = function () { |
42 | $scope.currentPage = 1; | 53 | $scope.currentPage = 1; |
43 | $scope.selectPage(1); | 54 | $scope.selectPage(1); |
44 | }; | 55 | }; |
45 | 56 | ||
46 | $scope.selectPage = function (page) { | 57 | $scope.selectPage = function (page) { |
47 | console.info(page); | 58 | console.info(page); |
48 | var start = (page - 1) * $scope.numPerPage; | 59 | var start = (page - 1) * $scope.numPerPage; |
49 | var end = start + $scope.numPerPage; | 60 | var end = start + $scope.numPerPage; |
50 | $scope.paginas = []; | 61 | $scope.paginas = []; |
51 | $scope.paginas = calcularPages(page); | 62 | $scope.paginas = calcularPages(page); |
52 | $scope.currentPageProveedores = $scope.filteredProveedores.slice(start, end); | 63 | $scope.currentPageProveedores = $scope.filteredProveedores.slice(start, end); |
53 | $scope.currentPage = page; | 64 | $scope.currentPage = page; |
54 | }; | 65 | }; |
55 | 66 | ||
56 | $scope.select = function(proveedor) { | 67 | $scope.select = function(proveedor) { |
57 | $uibModalInstance.close(proveedor); | 68 | $uibModalInstance.close(proveedor); |
58 | }; | 69 | }; |
59 | 70 | ||
60 | $scope.cancel = function() { | 71 | $scope.cancel = function() { |
61 | $uibModalInstance.dismiss('cancel'); | 72 | $uibModalInstance.dismiss('cancel'); |
62 | }; | 73 | }; |
63 | 74 | ||
64 | $scope.busquedaDown = function(key) { | 75 | $scope.busquedaDown = function(key) { |
65 | if (key === 40) { | 76 | if (key === 40) { |
66 | primera(key); | 77 | primera(key); |
67 | } | 78 | } |
68 | }; | 79 | }; |
69 | 80 | ||
70 | $scope.busquedaPress = function(key) { | ||
71 | if (key === 13) { | ||
72 | primera(key); | ||
73 | } | ||
74 | }; | ||
75 | |||
76 | $scope.itemProveedor = function(key) { | 81 | $scope.itemProveedor = function(key) { |
77 | if (key === 38) { | 82 | if (key === 38) { |
78 | anterior(key); | 83 | anterior(key); |
79 | } | 84 | } |
80 | 85 | ||
81 | if (key === 40) { | 86 | if (key === 40) { |
82 | siguiente(key); | 87 | siguiente(key); |
83 | } | 88 | } |
84 | 89 | ||
85 | if (key === 37) { | 90 | if (key === 37) { |
86 | retrocederPagina(); | 91 | retrocederPagina(); |
87 | } | 92 | } |
88 | 93 | ||
89 | if (key === 39) { | 94 | if (key === 39) { |
90 | avanzarPagina(); | 95 | avanzarPagina(); |
91 | } | 96 | } |
92 | }; | 97 | }; |
93 | 98 | ||
94 | function calcularPages(paginaActual) { | 99 | function calcularPages(paginaActual) { |
95 | var paginas = []; | 100 | var paginas = []; |
96 | paginas.push(paginaActual); | 101 | paginas.push(paginaActual); |
97 | 102 | ||
98 | if (paginaActual - 1 > 1) { | 103 | if (paginaActual - 1 > 1) { |
99 | 104 | ||
100 | paginas.unshift(paginaActual - 1); | 105 | paginas.unshift(paginaActual - 1); |
101 | if (paginaActual - 2 > 1) { | 106 | if (paginaActual - 2 > 1) { |
102 | paginas.unshift(paginaActual - 2); | 107 | paginas.unshift(paginaActual - 2); |
103 | } | 108 | } |
104 | } | 109 | } |
105 | 110 | ||
106 | if (paginaActual + 1 < $scope.lastPage) { | 111 | if (paginaActual + 1 < $scope.lastPage) { |
107 | paginas.push(paginaActual + 1); | 112 | paginas.push(paginaActual + 1); |
108 | if (paginaActual + 2 < $scope.lastPage) { | 113 | if (paginaActual + 2 < $scope.lastPage) { |
109 | paginas.push(paginaActual + 2); | 114 | paginas.push(paginaActual + 2); |
110 | } | 115 | } |
111 | } | 116 | } |
112 | 117 | ||
113 | if (paginaActual !== 1) { | 118 | if (paginaActual !== 1) { |
114 | paginas.unshift(1); | 119 | paginas.unshift(1); |
115 | } | 120 | } |
116 | 121 | ||
117 | if (paginaActual !== $scope.lastPage) { | 122 | if (paginaActual !== $scope.lastPage) { |
118 | paginas.push($scope.lastPage); | 123 | paginas.push($scope.lastPage); |
119 | } | 124 | } |
120 | 125 | ||
121 | return paginas; | 126 | return paginas; |
122 | } | 127 | } |
123 | 128 | ||
124 | function primera() { | 129 | function primera() { |
125 | $scope.selectedProveedores = 0; | 130 | $scope.selectedProveedores = 0; |
126 | } | 131 | } |
127 | 132 | ||
128 | function anterior() { | 133 | function anterior() { |
129 | if ($scope.selectedProveedores === 0 && $scope.currentPage > 1) { | 134 | if ($scope.selectedProveedores === 0 && $scope.currentPage > 1) { |
130 | retrocederPagina(); | 135 | retrocederPagina(); |
131 | } else { | 136 | } else { |
132 | $scope.selectedProveedores--; | 137 | $scope.selectedProveedores--; |
133 | } | 138 | } |
134 | } | 139 | } |
135 | 140 | ||
136 | function siguiente() { | 141 | function siguiente() { |
137 | if ($scope.selectedProveedores < $scope.currentPageProveedores.length - 1 ) { | 142 | if ($scope.selectedProveedores < $scope.currentPageProveedores.length - 1 ) { |
138 | $scope.selectedProveedores++; | 143 | $scope.selectedProveedores++; |
139 | } else { | 144 | } else { |
140 | avanzarPagina(); | 145 | avanzarPagina(); |
src/views/modal-proveedor.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <h5 class="modal-title">Búsqueda de Proveedor</h5> | 2 | <h5 class="modal-title">Búsqueda de Proveedor</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 | type="text" | 7 | ladda="searchLoading" |
8 | class="form-control" | 8 | type="text" |
9 | placeholder="Busqueda" | 9 | class="form-control" |
10 | ng-model="filters" | 10 | placeholder="Busqueda" |
11 | ng-change="search()" | 11 | ng-model="filters" |
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="selectedProveedores == -1" | 15 | foca-focus="selectedProveedores == -1" |
15 | ng-focus="selectedProveedores = -1" | 16 | ng-focus="selectedProveedores = -1" |
16 | > | 17 | > |
17 | <table class="table table-striped table-sm"> | 18 | <div class="input-group-append"> |
18 | <thead> | 19 | <button |
19 | <tr> | 20 | ladda="searchLoading" |
20 | <th>Código</th> | 21 | class="btn btn-outline-secondary" |
21 | <th>Nombre</th> | 22 | type="button" |
22 | <th>CUIT</th> | 23 | ng-click="busquedaPress(13)"> |
23 | <th></th> | 24 | <i class="fa fa-search" aria-hidden="true"></i> |
24 | </tr> | 25 | </button> |
25 | </thead> | ||
26 | <tbody> | ||
27 | <tr | ||
28 | class="selectable" | ||
29 | ng-repeat="(key, proveedor) in currentPageProveedores" | ||
30 | ng-click="select(proveedor)"> | ||
31 | <td ng-bind="proveedor.COD"></td> | ||
32 | <td ng-bind="proveedor.NOM"></td> | ||
33 | <td ng-bind="proveedor.CUIT"></td> | ||
34 | <td> | ||
35 | <button | ||
36 | type="button" | ||
37 | class="btn btn-xs p-1 float-right" | ||
38 | ng-class="{ | ||
39 | 'btn-secondary': selectedProveedores != key, | ||
40 | 'btn-primary': selectedProveedores == key | ||
41 | }" | ||
42 | ng-click="select(proveedor)" | ||
43 | foca-focus="selectedProveedores == {{key}}" | ||
44 | ng-keydown="itemProveedor($event.keyCode)" | ||
45 | > | ||
46 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
47 | </button> | ||
48 | </td> | ||
49 | </tr> | ||
50 | </tbody> | ||
51 | </table> | ||
52 | <nav> | ||
53 | <ul class="pagination pagination-sm justify-content-end mb-0"> | ||
54 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | ||
55 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | ||
56 | <span aria-hidden="true">«</span> | ||
57 | <span class="sr-only">Anterior</span> | ||
58 | </a> | ||
59 | </li> | ||
60 | <li | ||
61 | class="page-item" | ||
62 | ng-repeat="pagina in paginas" | ||
63 | ng-class="{'active': pagina == currentPage}" | ||
64 | > | ||
65 | <a | ||
66 | class="page-link" | ||
67 | href="#" | ||
68 | ng-click="selectPage(pagina)" | ||
69 | ng-bind="pagina" | ||
70 | ></a> | ||
71 | </li> | ||
72 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | ||
73 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | ||
74 | <span aria-hidden="true">»</span> | ||
75 | <span class="sr-only">Siguiente</span> | ||
76 | </a> | ||
77 | </li> | ||
78 | </ul> | ||
79 | </nav> | ||
80 | </div> | 26 | </div> |
81 | </div> | 27 | </div> |
28 | <table ng-show="primerBusqueda" class="table table-striped table-sm"> | ||
29 | <thead> | ||
30 | <tr> | ||
31 | <th>Código</th> | ||
32 | <th>Nombre</th> | ||
33 | <th>CUIT</th> | ||
34 | <th></th> | ||
35 | </tr> | ||
36 | </thead> | ||
37 | <tbody> | ||
38 | <tr ng-show="currentPageProveedores.length == 0 && primerBusqueda"> | ||
39 | <td colspan="4"> | ||
40 | No se encontraron resultados. | ||
41 | </td> | ||
42 | </tr> | ||
43 | <tr | ||
44 | class="selectable" | ||
45 | ng-repeat="(key, proveedor) in currentPageProveedores" |