Commit 3965c72666c1e806464f279c6a631b5b58ab2910
1 parent
58be81a70e
Exists in
master
and in
1 other branch
Modal precio condiciones recibe ingreso manual de plazos
Showing
7 changed files
with
270 additions
and
112 deletions
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 | htmlmin(), | 29 | htmlmin(), |
30 | templateCache('views.js', { | 30 | templateCache('views.js', { |
31 | module: 'focaModalPrecioCondicion', | 31 | module: 'focaModalPrecioCondicion', |
32 | root: '' | 32 | root: '' |
33 | }), | 33 | }), |
34 | gulp.dest(paths.tmp) | 34 | gulp.dest(paths.tmp) |
35 | ] | 35 | ] |
36 | ); | 36 | ); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | gulp.task('uglify', ['templates'], function() { | 39 | gulp.task('uglify', ['templates'], function() { |
40 | return pump( | 40 | return pump( |
41 | [ | 41 | [ |
42 | gulp.src([ | 42 | gulp.src([ |
43 | paths.srcJS, | 43 | paths.srcJS, |
44 | 'tmp/views.js' | 44 | 'tmp/views.js' |
45 | ]), | 45 | ]), |
46 | concat('foca-modal-precio-condiciones.js'), | 46 | concat('foca-modal-precio-condiciones.js'), |
47 | replace('src/views/', ''), | 47 | replace('src/views/', ''), |
48 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | 48 | replace("['ui.bootstrap', 'focaDirectivas', 'focaModal']", '[]'), |
49 | gulp.dest(paths.tmp), | 49 | gulp.dest(paths.tmp), |
50 | rename('foca-modal-precio-condiciones.min.js'), | 50 | rename('foca-modal-precio-condiciones.min.js'), |
51 | uglify(), | 51 | uglify(), |
52 | gulp.dest(paths.dist) | 52 | gulp.dest(paths.dist) |
53 | ] | 53 | ] |
54 | ); | 54 | ); |
55 | }); | 55 | }); |
56 | 56 | ||
57 | gulp.task('pre-commit', function() { | 57 | gulp.task('pre-commit', function() { |
58 | return pump( | 58 | return pump( |
59 | [ | 59 | [ |
60 | gulp.src(paths.srcJS), | 60 | gulp.src(paths.srcJS), |
61 | jshint('.jshintrc'), | 61 | jshint('.jshintrc'), |
62 | jshint.reporter('default'), | 62 | jshint.reporter('default'), |
63 | jshint.reporter('fail') | 63 | jshint.reporter('fail') |
64 | ] | 64 | ] |
65 | ); | 65 | ); |
66 | }); | 66 | }); |
67 | 67 | ||
68 | gulp.task('webserver', function() { | 68 | gulp.task('webserver', function() { |
69 | pump [ | 69 | pump [ |
70 | connect.server({port: 3000}) | 70 | connect.server({port: 3000}) |
71 | ] | 71 | ] |
72 | }); | 72 | }); |
73 | 73 | ||
74 | gulp.task('clean-post-install', function(){ | 74 | gulp.task('clean-post-install', function(){ |
75 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 75 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
76 | 'index.html'], {read: false}) | 76 | 'index.html'], {read: false}) |
77 | .pipe(clean()); | 77 | .pipe(clean()); |
78 | }); | 78 | }); |
79 | 79 | ||
80 | gulp.task('default', ['webserver']); | 80 | gulp.task('default', ['webserver']); |
81 | 81 | ||
82 | gulp.task('watch', function() { | 82 | gulp.task('watch', function() { |
83 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | 83 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) |
84 | }); | 84 | }); |
85 | 85 |
index.html
1 | <html ng-app="focaModalPrecioCondicion"> | 1 | <html ng-app="focaModalPrecioCondicion"> |
2 | <head> | 2 | <head> |
3 | <meta charset="UTF-8"/> | 3 | <meta charset="UTF-8"/> |
4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
5 | 5 | ||
6 | <!--CSS--> | 6 | <!--CSS--> |
7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> |
8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> |
9 | 9 | ||
10 | <!--VENDOR JS--> | 10 | <!--VENDOR JS--> |
11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
13 | <script src="node_modules/angular/angular.min.js"></script> | 13 | <script src="node_modules/angular/angular.min.js"></script> |
14 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 14 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
15 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 15 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
16 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | ||
16 | 17 | ||
17 | <!-- BUILD --> | 18 | <!-- BUILD --> |
18 | <script src="src/js/app.js"></script> | 19 | <script src="src/js/app.js"></script> |
19 | <script src="src/js/controller.js"></script> | 20 | <script src="src/js/controller.js"></script> |
20 | <script src="src/js/service.js"></script> | 21 | <script src="src/js/service.js"></script> |
21 | 22 | ||
22 | <!-- /BUILD --> | 23 | <!-- /BUILD --> |
23 | 24 | ||
24 | <!-- CONFIG PARA DEVELOP --> | 25 | <!-- CONFIG PARA DEVELOP --> |
25 | <script src="src/etc/develop.js"></script> | 26 | <script src="src/etc/develop.js"></script> |
26 | <script type="text/javascript"> | 27 | <script type="text/javascript"> |
27 | angular.module('focaModalPrecioCondicion') | 28 | angular.module('focaModalPrecioCondicion') |
28 | .controller('controller', [ | 29 | .controller('controller', [ |
29 | '$scope', | 30 | '$scope', |
30 | '$uibModal', | 31 | '$uibModal', |
31 | '$timeout', | 32 | '$timeout', |
32 | function($scope, $uibModal, $timeout) { | 33 | function($scope, $uibModal, $timeout) { |
33 | openModal(); | 34 | openModal(); |
34 | 35 | ||
35 | function openModal() { | 36 | function openModal() { |
36 | var modalInstance = $uibModal.open( | 37 | var modalInstance = $uibModal.open( |
37 | { | 38 | { |
38 | ariaLabelledBy: 'Busqueda de Precio Condicion', | 39 | ariaLabelledBy: 'Busqueda de Precio Condicion', |
39 | templateUrl: 'src/views/modal-precio-condicion.html', | 40 | templateUrl: 'src/views/modal-precio-condicion.html', |
40 | controller: 'focaModalPrecioCondicionController', | 41 | controller: 'focaModalPrecioCondicionController', |
41 | size: 'lg' | 42 | size: 'lg' |
42 | } | 43 | } |
43 | ); | 44 | ); |
44 | 45 | ||
45 | modalInstance.result.then( | 46 | modalInstance.result.then( |
46 | function (selectedItem) { | 47 | function (selectedItem) { |
47 | console.info(selectedItem); | 48 | console.info(selectedItem); |
48 | $timeout(openModal, 500); | 49 | $timeout(openModal, 500); |
49 | }, function () { | 50 | }, function () { |
50 | console.info('modal-component dismissed at: ' + new Date()); | 51 | console.info('modal-component dismissed at: ' + new Date()); |
51 | $timeout(openModal, 500); | 52 | $timeout(openModal, 500); |
52 | } | 53 | } |
53 | ); | 54 | ); |
54 | } | 55 | } |
55 | } | 56 | } |
56 | ]); | 57 | ]); |
57 | </script> | 58 | </script> |
58 | </head> | 59 | </head> |
59 | <body ng-controller="controller"> | 60 | <body ng-controller="controller"> |
60 | </body> | 61 | </body> |
61 | </html> | 62 | </html> |
62 | 63 |
package.json
1 | { | 1 | { |
2 | "name": "foca-modal-precio-condiciones", | 2 | "name": "foca-modal-precio-condiciones", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Modal de búsqueda de precios y condiciones", | 4 | "description": "Modal de búsqueda de precios y condiciones", |
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 font-awesome jquery bootstrap ui-bootstrap4 jshint gulp gulp-uglify gulp-concat gulp-htmlmin gulp-rename gulp-uglify gulp-jshint gulp-replace gulp-connect gulp-clean gulp-angular-templatecache git+https://debo.suite.repo/modulos-npm/foca-directivas.git" | 11 | "install-dev": "npm install -D angular font-awesome jquery bootstrap ui-bootstrap4 jshint gulp gulp-uglify gulp-concat gulp-htmlmin gulp-rename gulp-uglify gulp-jshint gulp-replace gulp-connect gulp-clean gulp-angular-templatecache git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal.git" |
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-precio-condiciones.git" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git" |
19 | }, | 19 | }, |
20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
21 | "license": "ISC", | 21 | "license": "ISC", |
22 | "devDependencies": { | 22 | "devDependencies": { |
23 | "angular": "^1.7.5", | 23 | "angular": "^1.7.5", |
24 | "bootstrap": "^4.1.3", | 24 | "bootstrap": "^4.1.3", |
25 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 25 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
26 | "font-awesome": "^4.7.0", | 26 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
27 | "gulp": "^3.9.1", | 27 | "font-awesome": "^4.7.0", |
28 | "gulp-angular-templatecache": "^2.2.2", | 28 | "gulp": "^3.9.1", |
29 | "gulp-clean": "^0.4.0", | 29 | "gulp-angular-templatecache": "^2.2.2", |
30 | "gulp-concat": "^2.6.1", | 30 | "gulp-clean": "^0.4.0", |
31 | "gulp-connect": "^5.6.1", | 31 | "gulp-concat": "^2.6.1", |
32 | "gulp-htmlmin": "^5.0.1", | 32 | "gulp-connect": "^5.6.1", |
33 | "gulp-jshint": "^2.1.0", | 33 | "gulp-htmlmin": "^5.0.1", |
34 | "gulp-rename": "^1.4.0", | 34 | "gulp-jshint": "^2.1.0", |
35 | "gulp-replace": "^1.0.0", | 35 | "gulp-rename": "^1.4.0", |
36 | "gulp-uglify": "^3.0.1", | 36 | "gulp-replace": "^1.0.0", |
37 | "jquery": "^3.3.1", | 37 | "gulp-uglify": "^3.0.1", |
38 | "jshint": "^2.9.6", | 38 | "jquery": "^3.3.1", |
39 | "pump": "^3.0.0", | 39 | "jshint": "^2.9.6", |
40 | "ui-bootstrap4": "^3.0.5" | 40 | "pump": "^3.0.0", |
41 | "ui-bootstrap4": "^3.0.5" | ||
41 | } | 42 | } |
42 | } | ||
43 | } |
src/js/app.js
1 | angular.module('focaModalPrecioCondicion', ['ui.bootstrap', 'focaDirectivas']); | 1 | angular.module('focaModalPrecioCondicion', ['ui.bootstrap', 'focaDirectivas', 'focaModal']); |
2 | 2 |
src/js/controller.js
1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') |
2 | .controller('focaModalPrecioCondicionController', | 2 | .controller('focaModalPrecioCondicionController', |
3 | [ | 3 | [ |
4 | '$filter', | 4 | '$filter', |
5 | '$scope', | 5 | '$scope', |
6 | '$uibModalInstance', | 6 | '$uibModalInstance', |
7 | 'focaModalService', | ||
7 | 'focaModalPrecioCondicionService', | 8 | 'focaModalPrecioCondicionService', |
8 | function($filter, $scope, $uibModalInstance, focaModalPrecioCondicionService) { | 9 | function($filter, $scope, $uibModalInstance, focaModalService, |
9 | focaModalPrecioCondicionService.getPreciosCondiciones().then( | 10 | focaModalPrecioCondicionService) { |
11 | |||
12 | focaModalPrecioCondicionService.getPreciosCondicionesPlazosPagos().then( | ||
10 | function(res) { | 13 | function(res) { |
14 | for(var i = 0; i < res.data.length; i++) { | ||
15 | var plazosTemp = ''; | ||
16 | for(var j = 0; j < res.data[i].plazoPago.length; j++) { | ||
17 | plazosTemp += res.data[i].plazoPago[j].dias + ' '; | ||
18 | } | ||
19 | res.data[i].plazos = plazosTemp.trim(); | ||
20 | } | ||
11 | $scope.precioCondicion = res.data; | 21 | $scope.precioCondicion = res.data; |
12 | $scope.search(); | 22 | $scope.search(); |
13 | } | 23 | } |
14 | ); | 24 | ); |
15 | 25 | $scope.ingreso = false; | |
26 | $scope.plazosNuevos =[]; | ||
27 | $scope.plazoACargar = | ||
28 | { | ||
29 | item: 1 | ||
30 | }; | ||
16 | // pagination | 31 | // pagination |
17 | $scope.numPerPage = 10; | 32 | $scope.numPerPage = 10; |
18 | $scope.currentPage = 1; | 33 | $scope.currentPage = 1; |
19 | $scope.filteredPrecioCondicion = []; | 34 | $scope.filteredPrecioCondicion = []; |
20 | $scope.currentPagePrecioCondicion = []; | 35 | $scope.currentPagePrecioCondicion = []; |
21 | $scope.selectedPrecioCondicion = -1; | 36 | $scope.selectedPrecioCondicion = -1; |
22 | 37 | ||
23 | //METODOS | 38 | //METODOS |
39 | |||
40 | $scope.agregarPlazo = function(key) { | ||
41 | if(key === 13) { | ||
42 | if(!$scope.plazoACargar.dias) { | ||
43 | focaModalService.alert('Ingrese cantidad de días'); | ||
44 | return; | ||
45 | } | ||
46 | var tieneEseDia = $scope.plazosNuevos.filter(function(a) { | ||
47 | return a.dias === $scope.plazoACargar.dias; | ||
48 | }); | ||
49 | if(tieneEseDia.length > 0) { | ||
50 | focaModalService.alert('Ya ha ingresado un plazo con esos días'); | ||
51 | return; | ||
52 | } | ||
53 | $scope.plazosNuevos.push($scope.plazoACargar); | ||
54 | $scope.plazoACargar = | ||
55 | { | ||
56 | item: $scope.plazosNuevos.length + 1 | ||
57 | }; | ||
58 | } | ||
59 | }; | ||
60 | |||
61 | $scope.volver = function() { | ||
62 | $scope.ingreso = false; | ||
63 | $scope.plazosNuevos = []; | ||
64 | $scope.plazoACargar = | ||
65 | { | ||
66 | item: $scope.plazosNuevos.length + 1 | ||
67 | }; | ||
68 | }; | ||
69 | |||
70 | $scope.quitarPlazo = function(key) { | ||
71 | $scope.plazosNuevos.splice(key, 1); | ||
72 | $scope.plazoACargar = | ||
73 | { | ||
74 | item: $scope.plazosNuevos.length + 1 | ||
75 | }; | ||
76 | }; | ||
77 | |||
24 | $scope.search = function() { | 78 | $scope.search = function() { |
25 | $scope.filteredPrecioCondicion = $filter('filter')( | 79 | $scope.filteredPrecioCondicion = $filter('filter')( |
26 | $scope.precioCondicion, | 80 | $scope.precioCondicion, |
27 | {$: $scope.filters} | 81 | {$: $scope.filters} |
28 | ); | 82 | ); |
29 | 83 | ||
30 | $scope.lastPage = Math.ceil( | 84 | $scope.lastPage = Math.ceil( |
31 | $scope.filteredPrecioCondicion.length / $scope.numPerPage | 85 | $scope.filteredPrecioCondicion.length / $scope.numPerPage |
32 | ); | 86 | ); |
33 | 87 | ||
34 | $scope.resetPage(); | 88 | $scope.resetPage(); |
35 | }; | 89 | }; |
36 | 90 | ||
37 | $scope.resetPage = function() { | 91 | $scope.resetPage = function() { |
38 | $scope.currentPage = 1; | 92 | $scope.currentPage = 1; |
39 | $scope.selectPage(1); | 93 | $scope.selectPage(1); |
40 | }; | 94 | }; |
41 | 95 | ||
42 | $scope.selectPage = function(page) { | 96 | $scope.selectPage = function(page) { |
43 | var start = (page - 1) * $scope.numPerPage; | 97 | var start = (page - 1) * $scope.numPerPage; |
44 | var end = start + $scope.numPerPage; | 98 | var end = start + $scope.numPerPage; |
45 | $scope.paginas = []; | 99 | $scope.paginas = []; |
46 | $scope.paginas = calcularPages(page); | 100 | $scope.paginas = calcularPages(page); |
47 | $scope.currentPagePrecioCondicion = | 101 | $scope.currentPagePrecioCondicion = |
48 | $scope.filteredPrecioCondicion.slice(start, end); | 102 | $scope.filteredPrecioCondicion.slice(start, end); |
49 | $scope.currentPage = page; | 103 | $scope.currentPage = page; |
50 | }; | 104 | }; |
51 | 105 | ||
52 | $scope.select = function(precioCondicion) { | 106 | $scope.select = function(precioCondicion) { |
53 | $uibModalInstance.close(precioCondicion); | 107 | $uibModalInstance.close(precioCondicion); |
54 | }; | 108 | }; |
55 | 109 | ||
56 | $scope.cancel = function() { | 110 | $scope.cancel = function() { |
57 | $uibModalInstance.dismiss('cancel'); | 111 | $uibModalInstance.dismiss('cancel'); |
58 | }; | 112 | }; |
59 | 113 | ||
60 | $scope.busquedaDown = function(key) { | 114 | $scope.busquedaDown = function(key) { |
61 | if (key === 40) { | 115 | if (key === 40) { |
62 | primera(key); | 116 | primera(key); |
63 | } | 117 | } |
64 | }; | 118 | }; |
65 | 119 | ||
66 | $scope.busquedaPress = function(key) { | 120 | $scope.busquedaPress = function(key) { |
67 | if (key === 13) { | 121 | if (key === 13) { |
68 | primera(key); | 122 | primera(key); |
69 | } | 123 | } |
70 | }; | 124 | }; |
71 | 125 | ||
72 | $scope.itemProducto = function(key) { | 126 | $scope.itemProducto = function(key) { |
73 | if (key === 38) { | 127 | if (key === 38) { |
74 | anterior(key); | 128 | anterior(key); |
75 | } | 129 | } |
76 | 130 | ||
77 | if (key === 40) { | 131 | if (key === 40) { |
78 | siguiente(key); | 132 | siguiente(key); |
79 | } | 133 | } |
80 | 134 | ||
81 | if (key === 37) { | 135 | if (key === 37) { |
82 | retrocederPagina(); | 136 | retrocederPagina(); |
83 | } | 137 | } |
84 | 138 | ||
85 | if (key === 39) { | 139 | if (key === 39) { |
86 | avanzarPagina(); | 140 | avanzarPagina(); |
87 | } | 141 | } |
88 | }; | 142 | }; |
89 | 143 | ||
90 | function calcularPages(paginaActual) { | 144 | function calcularPages(paginaActual) { |
91 | var paginas = []; | 145 | var paginas = []; |
92 | paginas.push(paginaActual); | 146 | paginas.push(paginaActual); |
93 | 147 | ||
94 | if (paginaActual - 1 > 1) { | 148 | if (paginaActual - 1 > 1) { |
95 | 149 | ||
96 | paginas.unshift(paginaActual - 1); | 150 | paginas.unshift(paginaActual - 1); |
97 | if (paginaActual - 2 > 1) { | 151 | if (paginaActual - 2 > 1) { |
98 | paginas.unshift(paginaActual - 2); | 152 | paginas.unshift(paginaActual - 2); |
99 | } | 153 | } |
100 | } | 154 | } |
101 | 155 | ||
102 | if (paginaActual + 1 < $scope.lastPage) { | 156 | if (paginaActual + 1 < $scope.lastPage) { |
103 | paginas.push(paginaActual + 1); | 157 | paginas.push(paginaActual + 1); |
104 | if (paginaActual + 2 < $scope.lastPage) { | 158 | if (paginaActual + 2 < $scope.lastPage) { |
105 | paginas.push(paginaActual + 2); | 159 | paginas.push(paginaActual + 2); |
106 | } | 160 | } |
107 | } | 161 | } |
108 | 162 | ||
109 | if (paginaActual !== 1) { | 163 | if (paginaActual !== 1) { |
110 | paginas.unshift(1); | 164 | paginas.unshift(1); |
111 | } | 165 | } |
112 | 166 | ||
113 | if (paginaActual !== $scope.lastPage) { | 167 | if (paginaActual !== $scope.lastPage) { |
114 | paginas.push($scope.lastPage); | 168 | paginas.push($scope.lastPage); |
115 | } | 169 | } |
116 | 170 | ||
117 | return paginas; | 171 | return paginas; |
118 | } | 172 | } |
119 | 173 | ||
120 | function primera() { | 174 | function primera() { |
121 | $scope.selectedPrecioCondicion = 0; | 175 | $scope.selectedPrecioCondicion = 0; |
122 | } | 176 | } |
123 | 177 | ||
124 | function anterior() { | 178 | function anterior() { |
125 | if ($scope.selectedPrecioCondicion === 0 && $scope.currentPage > 1) { | 179 | if ($scope.selectedPrecioCondicion === 0 && $scope.currentPage > 1) { |
126 | retrocederPagina(); | 180 | retrocederPagina(); |
127 | } else { | 181 | } else { |
128 | $scope.selectedPrecioCondicion--; | 182 | $scope.selectedPrecioCondicion--; |
129 | } | 183 | } |
130 | } | 184 | } |
131 | 185 | ||
132 | function siguiente() { | 186 | function siguiente() { |
133 | if ($scope.selectedPrecioCondicion < | 187 | if ($scope.selectedPrecioCondicion < |
134 | $scope.currentPagePrecioCondicion.length - 1 ) { | 188 | $scope.currentPagePrecioCondicion.length - 1 ) { |
135 | $scope.selectedPrecioCondicion++; | 189 | $scope.selectedPrecioCondicion++; |
136 | } else { | 190 | } else { |
137 | avanzarPagina(); | 191 | avanzarPagina(); |
138 | } | 192 | } |
139 | } | 193 | } |
140 | 194 | ||
141 | function retrocederPagina() { | 195 | function retrocederPagina() { |
142 | if ($scope.currentPage > 1) { | 196 | if ($scope.currentPage > 1) { |
143 | $scope.selectPage($scope.currentPage - 1); | 197 | $scope.selectPage($scope.currentPage - 1); |
144 | $scope.selectedPrecioCondicion = $scope.numPerPage - 1; | 198 | $scope.selectedPrecioCondicion = $scope.numPerPage - 1; |
145 | } | 199 | } |
146 | } | 200 | } |
147 | 201 | ||
148 | function avanzarPagina() { | 202 | function avanzarPagina() { |
149 | if ($scope.currentPage < $scope.lastPage) { | 203 | if ($scope.currentPage < $scope.lastPage) { |
150 | $scope.selectPage($scope.currentPage + 1); | 204 | $scope.selectPage($scope.currentPage + 1); |
151 | $scope.selectedPrecioCondicion = 0; | 205 | $scope.selectedPrecioCondicion = 0; |
152 | } | 206 | } |
153 | } | 207 | } |
154 | } | 208 | } |
155 | ] | 209 | ] |
156 | ); | 210 | ); |
157 | 211 |
src/js/service.js
1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') |
2 | .service('focaModalPrecioCondicionService', [ | 2 | .service('focaModalPrecioCondicionService', [ |
3 | '$http', | 3 | '$http', |
4 | 'API_ENDPOINT', | 4 | 'API_ENDPOINT', |
5 | function($http, API_ENDPOINT) { | 5 | function($http, API_ENDPOINT) { |
6 | return { | 6 | return { |
7 | getPreciosCondiciones: function() { | 7 | getPreciosCondiciones: function() { |
8 | return $http.get(API_ENDPOINT.URL + '/precio-condicion'); | 8 | return $http.get(API_ENDPOINT.URL + '/precio-condicion'); |
9 | }, | ||
10 | getPlazosByIdPrecioCondicion: function(id) { | ||
11 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id); | ||
12 | }, | ||
13 | getPreciosCondicionesPlazosPagos: function() { | ||
14 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago'); | ||
9 | } | 15 | } |
10 | }; | 16 | }; |
11 | } | 17 | } |
12 | ]); | 18 | ]); |
13 | 19 |
src/views/modal-precio-condicion.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <h5 class="modal-title">Busqueda de Precio-Condición</h5> | 2 | <h5 ng-show="!ingreso" class="modal-title">Busqueda de Precio-Condición</h5> |
3 | <h5 ng-show="ingreso" class="modal-title">Nuevos Plazos</h5> | ||
3 | </div> | 4 | </div> |
4 | <div class="modal-body" id="modal-body"> | 5 | <div class="modal-body" id="modal-body"> |
5 | <div class="input-group"> | 6 | <div class="input-group" ng-show="!ingreso"> |
6 | <input | 7 | <input |
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="selectedPrecioCondicion == -1" | 15 | foca-focus="selectedPrecioCondicion == -1" |
15 | ng-focus="selectedPrecioCondicion = -1" | 16 | ng-focus="selectedPrecioCondicion = -1" |
16 | > | 17 | > |
17 | <table class="table table-striped table-sm"> | 18 | <div class="input-group-append"> |
18 | <thead> | 19 | <button class="btn btn-outline-secondary" type="button" ng-click="busquedaPress(13)"> |
19 | <tr> | 20 | <i class="fa fa-search" aria-hidden="true"></i> |
20 | <th>Cod.</th> | 21 | </button> |
21 | <th>Nombre</th> | 22 | </div> |
22 | <th>Vigencia</th> | ||
23 | <th></th> | ||
24 | </tr> | ||
25 | </thead> | ||
26 | <tbody> | ||
27 | <tr class="selectable" | ||
28 | ng-repeat="(key, precioCondicion) in currentPagePrecioCondicion" | ||
29 | ng-click="select(precioCondicion)"> | ||
30 | <td ng-bind="precioCondicion.codigo"></td> | ||
31 | <td ng-bind="precioCondicion.nombre"></td> | ||
32 | <td ng-bind="precioCondicion.vigencia"></td> | ||
33 | <td> | ||
34 | <button | ||
35 | type="button" | ||
36 | class="btn btn-sm p-1 float-right" | ||
37 | ng-class="{ | ||
38 | 'btn-secondary': selectedPrecioCondicion != key, | ||
39 | 'btn-primary': selectedPrecioCondicion == key | ||
40 | }" | ||
41 | foca-focus="selectedPrecioCondicion == {{key}}" | ||
42 | ng-keydown="itemProducto($event.keyCode)" | ||
43 | > | ||
44 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
45 | </button> | ||
46 | </td> | ||
47 | </tr> | ||
48 | </tbody> | ||
49 | </table> | ||
50 | <nav> | ||
51 | <ul class="pagination pagination-sm justify-content-end mb-0"> | ||
52 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | ||
53 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | ||
54 | <span aria-hidden="true">«</span> | ||
55 | <span class="sr-only">Anterior</span> | ||
56 | </a> | ||
57 | </li> | ||
58 | <li | ||
59 | class="page-item" | ||
60 | ng-repeat="pagina in paginas" | ||
61 | ng-class="{'active': pagina == currentPage}" | ||
62 | > | ||
63 | <a | ||
64 | class="page-link" | ||
65 | href="#" | ||
66 | ng-click="selectPage(pagina)" | ||
67 | ng-bind="pagina" | ||
68 | ></a> | ||
69 | </li> | ||
70 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | ||
71 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | ||
72 | <span aria-hidden="true">»</span> | ||
73 | <span class="sr-only">Siguiente</span> | ||
74 | </a> | ||
75 | </li> | ||
76 | </ul> | ||
77 | </nav> | ||
78 | </div> | 23 | </div> |
24 | |||
25 | <table ng-show="!ingreso" class="table table-striped table-sm"> | ||
26 | <thead> | ||
27 | <tr> | ||
28 | <th>Código</th> | ||
29 | <th>Nombre</th> | ||
30 | <th>Lista Precio</th> | ||
31 | <th>Plazos</th> | ||
32 | <th></th> | ||
33 | </tr> | ||
34 | </thead> | ||
35 | <tbody> | ||
36 | <tr ng-show="currentPagePrecioCondicion.length == 0"> | ||
37 | <td colspan="6"> | ||
38 | No se encontraron resultados. | ||
39 | </td> | ||
40 | </tr> | ||
41 | <tr> | ||
42 | <td colspan="6" ng-show="!ingreso"> | ||
43 | <input | ||
44 | class="form-control" | ||
45 | type="text" | ||
46 | placeholder="Ingreso manual" | ||
47 | readonly | ||
48 | ng-click="ingreso = !ingreso" | ||
49 | /> | ||
50 | </td> | ||
51 | </tr> | ||
52 | <tr class="selectable" | ||
53 | ng-repeat="(key, precioCondicion) in currentPagePrecioCondicion" | ||
54 | ng-click="select(precioCondicion)"> | ||
55 | <td ng-bind="precioCondicion.codigo"></td> | ||
56 | <td ng-bind="precioCondicion.nombre"></td> | ||
57 | <td ng-bind="precioCondicion.idListaPrecio"></td> | ||
58 | <td ng-bind="precioCondicion.plazos"></td> | ||
59 | <td> | ||
60 | <button | ||
61 | type="button" | ||
62 | class="btn btn-sm p-1 float-right" | ||
63 | ng-class="{ | ||
64 | 'btn-secondary': selectedPrecioCondicion != key, | ||
65 | 'btn-primary': selectedPrecioCondicion == key | ||
66 | }" | ||
67 | foca-focus="selectedPrecioCondicion == {{key}}" | ||
68 | ng-keydown="itemProducto($event.keyCode)" | ||
69 | > | ||
70 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
71 | </button> | ||
72 | </td> | ||
73 | </tr> | ||
74 | </tbody> | ||
75 | </table> | ||
76 | <nav ng-show="currentPagePrecioCondicion.length > 0 && !ingreso"> | ||
77 | <ul class="pagination pagination-sm mb-0"> | ||
78 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | ||
79 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | ||
80 | <span aria-hidden="true">«</span> | ||
81 | <span class="sr-only">Anterior</span> | ||
82 | </a> | ||
83 | </li> | ||
84 | <li | ||
85 | class="page-item" | ||
86 | ng-repeat="pagina in paginas" | ||
87 | ng-class="{'active': pagina == currentPage}" | ||
88 | > | ||
89 | <a | ||
90 | class="page-link" | ||
91 | href="#" | ||
92 | ng-click="selectPage(pagina)" | ||
93 | ng-bind="pagina" | ||
94 | ></a> | ||
95 | </li> | ||
96 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | ||
97 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | ||
98 | <span aria-hidden="true">»</span> | ||
99 | <span class="sr-only">Siguiente</span> | ||
100 | </a> | ||
101 | </li> | ||
102 | </ul> | ||
103 | </nav> | ||
104 | <table class="table table-striped table-sm" ng-show="ingreso"> | ||
105 | <thead> | ||
106 | <tr> | ||
107 | <th>Item</th> | ||
108 | <th>Días</th> | ||
109 | <th></th> | ||
110 | </tr> | ||
111 | </thead> | ||
112 | <tbody> | ||
113 | <tr> | ||
114 | <td> | ||
115 | <input | ||
116 | type="number" | ||
117 | class="form-control text-right" | ||
118 | ng-model="plazoACargar.item" | ||
119 | readonly | ||
120 | /> | ||
121 | </td> | ||
122 | <td> | ||
123 | <input |