Commit 8c088fc687f4bcbac401f1e6f08be8df052888ec
1 parent
a98ca8d049
Exists in
master
- Modifiqué gulp para que uglifique despues de generar templates.
- Agregué método para procesar el cliente seleccionado. - Agregué on select al componente typeahead.
Showing
3 changed files
with
11 additions
and
7 deletions
Show diff stats
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-es').default; | 5 | const uglify = require('gulp-uglify-es').default; |
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 | 9 | ||
10 | var paths = { | 10 | var paths = { |
11 | srcJS: 'src/js/*.js', | 11 | srcJS: 'src/js/*.js', |
12 | srcViews: 'src/views/*.html', | 12 | srcViews: 'src/views/*.html', |
13 | tmp: 'tmp', | 13 | tmp: 'tmp', |
14 | dist: 'dist/' | 14 | dist: 'dist/' |
15 | }; | 15 | }; |
16 | 16 | ||
17 | gulp.task('templates', function() { | 17 | gulp.task('templates', function() { |
18 | pump( | 18 | pump( |
19 | [ | 19 | [ |
20 | gulp.src(paths.srcViews), | 20 | gulp.src(paths.srcViews), |
21 | htmlmin(), | 21 | htmlmin(), |
22 | templateCache('views.js', { | 22 | templateCache('views.js', { |
23 | module: 'focaBusquedaCliente', | 23 | module: 'focaBusquedaCliente', |
24 | root: '' | 24 | root: '' |
25 | }), | 25 | }), |
26 | gulp.dest(paths.tmp) | 26 | gulp.dest(paths.tmp) |
27 | ] | 27 | ] |
28 | ); | 28 | ); |
29 | }); | 29 | }); |
30 | 30 | ||
31 | gulp.task('uglify', function() { | 31 | gulp.task('uglify', ['templates'], function() { |
32 | pump( | 32 | pump( |
33 | [ | 33 | [ |
34 | gulp.src([ | 34 | gulp.src([ |
35 | paths.srcJS, | 35 | paths.srcJS, |
36 | 'tmp/views.js' | 36 | 'tmp/views.js' |
37 | ]), | 37 | ]), |
38 | concat('foca-busqueda-cliente.js'), | 38 | concat('foca-busqueda-cliente.js'), |
39 | gulp.dest(paths.tmp), | 39 | gulp.dest(paths.tmp), |
40 | rename('foca-busqueda-cliente.min.js'), | 40 | rename('foca-busqueda-cliente.min.js'), |
41 | uglify(), | 41 | uglify(), |
42 | gulp.dest(paths.dist) | 42 | gulp.dest(paths.dist) |
43 | ] | 43 | ] |
44 | ); | 44 | ); |
45 | }); | 45 | }); |
46 | 46 | ||
47 | gulp.task('pre-commit', function() { | 47 | gulp.task('pre-commit', function() { |
48 | pump( | 48 | pump( |
49 | [ | 49 | [ |
50 | gulp.src(paths.srcJS), | 50 | gulp.src(paths.srcJS), |
51 | jshint('.jshintrc'), | 51 | jshint('.jshintrc'), |
52 | jshint.reporter('default'), | 52 | jshint.reporter('default'), |
53 | jshint.reporter('fail') | 53 | jshint.reporter('fail') |
54 | ] | 54 | ] |
55 | ); | 55 | ); |
56 | }); | 56 | }); |
57 | |||
58 | gulp.task('compile', ['templates', 'uglify']); | ||
59 | 57 |
src/js/controller.js
1 | angular.module('focaBusquedaCliente') | 1 | angular.module('focaBusquedaCliente') |
2 | .controller('focaBusquedaClienteController', [ | 2 | .controller('focaBusquedaClienteController', [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModal', | 4 | '$uibModal', |
5 | function($scope, $uibModal) { | 5 | function($scope, $uibModal) { |
6 | $scope.abrirModal = function() { | 6 | $scope.abrirModal = function() { |
7 | $uibModal.open({ | 7 | $uibModal.open({ |
8 | animation: false, | 8 | animation: false, |
9 | templateUrl: 'foca-busqueda-cliente-modal.html', | 9 | templateUrl: 'foca-busqueda-cliente-modal.html', |
10 | backdrop: false, | 10 | backdrop: false, |
11 | controller: 'focaBusquedaClienteModalController' | 11 | controller: 'focaBusquedaClienteModalController' |
12 | }).result.then(function(cliente){ | ||
13 | console.log(cliente); | ||
12 | }); | 14 | }); |
13 | }; | 15 | }; |
14 | } | 16 | } |
15 | ]) | 17 | ]) |
16 | .controller('focaBusquedaClienteModalController', [ | 18 | .controller('focaBusquedaClienteModalController', [ |
17 | '$uibModalInstance', | 19 | '$uibModalInstance', |
18 | 'focaBusquedaClienteService', | 20 | 'focaBusquedaClienteService', |
19 | '$scope', | 21 | '$scope', |
20 | function($uibModalInstance, focaBusquedaClienteService, $scope) { | 22 | function($uibModalInstance, focaBusquedaClienteService, $scope) { |
21 | $scope.obtenerClientesPorNombreOCuit = function(textoBusqueda) { | 23 | $scope.obtenerClientesPorNombreOCuit = function(textoBusqueda) { |
22 | return focaBusquedaClienteService | 24 | return focaBusquedaClienteService |
23 | .obtenerClientesPorNombreOCuit(textoBusqueda) | 25 | .obtenerClientesPorNombreOCuit(textoBusqueda) |
24 | .then(function(datos) { | 26 | .then(function(datos) { |
25 | return datos.data; | 27 | return datos.data; |
26 | }); | 28 | }); |
27 | }; | 29 | }; |
30 | $scope.seleccionar = function(cliente) { | ||
31 | $scope.cliente = cliente; | ||
32 | }; | ||
28 | $scope.cancelar = function() { | 33 | $scope.cancelar = function() { |
29 | $uibModalInstance.close(); | 34 | $uibModalInstance.dismiss(); |
30 | }; | 35 | }; |
31 | $scope.seleccionar = function() { | 36 | $scope.aceptar = function() { |
32 | $uibModalInstance.close(); | 37 | $uibModalInstance.close($scope.cliente); |
33 | }; | 38 | }; |
34 | } | 39 | } |
35 | ]); | 40 | ]); |
36 | 41 |
src/views/foca-busqueda-cliente-modal.html
1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
2 | <h3 class="modal-title">Búsqueda de cliente</h3> | 2 | <h3 class="modal-title">Búsqueda de cliente</h3> |
3 | </div> | 3 | </div> |
4 | <div class="modal-body"> | 4 | <div class="modal-body"> |
5 | <form> | 5 | <form> |
6 | <div class="form-group row"> | 6 | <div class="form-group row"> |
7 | <label class="col-sm-4 col-form-label">Nombre o CUIT</label> | 7 | <label class="col-sm-4 col-form-label">Nombre o CUIT</label> |
8 | <div class="col-sm-8"> | 8 | <div class="col-sm-8"> |
9 | <input | 9 | <input |
10 | type="text" | 10 | type="text" |
11 | ng-model="cliente" | 11 | ng-model="cliente" |
12 | placeholder="Nombre o CUIT" | 12 | placeholder="Nombre o CUIT" |
13 | uib-typeahead=" | 13 | uib-typeahead=" |
14 | cliente.nom + ' (' + cliente.cuit + ')' | 14 | cliente.nom + ' (' + cliente.cuit + ')' |
15 | for cliente | 15 | for cliente |
16 | in obtenerClientesPorNombreOCuit($viewValue) | 16 | in obtenerClientesPorNombreOCuit($viewValue) |
17 | " | 17 | " |
18 | typeahead-loading="cargandoClientes" | 18 | typeahead-loading="cargandoClientes" |
19 | typeahead-no-results="sinResultados" | 19 | typeahead-no-results="sinResultados" |
20 | typeahead-min-length="3" | 20 | typeahead-min-length="3" |
21 | typeahead-on-select="seleccionar($item)" | ||
21 | class="form-control" | 22 | class="form-control" |
22 | > | 23 | > |
23 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> | 24 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> |
24 | <div ng-show="sinResultados"> | 25 | <div ng-show="sinResultados"> |
25 | <i class="fas fa-minus"></i> No se encontraron resultados. | 26 | <i class="fas fa-minus"></i> No se encontraron resultados. |
26 | </div> | 27 | </div> |
27 | </div> | 28 | </div> |
28 | </div> | 29 | </div> |
29 | </form> | 30 | </form> |
30 | </div> | 31 | </div> |
31 | <div class="modal-footer"> | 32 | <div class="modal-footer"> |
32 | <button ng-click="seleccionar()">Seleccionar</button> | 33 | <button ng-click="aceptar()">Aceptar</button> |
33 | <button ng-click="cancelar()">Cancelar</button> | 34 | <button ng-click="cancelar()">Cancelar</button> |
34 | </div> | 35 | </div> |
35 | 36 |