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
| ... | ... | @@ -46,7 +46,7 @@ gulp.task('uglify', ['templates'], function() { |
| 46 | 46 | ]), |
| 47 | 47 | concat('foca-modal-proveedor.js'), |
| 48 | 48 | replace('src/views/', ''), |
| 49 | - replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | |
| 49 | + replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), | |
| 50 | 50 | gulp.dest(paths.tmp), |
| 51 | 51 | rename('foca-modal-proveedor.min.js'), |
| 52 | 52 | uglify(), |
index.html
| 1 | -<html ng-app="focaModalProveedores"> | |
| 1 | +<html ng-app="focaModalProveedor"> | |
| 2 | 2 | |
| 3 | 3 | <head> |
| 4 | 4 | <meta charset="UTF-8" /> |
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | <!--CSS--> |
| 8 | 8 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" /> |
| 9 | 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 | 12 | <!--VENDOR JS--> |
| 12 | 13 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
| ... | ... | @@ -14,6 +15,9 @@ |
| 14 | 15 | <script src="node_modules/angular/angular.min.js"></script> |
| 15 | 16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
| 16 | 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 | 22 | <!-- BUILD --> |
| 19 | 23 | <script src="src/js/app.js"></script> |
package.json
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | "gulp-pre-commit": "gulp pre-commit", |
| 8 | 8 | "compile": "gulp uglify", |
| 9 | 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 | 12 | "pre-commit": [ |
| 13 | 13 | "gulp-pre-commit" |
| ... | ... | @@ -38,11 +38,12 @@ |
| 38 | 38 | }, |
| 39 | 39 | "devDependencies": { |
| 40 | 40 | "angular": "^1.7.5", |
| 41 | + "angular-ladda": "^0.4.3", | |
| 41 | 42 | "bootstrap": "^4.1.3", |
| 42 | 43 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", |
| 43 | 44 | "font-awesome": "^4.7.0", |
| 44 | 45 | "gulp": "^3.9.1", |
| 45 | - "gulp-angular-templatecache": "^2.2.1", | |
| 46 | + "gulp-angular-templatecache": "^2.2.3", | |
| 46 | 47 | "gulp-clean": "^0.4.0", |
| 47 | 48 | "gulp-concat": "^2.6.1", |
| 48 | 49 | "gulp-connect": "^5.6.1", |
| ... | ... | @@ -51,9 +52,11 @@ |
| 51 | 52 | "gulp-rename": "^1.4.0", |
| 52 | 53 | "gulp-replace": "^1.0.0", |
| 53 | 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 | 57 | "jquery": "^3.3.1", |
| 56 | 58 | "jshint": "^2.9.6", |
| 59 | + "ladda": "1.0.6", | |
| 57 | 60 | "pre-commit": "^1.2.2", |
| 58 | 61 | "pump": "^3.0.0", |
| 59 | 62 | "ui-bootstrap4": "^3.0.5" |
src/js/app.js
src/js/controller.js
| ... | ... | @@ -5,20 +5,9 @@ angular.module('focaModalProveedor') |
| 5 | 5 | '$uibModalInstance', |
| 6 | 6 | 'focaModalProveedorService', |
| 7 | 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 | 11 | // pagination |
| 23 | 12 | $scope.numPerPage = 10; |
| 24 | 13 | $scope.currentPage = 1; |
| ... | ... | @@ -26,6 +15,28 @@ angular.module('focaModalProveedor') |
| 26 | 15 | $scope.currentPageProveedores = []; |
| 27 | 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 | 40 | $scope.search = function () { |
| 30 | 41 | $scope.filteredProveedores = $filter('filter')( |
| 31 | 42 | $scope.proveedores, {$: $scope.filters} |
| ... | ... | @@ -67,12 +78,6 @@ angular.module('focaModalProveedor') |
| 67 | 78 | } |
| 68 | 79 | }; |
| 69 | 80 | |
| 70 | - $scope.busquedaPress = function(key) { | |
| 71 | - if (key === 13) { | |
| 72 | - primera(key); | |
| 73 | - } | |
| 74 | - }; | |
| 75 | - | |
| 76 | 81 | $scope.itemProveedor = function(key) { |
| 77 | 82 | if (key === 38) { |
| 78 | 83 | anterior(key); |
src/views/modal-proveedor.html
| ... | ... | @@ -3,82 +3,97 @@ |
| 3 | 3 | </div> |
| 4 | 4 | <div class="modal-body" id="modal-body"> |
| 5 | 5 | <div class="input-group"> |
| 6 | - <input | |
| 7 | - type="text" | |
| 8 | - class="form-control" | |
| 9 | - placeholder="Busqueda" | |
| 10 | - ng-model="filters" | |
| 11 | - ng-change="search()" | |
| 6 | + <input | |
| 7 | + ladda="searchLoading" | |
| 8 | + type="text" | |
| 9 | + class="form-control" | |
| 10 | + placeholder="Busqueda" | |
| 11 | + ng-model="filters" | |
| 12 | + ng-change="search()" | |
| 12 | 13 | ng-keydown="busquedaDown($event.keyCode)" |
| 13 | 14 | ng-keypress="busquedaPress($event.keyCode)" |
| 14 | 15 | foca-focus="selectedProveedores == -1" |
| 15 | 16 | ng-focus="selectedProveedores = -1" |
| 16 | 17 | > |
| 17 | - <table class="table table-striped table-sm"> | |
| 18 | - <thead> | |
| 19 | - <tr> | |
| 20 | - <th>Cรณdigo</th> | |
| 21 | - <th>Nombre</th> | |
| 22 | - <th>CUIT</th> | |
| 23 | - <th></th> | |
| 24 | - </tr> | |
| 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> | |
| 18 | + <div class="input-group-append"> | |
| 19 | + <button | |
| 20 | + ladda="searchLoading" | |
| 21 | + class="btn btn-outline-secondary" | |
| 22 | + type="button" | |
| 23 | + ng-click="busquedaPress(13)"> | |
| 24 | + <i class="fa fa-search" aria-hidden="true"></i> | |
| 25 | + </button> | |
| 80 | 26 | </div> |
| 81 | 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" | |
| 46 | + ng-click="select(proveedor)"> | |
| 47 | + <td ng-bind="proveedor.COD"></td> | |
| 48 | + <td ng-bind="proveedor.NOM"></td> | |
| 49 | + <td ng-bind="proveedor.CUIT"></td> | |
| 50 | + <td> | |
| 51 | + <button | |
| 52 | + type="button" | |
| 53 | + class="btn btn-xs p-1 float-right" | |
| 54 | + ng-class="{ | |
| 55 | + 'btn-secondary': selectedProveedores != key, | |
| 56 | + 'btn-primary': selectedProveedores == key | |
| 57 | + }" | |
| 58 | + ng-click="select(proveedor)" | |
| 59 | + foca-focus="selectedProveedores == {{key}}" | |
| 60 | + ng-keydown="itemProveedor($event.keyCode)" | |
| 61 | + > | |
| 62 | + <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
| 63 | + </button> | |
| 64 | + </td> | |
| 65 | + </tr> | |
| 66 | + </tbody> | |
| 67 | + </table> | |
| 68 | + <nav ng-show="currentPageProveedores.length > 0 && primerBusqueda"> | |
| 69 | + <ul class="pagination pagination-sm mb-0"> | |
| 70 | + <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
| 71 | + <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
| 72 | + <span aria-hidden="true">«</span> | |
| 73 | + <span class="sr-only">Anterior</span> | |
| 74 | + </a> | |
| 75 | + </li> | |
| 76 | + <li | |
| 77 | + class="page-item" | |
| 78 | + ng-repeat="pagina in paginas" | |
| 79 | + ng-class="{'active': pagina == currentPage}" | |
| 80 | + > | |
| 81 | + <a | |
| 82 | + class="page-link" | |
| 83 | + href="#" | |
| 84 | + ng-click="selectPage(pagina)" | |
| 85 | + ng-bind="pagina" | |
| 86 | + ></a> | |
| 87 | + </li> | |
| 88 | + <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
| 89 | + <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
| 90 | + <span aria-hidden="true">»</span> | |
| 91 | + <span class="sr-only">Siguiente</span> | |
| 92 | + </a> | |
| 93 | + </li> | |
| 94 | + </ul> | |
| 95 | + </nav> | |
| 96 | +</div> | |
| 82 | 97 | <div class="modal-footer py-1"> |
| 83 | 98 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
| 84 | 99 | </div> |