Commit 5072fb1e1ab1f57a5f430680cf1da97e25863063
1 parent
a4c899b20e
Exists in
master
primera versión
Showing
8 changed files
with
350 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,78 @@ |
| 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 | + htmlmin(), | |
| 25 | + templateCache('views.js', { | |
| 26 | + module: 'focaModalDatosHojaRuta', | |
| 27 | + root: '' | |
| 28 | + }), | |
| 29 | + gulp.dest(paths.tmp) | |
| 30 | + ] | |
| 31 | + ); | |
| 32 | +}); | |
| 33 | + | |
| 34 | +gulp.task('uglify', ['templates'], function() { | |
| 35 | + return pump( | |
| 36 | + [ | |
| 37 | + gulp.src([ | |
| 38 | + paths.srcJS, | |
| 39 | + 'tmp/views.js' | |
| 40 | + ]), | |
| 41 | + concat('foca-modal-datos-hoja-ruta.js'), | |
| 42 | + replace('src/views/', ''), | |
| 43 | + gulp.dest(paths.tmp), | |
| 44 | + rename('foca-modal-datos-hoja-ruta.min.js'), | |
| 45 | + uglify(), | |
| 46 | + gulp.dest(paths.dist) | |
| 47 | + ] | |
| 48 | + ); | |
| 49 | +}); | |
| 50 | + | |
| 51 | +gulp.task('pre-commit', function() { | |
| 52 | + return pump( | |
| 53 | + [ | |
| 54 | + gulp.src(paths.srcJS), | |
| 55 | + jshint('.jshintrc'), | |
| 56 | + jshint.reporter('default'), | |
| 57 | + jshint.reporter('fail') | |
| 58 | + ] | |
| 59 | + ); | |
| 60 | +}); | |
| 61 | + | |
| 62 | +gulp.task('webserver', function() { | |
| 63 | + pump [ | |
| 64 | + connect.server({port: 3000}) | |
| 65 | + ] | |
| 66 | +}); | |
| 67 | + | |
| 68 | +gulp.task('clean-post-install', function(){ | |
| 69 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
| 70 | + 'index.html'], {read: false}) | |
| 71 | + .pipe(clean()); | |
| 72 | +}); | |
| 73 | + | |
| 74 | +gulp.task('default', ['webserver']); | |
| 75 | + | |
| 76 | +gulp.task('watch', function() { | |
| 77 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
| 78 | +}); |
package.json
| ... | ... | @@ -0,0 +1,42 @@ |
| 1 | +{ | |
| 2 | + "name": "foca-modal-datos-hoja-ruta", | |
| 3 | + "version": "0.0.1", | |
| 4 | + "description": "Modal de datos extra hoja ruta", | |
| 5 | + "main": "index.js", | |
| 6 | + "scripts": { | |
| 7 | + "test": "echo \"Error: no test specified\" && exit 1", | |
| 8 | + "gulp-pre-commit": "gulp pre-commit", | |
| 9 | + "compile": "gulp uglify", | |
| 10 | + "postinstall": "npm run compile && gulp clean-post-install", | |
| 11 | + "install-dev": "npm install -D angular font-awesome pump jquery bootstrap ui-bootstrap4 jshint gulp gulp-uglify gulp-concat gulp-htmlmin gulp-rename gulp-uglify gulp-jshint gulp-replace gulp-connect gulp-clean gulp-angular-templatecache git+http://git.focasoftware.com/npm/foca-directivas.git" | |
| 12 | + }, | |
| 13 | + "pre-commit": [ | |
| 14 | + "gulp-pre-commit" | |
| 15 | + ], | |
| 16 | + "repository": { | |
| 17 | + "type": "git", | |
| 18 | + "url": "http://git.focasoftware.com/npm/foca-modal-datos-hoja-ruta.git" | |
| 19 | + }, | |
| 20 | + "author": "Foca Software", | |
| 21 | + "license": "ISC", | |
| 22 | + "devDependencies": { | |
| 23 | + "angular": "^1.7.6", | |
| 24 | + "bootstrap": "^4.2.1", | |
| 25 | + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | |
| 26 | + "font-awesome": "^4.7.0", | |
| 27 | + "gulp": "^3.9.1", | |
| 28 | + "gulp-angular-templatecache": "^2.2.6", | |
| 29 | + "gulp-clean": "^0.4.0", | |
| 30 | + "gulp-concat": "^2.6.1", | |
| 31 | + "gulp-connect": "^5.7.0", | |
| 32 | + "gulp-htmlmin": "^5.0.1", | |
| 33 | + "gulp-jshint": "^2.1.0", | |
| 34 | + "gulp-rename": "^1.4.0", | |
| 35 | + "gulp-replace": "^1.0.0", | |
| 36 | + "gulp-uglify": "^3.0.1", | |
| 37 | + "jquery": "^3.3.1", | |
| 38 | + "jshint": "^2.9.7", | |
| 39 | + "pump": "^3.0.0", | |
| 40 | + "ui-bootstrap4": "^3.0.6" | |
| 41 | + } | |
| 42 | +} |
src/etc/develop.js.ejemplo
src/js/app.js
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +angular.module('focaModalDatosHojaRuta', []); |
src/js/controller.js
| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | +angular.module('focaModalDatosHojaRuta') | |
| 2 | + .controller('focaModalDatosHojaRutaCtrl', | |
| 3 | + [ | |
| 4 | + '$filter', | |
| 5 | + '$scope', | |
| 6 | + '$uibModalInstance', | |
| 7 | + 'focaModalService', | |
| 8 | + 'parametrosDatos', | |
| 9 | + function($filter, $scope, $uibModalInstance, focaModalService, parametrosDatos) { | |
| 10 | + console.log(parametrosDatos.datosHojaRuta); | |
| 11 | + $scope.datosHojaRuta = parametrosDatos.datosHojaRuta; | |
| 12 | + $scope.focused = 0; | |
| 13 | + | |
| 14 | + $scope.aceptar = function(key) { | |
| 15 | + if(key === 13) { | |
| 16 | + if(!$scope.formDatosHojaRuta.$valid) { | |
| 17 | + focaModalService.alert('Formulario inválido'); | |
| 18 | + return; | |
| 19 | + } | |
| 20 | + $uibModalInstance.close($scope.datosHojaRuta); | |
| 21 | + } | |
| 22 | + }; | |
| 23 | + | |
| 24 | + $scope.next = function(key) { | |
| 25 | + if(key === 13) $scope.focused++; | |
| 26 | + } | |
| 27 | + | |
| 28 | + $scope.cancel = function() { | |
| 29 | + $uibModalInstance.dismiss('cancel'); | |
| 30 | + }; | |
| 31 | + } | |
| 32 | + ] | |
| 33 | + ); |
src/views/foca-modal-datos-hoja-ruta.html
| ... | ... | @@ -0,0 +1,123 @@ |
| 1 | +<div class="modal-header"> | |
| 2 | + <h3 class="modal-title">Datos de la hoja de ruta</h3> | |
| 3 | +</div> | |
| 4 | +<div class="modal-body" id="modal-body"> | |
| 5 | + <form name="formDatosHojaRuta"> | |
| 6 | + <div class="row"> | |
| 7 | + <div class="col-4"> | |
| 8 | + <label class="form-control-sm">Kilómetros iniciales del vehículo:</label> | |
| 9 | + </div> | |
| 10 | + <div class="col-2 px-0"> | |
| 11 | + <input | |
| 12 | + foca-tipo-input | |
| 13 | + foca-focus="focused === 0" | |
| 14 | + ng-focus="focused = 0" | |
| 15 | + teclado-virtual | |
| 16 | + class="form-control form-control-sm" | |
| 17 | + placeholder="Kilómetros iniciales" | |
| 18 | + ng-model="datosHojaRuta.kmInicialVehiculo" | |
| 19 | + ng-required="true" | |
| 20 | + ng-keypress="next($event.keyCode)" | |
| 21 | + /> | |
| 22 | + </div> | |
| 23 | + <div class="col-4"> | |
| 24 | + <label class="form-control-sm">Aforador inicial del vehículo:</label> | |
| 25 | + </div> | |
| 26 | + <div class="col-2 pl-0"> | |
| 27 | + <input | |
| 28 | + foca-tipo-input | |
| 29 | + teclado-virtual | |
| 30 | + foca-focus="focused === 1" | |
| 31 | + ng-focus="focused = 1" | |
| 32 | + class="form-control form-control-sm" | |
| 33 | + placeholder="Aforador inicial" | |
| 34 | + ng-model="datosHojaRuta.aforadorInicialVehiculo" | |
| 35 | + ng-required="true" | |
| 36 | + ng-keypress="next($event.keyCode)"/> | |
| 37 | + </div> | |
| 38 | + <div class="col-4 pr-0"> | |
| 39 | + <label class="form-control-sm">Cantidad de descarga por gravedad:</label> | |
| 40 | + </div> | |
| 41 | + <div class="col-2 px-0"> | |
| 42 | + <input | |
| 43 | + foca-tipo-input | |
| 44 | + teclado-virtual | |
| 45 | + foca-focus="focused === 2" | |
| 46 | + ng-focus="focused = 2" | |
| 47 | + class="form-control form-control-sm" | |
| 48 | + placeholder="Cantidad de descarga por gravedad" | |
| 49 | + ng-model="datosHojaRuta.cantidadDescargaPorGravedad" | |
| 50 | + ng-required="true" | |
| 51 | + ng-keypress="next($event.keyCode)"/> | |
| 52 | + </div> | |
| 53 | + <div class="col-4"> | |
| 54 | + <label class="form-control-sm">Litros cargados para movilidad:</label> | |
| 55 | + </div> | |
| 56 | + <div class="col-2 pl-0"> | |
| 57 | + <input | |
| 58 | + foca-tipo-input | |
| 59 | + teclado-virtual | |
| 60 | + foca-focus="focused === 3" | |
| 61 | + ng-focus="focused = 3" | |
| 62 | + class="form-control form-control-sm" | |
| 63 | + placeholder="Litros de combustible carga el camión para su movilidad" | |
| 64 | + ng-model="datosHojaRuta.litrosDescargadosPorGravedad" | |
| 65 | + ng-required="true" | |
| 66 | + ng-keypress="next($event.keyCode)"/> | |
| 67 | + </div> | |
| 68 | + <div class="col-2"> | |
| 69 | + <label class="form-control-sm">Precinto uno:</label> | |
| 70 | + </div> | |
| 71 | + <div class="col-2 px-0"> | |
| 72 | + <input | |
| 73 | + type="text" | |
| 74 | + teclado-virtual | |
| 75 | + foca-focus="focused === 4" | |
| 76 | + ng-focus="focused = 4" | |
| 77 | + class="form-control form-control-sm" | |
| 78 | + placeholder="Precinto boca uno" | |
| 79 | + ng-model="datosHojaRuta.precintoBocaUno" | |
| 80 | + ng-required="true" | |
| 81 | + ng-keypress="next($event.keyCode)"/> | |
| 82 | + </div> | |
| 83 | + <div class="col-2"> | |
| 84 | + <label class="form-control-sm">Precinto dos:</label> | |
| 85 | + </div> | |
| 86 | + <div class="col-2 px-0"> | |
| 87 | + <input | |
| 88 | + type="text" | |
| 89 | + teclado-virtual | |
| 90 | + foca-focus="focused === 5" | |
| 91 | + ng-focus="focused = 5" | |
| 92 | + class="form-control form-control-sm" | |
| 93 | + placeholder="Precinto boca dos" | |
| 94 | + ng-model="datosHojaRuta.precintoBocaDos" | |
| 95 | + ng-required="true" | |
| 96 | + ng-keypress="next($event.keyCode)"/> | |
| 97 | + </div> | |
| 98 | + <div class="col-2"> | |
| 99 | + <label class="form-control-sm">Precinto tres:</label> | |
| 100 | + </div> | |
| 101 | + <div class="col-2 pl-0"> | |
| 102 | + <input | |
| 103 | + type="text" | |
| 104 | + teclado-virtual | |
| 105 | + foca-focus="focused === 6" | |
| 106 | + ng-focus="focused = 6" | |
| 107 | + class="form-control form-control-sm" | |
| 108 | + placeholder="Precinto boca tres" | |
| 109 | + ng-model="datosHojaRuta.precintoBocaTres" | |
| 110 | + ng-required="true" | |
| 111 | + ng-keypress="aceptar($event.keyCode)"/> | |
| 112 | + </div> | |
| 113 | + </form> | |
| 114 | +</div> | |
| 115 | +<div class="modal-footer"> | |
| 116 | + <button | |
| 117 | + class="btn btn-primary" | |
| 118 | + type="button" | |
| 119 | + ng-click="aceptar(13)" | |
| 120 | + ng-disabled="!formDatosHojaRuta.$valid" | |
| 121 | + >Aceptar</button> | |
| 122 | + <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
| 123 | +</div> |