diff --git a/gulpfile.js b/gulpfile.js index 0e513b4..eb544dc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -45,7 +45,7 @@ gulp.task('uglify', ['templates'], function() { ]), concat('foca-modal-precio-condiciones.js'), replace('src/views/', ''), - replace("['ui.bootstrap', 'focaDirectivas']", '[]'), + replace("['ui.bootstrap', 'focaDirectivas', 'focaModal']", '[]'), gulp.dest(paths.tmp), rename('foca-modal-precio-condiciones.min.js'), uglify(), @@ -64,7 +64,7 @@ gulp.task('pre-commit', function() { ] ); }); - + gulp.task('webserver', function() { pump [ connect.server({port: 3000}) diff --git a/index.html b/index.html index 53ad6e6..6067168 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,7 @@ + diff --git a/package.json b/package.json index 1c7e11f..0e26dc6 100644 --- a/package.json +++ b/package.json @@ -1,42 +1,43 @@ { - "name": "foca-modal-precio-condiciones", - "version": "0.0.1", - "description": "Modal de búsqueda de precios y condiciones", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "gulp-pre-commit": "gulp pre-commit", - "compile": "gulp uglify", - "postinstall": "npm run compile && gulp clean-post-install", - "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" - }, - "pre-commit": [ - "gulp-pre-commit" - ], - "repository": { - "type": "git", - "url": "https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git" - }, - "author": "Foca Software", - "license": "ISC", - "devDependencies": { - "angular": "^1.7.5", - "bootstrap": "^4.1.3", - "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", - "font-awesome": "^4.7.0", - "gulp": "^3.9.1", - "gulp-angular-templatecache": "^2.2.2", - "gulp-clean": "^0.4.0", - "gulp-concat": "^2.6.1", - "gulp-connect": "^5.6.1", - "gulp-htmlmin": "^5.0.1", - "gulp-jshint": "^2.1.0", - "gulp-rename": "^1.4.0", - "gulp-replace": "^1.0.0", - "gulp-uglify": "^3.0.1", - "jquery": "^3.3.1", - "jshint": "^2.9.6", - "pump": "^3.0.0", - "ui-bootstrap4": "^3.0.5" + "name": "foca-modal-precio-condiciones", + "version": "0.0.1", + "description": "Modal de búsqueda de precios y condiciones", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "gulp-pre-commit": "gulp pre-commit", + "compile": "gulp uglify", + "postinstall": "npm run compile && gulp clean-post-install", + "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" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git" + }, + "author": "Foca Software", + "license": "ISC", + "devDependencies": { + "angular": "^1.7.5", + "bootstrap": "^4.1.3", + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", + "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.2", + "gulp-clean": "^0.4.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.5" } -} \ No newline at end of file +} diff --git a/src/js/app.js b/src/js/app.js index dee5d23..fa7c7bd 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -1 +1 @@ -angular.module('focaModalPrecioCondicion', ['ui.bootstrap', 'focaDirectivas']); +angular.module('focaModalPrecioCondicion', ['ui.bootstrap', 'focaDirectivas', 'focaModal']); diff --git a/src/js/controller.js b/src/js/controller.js index e95b69c..1b31e12 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -4,23 +4,77 @@ angular.module('focaModalPrecioCondicion') '$filter', '$scope', '$uibModalInstance', + 'focaModalService', 'focaModalPrecioCondicionService', - function($filter, $scope, $uibModalInstance, focaModalPrecioCondicionService) { - focaModalPrecioCondicionService.getPreciosCondiciones().then( + function($filter, $scope, $uibModalInstance, focaModalService, + focaModalPrecioCondicionService) { + + focaModalPrecioCondicionService.getPreciosCondicionesPlazosPagos().then( function(res) { + for(var i = 0; i < res.data.length; i++) { + var plazosTemp = ''; + for(var j = 0; j < res.data[i].plazoPago.length; j++) { + plazosTemp += res.data[i].plazoPago[j].dias + ' '; + } + res.data[i].plazos = plazosTemp.trim(); + } $scope.precioCondicion = res.data; $scope.search(); } ); - + $scope.ingreso = false; + $scope.plazosNuevos =[]; + $scope.plazoACargar = + { + item: 1 + }; // pagination $scope.numPerPage = 10; $scope.currentPage = 1; $scope.filteredPrecioCondicion = []; $scope.currentPagePrecioCondicion = []; $scope.selectedPrecioCondicion = -1; - + //METODOS + + $scope.agregarPlazo = function(key) { + if(key === 13) { + if(!$scope.plazoACargar.dias) { + focaModalService.alert('Ingrese cantidad de días'); + return; + } + var tieneEseDia = $scope.plazosNuevos.filter(function(a) { + return a.dias === $scope.plazoACargar.dias; + }); + if(tieneEseDia.length > 0) { + focaModalService.alert('Ya ha ingresado un plazo con esos días'); + return; + } + $scope.plazosNuevos.push($scope.plazoACargar); + $scope.plazoACargar = + { + item: $scope.plazosNuevos.length + 1 + }; + } + }; + + $scope.volver = function() { + $scope.ingreso = false; + $scope.plazosNuevos = []; + $scope.plazoACargar = + { + item: $scope.plazosNuevos.length + 1 + }; + }; + + $scope.quitarPlazo = function(key) { + $scope.plazosNuevos.splice(key, 1); + $scope.plazoACargar = + { + item: $scope.plazosNuevos.length + 1 + }; + }; + $scope.search = function() { $scope.filteredPrecioCondicion = $filter('filter')( $scope.precioCondicion, @@ -44,7 +98,7 @@ angular.module('focaModalPrecioCondicion') var end = start + $scope.numPerPage; $scope.paginas = []; $scope.paginas = calcularPages(page); - $scope.currentPagePrecioCondicion = + $scope.currentPagePrecioCondicion = $scope.filteredPrecioCondicion.slice(start, end); $scope.currentPage = page; }; diff --git a/src/js/service.js b/src/js/service.js index bfb252e..0c7f808 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -6,6 +6,12 @@ angular.module('focaModalPrecioCondicion') return { getPreciosCondiciones: function() { return $http.get(API_ENDPOINT.URL + '/precio-condicion'); + }, + getPlazosByIdPrecioCondicion: function(id) { + return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id); + }, + getPreciosCondicionesPlazosPagos: function() { + return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago'); } }; } diff --git a/src/views/modal-precio-condicion.html b/src/views/modal-precio-condicion.html index b44a974..126a093 100644 --- a/src/views/modal-precio-condicion.html +++ b/src/views/modal-precio-condicion.html @@ -1,8 +1,9 @@