diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09a9f61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/dist +/tmp +package-lock\.json +src/etc/develop\.js +/css diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..dd429f7 --- /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": true, + + // 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..6586a66 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,94 @@ +const clean = require('gulp-clean'); +const concat = require('gulp-concat'); +const connect = require('gulp-connect'); +const gulp = require('gulp'); +const htmlmin = require('gulp-htmlmin'); +const jshint = require('gulp-jshint'); +const pump = require('pump'); +const rename = require('gulp-rename'); +const replace = require('gulp-replace'); +const templateCache = require('gulp-angular-templatecache'); +const uglify = require('gulp-uglify-es').default; +const sass = require('gulp-sass'); + +var paths = { + dist: 'dist/', + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp' +}; + +gulp.task('templates', function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaCabeceraFacturador', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('sass', function() { + return gulp.src('src/sass/*.scss') + .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) + .pipe(gulp.dest('css')); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-cabecera-facturador.js'), + replace('src/views/', ''), + gulp.dest(paths.tmp), + rename('foca-cabecera-facturador.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function() { + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); +}); + +gulp.task('webserver', function() { + pump [ + connect.server( + { + port: 3000 + } + ) + ] +}); + +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/index.html b/index.html new file mode 100644 index 0000000..850f8d2 --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..c9b9402 --- /dev/null +++ b/package.json @@ -0,0 +1,59 @@ +{ + "name": "foca-cabecera-facturador", + "version": "0.0.1", + "description": "Componente de nombre de la empresa", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify", + "gulp-pre-commit": "gulp pre-commit", + "postinstall": "npm run compile && gulp clean-post-install", + "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-clean gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jasmine-core jquery jshint pre-commit pump && npm install angular-sanitize" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "git+ssh://git@debonline.dyndns.org:npm/foca-cabecera-facturador.git" + }, + "author": "Foca Software", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.x", + "bootstrap": "^4.1.x", + "jquery": "^3.3.x", + "font-awesome": "^4.7.x", + "gulp": "^3.9.x", + "gulp-concat": "2.6.x", + "gulp-jshint": "^2.1.x", + "gulp-rename": "^1.4.x", + "gulp-replace": "^1.0.x", + "gulp-uglify-es": "^1.0.x", + "jshint": "^2.9.x", + "pump": "^3.0.x" + }, + "devDependencies": { + "angular": "1.7.5", + "angular-route": "^1.7.5", + "angular-sanitize": "1.7.5", + "bootstrap": "4.1.3", + "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-sass": "4.0.2", + "gulp-uglify-es": "1.0.4", + "jasmine-core": "3.3.0", + "jquery": "3.3.1", + "jshint": "2.9.6", + "pre-commit": "1.2.2", + "pump": "3.0.0" + } +} diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..25f3203 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,11 @@ +angular.module('focaCabeceraFacturador', []) + .component('focaCabeceraFacturador', { + templateUrl: 'src/views/cabecera.html', + controller: 'focaCabeceraFacturadorController', + bindings: { + titulo: '<', + numero: '<', + fecha: '=', + busqueda: '<' + } + }); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..0138225 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,30 @@ +angular.module('focaCabeceraFacturador') + .controller('focaCabeceraFacturadorController', [ + '$scope', + '$filter', + function($scope, $filter) { + + $scope.showCabecera = true; + $scope.cabecera = []; + + $scope.$on('addCabecera', function(event, data) { + var propiedad = $filter('filter')($scope.cabecera, {label: data.label}, true); + if(propiedad.length === 1) { + propiedad[0].valor = data.valor; + }else { + $scope.cabecera.push({label: data.label, valor: data.valor}); + } + }); + + $scope.$on('removeCabecera', function(event, data) { + var propiedad = $filter('filter')($scope.cabecera, {label: data}, true); + if(propiedad.length === 1) { + $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); + } + }); + + $scope.$on('cleanCabecera', function() { + $scope.cabecera = []; + }); + + }]); diff --git a/src/views/cabecera.html b/src/views/cabecera.html new file mode 100644 index 0000000..8ad2f31 --- /dev/null +++ b/src/views/cabecera.html @@ -0,0 +1,77 @@ +
+
+
+
+
+
+
+
{{$ctrl.titulo}}
+
+
NÂș {{$ctrl.numero}} + +
+
+ Fecha: + + + +
+
+ Hora: + + +
+
+
+
+ + +
+ + + + +
+
+
+
+
+