diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d22e37 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/dist +/tmp +package-lock\.json diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..dd429f7 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": true, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..57b2713 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +Búsqueda de cliente +=================== diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..516bdfc --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,58 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify-es').default; +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', function() { + pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaBusquedaCliente', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', function() { + pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-busqueda-cliente.js'), + gulp.dest(paths.tmp), + rename('foca-busqueda-cliente.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('pre-commit', function() { + pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); +}); + +gulp.task('compile', ['templates', 'uglify']); diff --git a/package.json b/package.json new file mode 100644 index 0000000..88a813f --- /dev/null +++ b/package.json @@ -0,0 +1,56 @@ +{ + "name": "foca-abm-sectores", + "version": "1.0.0", + "description": "ABM de sectores", + "main": "dist/foca-abm-sectores.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify && gulp html", + "pre-commit": [ + "gulp-pre-commit" + ], + "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" + }, + "repository": { + "type": "git", + "url": "https://192.168.0.11/modulos-npm/foca-abm-sectores.git" + }, + "author": "Foca Software", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.x", + "bootstrap": "^4.1.x", + "jquery": "^3.3.x", + "font-awesome": "^4.7.x", + "gulp": "^3.9.x", + "gulp-concat": "2.6.x", + "gulp-jshint": "^2.1.x", + "gulp-rename": "^1.4.x", + "gulp-replace": "^1.0.x", + "gulp-uglify-es": "^1.0.x", + "jshint": "^2.9.x", + "pump": "^3.0.x" + }, + "devDependencies": { + "gulp-connect": "^5.6.1", + "jasmine-core": "3.2.1", + "pre-commit": "^1.2.2" + }, + "dependencies": { + "angular": "1.7.4", + "angular-ui-bootstrap": "2.5.6", + "bootstrap": "4.1.3", + "font-awesome": "4.7.0", + "gulp": "3.9.1", + "gulp-angular-templatecache": "2.2.1", + "gulp-concat": "2.6.1", + "gulp-htmlmin": "5.0.1", + "gulp-jshint": "2.1.0", + "gulp-rename": "1.4.0", + "gulp-replace": "1.0.0", + "gulp-uglify-es": "1.0.4", + "jquery": "3.3.1", + "jshint": "2.9.6", + "pump": "3.0.0" + } +} diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..9b0981f --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaBusquedaCliente', ['ui.bootstrap']); diff --git a/src/js/component.js b/src/js/component.js new file mode 100644 index 0000000..4016897 --- /dev/null +++ b/src/js/component.js @@ -0,0 +1,5 @@ +angular.module('focaBusquedaCliente') + .component('focaBusquedaCliente', { + templateUrl: 'foca-busqueda-cliente.html', + controller: 'focaBusquedaClienteController' + }); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..e1bcdf4 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,35 @@ +angular.module('focaBusquedaCliente') + .controller('focaBusquedaClienteController', [ + '$scope', + '$uibModal', + function($scope, $uibModal) { + $scope.abrirModal = function() { + $uibModal.open({ + animation: false, + templateUrl: 'foca-busqueda-cliente-modal.html', + backdrop: false, + controller: 'focaBusquedaClienteModalController' + }); + }; + } + ]) + .controller('focaBusquedaClienteModalController', [ + '$uibModalInstance', + 'focaBusquedaClienteService', + '$scope', + function($uibModalInstance, focaBusquedaClienteService, $scope) { + $scope.obtenerClientesPorNombreOCuit = function(textoBusqueda) { + return focaBusquedaClienteService + .obtenerClientesPorNombreOCuit(textoBusqueda) + .then(function(datos) { + return datos.data; + }); + }; + $scope.cancelar = function() { + $uibModalInstance.close(); + }; + $scope.seleccionar = function() { + $uibModalInstance.close(); + }; + } + ]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..dd2ad2a --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,14 @@ +angular.module('focaBusquedaCliente') + .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + return { + obtenerClientes: function() { + return $http.get(API_ENDPOINT.URL + '/cliente'); + }, + obtenerCliente: function(id) { + return $http.get(API_ENDPOINT.URL + '/cliente/' + id); + }, + obtenerClientesPorNombreOCuit: function(nombreOCuit) { + return $http.post(API_ENDPOINT.URL + '/cliente', {nombreOCuit: nombreOCuit}); + } + }; + }]); diff --git a/src/views/foca-busqueda-cliente-modal.html b/src/views/foca-busqueda-cliente-modal.html new file mode 100644 index 0000000..b57dfe2 --- /dev/null +++ b/src/views/foca-busqueda-cliente-modal.html @@ -0,0 +1,34 @@ +