Commit ac41716c0e7638d1afb97063feaa2a3d444833dd
1 parent
ac08d558f2
Exists in
master
Primera version
Showing
8 changed files
with
366 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,94 @@ |
1 | +const clean = require('gulp-clean'); | |
2 | +const concat = require('gulp-concat'); | |
3 | +const connect = require('gulp-connect'); | |
4 | +const gulp = require('gulp'); | |
5 | +const htmlmin = require('gulp-htmlmin'); | |
6 | +const jshint = require('gulp-jshint'); | |
7 | +const pump = require('pump'); | |
8 | +const rename = require('gulp-rename'); | |
9 | +const replace = require('gulp-replace'); | |
10 | +const templateCache = require('gulp-angular-templatecache'); | |
11 | +const uglify = require('gulp-uglify-es').default; | |
12 | +const sass = require('gulp-sass'); | |
13 | + | |
14 | +var paths = { | |
15 | + dist: 'dist/', | |
16 | + srcJS: 'src/js/*.js', | |
17 | + srcViews: 'src/views/*.html', | |
18 | + tmp: 'tmp' | |
19 | +}; | |
20 | + | |
21 | +gulp.task('templates', function() { | |
22 | + return pump( | |
23 | + [ | |
24 | + gulp.src(paths.srcViews), | |
25 | + htmlmin(), | |
26 | + templateCache('views.js', { | |
27 | + module: 'focaCabeceraFacturador', | |
28 | + root: '' | |
29 | + }), | |
30 | + gulp.dest(paths.tmp) | |
31 | + ] | |
32 | + ); | |
33 | +}); | |
34 | + | |
35 | +gulp.task('sass', function() { | |
36 | + return gulp.src('src/sass/*.scss') | |
37 | + .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) | |
38 | + .pipe(gulp.dest('css')); | |
39 | +}); | |
40 | + | |
41 | +gulp.task('uglify', ['templates'], function() { | |
42 | + return pump( | |
43 | + [ | |
44 | + gulp.src([ | |
45 | + paths.srcJS, | |
46 | + 'tmp/views.js' | |
47 | + ]), | |
48 | + concat('foca-cabecera-facturador.js'), | |
49 | + replace('src/views/', ''), | |
50 | + gulp.dest(paths.tmp), | |
51 | + rename('foca-cabecera-facturador.min.js'), | |
52 | + uglify(), | |
53 | + gulp.dest(paths.dist) | |
54 | + ] | |
55 | + ); | |
56 | +}); | |
57 | + | |
58 | +gulp.task('clean', function() { | |
59 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
60 | + .pipe(clean()); | |
61 | +}); | |
62 | + | |
63 | +gulp.task('pre-commit', function() { | |
64 | + pump( | |
65 | + [ | |
66 | + gulp.src(paths.srcJS), | |
67 | + jshint('.jshintrc'), | |
68 | + jshint.reporter('default'), | |
69 | + jshint.reporter('fail') | |
70 | + ] | |
71 | + ); | |
72 | +}); | |
73 | + | |
74 | +gulp.task('webserver', function() { | |
75 | + pump [ | |
76 | + connect.server( | |
77 | + { | |
78 | + port: 3000 | |
79 | + } | |
80 | + ) | |
81 | + ] | |
82 | +}); | |
83 | + | |
84 | +gulp.task('clean-post-install', function() { | |
85 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
86 | + 'index.html'], {read: false}) | |
87 | + .pipe(clean()); | |
88 | +}); | |
89 | + | |
90 | +gulp.task('default', ['webserver']); | |
91 | + | |
92 | +gulp.task('watch', function() { | |
93 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
94 | +}); |
index.html
... | ... | @@ -0,0 +1,25 @@ |
1 | +<html ng-app="focaCabeceraFacturador"> | |
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/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | |
15 | + | |
16 | + <!-- BUILD --> | |
17 | + <script src="src/js/app.js"></script> | |
18 | + <script src="src/js/controller.js"></script> | |
19 | + <!-- /BUILD --> | |
20 | + | |
21 | + </head> | |
22 | + <body> | |
23 | + <foca-cabecera-facturador> | |
24 | + </body> | |
25 | +</html> |
package.json
... | ... | @@ -0,0 +1,59 @@ |
1 | +{ | |
2 | + "name": "foca-cabecera-facturador", | |
3 | + "version": "0.0.1", | |
4 | + "description": "Componente de nombre de la empresa", | |
5 | + "main": "index.js", | |
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 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" | |
12 | + }, | |
13 | + "pre-commit": [ | |
14 | + "gulp-pre-commit" | |
15 | + ], | |
16 | + "repository": { | |
17 | + "type": "git", | |
18 | + "url": "git+ssh://git@debonline.dyndns.org:npm/foca-cabecera-facturador.git" | |
19 | + }, | |
20 | + "author": "Foca Software", | |
21 | + "license": "ISC", | |
22 | + "peerDependencies": { | |
23 | + "angular": "^1.7.x", | |
24 | + "bootstrap": "^4.1.x", | |
25 | + "jquery": "^3.3.x", | |
26 | + "font-awesome": "^4.7.x", | |
27 | + "gulp": "^3.9.x", | |
28 | + "gulp-concat": "2.6.x", | |
29 | + "gulp-jshint": "^2.1.x", | |
30 | + "gulp-rename": "^1.4.x", | |
31 | + "gulp-replace": "^1.0.x", | |
32 | + "gulp-uglify-es": "^1.0.x", | |
33 | + "jshint": "^2.9.x", | |
34 | + "pump": "^3.0.x" | |
35 | + }, | |
36 | + "devDependencies": { | |
37 | + "angular": "1.7.5", | |
38 | + "angular-route": "^1.7.5", | |
39 | + "angular-sanitize": "1.7.5", | |
40 | + "bootstrap": "4.1.3", | |
41 | + "font-awesome": "4.7.0", | |
42 | + "gulp": "3.9.1", | |
43 | + "gulp-angular-templatecache": "2.2.5", | |
44 | + "gulp-clean": "0.4.0", | |
45 | + "gulp-concat": "2.6.1", | |
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-sass": "4.0.2", | |
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 | + } | |
59 | +} |
src/js/app.js
... | ... | @@ -0,0 +1,11 @@ |
1 | +angular.module('focaCabeceraFacturador', []) | |
2 | + .component('focaCabeceraFacturador', { | |
3 | + templateUrl: 'src/views/cabecera.html', | |
4 | + controller: 'focaCabeceraFacturadorController', | |
5 | + bindings: { | |
6 | + titulo: '<', | |
7 | + numero: '<', | |
8 | + fecha: '=', | |
9 | + busqueda: '<' | |
10 | + } | |
11 | + }); |
src/js/controller.js
... | ... | @@ -0,0 +1,30 @@ |
1 | +angular.module('focaCabeceraFacturador') | |
2 | + .controller('focaCabeceraFacturadorController', [ | |
3 | + '$scope', | |
4 | + '$filter', | |
5 | + function($scope, $filter) { | |
6 | + | |
7 | + $scope.showCabecera = true; | |
8 | + $scope.cabecera = []; | |
9 | + | |
10 | + $scope.$on('addCabecera', function(event, data) { | |
11 | + var propiedad = $filter('filter')($scope.cabecera, {label: data.label}, true); | |
12 | + if(propiedad.length === 1) { | |
13 | + propiedad[0].valor = data.valor; | |
14 | + }else { | |
15 | + $scope.cabecera.push({label: data.label, valor: data.valor}); | |
16 | + } | |
17 | + }); | |
18 | + | |
19 | + $scope.$on('removeCabecera', function(event, data) { | |
20 | + var propiedad = $filter('filter')($scope.cabecera, {label: data}, true); | |
21 | + if(propiedad.length === 1) { | |
22 | + $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | |
23 | + } | |
24 | + }); | |
25 | + | |
26 | + $scope.$on('cleanCabecera', function() { | |
27 | + $scope.cabecera = []; | |
28 | + }); | |
29 | + | |
30 | + }]); |
src/views/cabecera.html
... | ... | @@ -0,0 +1,77 @@ |
1 | +<form name="formCrearNota"> | |
2 | + <div class="row"> | |
3 | + <div class="col-md-10 col-lg-12"> | |
4 | + <div class="row panel-informativo"> | |
5 | + <div class="col-12"> | |
6 | + <div class="row titulares"> | |
7 | + <div class="col-12 col-sm-3 nota-pedido border border-left-0 border-white align-middle"> | |
8 | + <h5 class="mb-0">{{$ctrl.titulo}}</h5> | |
9 | + </div> | |
10 | + <div class="col-12 col-sm-3 numero-pedido text-center text-md-left border border-white align-middle" | |
11 | + >Nยบ {{$ctrl.numero}} | |
12 | + <button | |
13 | + class="btn btn-xs btn-outline-light float-right" | |
14 | + type="button" | |
15 | + ng-click="$ctrl.busqueda()" | |
16 | + ng-if="$ctrl.busqueda" | |
17 | + > | |
18 | + <i class="fa fa-search"></i> | |
19 | + </button> | |
20 | + </div> | |
21 | + <div class="col-7 col-sm-3 border border-white align-middle"> | |
22 | + Fecha: | |
23 | + <span | |
24 | + ng-show="!datepickerAbierto" | |
25 | + ng-bind="$ctrl.fecha | date:'dd/MM/yyyy'" | |
26 | + ng-click="datepickerAbierto = true" | |
27 | + > | |
28 | + </span> | |
29 | + <input | |
30 | + ng-show="datepickerAbierto" | |
31 | + type="date" | |
32 | + ng-model="$ctrl.fecha" | |
33 | + ng-change="datepickerAbierto = false" | |
34 | + ng-blur="datepickerAbierto = false" | |
35 | + class="form-control form-control-sm col-8 float-right" | |
36 | + foca-focus="datepickerAbierto" | |
37 | + hasta-hoy | |
38 | + /> | |
39 | + </div> | |
40 | + <div class="col-5 col-sm-3 border border-white border-right-0 align-middle"> | |
41 | + Hora: | |
42 | + <span | |
43 | + ng-show="!datepickerAbierto" | |
44 | + ng-bind="$ctrl.fecha | date:'HH:mm'" | |
45 | + ng-click="datepickerAbierto = true" | |
46 | + > | |
47 | + </span> | |
48 | + </div> | |
49 | + </div> | |
50 | + <div class="row py-2"> | |
51 | + <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | |
52 | + <span class="label" ng-bind="cab.label"></span> | |
53 | + <span class="valor" ng-bind="cab.valor"></span> | |
54 | + </div> | |
55 | + <a | |
56 | + class="btn col-12 btn-secondary d-sm-none" | |
57 | + ng-show="cabecera.length > 0" | |
58 | + ng-click="showCabecera = !showCabecera" | |
59 | + > | |
60 | + <i | |
61 | + class="fa fa-chevron-down" | |
62 | + ng-hide="showCabecera" | |
63 | + aria-hidden="true" | |
64 | + > | |
65 | + </i> | |
66 | + <i | |
67 | + class="fa fa-chevron-up" | |
68 | + ng-show="showCabecera" | |
69 | + aria-hidden="true"> | |
70 | + </i> | |
71 | + </a> | |
72 | + </div> | |
73 | + </div> | |
74 | + </div> | |
75 | + </div> | |
76 | + </div> | |
77 | +</form> |