Commit a98ca8d049edfc19fba05e7cd7e85e2a1c193720
0 parents
Exists in
master
and in
1 other branch
Primera versión estable del componente de búsqueda.
Showing
11 changed files
with
274 additions
and
0 deletions
Show diff stats
.gitignore
File was created | 1 | /node_modules | |
2 | /dist | ||
3 | /tmp | ||
4 | package-lock\.json | ||
5 |
.jshintrc
File was created | 1 | { | |
2 | /* | ||
3 | * ENVIRONMENTS | ||
4 | * ================= | ||
5 | */ | ||
6 | |||
7 | // Define globals exposed by modern browsers. | ||
8 | "browser": true, | ||
9 | |||
10 | // Define globals exposed by jQuery. | ||
11 | "jquery": true, | ||
12 | |||
13 | // Define globals exposed by Node.js. | ||
14 | "node": true, | ||
15 | |||
16 | // Allow ES6. | ||
17 | "esversion": 6, | ||
18 | |||
19 | /* | ||
20 | * ENFORCING OPTIONS | ||
21 | * ================= | ||
22 | */ | ||
23 | |||
24 | // Force all variable names to use either camelCase style or UPPER_CASE | ||
25 | // with underscores. | ||
26 | "camelcase": true, | ||
27 | |||
28 | // Prohibit use of == and != in favor of === and !==. | ||
29 | "eqeqeq": true, | ||
30 | |||
31 | // Enforce tab width of 2 spaces. | ||
32 | "indent": 4, | ||
33 | |||
34 | // Prohibit use of a variable before it is defined. | ||
35 | "latedef": true, | ||
36 | |||
37 | // Enforce line length to 100 characters | ||
38 | "maxlen": 100, | ||
39 | |||
40 | // Require capitalized names for constructor functions. | ||
41 | "newcap": true, | ||
42 | |||
43 | // Enforce use of single quotation marks for strings. | ||
44 | "quotmark": "single", | ||
45 | |||
46 | // Enforce placing 'use strict' at the top function scope | ||
47 | "strict": false, | ||
48 | |||
49 | // Prohibit use of explicitly undeclared variables. | ||
50 | "undef": true, | ||
51 | |||
52 | // Warn when variables are defined but never used. | ||
53 | "unused": true, | ||
54 | |||
55 | // Para que funcione en angular | ||
56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | ||
57 | /* | ||
58 | * RELAXING OPTIONS | ||
59 | * ================= | ||
60 | */ | ||
61 | |||
62 | // Suppress warnings about == null comparisons. | ||
63 | "eqnull": true | ||
64 | } | ||
65 |
README.md
File was created | 1 | Búsqueda de cliente | |
2 | =================== | ||
3 |
gulpfile.js
File was created | 1 | const templateCache = require('gulp-angular-templatecache'); | |
2 | const concat = require('gulp-concat'); | ||
3 | const htmlmin = require('gulp-htmlmin'); | ||
4 | const rename = require('gulp-rename'); | ||
5 | const uglify = require('gulp-uglify-es').default; | ||
6 | const gulp = require('gulp'); | ||
7 | const pump = require('pump'); | ||
8 | const jshint = require('gulp-jshint'); | ||
9 | |||
10 | var paths = { | ||
11 | srcJS: 'src/js/*.js', | ||
12 | srcViews: 'src/views/*.html', | ||
13 | tmp: 'tmp', | ||
14 | dist: 'dist/' | ||
15 | }; | ||
16 | |||
17 | gulp.task('templates', function() { | ||
18 | pump( | ||
19 | [ | ||
20 | gulp.src(paths.srcViews), | ||
21 | htmlmin(), | ||
22 | templateCache('views.js', { | ||
23 | module: 'focaBusquedaCliente', | ||
24 | root: '' | ||
25 | }), | ||
26 | gulp.dest(paths.tmp) | ||
27 | ] | ||
28 | ); | ||
29 | }); | ||
30 | |||
31 | gulp.task('uglify', function() { | ||
32 | pump( | ||
33 | [ | ||
34 | gulp.src([ | ||
35 | paths.srcJS, | ||
36 | 'tmp/views.js' | ||
37 | ]), | ||
38 | concat('foca-busqueda-cliente.js'), | ||
39 | gulp.dest(paths.tmp), | ||
40 | rename('foca-busqueda-cliente.min.js'), | ||
41 | uglify(), | ||
42 | gulp.dest(paths.dist) | ||
43 | ] | ||
44 | ); | ||
45 | }); | ||
46 | |||
47 | gulp.task('pre-commit', function() { | ||
48 | pump( | ||
49 | [ | ||
50 | gulp.src(paths.srcJS), | ||
51 | jshint('.jshintrc'), | ||
52 | jshint.reporter('default'), | ||
53 | jshint.reporter('fail') | ||
54 | ] | ||
55 | ); | ||
56 | }); | ||
57 | |||
58 | gulp.task('compile', ['templates', 'uglify']); | ||
59 |
package.json
File was created | 1 | { | |
2 | "name": "foca-abm-sectores", | ||
3 | "version": "1.0.0", | ||
4 | "description": "ABM de sectores", | ||
5 | "main": "dist/foca-abm-sectores.js", | ||
6 | "scripts": { | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | ||
8 | "compile": "gulp uglify && gulp html", | ||
9 | "pre-commit": [ | ||
10 | "gulp-pre-commit" | ||
11 | ], | ||
12 | "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" | ||
13 | }, | ||
14 | "repository": { | ||
15 | "type": "git", | ||
16 | "url": "https://192.168.0.11/modulos-npm/foca-abm-sectores.git" | ||
17 | }, | ||
18 | "author": "Foca Software", | ||
19 | "license": "ISC", | ||
20 | "peerDependencies": { | ||
21 | "angular": "^1.7.x", | ||
22 | "bootstrap": "^4.1.x", | ||
23 | "jquery": "^3.3.x", | ||
24 | "font-awesome": "^4.7.x", | ||
25 | "gulp": "^3.9.x", | ||
26 | "gulp-concat": "2.6.x", | ||
27 | "gulp-jshint": "^2.1.x", | ||
28 | "gulp-rename": "^1.4.x", | ||
29 | "gulp-replace": "^1.0.x", | ||
30 | "gulp-uglify-es": "^1.0.x", | ||
31 | "jshint": "^2.9.x", | ||
32 | "pump": "^3.0.x" | ||
33 | }, | ||
34 | "devDependencies": { | ||
35 | "gulp-connect": "^5.6.1", | ||
36 | "jasmine-core": "3.2.1", | ||
37 | "pre-commit": "^1.2.2" | ||
38 | }, | ||
39 | "dependencies": { | ||
40 | "angular": "1.7.4", | ||
41 | "angular-ui-bootstrap": "2.5.6", | ||
42 | "bootstrap": "4.1.3", | ||
43 | "font-awesome": "4.7.0", | ||
44 | "gulp": "3.9.1", | ||
45 | "gulp-angular-templatecache": "2.2.1", | ||
46 | "gulp-concat": "2.6.1", | ||
47 | "gulp-htmlmin": "5.0.1", | ||
48 | "gulp-jshint": "2.1.0", | ||
49 | "gulp-rename": "1.4.0", | ||
50 | "gulp-replace": "1.0.0", | ||
51 | "gulp-uglify-es": "1.0.4", | ||
52 | "jquery": "3.3.1", | ||
53 | "jshint": "2.9.6", | ||
54 | "pump": "3.0.0" | ||
55 | } | ||
56 | } | ||
57 |
src/js/app.js
File was created | 1 | angular.module('focaBusquedaCliente', ['ui.bootstrap']); | |
2 |
src/js/component.js
File was created | 1 | angular.module('focaBusquedaCliente') | |
2 | .component('focaBusquedaCliente', { | ||
3 | templateUrl: 'foca-busqueda-cliente.html', | ||
4 | controller: 'focaBusquedaClienteController' | ||
5 | }); | ||
6 |
src/js/controller.js
File was created | 1 | angular.module('focaBusquedaCliente') | |
2 | .controller('focaBusquedaClienteController', [ | ||
3 | '$scope', | ||
4 | '$uibModal', | ||
5 | function($scope, $uibModal) { | ||
6 | $scope.abrirModal = function() { | ||
7 | $uibModal.open({ | ||
8 | animation: false, | ||
9 | templateUrl: 'foca-busqueda-cliente-modal.html', | ||
10 | backdrop: false, | ||
11 | controller: 'focaBusquedaClienteModalController' | ||
12 | }); | ||
13 | }; | ||
14 | } | ||
15 | ]) | ||
16 | .controller('focaBusquedaClienteModalController', [ | ||
17 | '$uibModalInstance', | ||
18 | 'focaBusquedaClienteService', | ||
19 | '$scope', | ||
20 | function($uibModalInstance, focaBusquedaClienteService, $scope) { | ||
21 | $scope.obtenerClientesPorNombreOCuit = function(textoBusqueda) { | ||
22 | return focaBusquedaClienteService | ||
23 | .obtenerClientesPorNombreOCuit(textoBusqueda) | ||
24 | .then(function(datos) { | ||
25 | return datos.data; | ||
26 | }); | ||
27 | }; | ||
28 | $scope.cancelar = function() { | ||
29 | $uibModalInstance.close(); | ||
30 | }; | ||
31 | $scope.seleccionar = function() { | ||
32 | $uibModalInstance.close(); | ||
33 | }; | ||
34 | } | ||
35 | ]); | ||
36 |
src/js/service.js
File was created | 1 | angular.module('focaBusquedaCliente') | |
2 | .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | ||
3 | return { | ||
4 | obtenerClientes: function() { | ||
5 | return $http.get(API_ENDPOINT.URL + '/cliente'); | ||
6 | }, | ||
7 | obtenerCliente: function(id) { | ||
8 | return $http.get(API_ENDPOINT.URL + '/cliente/' + id); | ||
9 | }, | ||
10 | obtenerClientesPorNombreOCuit: function(nombreOCuit) { | ||
11 | return $http.post(API_ENDPOINT.URL + '/cliente', {nombreOCuit: nombreOCuit}); | ||
12 | } | ||
13 | }; | ||
14 | }]); | ||
15 |
src/views/foca-busqueda-cliente-modal.html
File was created | 1 | <div class="modal-header"> | |
2 | <h3 class="modal-title">Búsqueda de cliente</h3> | ||
3 | </div> | ||
4 | <div class="modal-body"> | ||
5 | <form> | ||
6 | <div class="form-group row"> | ||
7 | <label class="col-sm-4 col-form-label">Nombre o CUIT</label> | ||
8 | <div class="col-sm-8"> | ||
9 | <input | ||
10 | type="text" | ||
11 | ng-model="cliente" | ||
12 | placeholder="Nombre o CUIT" | ||
13 | uib-typeahead=" | ||
14 | cliente.nom + ' (' + cliente.cuit + ')' | ||
15 | for cliente | ||
16 | in obtenerClientesPorNombreOCuit($viewValue) | ||
17 | " | ||
18 | typeahead-loading="cargandoClientes" | ||
19 | typeahead-no-results="sinResultados" | ||
20 | typeahead-min-length="3" | ||
21 | class="form-control" | ||
22 | > | ||
23 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> | ||
24 | <div ng-show="sinResultados"> | ||
25 | <i class="fas fa-minus"></i> No se encontraron resultados. | ||
26 | </div> | ||
27 | </div> | ||
28 | </div> | ||
29 | </form> | ||
30 | </div> | ||
31 | <div class="modal-footer"> | ||
32 | <button ng-click="seleccionar()">Seleccionar</button> | ||
33 | <button ng-click="cancelar()">Cancelar</button> | ||
34 | </div> | ||
35 |
src/views/foca-busqueda-cliente.html
File was created | 1 | <button ng-click="abrirModal()">Seleccionar cliente</button> | |
2 |