Commit 15ed2516caa080ad87b8246551bda0383b7a7636
1 parent
c7d8997308
Exists in
master
version 0.1
Showing
8 changed files
with
261 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": 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 | +} |
gulpfile.js
| ... | ... | @@ -0,0 +1,85 @@ |
| 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 | +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('clean', function(){ | |
| 21 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
| 22 | + .pipe(clean()); | |
| 23 | +}); | |
| 24 | + | |
| 25 | +gulp.task('templates', ['clean'], function() { | |
| 26 | + return pump( | |
| 27 | + [ | |
| 28 | + gulp.src(paths.srcViews), | |
| 29 | + htmlmin(), | |
| 30 | + templateCache('views.js', { | |
| 31 | + module: 'focaModalLogin', | |
| 32 | + root: '' | |
| 33 | + }), | |
| 34 | + gulp.dest(paths.tmp) | |
| 35 | + ] | |
| 36 | + ); | |
| 37 | +}); | |
| 38 | + | |
| 39 | +gulp.task('uglify', ['templates'], function() { | |
| 40 | + return pump( | |
| 41 | + [ | |
| 42 | + gulp.src([ | |
| 43 | + paths.srcJS, | |
| 44 | + 'tmp/views.js' | |
| 45 | + ]), | |
| 46 | + concat('foca-modal-login.js'), | |
| 47 | + replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), | |
| 48 | + replace('src/views/', ''), | |
| 49 | + gulp.dest(paths.tmp), | |
| 50 | + rename('foca-modal-login.min.js'), | |
| 51 | + uglify(), | |
| 52 | + gulp.dest(paths.dist) | |
| 53 | + ] | |
| 54 | + ); | |
| 55 | +}); | |
| 56 | + | |
| 57 | +gulp.task('pre-commit', function() { | |
| 58 | + return pump( | |
| 59 | + [ | |
| 60 | + gulp.src(paths.srcJS), | |
| 61 | + jshint('.jshintrc'), | |
| 62 | + jshint.reporter('default'), | |
| 63 | + jshint.reporter('fail') | |
| 64 | + ] | |
| 65 | + ); | |
| 66 | +}); | |
| 67 | + | |
| 68 | + | |
| 69 | +gulp.task('webserver', function() { | |
| 70 | + pump [ | |
| 71 | + connect.server({port: 3000}) | |
| 72 | + ] | |
| 73 | +}); | |
| 74 | + | |
| 75 | +gulp.task('clean-post-install', function() { | |
| 76 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
| 77 | + 'index.html'], {read: false}) | |
| 78 | + .pipe(clean()); | |
| 79 | +}); | |
| 80 | + | |
| 81 | +gulp.task('default', ['webserver']); | |
| 82 | + | |
| 83 | +gulp.task('watch', function(){ | |
| 84 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
| 85 | +}); |
src/etc/develop.js.ejemplo
src/js/app.js
src/js/controller.js
| ... | ... | @@ -0,0 +1,50 @@ |
| 1 | +angular.module('focaModalLogin') | |
| 2 | + .controller('focaModalLoginController', [ | |
| 3 | + '$uibModalInstance', '$scope', 'parametros', 'focaModalLoginService', | |
| 4 | + function($uibModalInstance, $scope, parametros, focaModalLoginService) { | |
| 5 | + init(); | |
| 6 | + | |
| 7 | + function init() { | |
| 8 | + console.info(parametros); | |
| 9 | + $scope.cuenta = parametros.cuenta; | |
| 10 | + $scope.usuario = { | |
| 11 | + login: '', | |
| 12 | + pass: '' | |
| 13 | + } | |
| 14 | + | |
| 15 | + if (parametros.tipo == 'Transportistas') { | |
| 16 | + $scope.usuario.login = parametros.cuenta.dni; | |
| 17 | + } | |
| 18 | + | |
| 19 | + if (parametros.tipo == 'Cobradores' || parametros.tipo == 'Vendedores') { | |
| 20 | + $scope.usuario.login = parametros.cuenta.CodVen; | |
| 21 | + } | |
| 22 | + } | |
| 23 | + | |
| 24 | + $scope.guardar = function() { | |
| 25 | + var result = { | |
| 26 | + login: { | |
| 27 | + username: $scope.usuario.login, | |
| 28 | + password: $scope.usuario.pass, | |
| 29 | + activo: true | |
| 30 | + }, | |
| 31 | + cuenta: { | |
| 32 | + tipo: parametros.tipo, | |
| 33 | + id: parametros.cuenta.id | |
| 34 | + } | |
| 35 | + } | |
| 36 | + | |
| 37 | + if (parametros.cuenta.idLogin) { | |
| 38 | + result.login.id = parametros.cuenta.idLogin; | |
| 39 | + } | |
| 40 | + | |
| 41 | + focaModalLoginService.postLogin(result).then(function(data) { | |
| 42 | + $uibModalInstance.close(data); | |
| 43 | + }); | |
| 44 | + } | |
| 45 | + | |
| 46 | + $scope.cancel = function() { | |
| 47 | + $uibModalInstance.dismiss(); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + ]); | |
| 0 | 51 | \ No newline at end of file |
src/js/service.js
src/views/modal-login.html
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +<div class="modal-header py-1"> | |
| 2 | + <div class="row w-100"> | |
| 3 | + <div class="col-lg-6"> | |
| 4 | + <h5 class="modal-title my-1">Editar Ingreso</h5> | |
| 5 | + </div> | |
| 6 | + </div> | |
| 7 | +</div> | |
| 8 | +<div class="modal-body" id="modal-body"> | |
| 9 | + <form name="formCliente"> | |
| 10 | + <div class="row"> | |
| 11 | + <div class="col-12"> | |
| 12 | + <label>Usuario</label> | |
| 13 | + <input | |
| 14 | + type="text" | |
| 15 | + class="form-control form-control-sm" | |
| 16 | + ng-model="usuario.login" | |
| 17 | + ng-required="true" | |
| 18 | + readonly | |
| 19 | + /> | |
| 20 | + </div> | |
| 21 | + <div class="col-12"> | |
| 22 | + <label>Contraseña</label> | |
| 23 | + <input | |
| 24 | + type="password" | |
| 25 | + foca-focus="ingreso" | |
| 26 | + class="form-control form-control-sm" | |
| 27 | + ng-model="usuario.pass" | |
| 28 | + placeholder="Ingrese Contraseña" | |
| 29 | + ng-required="true" | |
| 30 | + teclado-virtual | |
| 31 | + autocomplete="new-password" | |
| 32 | + /> | |
| 33 | + </div> | |
| 34 | + </div> | |
| 35 | + </form> | |
| 36 | +</div> | |
| 37 | +<div class="modal-footer py-1"> | |
| 38 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
| 39 | + <button class="btn btn-sm btn-primary" type="button" ng-click="guardar()">Guardar</button> | |
| 40 | +</div> |