Commit b03db7edac8a60d998b47668c14692b934c3af55
Exists in
master
Merge branch 'master' into 'master'
Modal precio condiciones recibe ingreso manual de plazos See merge request modulos-npm/foca-modal-precio-condiciones!3
Showing
7 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 | 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( |
9 | focaModalPrecioCondicionService.getPreciosCondiciones().then( | 10 | $filter, $scope, $uibModalInstance, |
11 | focaModalService, focaModalPrecioCondicionService | ||
12 | ) { | ||
13 | |||
14 | focaModalPrecioCondicionService.getPreciosCondicionesPlazosPagos().then( | ||
10 | function(res) { | 15 | function(res) { |
16 | for(var i = 0; i < res.data.length; i++) { | ||
17 | var plazosTemp = ''; | ||
18 | for(var j = 0; j < res.data[i].plazoPago.length; j++) { | ||
19 | plazosTemp += res.data[i].plazoPago[j].dias + ' '; | ||
20 | } | ||
21 | res.data[i].plazos = plazosTemp.trim(); | ||
22 | } | ||
11 | $scope.precioCondicion = res.data; | 23 | $scope.precioCondicion = res.data; |
12 | $scope.search(); | 24 | $scope.search(); |
13 | } | 25 | } |
14 | ); | 26 | ); |
15 | 27 | $scope.ingreso = false; | |
28 | $scope.plazosNuevos = []; | ||
29 | $scope.plazoACargar = | ||
30 | { | ||
31 | item: 1 | ||
32 | }; | ||
16 | // pagination | 33 | // pagination |
17 | $scope.numPerPage = 10; | 34 | $scope.numPerPage = 10; |
18 | $scope.currentPage = 1; | 35 | $scope.currentPage = 1; |
19 | $scope.filteredPrecioCondicion = []; | 36 | $scope.filteredPrecioCondicion = []; |
20 | $scope.currentPagePrecioCondicion = []; | 37 | $scope.currentPagePrecioCondicion = []; |
21 | $scope.selectedPrecioCondicion = -1; | 38 | $scope.selectedPrecioCondicion = -1; |
22 | 39 | ||
23 | //METODOS | 40 | //METODOS |
41 | |||
42 | $scope.agregarPlazo = function(key) { | ||
43 | if(key === 13) { | ||
44 | if(!$scope.plazoACargar.dias) { | ||
45 | focaModalService.alert('Ingrese cantidad de días'); | ||
46 | return; | ||
47 | } | ||
48 | var tieneEseDia = $scope.plazosNuevos.filter(function(a) { | ||
49 | return a.dias === $scope.plazoACargar.dias; | ||
50 | }); | ||
51 | if(tieneEseDia.length > 0) { | ||
52 | focaModalService.alert('Ya ha ingresado un plazo con esos días'); | ||
53 | return; | ||
54 | } | ||
55 | $scope.plazosNuevos.push($scope.plazoACargar); | ||
56 | $scope.plazoACargar = | ||
57 | { | ||
58 | item: $scope.plazosNuevos.length + 1 | ||
59 | }; | ||
60 | } | ||
61 | }; | ||
62 | |||
63 | $scope.volver = function() { | ||
64 | $scope.ingreso = false; | ||
65 | $scope.plazosNuevos = []; | ||
66 | $scope.plazoACargar = | ||
67 | { | ||
68 | item: $scope.plazosNuevos.length + 1 | ||
69 | }; | ||
70 | }; | ||
71 | |||
72 | $scope.quitarPlazo = function(key) { | ||
73 | $scope.plazosNuevos.splice(key, 1); | ||
74 | $scope.plazoACargar = | ||
75 | { | ||
76 | item: $scope.plazosNuevos.length + 1 | ||
77 | }; | ||
78 | }; | ||
79 | |||
24 | $scope.search = function() { | 80 | $scope.search = function() { |
25 | $scope.filteredPrecioCondicion = $filter('filter')( | 81 | $scope.filteredPrecioCondicion = $filter('filter')( |
26 | $scope.precioCondicion, | 82 | $scope.precioCondicion, |
27 | {$: $scope.filters} | 83 | {$: $scope.filters} |
28 | ); | 84 | ); |
29 | 85 | ||
30 | $scope.lastPage = Math.ceil( | 86 | $scope.lastPage = Math.ceil( |
31 | $scope.filteredPrecioCondicion.length / $scope.numPerPage | 87 | $scope.filteredPrecioCondicion.length / $scope.numPerPage |
32 | ); | 88 | ); |
33 | 89 | ||
34 | $scope.resetPage(); | 90 | $scope.resetPage(); |
35 | }; | 91 | }; |
36 | 92 | ||
37 | $scope.resetPage = function() { | 93 | $scope.resetPage = function() { |
38 | $scope.currentPage = 1; | 94 | $scope.currentPage = 1; |
39 | $scope.selectPage(1); | 95 | $scope.selectPage(1); |
40 | }; | 96 | }; |
41 | 97 | ||
42 | $scope.selectPage = function(page) { | 98 | $scope.selectPage = function(page) { |
43 | var start = (page - 1) * $scope.numPerPage; | 99 | var start = (page - 1) * $scope.numPerPage; |
44 | var end = start + $scope.numPerPage; | 100 | var end = start + $scope.numPerPage; |
45 | $scope.paginas = []; | 101 | $scope.paginas = []; |
46 | $scope.paginas = calcularPages(page); | 102 | $scope.paginas = calcularPages(page); |
47 | $scope.currentPagePrecioCondicion = | 103 | $scope.currentPagePrecioCondicion = |
48 | $scope.filteredPrecioCondicion.slice(start, end); | 104 | $scope.filteredPrecioCondicion.slice(start, end); |
49 | $scope.currentPage = page; | 105 | $scope.currentPage = page; |
50 | }; | 106 | }; |
51 | 107 | ||
52 | $scope.select = function(precioCondicion) { | 108 | $scope.select = function(precioCondicion) { |
53 | $uibModalInstance.close(precioCondicion); | 109 | $uibModalInstance.close(precioCondicion); |
54 | }; | 110 | }; |
55 | 111 | ||
56 | $scope.cancel = function() { | 112 | $scope.cancel = function() { |
57 | $uibModalInstance.dismiss('cancel'); | 113 | $uibModalInstance.dismiss('cancel'); |
58 | }; | 114 | }; |
59 | 115 | ||
60 | $scope.busquedaDown = function(key) { | 116 | $scope.busquedaDown = function(key) { |
61 | if (key === 40) { | 117 | if (key === 40) { |
62 | primera(key); | 118 | primera(key); |
63 | } | 119 | } |
64 | }; | 120 | }; |
65 | 121 | ||
66 | $scope.busquedaPress = function(key) { | 122 | $scope.busquedaPress = function(key) { |
67 | if (key === 13) { | 123 | if (key === 13) { |
68 | primera(key); | 124 | primera(key); |
69 | } | 125 | } |
70 | }; | 126 | }; |
71 | 127 | ||
72 | $scope.itemProducto = function(key) { | 128 | $scope.itemProducto = function(key) { |
73 | if (key === 38) { | 129 | if (key === 38) { |
74 | anterior(key); | 130 | anterior(key); |
75 | } | 131 | } |
76 | 132 | ||
77 | if (key === 40) { | 133 | if (key === 40) { |
78 | siguiente(key); | 134 | siguiente(key); |
79 | } | 135 | } |
80 | 136 | ||
81 | if (key === 37) { | 137 | if (key === 37) { |
82 | retrocederPagina(); | 138 | retrocederPagina(); |
83 | } | 139 | } |
84 | 140 | ||
85 | if (key === 39) { | 141 | if (key === 39) { |
86 | avanzarPagina(); | 142 | avanzarPagina(); |
87 | } | 143 | } |
88 | }; | 144 | }; |
89 | 145 | ||
90 | function calcularPages(paginaActual) { | 146 | function calcularPages(paginaActual) { |
91 | var paginas = []; | 147 | var paginas = []; |
92 | paginas.push(paginaActual); | 148 | paginas.push(paginaActual); |
93 | 149 | ||
94 | if (paginaActual - 1 > 1) { | 150 | if (paginaActual - 1 > 1) { |
95 | 151 | ||
96 | paginas.unshift(paginaActual - 1); | 152 | paginas.unshift(paginaActual - 1); |
97 | if (paginaActual - 2 > 1) { | 153 | if (paginaActual - 2 > 1) { |
98 | paginas.unshift(paginaActual - 2); | 154 | paginas.unshift(paginaActual - 2); |
99 | } | 155 | } |
100 | } | 156 | } |
101 | 157 | ||
102 | if (paginaActual + 1 < $scope.lastPage) { | 158 | if (paginaActual + 1 < $scope.lastPage) { |
103 | paginas.push(paginaActual + 1); | 159 | paginas.push(paginaActual + 1); |
104 | if (paginaActual + 2 < $scope.lastPage) { | 160 | if (paginaActual + 2 < $scope.lastPage) { |
105 | paginas.push(paginaActual + 2); | 161 | paginas.push(paginaActual + 2); |
106 | } | 162 | } |
107 | } | 163 | } |
108 | 164 | ||
109 | if (paginaActual !== 1) { | 165 | if (paginaActual !== 1) { |
110 | paginas.unshift(1); | 166 | paginas.unshift(1); |
111 | } | 167 | } |
112 | 168 | ||
113 | if (paginaActual !== $scope.lastPage) { | 169 | if (paginaActual !== $scope.lastPage) { |
114 | paginas.push($scope.lastPage); | 170 | paginas.push($scope.lastPage); |
115 | } | 171 | } |
116 | 172 | ||
117 | return paginas; | 173 | return paginas; |
118 | } | 174 | } |
119 | 175 | ||
120 | function primera() { | 176 | function primera() { |
121 | $scope.selectedPrecioCondicion = 0; | 177 | $scope.selectedPrecioCondicion = 0; |
122 | } | 178 | } |
123 | 179 | ||
124 | function anterior() { | 180 | function anterior() { |
125 | if ($scope.selectedPrecioCondicion === 0 && $scope.currentPage > 1) { | 181 | if ($scope.selectedPrecioCondicion === 0 && $scope.currentPage > 1) { |
126 | retrocederPagina(); | 182 | retrocederPagina(); |
127 | } else { | 183 | } else { |
128 | $scope.selectedPrecioCondicion--; | 184 | $scope.selectedPrecioCondicion--; |
129 | } | 185 | } |
130 | } | 186 | } |
131 | 187 | ||
132 | function siguiente() { | 188 | function siguiente() { |
133 | if ($scope.selectedPrecioCondicion < | 189 | if ($scope.selectedPrecioCondicion < |
134 | $scope.currentPagePrecioCondicion.length - 1 ) { | 190 | $scope.currentPagePrecioCondicion.length - 1 ) { |
135 | $scope.selectedPrecioCondicion++; | 191 | $scope.selectedPrecioCondicion++; |
136 | } else { | 192 | } else { |
137 | avanzarPagina(); | 193 | avanzarPagina(); |
138 | } | 194 | } |
139 | } | 195 | } |
140 | 196 | ||
141 | function retrocederPagina() { | 197 | function retrocederPagina() { |
142 | if ($scope.currentPage > 1) { | 198 | if ($scope.currentPage > 1) { |
143 | $scope.selectPage($scope.currentPage - 1); | 199 | $scope.selectPage($scope.currentPage - 1); |
144 | $scope.selectedPrecioCondicion = $scope.numPerPage - 1; | 200 | $scope.selectedPrecioCondicion = $scope.numPerPage - 1; |
145 | } | 201 | } |
146 | } | 202 | } |
147 | 203 | ||
148 | function avanzarPagina() { | 204 | function avanzarPagina() { |
149 | if ($scope.currentPage < $scope.lastPage) { | 205 | if ($scope.currentPage < $scope.lastPage) { |
150 | $scope.selectPage($scope.currentPage + 1); | 206 | $scope.selectPage($scope.currentPage + 1); |
151 | $scope.selectedPrecioCondicion = 0; | 207 | $scope.selectedPrecioCondicion = 0; |
152 | } | 208 | } |
153 | } | 209 | } |
154 | } | 210 | } |
155 | ] | 211 | ] |
156 | ); | 212 | ); |
157 | 213 |
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 |