Commit 12e8d01218ffad2cbc745b0bc4aa311d71527b23
Exists in
master
Merge branch 'master' into 'master'
Master (pmarco) See merge request modulos-npm/foca-modal-proveedor!5
Showing
10 changed files
Show diff stats
README.md
| 1 | # foca-modal-petroleras | 1 | # foca-modal-proveedor |
| 2 | 2 | ||
| 3 | Modal para listar petroleras | ||
| 3 | Modal para listar proveedores |
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('templates', function() { | 20 | gulp.task('clean', function() { |
| 21 | return gulp.src(['tmp', 'dist'], {read: false}) | ||
| 22 | .pipe(clean()); | ||
| 23 | }); | ||
| 24 | |||
| 25 | gulp.task('templates', ['clean'], function() { | ||
| 21 | return pump( | 26 | return pump( |
| 22 | [ | 27 | [ |
| 23 | gulp.src(paths.srcViews), | 28 | gulp.src(paths.srcViews), |
| 24 | replace('views/', ''), | 29 | replace('views/', ''), |
| 25 | htmlmin(), | 30 | htmlmin(), |
| 26 | templateCache('views.js', { | 31 | templateCache('views.js', { |
| 27 | module: 'focaModalPetroleras', | 32 | module: 'focaModalProveedor', |
| 28 | root: '' | 33 | root: '' |
| 29 | }), | 34 | }), |
| 30 | gulp.dest(paths.tmp) | 35 | gulp.dest(paths.tmp) |
| 31 | ] | 36 | ] |
| 32 | ); | 37 | ); |
| 33 | }); | 38 | }); |
| 34 | 39 | ||
| 35 | gulp.task('uglify', ['templates'], function() { | 40 | gulp.task('uglify', ['templates'], function() { |
| 36 | return pump( | 41 | return pump( |
| 37 | [ | 42 | [ |
| 38 | gulp.src([ | 43 | gulp.src([ |
| 39 | paths.srcJS, | 44 | paths.srcJS, |
| 40 | 'tmp/views.js' | 45 | 'tmp/views.js' |
| 41 | ]), | 46 | ]), |
| 42 | concat('foca-modal-petroleras.js'), | 47 | concat('foca-modal-proveedor.js'), |
| 43 | replace('src/views/', ''), | 48 | replace('src/views/', ''), |
| 44 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | 49 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), |
| 45 | gulp.dest(paths.tmp), | 50 | gulp.dest(paths.tmp), |
| 46 | rename('foca-modal-petroleras.min.js'), | 51 | rename('foca-modal-proveedor.min.js'), |
| 47 | uglify(), | 52 | uglify(), |
| 48 | gulp.dest(paths.dist) | 53 | gulp.dest(paths.dist) |
| 49 | ] | 54 | ] |
| 50 | ); | 55 | ); |
| 51 | }); | 56 | }); |
| 52 | 57 | ||
| 53 | gulp.task('pre-commit', function() { | 58 | gulp.task('pre-commit', function() { |
| 54 | return pump( | 59 | return pump( |
| 55 | [ | 60 | [ |
| 56 | gulp.src(paths.srcJS), | 61 | gulp.src(paths.srcJS), |
| 57 | jshint('.jshintrc'), | 62 | jshint('.jshintrc'), |
| 58 | jshint.reporter('default'), | 63 | jshint.reporter('default'), |
| 59 | jshint.reporter('fail') | 64 | jshint.reporter('fail') |
| 60 | ] | 65 | ] |
| 61 | ); | 66 | ); |
| 62 | 67 | ||
| 63 | gulp.start('uglify'); | 68 | gulp.start('uglify'); |
| 64 | }); | 69 | }); |
| 65 | 70 | ||
| 66 | gulp.task('webserver', function() { | 71 | gulp.task('webserver', function() { |
| 67 | pump [ | 72 | pump [ |
| 68 | connect.server({port: 3000}) | 73 | connect.server({port: 3000}) |
| 69 | ] | 74 | ] |
| 70 | }); | 75 | }); |
| 71 | 76 | ||
| 72 | gulp.task('clean-post-install', function() { | 77 | gulp.task('clean-post-install', function() { |
| 73 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 78 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
| 74 | 'index.html'], {read: false}) | 79 | 'index.html'], {read: false}) |
| 75 | .pipe(clean()); | 80 | .pipe(clean()); |
| 76 | }); | 81 | }); |
| 77 | 82 | ||
| 78 | gulp.task('default', ['webserver']); | ||
| 83 | gulp.task('default', ['webserver']); | ||
| 84 | |||
| 85 | gulp.task('watch', function() { | ||
| 86 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | ||
| 87 | }); |
index.html
| 1 | <html ng-app="focaModalPetroleras"> | 1 | <html ng-app="focaModalProveedores"> |
| 2 | 2 | ||
| 3 | <head> | 3 | <head> |
| 4 | <meta charset="UTF-8" /> | 4 | <meta charset="UTF-8" /> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 6 | 6 | ||
| 7 | <!--CSS--> | 7 | <!--CSS--> |
| 8 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" /> | 8 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" /> |
| 9 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" /> | 9 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" /> |
| 10 | 10 | ||
| 11 | <!--VENDOR JS--> | 11 | <!--VENDOR JS--> |
| 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
| 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
| 14 | <script src="node_modules/angular/angular.min.js"></script> | 14 | <script src="node_modules/angular/angular.min.js"></script> |
| 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
| 16 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 16 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
| 17 | 17 | ||
| 18 | <!-- BUILD --> | 18 | <!-- BUILD --> |
| 19 | <script src="src/js/app.js"></script> | 19 | <script src="src/js/app.js"></script> |
| 20 | <script src="src/js/controller.js"></script> | 20 | <script src="src/js/controller.js"></script> |
| 21 | <script src="src/js/service.js"></script> | 21 | <script src="src/js/service.js"></script> |
| 22 | 22 | ||
| 23 | <!-- /BUILD --> | 23 | <!-- /BUILD --> |
| 24 | 24 | ||
| 25 | <!-- CONFIG PARA DEVELOP --> | 25 | <!-- CONFIG PARA DEVELOP --> |
| 26 | <script src="src/etc/develop.js"></script> | 26 | <script src="src/etc/develop.js"></script> |
| 27 | 27 | ||
| 28 | <script type="text/javascript"> | 28 | <script type="text/javascript"> |
| 29 | angular.module('focaModalPetroleras') | 29 | angular.module('focaModalProveedor') |
| 30 | .controller('controller', ['$uibModal', '$timeout', function ($uibModal, $timeout) { | 30 | .controller('controller', ['$uibModal', '$timeout', function ($uibModal, $timeout) { |
| 31 | openModal(); | 31 | openModal(); |
| 32 | 32 | ||
| 33 | function openModal() { | 33 | function openModal() { |
| 34 | var modalInstance = $uibModal.open( | 34 | var modalInstance = $uibModal.open( |
| 35 | { | 35 | { |
| 36 | ariaLabelledBy: 'Busqueda de Petroleras', | 36 | ariaLabelledBy: 'Busqueda de Proveedores', |
| 37 | templateUrl: 'src/views/modal-petroleras.html', | 37 | templateUrl: 'src/views/modal-proveedor.html', |
| 38 | controller: 'modalPetrolerasCtrl', | 38 | controller: 'focaModalProveedorCtrl', |
| 39 | size: 'lg' | 39 | size: 'lg' |
| 40 | } | 40 | } |
| 41 | ); | 41 | ); |
| 42 | 42 | ||
| 43 | modalInstance.result.then( | 43 | modalInstance.result.then( |
| 44 | function (selectedItem) { | 44 | function (selectedItem) { |
| 45 | console.info(selectedItem); | 45 | console.info(selectedItem); |
| 46 | $timeout(openModal, 500); | 46 | $timeout(openModal, 500); |
| 47 | }, function () { | 47 | }, function () { |
| 48 | console.info('modal-component dismissed at: ' + new Date()); | 48 | console.info('modal-component dismissed at: ' + new Date()); |
| 49 | $timeout(openModal, 500); | 49 | $timeout(openModal, 500); |
| 50 | } | 50 | } |
| 51 | ); | 51 | ); |
| 52 | } | 52 | } |
| 53 | }]); | 53 | }]); |
| 54 | </script> | 54 | </script> |
| 55 | </head> | 55 | </head> |
| 56 | 56 | ||
| 57 | <body ng-controller="controller"> | 57 | <body ng-controller="controller"> |
| 58 | <style> | 58 | <style> |
| 59 | .p-5 { | 59 | .p-5 { |
| 60 | padding: 5px !important; | 60 | padding: 5px !important; |
| 61 | } | 61 | } |
| 62 | </style> | 62 | </style> |
| 63 | </body> | 63 | </body> |
| 64 | 64 | ||
| 65 | </html> | 65 | </html> |
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-modal-petroleras", | 2 | "name": "foca-modal-proveedor", |
| 3 | "version": "0.0.2", | 3 | "version": "0.0.2", |
| 4 | "description": "Modal para seleccionar petroleras", | 4 | "description": "Modal para seleccionar proveedores", |
| 5 | "scripts": { | 5 | "scripts": { |
| 6 | "test": "echo \"Error: no test specified\" && exit 1", | 6 | "test": "echo \"Error: no test specified\" && exit 1", |
| 7 | "gulp-pre-commit": "gulp pre-commit", | 7 | "gulp-pre-commit": "gulp pre-commit", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "postinstall": "npm run compile && gulp clean-post-install", | 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://192.168.0.11/modulos-npm/foca-directivas" | 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" |
| 11 | }, | 11 | }, |
| 12 | "pre-commit": [ | 12 | "pre-commit": [ |
| 13 | "gulp-pre-commit" | 13 | "gulp-pre-commit" |
| 14 | ], | 14 | ], |
| 15 | "repository": { | 15 | "repository": { |
| 16 | "type": "git", | 16 | "type": "git", |
| 17 | "url": "https://192.168.0.11/modulos-npm/foca-modal-petroleras" | 17 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-proveedor" |
| 18 | }, | 18 | }, |
| 19 | "author": "Nicolás Guarnieri", | 19 | "author": "Nicolás Guarnieri", |
| 20 | "license": "ISC", | 20 | "license": "ISC", |
| 21 | "peerDependencies": { | 21 | "peerDependencies": { |
| 22 | "angular": "^1.7.4", | 22 | "angular": "^1.7.4", |
| 23 | "bootstrap": "^4.1.3", | 23 | "bootstrap": "^4.1.3", |
| 24 | "font-awesome": "^4.7.0", | 24 | "font-awesome": "^4.7.0", |
| 25 | "ui-bootstrap4": "^3.0.4", | 25 | "ui-bootstrap4": "^3.0.4", |
| 26 | "gulp": "^3.9.1", | 26 | "gulp": "^3.9.1", |
| 27 | "gulp-angular-templatecache": "^2.2.1", | 27 | "gulp-angular-templatecache": "^2.2.1", |
| 28 | "gulp-clean": "^0.4.0", | 28 | "gulp-clean": "^0.4.0", |
| 29 | "gulp-concat": "^2.6.1", | 29 | "gulp-concat": "^2.6.1", |
| 30 | "gulp-connect": "^5.6.1", | 30 | "gulp-connect": "^5.6.1", |
| 31 | "gulp-htmlmin": "^5.0.1", | 31 | "gulp-htmlmin": "^5.0.1", |
| 32 | "gulp-rename": "^1.4.0", | 32 | "gulp-rename": "^1.4.0", |
| 33 | "gulp-replace": "^1.0.0", | 33 | "gulp-replace": "^1.0.0", |
| 34 | "gulp-uglify": "^3.0.1", | 34 | "gulp-uglify": "^3.0.1", |
| 35 | "jquery": "^3.3.1", | 35 | "jquery": "^3.3.1", |
| 36 | "pump": "^3.0.0", | 36 | "pump": "^3.0.0", |
| 37 | "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas" | 37 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas" |
| 38 | }, | 38 | }, |
| 39 | "devDependencies": { | 39 | "devDependencies": { |
| 40 | "angular": "^1.7.5", | 40 | "angular": "^1.7.5", |
| 41 | "bootstrap": "^4.1.3", | 41 | "bootstrap": "^4.1.3", |
| 42 | "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas", | 42 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", |
| 43 | "font-awesome": "^4.7.0", | 43 | "font-awesome": "^4.7.0", |
| 44 | "gulp": "^3.9.1", | 44 | "gulp": "^3.9.1", |
| 45 | "gulp-angular-templatecache": "^2.2.1", | 45 | "gulp-angular-templatecache": "^2.2.1", |
| 46 | "gulp-clean": "^0.4.0", | 46 | "gulp-clean": "^0.4.0", |
| 47 | "gulp-concat": "^2.6.1", | 47 | "gulp-concat": "^2.6.1", |
| 48 | "gulp-connect": "^5.6.1", | 48 | "gulp-connect": "^5.6.1", |
| 49 | "gulp-htmlmin": "^5.0.1", | 49 | "gulp-htmlmin": "^5.0.1", |
| 50 | "gulp-jshint": "^2.1.0", | 50 | "gulp-jshint": "^2.1.0", |
| 51 | "gulp-rename": "^1.4.0", | 51 | "gulp-rename": "^1.4.0", |
| 52 | "gulp-replace": "^1.0.0", | 52 | "gulp-replace": "^1.0.0", |
| 53 | "gulp-uglify": "^3.0.1", | 53 | "gulp-uglify": "^3.0.1", |
| 54 | "jasmine-core": "^3.2.1", | 54 | "jasmine-core": "^3.2.1", |
| 55 | "jquery": "^3.3.1", | 55 | "jquery": "^3.3.1", |
| 56 | "jshint": "^2.9.6", | 56 | "jshint": "^2.9.6", |
| 57 | "pre-commit": "^1.2.2", | 57 | "pre-commit": "^1.2.2", |
| 58 | "pump": "^3.0.0", | 58 | "pump": "^3.0.0", |
| 59 | "ui-bootstrap4": "^3.0.5" | 59 | "ui-bootstrap4": "^3.0.5" |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
| 62 | 62 |
src/etc/develop.js.ejemplo
| 1 | angular.module('focaModalPetroleras') | 1 | angular.module('focaModalProveedor') |
| 2 | .constant("API_ENDPOINT", { | 2 | .constant("API_ENDPOINT", { |
| 3 | 'URL': '//127.0.0.1:9000' | 3 | 'URL': '//127.0.0.1:9000' |
| 4 | }); | 4 | }); |
| 5 | 5 |
src/js/app.js
| 1 | angular.module('focaModalPetroleras', ['ui.bootstrap', 'focaDirectivas']); | 1 | angular.module('focaModalProveedor', ['ui.bootstrap', 'focaDirectivas']); |
| 2 | 2 |
src/js/controller.js
| 1 | angular.module('focaModalPetroleras') | 1 | angular.module('focaModalProveedor') |
| 2 | .controller('modalPetrolerasCtrl', [ | 2 | .controller('focaModalProveedorCtrl', [ |
| 3 | '$filter', | 3 | '$filter', |
| 4 | '$scope', | 4 | '$scope', |
| 5 | '$uibModalInstance', | 5 | '$uibModalInstance', |
| 6 | 'focaPetrolerasService', | 6 | 'focaModalProveedorService', |
| 7 | function ($filter, $scope, $uibModalInstance, focaPetrolerasService) { | 7 | function ($filter, $scope, $uibModalInstance, focaModalProveedorService) { |
| 8 | var json = {razonCuitCod: ''}; | 8 | var json = {razonCuitCod: ''}; |
| 9 | 9 | ||
| 10 | focaPetrolerasService.getPetroleras(json).then( | 10 | focaModalProveedorService.getProveedores(json).then( |
| 11 | function (res) { | 11 | function (res) { |
| 12 | for (var i = res.data.length - 1; i >= 0; i--) { | 12 | for (var i = res.data.length - 1; i >= 0; i--) { |
| 13 | if (res.data[i].COD === 0) { | 13 | if (res.data[i].COD === 0) { |
| 14 | delete res.data[i]; | 14 | delete res.data[i]; |
| 15 | } | 15 | } |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | $scope.petroleras = res.data; | 18 | $scope.proveedores = res.data; |
| 19 | $scope.search(); | 19 | $scope.search(); |
| 20 | }); | 20 | }); |
| 21 | 21 | ||
| 22 | // pagination | 22 | // pagination |
| 23 | $scope.numPerPage = 10; | 23 | $scope.numPerPage = 10; |
| 24 | $scope.currentPage = 1; | 24 | $scope.currentPage = 1; |
| 25 | $scope.filteredPetroleras = []; | 25 | $scope.filteredProveedores = []; |
| 26 | $scope.currentPagePetroleras = []; | 26 | $scope.currentPageProveedores = []; |
| 27 | $scope.selectedPetroleras = -1; | 27 | $scope.selectedProveedores = -1; |
| 28 | 28 | ||
| 29 | $scope.search = function () { | 29 | $scope.search = function () { |
| 30 | $scope.filteredPetroleras = $filter('filter')( | 30 | $scope.filteredProveedores = $filter('filter')( |
| 31 | $scope.petroleras, {$: $scope.filters} | 31 | $scope.proveedores, {$: $scope.filters} |
| 32 | ); | 32 | ); |
| 33 | 33 | ||
| 34 | $scope.lastPage = Math.ceil( | 34 | $scope.lastPage = Math.ceil( |
| 35 | $scope.filteredPetroleras.length / $scope.numPerPage | 35 | $scope.filteredProveedores.length / $scope.numPerPage |
| 36 | ); | 36 | ); |
| 37 | 37 | ||
| 38 | $scope.resetPage(); | 38 | $scope.resetPage(); |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | $scope.resetPage = function () { | 41 | $scope.resetPage = function () { |
| 42 | $scope.currentPage = 1; | 42 | $scope.currentPage = 1; |
| 43 | $scope.selectPage(1); | 43 | $scope.selectPage(1); |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | $scope.selectPage = function (page) { | 46 | $scope.selectPage = function (page) { |
| 47 | console.info(page); | 47 | console.info(page); |
| 48 | var start = (page - 1) * $scope.numPerPage; | 48 | var start = (page - 1) * $scope.numPerPage; |
| 49 | var end = start + $scope.numPerPage; | 49 | var end = start + $scope.numPerPage; |
| 50 | $scope.paginas = []; | 50 | $scope.paginas = []; |
| 51 | $scope.paginas = calcularPages(page); | 51 | $scope.paginas = calcularPages(page); |
| 52 | $scope.currentPagePetroleras = $scope.filteredPetroleras.slice(start, end); | 52 | $scope.currentPageProveedores = $scope.filteredProveedores.slice(start, end); |
| 53 | $scope.currentPage = page; | 53 | $scope.currentPage = page; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | $scope.select = function(petrolera) { | 56 | $scope.select = function(proveedor) { |
| 57 | $uibModalInstance.close(petrolera); | 57 | $uibModalInstance.close(proveedor); |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | $scope.cancel = function() { | 60 | $scope.cancel = function() { |
| 61 | $uibModalInstance.dismiss('cancel'); | 61 | $uibModalInstance.dismiss('cancel'); |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | $scope.busquedaDown = function(key) { | 64 | $scope.busquedaDown = function(key) { |
| 65 | if (key === 40) { | 65 | if (key === 40) { |
| 66 | primera(key); | 66 | primera(key); |
| 67 | } | 67 | } |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | $scope.busquedaPress = function(key) { | 70 | $scope.busquedaPress = function(key) { |
| 71 | if (key === 13) { | 71 | if (key === 13) { |
| 72 | primera(key); | 72 | primera(key); |
| 73 | } | 73 | } |
| 74 | }; | 74 | }; |
| 75 | 75 | ||
| 76 | $scope.itemPetrolera = function(key) { | 76 | $scope.itemProveedor = function(key) { |
| 77 | if (key === 38) { | 77 | if (key === 38) { |
| 78 | anterior(key); | 78 | anterior(key); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | if (key === 40) { | 81 | if (key === 40) { |
| 82 | siguiente(key); | 82 | siguiente(key); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | if (key === 37) { | 85 | if (key === 37) { |
| 86 | retrocederPagina(); | 86 | retrocederPagina(); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | if (key === 39) { | 89 | if (key === 39) { |
| 90 | avanzarPagina(); | 90 | avanzarPagina(); |
| 91 | } | 91 | } |
| 92 | }; | 92 | }; |
| 93 | 93 | ||
| 94 | function calcularPages(paginaActual) { | 94 | function calcularPages(paginaActual) { |
| 95 | var paginas = []; | 95 | var paginas = []; |
| 96 | paginas.push(paginaActual); | 96 | paginas.push(paginaActual); |
| 97 | 97 | ||
| 98 | if (paginaActual - 1 > 1) { | 98 | if (paginaActual - 1 > 1) { |
| 99 | 99 | ||
| 100 | paginas.unshift(paginaActual - 1); | 100 | paginas.unshift(paginaActual - 1); |
| 101 | if (paginaActual - 2 > 1) { | 101 | if (paginaActual - 2 > 1) { |
| 102 | paginas.unshift(paginaActual - 2); | 102 | paginas.unshift(paginaActual - 2); |
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | if (paginaActual + 1 < $scope.lastPage) { | 106 | if (paginaActual + 1 < $scope.lastPage) { |
| 107 | paginas.push(paginaActual + 1); | 107 | paginas.push(paginaActual + 1); |
| 108 | if (paginaActual + 2 < $scope.lastPage) { | 108 | if (paginaActual + 2 < $scope.lastPage) { |
| 109 | paginas.push(paginaActual + 2); | 109 | paginas.push(paginaActual + 2); |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | if (paginaActual !== 1) { | 113 | if (paginaActual !== 1) { |
| 114 | paginas.unshift(1); | 114 | paginas.unshift(1); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | if (paginaActual !== $scope.lastPage) { | 117 | if (paginaActual !== $scope.lastPage) { |
| 118 | paginas.push($scope.lastPage); | 118 | paginas.push($scope.lastPage); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | return paginas; | 121 | return paginas; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | function primera() { | 124 | function primera() { |
| 125 | $scope.selectedPetroleras = 0; | 125 | $scope.selectedProveedores = 0; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | function anterior() { | 128 | function anterior() { |
| 129 | if ($scope.selectedPetroleras === 0 && $scope.currentPage > 1) { | 129 | if ($scope.selectedProveedores === 0 && $scope.currentPage > 1) { |
| 130 | retrocederPagina(); | 130 | retrocederPagina(); |
| 131 | } else { | 131 | } else { |
| 132 | $scope.selectedPetroleras--; | 132 | $scope.selectedProveedores--; |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | function siguiente() { | 136 | function siguiente() { |
| 137 | if ($scope.selectedPetroleras < $scope.currentPagePetroleras.length - 1 ) { | 137 | if ($scope.selectedProveedores < $scope.currentPageProveedores.length - 1 ) { |
| 138 | $scope.selectedPetroleras++; | 138 | $scope.selectedProveedores++; |
| 139 | } else { | 139 | } else { |
| 140 | avanzarPagina(); | 140 | avanzarPagina(); |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | function retrocederPagina() { | 144 | function retrocederPagina() { |
| 145 | if ($scope.currentPage > 1) { | 145 | if ($scope.currentPage > 1) { |
| 146 | $scope.selectPage($scope.currentPage - 1); | 146 | $scope.selectPage($scope.currentPage - 1); |
| 147 | $scope.selectedPetroleras = $scope.numPerPage - 1; | 147 | $scope.selectedProveedores = $scope.numPerPage - 1; |
| 148 | } | 148 | } |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | function avanzarPagina() { | 151 | function avanzarPagina() { |
| 152 | if ($scope.currentPage < $scope.lastPage) { | 152 | if ($scope.currentPage < $scope.lastPage) { |
| 153 | $scope.selectPage($scope.currentPage + 1); | 153 | $scope.selectPage($scope.currentPage + 1); |
| 154 | $scope.selectedPetroleras = 0; | 154 | $scope.selectedProveedores = 0; |
| 155 | } | 155 | } |
| 156 | } | 156 | } |
| 157 | }] | 157 | }] |
| 158 | ); | 158 | ); |
| 159 | 159 |
src/js/service.js
| 1 | angular.module('focaModalPetroleras') | 1 | angular.module('focaModalProveedor') |
| 2 | .service('focaPetrolerasService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('focaModalProveedorService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | return { | 3 | return { |
| 4 | getPetroleras: function(json) { | 4 | getProveedores: function(json) { |
| 5 | return $http.post(API_ENDPOINT.URL + '/petroleras', json); | 5 | return $http.post(API_ENDPOINT.URL + '/proveedor', json); |
| 6 | } | 6 | } |
| 7 | }; | 7 | }; |
| 8 | }]); | 8 | }]); |
| 9 | 9 |
src/views/modal-petroleras.html
| 1 | <div class="modal-header"> | File was deleted | |
| 2 | <h3 class="modal-title">Búsqueda de Petrolera</h3> | ||
| 3 | </div> | ||
| 4 | <div class="modal-body" id="modal-body"> | ||
| 5 | <div class="input-group mb-3"> | ||
| 6 | <input | ||
| 7 | type="text" | ||
| 8 | class="form-control" | ||
| 9 | placeholder="Busqueda" | ||
| 10 | ng-model="filters" | ||
| 11 | ng-change="search()" | ||
| 12 | ng-keydown="busquedaDown($event.keyCode)" | ||
| 13 | ng-keypress="busquedaPress($event.keyCode)" | ||
| 14 | foca-focus="selectedPetroleras == -1" | ||
| 15 | ng-focus="selectedPetroleras = -1" | ||
| 16 | > | ||
| 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 ng-repeat="(key, petrolera) in currentPagePetroleras"> | ||
| 28 | <td ng-bind="petrolera.COD"></td> | ||
| 29 | <td ng-bind="petrolera.NOM"></td> | ||
| 30 | <td ng-bind="petrolera.CUIT"></td> | ||
| 31 | <td> | ||
| 32 | <button | ||
| 33 | type="button" | ||
| 34 | class="btn p-2 float-right" | ||
| 35 | ng-class="{ | ||
| 36 | 'btn-secondary': selectedPetroleras != key, | ||
| 37 | 'btn-primary': selectedPetroleras == key | ||
| 38 | }" | ||
| 39 | ng-click="select(petrolera)" | ||
| 40 | foca-focus="selectedPetroleras == {{key}}" | ||
| 41 | ng-keydown="itemPetrolera($event.keyCode)" | ||
| 42 | > | ||
| 43 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
| 44 | </button> | ||
| 45 | </td> | ||
| 46 | </tr> | ||
| 47 | </tbody> | ||
| 48 | </table> | ||
| 49 | <nav> | ||
| 50 | <ul class="pagination justify-content-end"> | ||
| 51 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | ||
| 52 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | ||
| 53 | <span aria-hidden="true">«</span> | ||
| 54 | <span class="sr-only">Anterior</span> | ||
| 55 | </a> | ||
| 56 | </li> | ||
| 57 | <li | ||
| 58 | class="page-item" | ||
| 59 | ng-repeat="pagina in paginas" | ||
| 60 | ng-class="{'active': pagina == currentPage}" | ||
| 61 | > | ||
| 62 | <a | ||
| 63 | class="page-link" | ||
| 64 | href="#" | ||
| 65 | ng-click="selectPage(pagina)" | ||
| 66 | ng-bind="pagina" | ||
| 67 | ></a> | ||
| 68 | </li> | ||
| 69 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | ||
| 70 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | ||
| 71 | <span aria-hidden="true">»</span> | ||
| 72 | <span class="sr-only">Siguiente</span> | ||
| 73 | </a> | ||
| 74 | </li> | ||
| 75 | </ul> | ||
| 76 | </nav> | ||
| 77 | </div> | ||
| 78 | </div> | ||
| 79 | <div class="modal-footer"> | ||
| 80 | <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
| 81 | </div> | ||
| 82 | 1 | <div class="modal-header"> |
src/views/modal-proveedor.html
| File was created | 1 | <div class="modal-header py-1"> | |
| 2 | <h5 class="modal-title">Búsqueda de Proveedor</h5> | ||
| 3 | </div> | ||
| 4 | <div class="modal-body" id="modal-body"> | ||
| 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()" | ||
| 12 | ng-keydown="busquedaDown($event.keyCode)" | ||
| 13 | ng-keypress="busquedaPress($event.keyCode)" | ||
| 14 | foca-focus="selectedProveedores == -1" | ||
| 15 | ng-focus="selectedProveedores = -1" | ||
| 16 | > | ||
| 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 ng-repeat="(key, proveedor) in currentPageProveedores"> | ||
| 28 | <td ng-bind="proveedor.COD"></td> | ||
| 29 | <td ng-bind="proveedor.NOM"></td> | ||
| 30 | <td ng-bind="proveedor.CUIT"></td> | ||
| 31 | <td> | ||
| 32 | <button | ||
| 33 | type="button" | ||
| 34 | class="btn btn-xs p-1 float-right" | ||
| 35 | ng-class="{ | ||
| 36 | 'btn-secondary': selectedProveedores != key, | ||
| 37 | 'btn-primary': selectedProveedores == key | ||
| 38 | }" | ||
| 39 | ng-click="select(proveedor)" | ||
| 40 | foca-focus="selectedProveedores == {{key}}" | ||
| 41 | ng-keydown="itemProveedor($event.keyCode)" | ||
| 42 | > | ||
| 43 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
| 44 | </button> | ||
| 45 | </td> | ||
| 46 | </tr> | ||
| 47 | </tbody> | ||
| 48 | </table> | ||
| 49 | <nav> | ||
| 50 | <ul class="pagination pagination-sm justify-content-end mb-0"> | ||
| 51 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | ||
| 52 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | ||
| 53 | <span aria-hidden="true">«</span> | ||
| 54 | <span class="sr-only">Anterior</span> | ||
| 55 | </a> | ||
| 56 | </li> | ||
| 57 | <li | ||
| 58 | class="page-item" | ||
| 59 | ng-repeat="pagina in paginas" | ||
| 60 | ng-class="{'active': pagina == currentPage}" | ||
| 61 | > | ||
| 62 | <a | ||
| 63 | class="page-link" | ||
| 64 | href="#" | ||
| 65 | ng-click="selectPage(pagina)" | ||
| 66 | ng-bind="pagina" | ||
| 67 | ></a> | ||
| 68 | </li> | ||
| 69 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | ||
| 70 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | ||
| 71 | <span aria-hidden="true">»</span> | ||
| 72 | <span class="sr-only">Siguiente</span> | ||
| 73 | </a> | ||
| 74 | </li> | ||
| 75 | </ul> | ||
| 76 | </nav> | ||
| 77 | </div> | ||
| 78 | </div> | ||
| 79 | <div class="modal-footer py-1"> | ||
| 80 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
| 81 | </div> | ||
| 82 |