diff --git a/gulpfile.js b/gulpfile.js index c21a400..d7ac689 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -73,3 +73,16 @@ gulp.task('clean-post-install', function(){ }); gulp.task('default', ['webserver']); + +gulp.task('watch', function() { + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) +}); + +gulp.task('copy', ['uglify'], function() { + gulp.src('dist/*.js') + .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-modal-transportista/dist')); +}); + +gulp.task('watchAndCopy', function() { + return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); +}); diff --git a/package.json b/package.json index be9e3e5..e8be54b 100644 --- a/package.json +++ b/package.json @@ -1,42 +1,62 @@ { - "name": "foca-modal-transportista", - "version": "0.0.1", - "description": "Modal de búsqueda de transportistas", - "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 pump 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-transportista.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-transportista", + "version": "0.0.1", + "description": "Modal de búsqueda de transportistas", + "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 angular-ladda bootstrap font-awesome gulp gulp-angular-templatecache gulp-clean gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify jasmine-core jquery jshint ladda@1.0.6 pre-commit pump ui-bootstrap4 && npm i -D 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-transportista.git" + }, + "author": "Foca Software", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.4", + "bootstrap": "^4.1.3", + "font-awesome": "^4.7.0", + "ui-bootstrap4": "^3.0.4", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.1", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jquery": "^3.3.1", + "pump": "^3.0.0", + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas" + }, + "devDependencies": { + "angular": "^1.7.5", + "angular-ladda": "^0.4.3", + "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.5", + "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", + "jasmine-core": "^3.3.0", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "ladda": "1.0.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.5" } } diff --git a/src/js/controller.js b/src/js/controller.js index d25057d..00bc110 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -5,33 +5,48 @@ angular.module('focaModalTransportista') '$scope', '$uibModalInstance', 'focaModalTransportistaService', - function($filter, $scope, $uibModalInstance, focaModalTransportistaService) { - focaModalTransportistaService.getTransportistas().then( - function(res) { - $scope.transportista = res.data; - $scope.search(); - } - ); - + function($filter, $scope, $uibModalInstance, + focaModalTransportistaService + ) { + + $scope.filters = ''; + $scope.transportistas = []; + $scope.primerBusqueda = false; + $scope.searchLoading = false; // pagination $scope.numPerPage = 10; $scope.currentPage = 1; - $scope.filteredTransportista = []; - $scope.currentPageTransportista = []; + $scope.filteredTransportistas = []; + $scope.currentPageTransportistas = []; $scope.selectedTransportista = -1; - + //METODOS + $scope.busquedaPress = function(key) { + if (key === 13) { + $scope.searchLoading = true; + focaModalTransportistaService.getTransportistas().then(llenarDatos); + } + }; + function llenarDatos(res) { + $scope.searchLoading = false; + $scope.primerBusqueda = true; + $scope.transportistas = res.data; + $scope.search(); + primera(); + } $scope.search = function() { - $scope.filteredTransportista = $filter('filter')( - $scope.transportista, - {$: $scope.filters} - ); + if($scope.transportistas.length > 0) { + $scope.filteredTransportistas = $filter('filter')( + $scope.transportistas, + {$: $scope.filters} + ); - $scope.lastPage = Math.ceil( - $scope.filteredTransportista.length / $scope.numPerPage - ); + $scope.lastPage = Math.ceil( + $scope.filteredTransportistas.length / $scope.numPerPage + ); - $scope.resetPage(); + $scope.resetPage(); + } }; $scope.resetPage = function() { @@ -44,8 +59,8 @@ angular.module('focaModalTransportista') var end = start + $scope.numPerPage; $scope.paginas = []; $scope.paginas = calcularPages(page); - $scope.currentPageTransportista = - $scope.filteredTransportista.slice(start, end); + $scope.currentPageTransportistas = + $scope.filteredTransportistas.slice(start, end); $scope.currentPage = page; }; @@ -63,13 +78,7 @@ angular.module('focaModalTransportista') } }; - $scope.busquedaPress = function(key) { - if (key === 13) { - primera(key); - } - }; - - $scope.itemProducto = function(key) { + $scope.itemTransportista = function(key) { if (key === 38) { anterior(key); } @@ -130,8 +139,9 @@ angular.module('focaModalTransportista') } function siguiente() { - if ($scope.selectedTransportista < - $scope.currentPageTransportista.length - 1 ) { + if ( + $scope.selectedTransportista < $scope.currentPageTransportistas.length - 1 + ) { $scope.selectedTransportista++; } else { avanzarPagina(); diff --git a/src/views/modal-transportista.html b/src/views/modal-transportista.html index 08296f4..11414d1 100644 --- a/src/views/modal-transportista.html +++ b/src/views/modal-transportista.html @@ -1,81 +1,96 @@ -