Commit 029fad3b4e429c858c4d837302cd706e94cb90c7
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
primera version See merge request !1
Showing
12 changed files
Show diff stats
.gitignore
| File was created | 1 | /node_modules | |
| 2 | /dist | ||
| 3 | /tmp | ||
| 4 | package-lock\.json | ||
| 5 | src/etc/develop.js | ||
| 6 |
.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": 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 | } | ||
| 65 |
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 | 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: 'focaAbmChofer', | ||
| 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-abm-chofer.js'), | ||
| 43 | replace("['ngRoute', 'focaModal', 'ui.bootstrap']", '[]'), | ||
| 44 | replace("src/views/", ''), | ||
| 45 | gulp.dest(paths.tmp), | ||
| 46 | rename('foca-abm-chofer.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']); | ||
| 90 |
index.html
| File was created | 1 | <html ng-app="focaAbmChofer"> | |
| 2 | <head> | ||
| 3 | <meta charset="UTF-8"/> | ||
| 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
| 5 | |||
| 6 | <!--CSS--> | ||
| 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | ||
| 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | ||
| 9 | |||
| 10 | <!--VENDOR JS--> | ||
| 11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | ||
| 12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | ||
| 13 | <script src="node_modules/angular/angular.min.js"></script> | ||
| 14 | <script src="node_modules/angular-route/angular-route.min.js"></script> | ||
| 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | ||
| 16 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | ||
| 17 | |||
| 18 | <!-- BUILD --> | ||
| 19 | <script src="src/js/app.js"></script> | ||
| 20 | <script src="src/js/controller.js"></script> | ||
| 21 | <script src="src/js/route.js"></script> | ||
| 22 | <script src="src/js/service.js"></script> | ||
| 23 | <!-- /BUILD --> | ||
| 24 | |||
| 25 | <!-- CONFIG PARA DEVELOP --> | ||
| 26 | <script src="src/etc/develop.js"></script> | ||
| 27 | </head> | ||
| 28 | <body style="background: #afafaf;padding: 25px"> | ||
| 29 | <div class="container-fluid pt-3 pb-3" ng-view style="background: #fff"></div> | ||
| 30 | </body> | ||
| 31 | </html> | ||
| 32 |
package.json
| File was created | 1 | { | |
| 2 | "name": "foca-abm-vehiculo", | ||
| 3 | "version": "0.0.1", | ||
| 4 | "description": "Abm de vehiculo", | ||
| 5 | "main": "index.html", | ||
| 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 angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.git" | ||
| 12 | }, | ||
| 13 | "pre-commit": [ | ||
| 14 | "gulp-pre-commit" | ||
| 15 | ], | ||
| 16 | "repository": { | ||
| 17 | "type": "git", | ||
| 18 | "url": "http://git.focasoftware.com/npm/foca-abm-vehiculo.git" | ||
| 19 | }, | ||
| 20 | "author": "Foca Software", | ||
| 21 | "license": "ISC", | ||
| 22 | "peerDependencies": { | ||
| 23 | "angular": "^1.7.x", | ||
| 24 | "angular-route": "^1.7.x", | ||
| 25 | "bootstrap": "^4.1.x", | ||
| 26 | "jquery": "^3.3.x", | ||
| 27 | "font-awesome": "^4.7.x", | ||
| 28 | "gulp": "^3.9.x", | ||
| 29 | "gulp-concat": "2.6.x", | ||
| 30 | "gulp-jshint": "^2.1.x", | ||
| 31 | "gulp-rename": "^1.4.x", | ||
| 32 | "gulp-replace": "^1.0.x", | ||
| 33 | "gulp-uglify-es": "^1.0.x", | ||
| 34 | "jshint": "^2.9.x", | ||
| 35 | "pump": "^3.0.x" | ||
| 36 | }, | ||
| 37 | "devDependencies": { | ||
| 38 | "angular": "^1.7.5", | ||
| 39 | "angular-route": "^1.7.5", | ||
| 40 | "bootstrap": "^4.1.3", | ||
| 41 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | ||
| 42 | "font-awesome": "^4.7.0", | ||
| 43 | "gulp": "^3.9.1", | ||
| 44 | "gulp-angular-templatecache": "^2.2.5", | ||
| 45 | "gulp-clean": "^0.4.0", | ||
| 46 | "gulp-connect": "^5.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": "^3.0.1", | ||
| 52 | "gulp-uglify-es": "^1.0.4", | ||
| 53 | "jasmine-core": "^3.3.0", | ||
| 54 | "jquery": "^3.3.1", | ||
| 55 | "jshint": "^2.9.6", | ||
| 56 | "pre-commit": "^1.2.2", | ||
| 57 | "pump": "^3.0.0", | ||
| 58 | "ui-bootstrap4": "^3.0.5" | ||
| 59 | } | ||
| 60 | } | ||
| 61 |
src/etc/develop.js.ejemplo
| File was created | 1 | angular.module('focaAbmVehiculo') | |
| 2 | .constant("API_ENDPOINT", { | ||
| 3 | 'URL': '//127.0.0.1:9000' | ||
| 4 | }); | ||
| 5 |
src/js/app.js
| File was created | 1 | angular.module('focaAbmChofer', ['ngRoute', 'focaModal', 'ui.bootstrap']); | |
| 2 |
src/js/controller.js
| File was created | 1 | angular.module('focaAbmChofer') | |
| 2 | .controller('focaAbmChoferesController', [ | ||
| 3 | '$scope', 'focaAbmChoferService', '$location', 'focaModalService', | ||
| 4 | function($scope, focaAbmChoferService, $location, focaModalService) { | ||
| 5 | |||
| 6 | $scope.filters = ''; | ||
| 7 | $scope.choferes = []; | ||
| 8 | $scope.choferesFiltrados = []; | ||
| 9 | |||
| 10 | focaAbmChoferService.getChoferes().then(function(datos) { | ||
| 11 | $scope.choferes = datos.data; | ||
| 12 | $scope.choferesFiltrados = $scope.choferes; | ||
| 13 | }); | ||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | $scope.editar = function(id) { | ||
| 18 | $location.path('/chofer/' + id); | ||
| 19 | }; | ||
| 20 | |||
| 21 | $scope.solicitarConfirmacion = function(chofer) { | ||
| 22 | focaModalService.confirm('¿Está seguro que desea borrar el chofer ' + | ||
| 23 | chofer.nombre + ' ?').then(function(confirmed) { | ||
| 24 | if(confirmed) { | ||
| 25 | focaAbmChoferService.deleteChofer(chofer.id); | ||
| 26 | $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); | ||
| 27 | } | ||
| 28 | }); | ||
| 29 | }; | ||
| 30 | |||
| 31 | |||
| 32 | } | ||
| 33 | ]) | ||
| 34 | .controller('focaAbmChoferController', [ | ||
| 35 | '$scope', 'focaAbmChoferService', '$routeParams', '$location', | ||
| 36 | function($scope, focaAbmChoferService, $routeParams, $location) { | ||
| 37 | |||
| 38 | $scope.chofer = {}; | ||
| 39 | $scope.transportistas = []; | ||
| 40 | |||
| 41 | focaAbmChoferService.getChofer($routeParams.id).then(function(res) { | ||
| 42 | if(res.data) $scope.chofer = res.data; | ||
| 43 | }); | ||
| 44 | |||
| 45 | focaAbmChoferService.getTransportistas().then(function(res) { | ||
| 46 | $scope.transportistas = res.data; | ||
| 47 | }); | ||
| 48 | |||
| 49 | $scope.cancelar = function() { | ||
| 50 | $location.path('/chofer'); | ||
| 51 | }; | ||
| 52 | |||
| 53 | $scope.guardar = function() { | ||
| 54 | $scope.chofer.idTransportista = $scope.chofer.transportista.COD; | ||
| 55 | delete $scope.chofer.transportista; | ||
| 56 | focaAbmChoferService.guardarChofer($scope.chofer).then(function() { | ||
| 57 | $location.path('/chofer'); | ||
| 58 | }); | ||
| 59 | }; | ||
| 60 | |||
| 61 | } | ||
| 62 | ]); | ||
| 63 |
src/js/route.js
| File was created | 1 | angular.module('focaAbmChofer') | |
| 2 | .config([ | ||
| 3 | '$routeProvider', | ||
| 4 | function($routeProvider) { | ||
| 5 | $routeProvider.when('/chofer', { | ||
| 6 | controller: 'focaAbmChoferesController', | ||
| 7 | templateUrl: 'src/views/foca-abm-choferes-listado.html' | ||
| 8 | }); | ||
| 9 | } | ||
| 10 | ]) | ||
| 11 | .config([ | ||
| 12 | '$routeProvider', | ||
| 13 | function($routeProvider) { | ||
| 14 | $routeProvider.when('/chofer/:id', { | ||
| 15 | controller: 'focaAbmChoferController', | ||
| 16 | templateUrl: 'src/views/foca-abm-choferes-item.html' | ||
| 17 | }); | ||
| 18 | } | ||
| 19 | ]); | ||
| 20 |
src/js/service.js
| File was created | 1 | angular.module('focaAbmChofer') | |
| 2 | .factory('focaAbmChoferService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | ||
| 3 | return { | ||
| 4 | getChoferes: function() { | ||
| 5 | return $http.get(API_ENDPOINT.URL + '/chofer'); | ||
| 6 | }, | ||
| 7 | getChofer: function(id) { | ||
| 8 | return $http.get(API_ENDPOINT.URL + '/chofer/' + id); | ||
| 9 | }, | ||
| 10 | guardarChofer: function(chofer) { | ||
| 11 | return $http.post(API_ENDPOINT.URL + '/chofer', {chofer: chofer}); | ||
| 12 | }, | ||
| 13 | getTransportistas: function() { | ||
| 14 | return $http.get(API_ENDPOINT.URL + '/transportista'); | ||
| 15 | }, | ||
| 16 | deleteChofer: function(id) { | ||
| 17 | return $http.delete(API_ENDPOINT.URL + '/chofer/' + id); | ||
| 18 | } | ||
| 19 | }; | ||
| 20 | }]); | ||
| 21 |
src/views/foca-abm-choferes-item.html
| File was created | 1 | <h4 class="pt-4">Chofer</h4> | |
| 2 | <form name="formChofer"> | ||
| 3 | <input type="hidden" name="id" ng-model="chofer.id" /> | ||
| 4 | <div class="form-group row"> | ||
| 5 | <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> | ||
| 6 | <div class="col-sm-4"> | ||
| 7 | <select class="form-control" ng-model="chofer.transportista" | ||
| 8 | ng-options="transportista as transportista.NOM for transportista in transportistas" | ||
| 9 | > | ||
| 10 | </select> | ||
| 11 | </div> | ||
| 12 | </div> | ||
| 13 | <div class="form-group row"> | ||
| 14 | <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> | ||
| 15 | <div class="col-sm-4"> | ||
| 16 | <input | ||
| 17 | class="form-control" | ||
| 18 | type="text" | ||
| 19 | teclado-virtual | ||
| 20 | ng-model="chofer.nombre" | ||
| 21 | ng-required="true" | ||
| 22 | /> | ||
| 23 | </div> | ||
| 24 | </div> | ||
| 25 | <div class="form-group row"> | ||
| 26 | <label class="offset-sm-1 col-sm-2 col-form-label">DNI</label> | ||
| 27 | <div class="col-sm-4"> | ||
| 28 | <input | ||
| 29 | class="form-control" | ||
| 30 | type="text" | ||
| 31 | teclado-virtual | ||
| 32 | ng-model="chofer.dni" | ||
| 33 | ng-required="true" | ||
| 34 | /> | ||
| 35 | </div> | ||
| 36 | </div> | ||
| 37 | <div class="form-group row"> | ||
| 38 | <label class="offset-sm-1 col-sm-2 col-form-label">Teléfono</label> | ||
| 39 | <div class="col-sm-4"> | ||
| 40 | <input | ||
| 41 | class="form-control" | ||
| 42 | type="text" | ||
| 43 | teclado-virtual | ||
| 44 | ng-model="chofer.telefono" | ||
| 45 | ng-required="true" | ||
| 46 | /> | ||
| 47 | </div> | ||
| 48 | </div> | ||
| 49 | <div class="form-group row"> | ||
| 50 | <div class="col-sm-7 text-right"> | ||
| 51 | <button | ||
| 52 | class="btn btn-primary" | ||
| 53 | ng-click="guardar()" | ||
| 54 | ng-disabled="!formChofer.$valid" | ||
| 55 | >Guardar</button> | ||
| 56 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | ||
| 57 | </div> | ||
| 58 | </div> | ||
| 59 | </form> | ||
| 60 |
src/views/foca-abm-choferes-listado.html
| File was created | 1 | <div class="col-12 pt-4"> | |
| 2 | <h4>Choferes</h4> | ||
| 3 | <div class="form-group"> | ||
| 4 | <input | ||
| 5 | type="text" | ||
| 6 | class="form-control form-control-sm" | ||
| 7 | placeholder="Búsqueda" | ||
| 8 | ng-model="filtros" | ||
| 9 | teclado-virtual | ||
| 10 | /> | ||
| 11 | </div> | ||
| 12 | <table class="table table-sm table-striped table-dark"> | ||
| 13 | <thead> | ||
| 14 | <tr> | ||
| 15 | <th>Código</th> | ||
| 16 | <th>Nombre</th> | ||
| 17 | <th>DNI</th> | ||
| 18 | <th>Teléfono</th> | ||
| 19 | <th>Transportista</th> | ||
| 20 | <th class="text-center"> | ||
| 21 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> | ||
| 22 | <i class="fa fa-plus"></i> | ||
| 23 | </button> | ||
| 24 | </th> | ||
| 25 | </tr> | ||
| 26 | </thead> | ||
| 27 | <tbody> | ||
| 28 | <tr ng-repeat="chofer in choferesFiltrados | filter:filtros"> | ||
| 29 | <td ng-bind="chofer.id"></td> | ||
| 30 | <td ng-bind="chofer.nombre"></td> | ||
| 31 | <td ng-bind="chofer.dni"></td> | ||
| 32 | <td ng-bind="chofer.telefono"></td> | ||
| 33 | <td ng-bind="chofer.transportista.NOM || 'No tiene'"></td> | ||
| 34 | <td class="text-center"> | ||
| 35 | <button | ||
| 36 | class="btn btn-default boton-accion" | ||
| 37 | ng-click="editar(chofer.id)" | ||
| 38 | > | ||
| 39 | <i class="fa fa-pencil"></i> | ||
| 40 | </button> | ||
| 41 | <button | ||
| 42 | class="btn btn-default boton-accion" | ||
| 43 | ng-click="solicitarConfirmacion(chofer)" | ||
| 44 | > | ||
| 45 | <i class="fa fa-trash"></i> | ||
| 46 | </button> | ||
| 47 | </td> | ||
| 48 | </tr> | ||
| 49 | </body> | ||
| 50 | </table> | ||
| 51 | <a href="#!/" title="Salir" | ||
| 52 | class="btn btn-secondary btn-block float-right col-md-2" | ||
| 53 | > | ||
| 54 | Salir | ||
| 55 | </a> | ||
| 56 | </div> | ||
| 57 |