Commit 599b49f2f77f4333bc3e491fae7a6512b257f8d5

Authored by Eric Fernandez
0 parents
Exists in master

primera versión

File was created 1 /node_modules
2 /dist
3 /tmp
4 package-lock\.json
5 src/etc/develop.js
6
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
File was created 1 ABM vehiculo
2 ============
3
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: 'focaAbmVehiculo',
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-vehiculo.js'),
43 replace("['ngRoute', 'focaModal', 'ui.bootstrap']", '[]'),
44 replace("src/views/", ''),
45 gulp.dest(paths.tmp),
46 rename('foca-abm-vehiculo.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
File was created 1 <html ng-app="focaAbmVehiculo">
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/route.js"></script>
21 <script src="src/js/controller.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
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
File was created 1 angular.module('focaAbmVehiculo', ['ngRoute', 'focaModal', 'ui.bootstrap']);
2
src/js/controller.js
File was created 1 angular.module('focaAbmVehiculo')
2 .controller('focaAbmVehiculosController', [
3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService',
4 function($scope, focaAbmVehiculoService, $location, focaModalService) {
5 focaAbmVehiculoService.getVehiculos().then(function(datos) {
6 $scope.vehiculos = datos.data;
7 $scope.vehiculosFiltrados = $scope.vehiculos;
8 });
9 $scope.editar = function(id) {
10 $location.path('/vehiculo/' + id);
11 };
12 $scope.solicitarConfirmacion = function(vehiculo) {
13 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
14 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
15 function(data) {
16 if(data) {
17 focaAbmVehiculoService.deleteVehiculo(vehiculo.id);
18 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
19 }
20 }
21 );
22 };
23 }
24 ])
25 .controller('focaAbmVehiculoController', [
26 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location',
27 function($scope, focaAbmVehiculoService, $routeParams, $location) {
28 focaAbmVehiculoService.getVehiculo($routeParams.id).then(function(res) {
29 if(!res.data[0].transportista.COD) {
30 res.data[0].transportista = '';
31 }
32 $scope.vehiculo = res.data[0];
33 });
34 focaAbmVehiculoService.getTransportistas().then(function(res) {
35 $scope.transportistas = res.data;
36 });
37 $scope.cancelar = function() {
38 $location.path('/vehiculo');
39 };
40 $scope.guardar = function() {
41 $scope.vehiculo.idTransportista = $scope.vehiculo.transportista.COD;
42 delete $scope.vehiculo.transportista;
43 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function() {
44 $location.path('/vehiculo');
45 });
46 };
47 }
48 ]);
49
File was created 1 angular.module('focaAbmVehiculo')
2 .config([
3 '$routeProvider',
4 function($routeProvider) {
5 $routeProvider.when('/vehiculo', {
6 controller: 'focaAbmVehiculosController',
7 templateUrl: 'src/views/foca-abm-vehiculos-listado.html'
8 });
9 }
10 ])
11 .config([
12 '$routeProvider',
13 function($routeProvider) {
14 $routeProvider.when('/vehiculo/:id', {
15 controller: 'focaAbmVehiculoController',
16 templateUrl: 'src/views/foca-abm-vehiculos-item.html'
17 });
18 }
19 ]);
20
File was created 1 angular.module('focaAbmVehiculo')
2 .factory('focaAbmVehiculoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 return {
4 getVehiculos: function() {
5 return $http.get(API_ENDPOINT.URL + '/vehiculo');
6 },
7 getVehiculo: function(id) {
8 return $http.get(API_ENDPOINT.URL + '/vehiculo/' + id);
9 },
10 getTransportistas: function() {
11 return $http.get(API_ENDPOINT.URL + '/transportista');
12 },
13 guerdarVehiculo: function(vehiculo) {
14 return $http.post(API_ENDPOINT.URL + '/vehiculo', {vehiculo: vehiculo});
15 },
16 deleteVehiculo: function(id) {
17 return $http.delete(API_ENDPOINT.URL + '/vehiculo/' + id);
18 }
19 };
20 }]);
21
src/views/foca-abm-vehiculos-item.html
File was created 1 <h4>Sectores</h4>
2 <form name="formVehiculo">
3 <input type="hidden" name="id" ng-model="sector.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 <input
8 class="form-control"
9 type="text"
10 teclado-virtual
11 ng-model="vehiculo.transportista"
12 ng-model-options="{allowInvalid: false}"
13 uib-typeahead="transportista as transportista.COD + ' ' +
14 transportista.NOM for transportista in transportistas | filter:$viewValue"
15 />
16 </div>
17 </div>
18 <div class="form-group row">
19 <label class="offset-sm-1 col-sm-2 col-form-label">Código</label>
20 <div class="col-sm-4">
21 <input
22 class="form-control"
23 type="text"
24 teclado-virtual
25 ng-model="vehiculo.id"
26 readonly
27 />
28 </div>
29 </div>
30 <div class="form-group row">
31 <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label>
32 <div class="col-sm-4">
33 <input
34 class="form-control"
35 type="text"
36 teclado-virtual
37 ng-model="vehiculo.tractor"
38 ng-required="true"
39 />
40 </div>
41 </div>
42 <div class="form-group row">
43 <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label>
44 <div class="col-sm-4">
45 <input
46 class="form-control"
47 type="text"
48 teclado-virtual
49 ng-model="vehiculo.semi"
50 ng-required="true"
51 />
52 </div>
53 </div>
54 <div class="form-group row">
55 <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label>
56 <div class="col-sm-4">
57 <input
58 class="form-control"
59 type="text"
60 teclado-virtual
61 ng-model="vehiculo.capacidad"
62 ng-required="true"
63 />
64 </div>
65 </div>
66 <div class="form-group row">
67 <label class="offset-sm-1 col-sm-2 col-form-label">Cisternado</label>
68 <div class="col-sm-4">
69 <input
70 class="form-control"
71 type="text"
72 teclado-virtual
73 ng-model="vehiculo.cisternado"
74 ng-required="true"
75 />
76 </div>
77 </div>
78 <div class="form-group row">
79 <div class="col-sm-7 text-right">
80 <button
81 class="btn btn-primary"
82 ng-click="guardar()"
83 ng-disabled="!formVehiculo.$valid"
84 >Guardar</button>
85 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button>
86 </div>
87 </div>
88 </form>
89
src/views/foca-abm-vehiculos-listado.html
File was created 1 <div class="col-12">
2 <h4>Vehiculos</h4>
3 <div class="form-group">
4 <input
5 type="text"
6 teclado-virtual
7 class="form-control form-control-sm"
8 placeholder="Búsqueda"
9 ng-model="filtros"
10 />
11 </div>
12 <table class="table table-sm table-striped table-dark">
13 <thead>
14 <tr>
15 <th>Código</th>
16 <th>Transportista</th>
17 <th>Tractor</th>
18 <th>Capacidad</th>
19 <th class="text-center">
20 <button class="btn btn-default boton-accion" ng-click="editar(0)">
21 <i class="fa fa-plus"></i>
22 </button>
23 </th>
24 </tr>
25 </thead>
26 <tbody>
27 <tr ng-repeat="vehiculo in vehiculosFiltrados | filter:filtros">
28 <td ng-bind="vehiculo.id"></td>
29 <td ng-bind="vehiculo.transportista.NOM || 'No tiene'"></td>
30 <td ng-bind="vehiculo.tractor"></td>
31 <td ng-bind="vehiculo.capacidad"></td>
32 <td class="text-center">
33 <button
34 class="btn btn-default boton-accion"
35 ng-click="editar(vehiculo.id)"
36 >
37 <i class="fa fa-pencil"></i>
38 </button>
39 <button
40 class="btn btn-default boton-accion"
41 ng-click="solicitarConfirmacion(vehiculo)"
42 >
43 <i class="fa fa-trash"></i>
44 </button>
45 </td>
46 </tr>
47 </body>
48 </table>
49 </div>
50