diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76a3502 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/dist +package-lock\.json +/src/etc/develop.js + +tmp/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..d8cbb07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": false, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..0a0aac5 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,91 @@ +const templateCache = require('gulp-angular-templatecache'); +const clean = require('gulp-clean'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', ['clean'], function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaListaHojaRuta', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-hoja-ruta.js'), + replace('src/views/', ''), + replace("'ngRoute'", ''), + gulp.dest(paths.tmp), + rename('foca-hoja-ruta.min.js'), + uglify(), + /*replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ + '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ + '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ + '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+ + '"cordovaGeolocationModule"', ''),*/ + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function() { + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + return pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3300, host: '0.0.0.0'}) + ] +}); + +gulp.task('clean-post-install', function() { + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', + 'index.html'], {read: false}) + .pipe(clean()); +}); + +gulp.task('default', ['webserver']); + +gulp.task('watch', function() { + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..a48eb7b --- /dev/null +++ b/package.json @@ -0,0 +1,42 @@ +{ + "name": "foca--hoja-ruta", + "version": "0.0.1", + "description": "foca-hoja-ruta", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://debo.suite.repo/modulos-npm/foca-hoja-ruta.git" + }, + "author": "Foca Software", + "license": "ISC", + "devDependencies": { + "angular": "^1.7.5", + "angular-ladda": "^0.4.3", + "angular-route": "^1.7.5", + "bootstrap": "^4.1.3", + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", + "foca-modal-remito": "git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.5", + "gulp-clean": "^0.4.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-sequence": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jasmine-core": "^3.3.0", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "ladda": "1.0.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.5" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..25cd0cd --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaCrearHojaRuta') + .constant("API_ENDPOINT", { + 'URL': '//127.0.0.1:9000' + }); diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..2f11d18 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,16 @@ +angular.module('focaListaHojaRuta', [ + 'ngRoute' + /*'focaBusquedaProductos', + 'focaModalProveedor', + 'focaBusquedaCliente', + 'focaModalPrecioCondicion', + 'focaModalFlete', + 'focaDirectivas', + 'focaModal', + 'focaModalDomicilio', + 'focaModalMoneda', + 'focaModalCotizacion', + 'focaSeguimiento', + 'angular-ladda', + 'cordovaGeolocationModule'*/ +]); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..c12ca7d --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,44 @@ +angular.module('focaListaHojaRuta') + .controller('listaHojaRutaCtrl', + [ + '$scope', '$filter', 'hojaRutaService', + function($scope, $filter, hojaRutaService) { + hojaRutaService.getHojasRuta().then(function(res) { + $scope.hojasRuta = res.data; + }); + $scope.cabecera = []; + $scope.showCabecera = true; + addCabecera('Transportista:', 'Andesmar'); + addCabecera('Chofer:', 'Carlos'); + addCabecera('Vehículo:', 'SCANIA TODOPODEROSO'); + $scope.now = new Date(); + $scope.puntoVenta = '0000'; + $scope.comprobante = '00000000'; + + function addCabecera(label, valor) { + var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); + if(propiedad.length === 1) { + propiedad[0].valor = valor; + } else { + $scope.cabecera.push({label: label, valor: valor}); + } + } + + function removeCabecera(label) { + var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); + if(propiedad.length === 1) { + $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); + } + } + + function rellenar(relleno, longitud) { + relleno = '' + relleno; + while (relleno.length < longitud) { + relleno = '0' + relleno; + } + + return relleno; + } + } + ]); + diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..dcc9caf --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,7 @@ +angular.module('focaListaHojaRuta') + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/venta-hoja-ruta/lista', { + controller: 'listaHojaRutaCtrl', + templateUrl: 'src/views/lista-hoja-ruta.html' + }); + }]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..cc1977e --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,9 @@ +angular.module('focaListaHojaRuta') + .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + var route = API_ENDPOINT.URL; + return { + getHojasRuta: function() { + return $http.get(route + '/hoja-ruta'); + } + }; + }]); diff --git a/src/views/lista-hoja-ruta.html b/src/views/lista-hoja-ruta.html new file mode 100644 index 0000000..7ffffb5 --- /dev/null +++ b/src/views/lista-hoja-ruta.html @@ -0,0 +1,101 @@ +
# | +Sucursal | +#HojaRuta | +
---|---|---|
+ | + | + |