Commit 3965c72666c1e806464f279c6a631b5b58ab2910
1 parent
58be81a70e
Exists in
master
Modal precio condiciones recibe ingreso manual de plazos
Showing
7 changed files
with
270 additions
and
112 deletions
Show diff stats
gulpfile.js
| ... | ... | @@ -45,7 +45,7 @@ gulp.task('uglify', ['templates'], function() { |
| 45 | 45 | ]), |
| 46 | 46 | concat('foca-modal-precio-condiciones.js'), |
| 47 | 47 | replace('src/views/', ''), |
| 48 | - replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | |
| 48 | + replace("['ui.bootstrap', 'focaDirectivas', 'focaModal']", '[]'), | |
| 49 | 49 | gulp.dest(paths.tmp), |
| 50 | 50 | rename('foca-modal-precio-condiciones.min.js'), |
| 51 | 51 | uglify(), |
| ... | ... | @@ -64,7 +64,7 @@ gulp.task('pre-commit', function() { |
| 64 | 64 | ] |
| 65 | 65 | ); |
| 66 | 66 | }); |
| 67 | - | |
| 67 | + | |
| 68 | 68 | gulp.task('webserver', function() { |
| 69 | 69 | pump [ |
| 70 | 70 | connect.server({port: 3000}) |
index.html
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | <script src="node_modules/angular/angular.min.js"></script> |
| 14 | 14 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
| 15 | 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 | 18 | <!-- BUILD --> |
| 18 | 19 | <script src="src/js/app.js"></script> |
package.json
| 1 | 1 | { |
| 2 | - "name": "foca-modal-precio-condiciones", | |
| 3 | - "version": "0.0.1", | |
| 4 | - "description": "Modal de búsqueda de precios y condiciones", | |
| 5 | - "main": "index.js", | |
| 6 | - "scripts": { | |
| 7 | - "test": "echo \"Error: no test specified\" && exit 1", | |
| 8 | - "gulp-pre-commit": "gulp pre-commit", | |
| 9 | - "compile": "gulp uglify", | |
| 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" | |
| 12 | - }, | |
| 13 | - "pre-commit": [ | |
| 14 | - "gulp-pre-commit" | |
| 15 | - ], | |
| 16 | - "repository": { | |
| 17 | - "type": "git", | |
| 18 | - "url": "https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git" | |
| 19 | - }, | |
| 20 | - "author": "Foca Software", | |
| 21 | - "license": "ISC", | |
| 22 | - "devDependencies": { | |
| 23 | - "angular": "^1.7.5", | |
| 24 | - "bootstrap": "^4.1.3", | |
| 25 | - "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | |
| 26 | - "font-awesome": "^4.7.0", | |
| 27 | - "gulp": "^3.9.1", | |
| 28 | - "gulp-angular-templatecache": "^2.2.2", | |
| 29 | - "gulp-clean": "^0.4.0", | |
| 30 | - "gulp-concat": "^2.6.1", | |
| 31 | - "gulp-connect": "^5.6.1", | |
| 32 | - "gulp-htmlmin": "^5.0.1", | |
| 33 | - "gulp-jshint": "^2.1.0", | |
| 34 | - "gulp-rename": "^1.4.0", | |
| 35 | - "gulp-replace": "^1.0.0", | |
| 36 | - "gulp-uglify": "^3.0.1", | |
| 37 | - "jquery": "^3.3.1", | |
| 38 | - "jshint": "^2.9.6", | |
| 39 | - "pump": "^3.0.0", | |
| 40 | - "ui-bootstrap4": "^3.0.5" | |
| 2 | + "name": "foca-modal-precio-condiciones", | |
| 3 | + "version": "0.0.1", | |
| 4 | + "description": "Modal de búsqueda de precios y condiciones", | |
| 5 | + "main": "index.js", | |
| 6 | + "scripts": { | |
| 7 | + "test": "echo \"Error: no test specified\" && exit 1", | |
| 8 | + "gulp-pre-commit": "gulp pre-commit", | |
| 9 | + "compile": "gulp uglify", | |
| 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 git+https://debo.suite.repo/modulos-npm/foca-modal.git" | |
| 12 | + }, | |
| 13 | + "pre-commit": [ | |
| 14 | + "gulp-pre-commit" | |
| 15 | + ], | |
| 16 | + "repository": { | |
| 17 | + "type": "git", | |
| 18 | + "url": "https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git" | |
| 19 | + }, | |
| 20 | + "author": "Foca Software", | |
| 21 | + "license": "ISC", | |
| 22 | + "devDependencies": { | |
| 23 | + "angular": "^1.7.5", | |
| 24 | + "bootstrap": "^4.1.3", | |
| 25 | + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | |
| 26 | + "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | |
| 27 | + "font-awesome": "^4.7.0", | |
| 28 | + "gulp": "^3.9.1", | |
| 29 | + "gulp-angular-templatecache": "^2.2.2", | |
| 30 | + "gulp-clean": "^0.4.0", | |
| 31 | + "gulp-concat": "^2.6.1", | |
| 32 | + "gulp-connect": "^5.6.1", | |
| 33 | + "gulp-htmlmin": "^5.0.1", | |
| 34 | + "gulp-jshint": "^2.1.0", | |
| 35 | + "gulp-rename": "^1.4.0", | |
| 36 | + "gulp-replace": "^1.0.0", | |
| 37 | + "gulp-uglify": "^3.0.1", | |
| 38 | + "jquery": "^3.3.1", | |
| 39 | + "jshint": "^2.9.6", | |
| 40 | + "pump": "^3.0.0", | |
| 41 | + "ui-bootstrap4": "^3.0.5" | |
| 41 | 42 | } |
| 42 | -} | |
| 43 | 43 | \ No newline at end of file |
| 44 | +} |
src/js/app.js
src/js/controller.js
| ... | ... | @@ -4,23 +4,77 @@ angular.module('focaModalPrecioCondicion') |
| 4 | 4 | '$filter', |
| 5 | 5 | '$scope', |
| 6 | 6 | '$uibModalInstance', |
| 7 | + 'focaModalService', | |
| 7 | 8 | 'focaModalPrecioCondicionService', |
| 8 | - function($filter, $scope, $uibModalInstance, focaModalPrecioCondicionService) { | |
| 9 | - focaModalPrecioCondicionService.getPreciosCondiciones().then( | |
| 9 | + function($filter, $scope, $uibModalInstance, focaModalService, | |
| 10 | + focaModalPrecioCondicionService) { | |
| 11 | + | |
| 12 | + focaModalPrecioCondicionService.getPreciosCondicionesPlazosPagos().then( | |
| 10 | 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 | 21 | $scope.precioCondicion = res.data; |
| 12 | 22 | $scope.search(); |
| 13 | 23 | } |
| 14 | 24 | ); |
| 15 | - | |
| 25 | + $scope.ingreso = false; | |
| 26 | + $scope.plazosNuevos =[]; | |
| 27 | + $scope.plazoACargar = | |
| 28 | + { | |
| 29 | + item: 1 | |
| 30 | + }; | |
| 16 | 31 | // pagination |
| 17 | 32 | $scope.numPerPage = 10; |
| 18 | 33 | $scope.currentPage = 1; |
| 19 | 34 | $scope.filteredPrecioCondicion = []; |
| 20 | 35 | $scope.currentPagePrecioCondicion = []; |
| 21 | 36 | $scope.selectedPrecioCondicion = -1; |
| 22 | - | |
| 37 | + | |
| 23 | 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 | 78 | $scope.search = function() { |
| 25 | 79 | $scope.filteredPrecioCondicion = $filter('filter')( |
| 26 | 80 | $scope.precioCondicion, |
| ... | ... | @@ -44,7 +98,7 @@ angular.module('focaModalPrecioCondicion') |
| 44 | 98 | var end = start + $scope.numPerPage; |
| 45 | 99 | $scope.paginas = []; |
| 46 | 100 | $scope.paginas = calcularPages(page); |
| 47 | - $scope.currentPagePrecioCondicion = | |
| 101 | + $scope.currentPagePrecioCondicion = | |
| 48 | 102 | $scope.filteredPrecioCondicion.slice(start, end); |
| 49 | 103 | $scope.currentPage = page; |
| 50 | 104 | }; |
src/js/service.js
| ... | ... | @@ -6,6 +6,12 @@ angular.module('focaModalPrecioCondicion') |
| 6 | 6 | return { |
| 7 | 7 | getPreciosCondiciones: function() { |
| 8 | 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 | } |
src/views/modal-precio-condicion.html
| 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 | 4 | </div> |
| 4 | 5 | <div class="modal-body" id="modal-body"> |
| 5 | - <div class="input-group"> | |
| 6 | + <div class="input-group" ng-show="!ingreso"> | |
| 6 | 7 | <input |
| 7 | 8 | type="text" |
| 8 | 9 | class="form-control form-control-sm" |
| ... | ... | @@ -14,69 +15,164 @@ |
| 14 | 15 | foca-focus="selectedPrecioCondicion == -1" |
| 15 | 16 | ng-focus="selectedPrecioCondicion = -1" |
| 16 | 17 | > |
| 17 | - <table class="table table-striped table-sm"> | |
| 18 | - <thead> | |
| 19 | - <tr> | |
| 20 | - <th>Cod.</th> | |
| 21 | - <th>Nombre</th> | |
| 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> | |
| 18 | + <div class="input-group-append"> | |
| 19 | + <button class="btn btn-outline-secondary" type="button" ng-click="busquedaPress(13)"> | |
| 20 | + <i class="fa fa-search" aria-hidden="true"></i> | |
| 21 | + </button> | |
| 22 | + </div> | |
| 78 | 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 | |
| 124 | + type="number" | |
| 125 | + class="form-control text-right" | |
| 126 | + min="0" | |
| 127 | + ng-model="plazoACargar.dias" | |
| 128 | + ng-keypress="agregarPlazo($event.keyCode)" | |
| 129 | + foca-focus="ingreso" | |
| 130 | + /> | |
| 131 | + </td> | |
| 132 | + <td class="text-center"> | |
| 133 | + <button | |
| 134 | + class="btn btn-outline-secondary" | |
| 135 | + ng-click="agregarPlazo(13)" | |
| 136 | + > | |
| 137 | + <i class="fa fa-save"></i> | |
| 138 | + </button> | |
| 139 | + </td> | |
| 140 | + </tr> | |
| 141 | + <tr ng-repeat="(key, plazo) in plazosNuevos"> | |
| 142 | + <td class="text-right" ng-bind="key + 1"></td> | |
| 143 | + <td class="text-right" ng-bind="plazo.dias"></td> | |
| 144 | + <td class="text-center"> | |
| 145 | + <button | |
| 146 | + class="btn btn-outline-secondary" | |
| 147 | + ng-click="quitarPlazo(key)" | |
| 148 | + > | |
| 149 | + <i class="fa fa-trash"></i> | |
| 150 | + </button> | |
| 151 | + </td> | |
| 152 | + </tr> | |
| 153 | + </tbody> | |
| 154 | + </table> | |
| 79 | 155 | </div> |
| 80 | 156 | <div class="modal-footer py-1"> |
| 81 | - <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
| 157 | + <button | |
| 158 | + ng-show="!ingreso" | |
| 159 | + class="btn btn-sm btn-secondary" | |
| 160 | + type="button" | |
| 161 | + ng-click="cancel()" | |
| 162 | + >Cancelar | |
| 163 | + </button> | |
| 164 | + <button | |
| 165 | + ng-show="ingreso" | |
| 166 | + class="btn btn-sm btn-primary" | |
| 167 | + type="button" | |
| 168 | + ng-click="select(plazosNuevos)" | |
| 169 | + >Aceptar | |
| 170 | + </button> | |
| 171 | + <button | |
| 172 | + ng-show="ingreso" | |
| 173 | + class="btn btn-sm btn-secondary" | |
| 174 | + type="button" | |
| 175 | + ng-click="volver()" | |
| 176 | + >Volver | |
| 177 | + </button> | |
| 82 | 178 | </div> |