Commit c8541c3de157d069bdb0fc112e6f5d36e582deca
1 parent
2a55b472a7
Exists in
master
Primera version
Showing
10 changed files
with
401 additions
and
0 deletions
Show diff stats
.gitignore
.jshintrc
... | ... | @@ -0,0 +1,64 @@ |
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": false, | |
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 | +} |
gulpfile.js
... | ... | @@ -0,0 +1,89 @@ |
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'); | |
6 | +const gulp = require('gulp'); | |
7 | +const pump = require('pump'); | |
8 | +const jshint = require('gulp-jshint'); | |
9 | +const replace = require('gulp-replace'); | |
10 | +const connect = require('gulp-connect'); | |
11 | +const clean = require('gulp-clean'); | |
12 | + | |
13 | +var paths = { | |
14 | + srcJS: 'src/js/*.js', | |
15 | + srcViews: 'src/views/*.html', | |
16 | + tmp: 'tmp', | |
17 | + dist: 'dist/' | |
18 | +}; | |
19 | + | |
20 | +gulp.task('templates', function() { | |
21 | + return pump( | |
22 | + [ | |
23 | + gulp.src(paths.srcViews), | |
24 | + replace('views/', ''), | |
25 | + htmlmin(), | |
26 | + templateCache('views.js', { | |
27 | + module: 'focaAgendarVisita', | |
28 | + root: '' | |
29 | + }), | |
30 | + gulp.dest(paths.tmp) | |
31 | + ] | |
32 | + ); | |
33 | +}); | |
34 | + | |
35 | +gulp.task('uglify', ['templates'], function() { | |
36 | + return pump( | |
37 | + [ | |
38 | + gulp.src([ | |
39 | + paths.srcJS, | |
40 | + 'tmp/views.js' | |
41 | + ]), | |
42 | + concat('foca-agendar-visita.js'), | |
43 | + replace("['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']", '[]'), | |
44 | + replace("src/views/", ''), | |
45 | + gulp.dest(paths.tmp), | |
46 | + rename('foca-agendar-visita.min.js'), | |
47 | + uglify(), | |
48 | + gulp.dest(paths.dist) | |
49 | + ] | |
50 | + ); | |
51 | +}); | |
52 | + | |
53 | +gulp.task('clean', function() { | |
54 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
55 | + .pipe(clean()); | |
56 | +}); | |
57 | + | |
58 | +gulp.task('pre-commit', function() { | |
59 | + pump( | |
60 | + [ | |
61 | + gulp.src(paths.srcJS), | |
62 | + jshint('.jshintrc'), | |
63 | + jshint.reporter('default'), | |
64 | + jshint.reporter('fail') | |
65 | + ] | |
66 | + ); | |
67 | + | |
68 | + gulp.start('uglify'); | |
69 | +}); | |
70 | + | |
71 | +gulp.task('clean-post-install', function() { | |
72 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
73 | + 'index.html'], {read: false}) | |
74 | + .pipe(clean()); | |
75 | +}); | |
76 | + | |
77 | +gulp.task('compile', ['templates', 'uglify']); | |
78 | + | |
79 | +gulp.task('watch', function() { | |
80 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
81 | +}); | |
82 | + | |
83 | +gulp.task('webserver', function() { | |
84 | + pump [ | |
85 | + connect.server({port: 3000}) | |
86 | + ] | |
87 | +}); | |
88 | + | |
89 | +gulp.task('default', ['webserver']); |
package.json
... | ... | @@ -0,0 +1,32 @@ |
1 | +{ | |
2 | + "name": "foca-activar-hoja-ruta", | |
3 | + "version": "0.0.1", | |
4 | + "description": "", | |
5 | + "main": "index.js", | |
6 | + "scripts": { | |
7 | + "test": "echo \"Error: no test specified\" && exit 1", | |
8 | + "compile": "gulp uglify", | |
9 | + "gulp-pre-commit": "gulp pre-commit", | |
10 | + "postinstall": "npm run compile && gulp clean-post-install", | |
11 | + "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-remito.git" | |
12 | + }, | |
13 | + "pre-commit": [ | |
14 | + "gulp-pre-commit" | |
15 | + ], | |
16 | + "author": "", | |
17 | + "license": "ISC", | |
18 | + "devDependencies": { | |
19 | + "gulp": "^3.9.1", | |
20 | + "gulp-angular-templatecache": "^2.2.6", | |
21 | + "gulp-clean": "^0.4.0", | |
22 | + "gulp-connect": "^5.7.0", | |
23 | + "gulp-htmlmin": "^5.0.1", | |
24 | + "gulp-jshint": "^2.1.0", | |
25 | + "gulp-rename": "^1.4.0", | |
26 | + "gulp-replace": "^1.0.0", | |
27 | + "gulp-uglify": "^3.0.1", | |
28 | + "jshint": "^2.9.7", | |
29 | + "pre-commit": "^1.2.2", | |
30 | + "pump": "^3.0.0" | |
31 | + } | |
32 | +} |
src/etc/develop.js.ejemplo
src/js/app.js
... | ... | @@ -0,0 +1 @@ |
1 | +angular.module('focaAgendarVisita', ['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']); |
src/js/controller.js
... | ... | @@ -0,0 +1,102 @@ |
1 | +angular.module('focaAgendarVisita') | |
2 | + .controller('focaAgendarVisitaController', [ | |
3 | + '$scope', 'focaAgendarVisitaService', '$location', '$timeout', | |
4 | + '$uibModal', 'focaBotoneraLateralService', '$filter', 'focaLoginService', | |
5 | + 'focaModalService', 'focaSeguimientoService', | |
6 | + function($scope, focaAgendarVisitaService, $location, $timeout, | |
7 | + $uibModal, focaBotoneraLateralService, $filter, focaLoginService, | |
8 | + focaModalService, focaSeguimientoService) { | |
9 | + $scope.focused = 0; | |
10 | + $scope.rol = 1; | |
11 | + $scope.visita = {}; | |
12 | + $scope.now = new Date(); | |
13 | + $scope.botonera = [ | |
14 | + { | |
15 | + label: 'Agendar', | |
16 | + image: 'precios-condiciones.png' | |
17 | + } | |
18 | + ]; | |
19 | + $timeout(function() { | |
20 | + focaBotoneraLateralService.showSalir(true); | |
21 | + focaBotoneraLateralService.showPausar(true); | |
22 | + focaBotoneraLateralService.showGuardar(true, $scope.guardar); | |
23 | + }); | |
24 | + | |
25 | + $scope.seleccionarCliente = function() { | |
26 | + var modalInstance = $uibModal.open( | |
27 | + { | |
28 | + ariaLabelledBy: 'Busqueda de Cliente', | |
29 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
30 | + controller: 'focaBusquedaClienteModalController', | |
31 | + resolve: { | |
32 | + vendedor: function() { return null; } | |
33 | + }, | |
34 | + size: 'lg' | |
35 | + } | |
36 | + ); | |
37 | + modalInstance.result.then( | |
38 | + function(cliente) { | |
39 | + $scope.visita.cliente = cliente; | |
40 | + } | |
41 | + ); | |
42 | + }; | |
43 | + $scope.seleccionarVisitante = function() { | |
44 | + var parametrosModal = { | |
45 | + query: '/vendedor-cobrador', | |
46 | + columnas: [ | |
47 | + { | |
48 | + propiedad: 'NUM', | |
49 | + nombre: 'Codigo', | |
50 | + filtro: { | |
51 | + nombre: 'rellenarDigitos', | |
52 | + parametro: 3 | |
53 | + } | |
54 | + }, | |
55 | + { | |
56 | + propiedad: 'NOM', | |
57 | + nombre: 'Nombre' | |
58 | + } | |
59 | + ], | |
60 | + titulo:'Bรบsqueda de vendedores y cobradores', | |
61 | + size: 'md' | |
62 | + }; | |
63 | + focaModalService.modal(parametrosModal).then(function(vendedorCobrador) { | |
64 | + $scope.visita.visitante = vendedorCobrador; | |
65 | + }); | |
66 | + }; | |
67 | + | |
68 | + $scope.next = function(key) { | |
69 | + if (key === 13) $scope.focused ++; | |
70 | + }; | |
71 | + | |
72 | + $scope.guardar = function() { | |
73 | + var rol; | |
74 | + if($scope.visita.visitante.rol === 1){ | |
75 | + rol = 'Nota de pedido'; | |
76 | + } else if($scope.visita.visitante.rol === 2){ | |
77 | + rol = 'Cobranza'; | |
78 | + } else { | |
79 | + rol = ($scope.rol === 1) ? 'Nota de pedido' : 'Cobranza'; | |
80 | + } | |
81 | + | |
82 | + focaAgendarVisitaService | |
83 | + .guardarVisita({ | |
84 | + idVisitante: $scope.visita.visitante.NUM, | |
85 | + tipoVisitante: ($scope.visita.visitante.rol !== 3) ? | |
86 | + $scope.visita.visitante.rol : $scope.rol, | |
87 | + idCliente: $scope.visita.cliente.cod | |
88 | + }) | |
89 | + .then(function(data) { | |
90 | + focaSeguimientoService.guardarPosicion( | |
91 | + rol, | |
92 | + data.data.id, | |
93 | + $scope.visita.observacion, | |
94 | + true | |
95 | + ); | |
96 | + }) | |
97 | + .then(function() { | |
98 | + $location.path('/'); | |
99 | + }); | |
100 | + }; | |
101 | + } | |
102 | + ]); |
src/js/route.js
src/js/service.js
... | ... | @@ -0,0 +1,8 @@ |
1 | +angular.module('focaAgendarVisita') | |
2 | + .factory('focaAgendarVisitaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | |
3 | + return { | |
4 | + guardarVisita: function(visita) { | |
5 | + return $http.post(API_ENDPOINT.URL + '/visita', {visita: visita}); | |
6 | + } | |
7 | + }; | |
8 | + }]); |
src/views/agendar-visita.html
... | ... | @@ -0,0 +1,85 @@ |
1 | +<div class="row"> | |
2 | + <foca-cabecera-facturador | |
3 | + titulo="'Agendar visita'" | |
4 | + fecha="now" | |
5 | + class="mb-0 col-lg-12" | |
6 | + ></foca-cabecera-facturador> | |
7 | +</div> | |
8 | +<div class="row"> | |
9 | + <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | |
10 | + <form class="row py-2 mt-3 botonera-secundaria"> | |
11 | + <div class="col-md-6"> | |
12 | + <div class="form-group mb-2 col-md-12 d-md-flex"> | |
13 | + <label class="col-form-label col-md-4 col-12">Cliente</label> | |
14 | + <div class="input-group col-md-8 col-12 pl-0"> | |
15 | + <input | |
16 | + class="form-control" | |
17 | + type="text" | |
18 | + teclado-virtual | |
19 | + ng-model="visita.cliente.nom" | |
20 | + foca-focus="focused == 1" | |
21 | + ng-focus="focused = 1" | |
22 | + ng-keypress="next($event.keyCode)" | |
23 | + disabled> | |
24 | + <div class="input-group-append"> | |
25 | + <button | |
26 | + class="btn btn-outline-secondary form-control" | |
27 | + title="Buscar" | |
28 | + type="button" | |
29 | + ng-click="seleccionarCliente()"> | |
30 | + <i class="fa fa-search" aria-hidden="true"></i> | |
31 | + </button> | |
32 | + </div> | |
33 | + </div> | |
34 | + </div> | |
35 | + <div class="form-group mb-2 col-md-12 d-md-flex"> | |
36 | + <label class="col-form-label col-md-4 col-12">Visitante</label> | |
37 | + <div class="input-group col-md-8 col-12 pl-0"> | |
38 | + <input | |
39 | + class="form-control" | |
40 | + type="text" | |
41 | + teclado-virtual | |
42 | + ng-model="visita.visitante.NOM" | |
43 | + foca-focus="focused == 1" | |
44 | + ng-focus="focused = 1" | |
45 | + ng-keypress="next($event.keyCode)" | |
46 | + disabled> | |
47 | + <div class="input-group-append"> | |
48 | + <button | |
49 | + class="btn btn-outline-secondary form-control" | |
50 | + title="Buscar" | |
51 | + type="button" | |
52 | + ng-click="seleccionarVisitante()"> | |
53 | + <i class="fa fa-search" aria-hidden="true"></i> | |
54 | + </button> | |
55 | + </div> | |
56 | + </div> | |
57 | + </div> | |
58 | + <div | |
59 | + class="form-group mb-2 col-md-12 d-md-flex" | |
60 | + ng-show="visita.visitante.rol === 3"> | |
61 | + <label class="col-form-label col-md-4 col-12">Tipo</label> | |
62 | + <div class="input-group col-md-8 col-12 pl-0"> | |
63 | + <select class="form-control" ng-model="rol"> | |
64 | + <option value="1">Vendedor</option> | |
65 | + <option value="2">Cobrador</option> | |
66 | + </select> | |
67 | + </div> | |
68 | + </div> | |
69 | + </div> | |
70 | + <div class="form-group mb-2 col-md-6 d-md-flex"> | |
71 | + <label class="col-form-label col-md-4 col-12">Observaciones</label> | |
72 | + <div class="input-group col-md-8 col-12 pl-0"> | |
73 | + <textarea | |
74 | + rows="5" | |
75 | + class="form-control" | |
76 | + teclado-virtual | |
77 | + ng-model="visita.observacion" | |
78 | + foca-focus="focused == 1" | |
79 | + ng-focus="focused = 1" | |
80 | + ng-keypress="next($event.keyCode)"> | |
81 | + </div> | |
82 | + </div> | |
83 | + </form> | |
84 | + </div> | |
85 | +</div> |