Commit 9c908cb50ce664a97a3d094358d31015ed12b8ab
1 parent
d3180efba4
Exists in
master
Primera version
Showing
10 changed files
with
473 additions
and
0 deletions
Show diff stats
.gitignore
| File was created | 1 | /node_modules | |
| 2 | /dist | ||
| 3 | /tmp | ||
| 4 | package-lock\.json | ||
| 5 | |||
| 6 | src/etc/develop\.js | ||
| 7 |
.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'); | ||
| 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('clean', function() { | ||
| 21 | return gulp.src(['tmp', 'dist'], {read: false}) | ||
| 22 | .pipe(clean()); | ||
| 23 | }); | ||
| 24 | |||
| 25 | gulp.task('templates', ['clean'], function() { | ||
| 26 | return pump( | ||
| 27 | [ | ||
| 28 | gulp.src(paths.srcViews), | ||
| 29 | htmlmin(), | ||
| 30 | templateCache('views.js', { | ||
| 31 | module: 'focaModalInformeHojaRuta', | ||
| 32 | root: '' | ||
| 33 | }), | ||
| 34 | gulp.dest(paths.tmp) | ||
| 35 | ] | ||
| 36 | ); | ||
| 37 | }); | ||
| 38 | |||
| 39 | gulp.task('uglify', ['templates'], function() { | ||
| 40 | return pump( | ||
| 41 | [ | ||
| 42 | gulp.src([ | ||
| 43 | paths.srcJS, | ||
| 44 | 'tmp/views.js' | ||
| 45 | ]), | ||
| 46 | concat('foca-modal-informe-hoja-ruta.js'), | ||
| 47 | replace('src/views/', ''), | ||
| 48 | replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda', 'focaModal']", '[]'), | ||
| 49 | gulp.dest(paths.tmp), | ||
| 50 | rename('foca-modal-informe-hoja-ruta.min.js'), | ||
| 51 | uglify(), | ||
| 52 | gulp.dest(paths.dist) | ||
| 53 | ] | ||
| 54 | ); | ||
| 55 | }); | ||
| 56 | |||
| 57 | gulp.task('pre-commit', function() { | ||
| 58 | return pump( | ||
| 59 | [ | ||
| 60 | gulp.src(paths.srcJS), | ||
| 61 | jshint('.jshintrc'), | ||
| 62 | jshint.reporter('default'), | ||
| 63 | jshint.reporter('fail') | ||
| 64 | ] | ||
| 65 | ); | ||
| 66 | |||
| 67 | gulp.start('uglify'); | ||
| 68 | }); | ||
| 69 | |||
| 70 | gulp.task('webserver', function() { | ||
| 71 | pump [ | ||
| 72 | connect.server({port: 3000}) | ||
| 73 | ] | ||
| 74 | }); | ||
| 75 | |||
| 76 | gulp.task('clean-post-install', function() { | ||
| 77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | ||
| 78 | 'index.html'], {read: false}) | ||
| 79 | .pipe(clean()); | ||
| 80 | }); | ||
| 81 | |||
| 82 | gulp.task('default', ['webserver']); | ||
| 83 | |||
| 84 | gulp.task('watch', function() { | ||
| 85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | ||
| 86 | }); | ||
| 87 | |||
| 88 | gulp.task('copy', ['uglify'], function() { | ||
| 89 | gulp.src('dist/*.js') | ||
| 90 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-modal-nota-pedido/dist')); | ||
| 91 | }); | ||
| 92 | |||
| 93 | gulp.task('watchAndCopy', function() { | ||
| 94 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | ||
| 95 | }); | ||
| 96 |
index.html
| File was created | 1 | <html ng-app="focaModalInformeHojaRuta"> | |
| 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 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> | ||
| 10 | |||
| 11 | <!--VENDOR JS--> | ||
| 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | ||
| 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | ||
| 14 | <script src="node_modules/angular/angular.min.js"></script> | ||
| 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | ||
| 16 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | ||
| 17 | <script src="node_modules/ladda/dist/spin.min.js"></script> | ||
| 18 | <script src="node_modules/ladda/dist/ladda.min.js"></script> | ||
| 19 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> | ||
| 20 | |||
| 21 | <!-- BUILD --> | ||
| 22 | <script src="src/js/app.js"></script> | ||
| 23 | <script src="src/js/controller.js"></script> | ||
| 24 | <script src="src/js/service.js"></script> | ||
| 25 | |||
| 26 | <!-- /BUILD --> | ||
| 27 | |||
| 28 | <!-- CONFIG PARA DEVELOP --> | ||
| 29 | <script src="src/etc/develop.js"></script> | ||
| 30 | </head> | ||
| 31 | <body ng-controller="controller"> | ||
| 32 | </body> | ||
| 33 | </html> | ||
| 34 |
package.json
| File was created | 1 | { | |
| 2 | "name": "foca-modal-nota-pedido", | ||
| 3 | "version": "0.0.1", | ||
| 4 | "description": "Modal para seleccion de notasPedido", | ||
| 5 | "scripts": { | ||
| 6 | "test": "echo \"Error: no test specified\" && exit 1", | ||
| 7 | "gulp-pre-commit": "gulp pre-commit", | ||
| 8 | "compile": "gulp uglify", | ||
| 9 | "postinstall": "npm run compile && gulp clean-post-install", | ||
| 10 | "install-dev": "npm install -D angular angular-ladda ladda@1.0.6 bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+http://git.focasoftware.com/npm/foca-directivas.git" | ||
| 11 | }, | ||
| 12 | "pre-commit": [ | ||
| 13 | "gulp-pre-commit" | ||
| 14 | ], | ||
| 15 | "repository": { | ||
| 16 | "type": "git", | ||
| 17 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-nota-pedido" | ||
| 18 | }, | ||
| 19 | "author": "Nicolรกs Guarnieri", | ||
| 20 | "license": "ISC", | ||
| 21 | "peerDependencies": { | ||
| 22 | "angular": "^1.7.4", | ||
| 23 | "bootstrap": "^4.1.3", | ||
| 24 | "font-awesome": "^4.7.0", | ||
| 25 | "ui-bootstrap4": "^3.0.4", | ||
| 26 | "gulp": "^3.9.1", | ||
| 27 | "gulp-angular-templatecache": "^2.2.1", | ||
| 28 | "gulp-concat": "^2.6.1", | ||
| 29 | "gulp-connect": "^5.6.1", | ||
| 30 | "gulp-htmlmin": "^5.0.1", | ||
| 31 | "gulp-rename": "^1.4.0", | ||
| 32 | "gulp-replace": "^1.0.0", | ||
| 33 | "gulp-uglify": "^3.0.1", | ||
| 34 | "jquery": "^3.3.1", | ||
| 35 | "pump": "^3.0.0", | ||
| 36 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" | ||
| 37 | }, | ||
| 38 | "devDependencies": { | ||
| 39 | "angular": "^1.7.5", | ||
| 40 | "angular-ladda": "^0.4.3", | ||
| 41 | "bootstrap": "^4.1.3", | ||
| 42 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | ||
| 43 | "font-awesome": "^4.7.0", | ||
| 44 | "gulp": "^3.9.1", | ||
| 45 | "gulp-angular-templatecache": "^2.2.3", | ||
| 46 | "gulp-clean": "^0.4.0", | ||
| 47 | "gulp-concat": "^2.6.1", | ||
| 48 | "gulp-connect": "^5.6.1", | ||
| 49 | "gulp-htmlmin": "^5.0.1", | ||
| 50 | "gulp-jshint": "^2.1.0", | ||
| 51 | "gulp-rename": "^1.4.0", | ||
| 52 | "gulp-replace": "^1.0.0", | ||
| 53 | "gulp-uglify": "^3.0.1", | ||
| 54 | "jasmine-core": "^3.3.0", | ||
| 55 | "jquery": "^3.3.1", | ||
| 56 | "jshint": "^2.9.6", | ||
| 57 | "ladda": "1.0.6", | ||
| 58 | "pre-commit": "^1.2.2", | ||
| 59 | "pump": "^3.0.0", | ||
| 60 | "ui-bootstrap4": "^3.0.5" | ||
| 61 | } | ||
| 62 | } | ||
| 63 |
src/etc/develop.js.ejemplo
| File was created | 1 | angular.module('focaModalNotaPedido') | |
| 2 | .constant("API_ENDPOINT", { | ||
| 3 | 'URL': '//127.0.0.1:9000' | ||
| 4 | }); | ||
| 5 |
src/js/app.js
| File was created | 1 | angular.module('focaModalInformeHojaRuta', [ | |
| 2 | 'ui.bootstrap' | ||
| 3 | ]); | ||
| 4 |
src/js/controller.js
| File was created | 1 | angular.module('focaModalInformeHojaRuta') | |
| 2 | .controller('focaModalInformeHojaRutaController', | ||
| 3 | [ | ||
| 4 | '$filter', | ||
| 5 | '$scope', | ||
| 6 | '$uibModalInstance', | ||
| 7 | 'focaModalInformeHojaRutaService', | ||
| 8 | 'i18nService', | ||
| 9 | function($filter, $scope, $uibModalInstance, | ||
| 10 | focaModalInformeHojaRutaService, i18nService | ||
| 11 | ) { | ||
| 12 | var fecha = new Date(); | ||
| 13 | $scope.fechaHasta = new Date(); | ||
| 14 | $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); | ||
| 15 | $scope.buscar = true; | ||
| 16 | $scope.informe = {}; | ||
| 17 | i18nService.setCurrentLang('es'); | ||
| 18 | $scope.gridOptions = { | ||
| 19 | enableGridMenu: true, | ||
| 20 | exporterMenuCsv: false, | ||
| 21 | exporterPdfPageSize: 'A4', | ||
| 22 | exporterPdfFooter: function (currentPage, pageCount) { | ||
| 23 | return { | ||
| 24 | columns: [ | ||
| 25 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), | ||
| 26 | margin: [40, 0]}, | ||
| 27 | {text: currentPage + ' de ' + pageCount, | ||
| 28 | margin: [28, 0], alignment: 'right'} | ||
| 29 | ] | ||
| 30 | }; | ||
| 31 | }, | ||
| 32 | |||
| 33 | }; | ||
| 34 | $scope.generarInforme = function() { | ||
| 35 | focaModalInformeHojaRutaService | ||
| 36 | .getHojasRuta( | ||
| 37 | $scope.fechaDesde.toISOString().split('.')[0], | ||
| 38 | $scope.fechaHasta.toISOString().split('.')[0] | ||
| 39 | ) | ||
| 40 | .then(function(res) { | ||
| 41 | $scope.gridOptions.data = res.data.map(function(hojaRuta) { | ||
| 42 | return { | ||
| 43 | sucursal: hojaRuta.sucursal, | ||
| 44 | numero: hojaRuta.numeroHojaRuta, | ||
| 45 | transportista: hojaRuta.transportista.NOM, | ||
| 46 | unidad: hojaRuta.vehiculo.codigo, | ||
| 47 | chofer: hojaRuta.chofer.nombre, | ||
| 48 | fechaDeReparto: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') | ||
| 49 | }; | ||
| 50 | }); | ||
| 51 | |||
| 52 | //TODO: sacar id empresa hardcodeado | ||
| 53 | return focaModalInformeHojaRutaService.getEmpresa(1); | ||
| 54 | }) | ||
| 55 | .then(function(res) { | ||
| 56 | var filenameStamp = 'Informe de correlatividad de hojas de ruta - ' + | ||
| 57 | $filter('date')(new Date(), 'dd/MM/yyyy'); | ||
| 58 | $scope.informe.nombreEmpresa = res.data.NOM.trim(); | ||
| 59 | $scope.informe.direccionEmpresa = res.data.DIR.trim(); | ||
| 60 | $scope.gridOptions.exporterPdfFilename = filenameStamp + '.pdf'; | ||
| 61 | $scope.gridOptions.exporterExcelFilename = filenameStamp + '.xlsx'; | ||
| 62 | $scope.gridOptions.exporterPdfHeader = { | ||
| 63 | columns: [ | ||
| 64 | { | ||
| 65 | text: $scope.informe.nombreEmpresa, | ||
| 66 | margin: [40, 0], | ||
| 67 | fontSize: 9 | ||
| 68 | }, | ||
| 69 | { | ||
| 70 | text: '\nInforme de correlatividad de hojas de ruta', | ||
| 71 | margin: [-170, -4, 0, 0], | ||
| 72 | fontSize: 12 | ||
| 73 | }, | ||
| 74 | { | ||
| 75 | text: [ | ||
| 76 | '\n\nFiltros: ', | ||
| 77 | 'Fecha desde: ', | ||
| 78 | $filter('date')($scope.fechaDesde, 'dd/MM/yyyy'), | ||
| 79 | ' Fecha hasta: ', | ||
| 80 | $filter('date')($scope.fechaHasta, 'dd/MM/yyyy') | ||
| 81 | ], | ||
| 82 | margin: [-380, 2, 0, 0], | ||
| 83 | fontSize: 9 | ||
| 84 | }, | ||
| 85 | { | ||
| 86 | text: $scope.informe.direccionEmpresa, | ||
| 87 | margin: [28, 0], | ||
| 88 | alignment: 'right', | ||
| 89 | fontSize: 9 | ||
| 90 | } | ||
| 91 | ] | ||
| 92 | }; | ||
| 93 | $scope.buscar = false; | ||
| 94 | }); | ||
| 95 | }; | ||
| 96 | $scope.volver = function() { | ||
| 97 | $scope.buscar = true; | ||
| 98 | }; | ||
| 99 | $scope.cancel = function() { | ||
| 100 | $uibModalInstance.dismiss('Cancelar'); | ||
| 101 | }; | ||
| 102 | } | ||
| 103 | ] | ||
| 104 | ); | ||
| 105 |
src/js/service.js
| File was created | 1 | angular.module('focaModalInformeHojaRuta') | |
| 2 | .service('focaModalInformeHojaRutaService', [ | ||
| 3 | '$http', | ||
| 4 | 'API_ENDPOINT', | ||
| 5 | function($http, API_ENDPOINT) { | ||
| 6 | return { | ||
| 7 | getHojasRuta: function(fechaDesde, fechaHasta) { | ||
| 8 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/listar/' + | ||
| 9 | fechaDesde + '/' + fechaHasta); | ||
| 10 | }, | ||
| 11 | getEmpresa: function(id) { | ||
| 12 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); | ||
| 13 | } | ||
| 14 | }; | ||
| 15 | } | ||
| 16 | ]); | ||
| 17 |
src/views/modal-informe-hoja-ruta.html
| File was created | 1 | <div class="modal-header py-1"> | |
| 2 | <div class="row w-100"> | ||
| 3 | <div class="col-6" ng-bind="informe.nombreEmpresa" ng-hide="buscar"></div> | ||
| 4 | <div class="col-6 text-right" ng-bind="informe.direccionEmpresa" ng-hide="buscar"></div> | ||
| 5 | <div class="col-12"><h5 class="modal-title">Informe de correlatividad de hojas de ruta</h5></div> | ||
| 6 | <div class="col-12" ng-hide="buscar">Filtros: Fecha desde: {{fechaDesde | date: 'dd/MM/yyyy'}} Fecha hasta: {{fechaHasta | date: 'dd/MM/yyyy'}}</div> | ||
| 7 | </div> | ||
| 8 | </div> | ||
| 9 | <div class="modal-body" id="modal-body"> | ||
| 10 | |||
| 11 | <div class="input-group row" | ||
| 12 | ng-show="buscar"> | ||
| 13 | <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> | ||
| 14 | <div class="col-md-4 col-8 input-group mb-2"> | ||
| 15 | <div class="input-group-prepend"> | ||
| 16 | <div class="input-group-text form-control-sm"> | ||
| 17 | <i class="fa fa-calendar"></i> | ||
| 18 | </div> | ||
| 19 | </div> | ||
| 20 | <input | ||
| 21 | class="form-control form-control-sm" | ||
| 22 | id="inlineFormInputGroup" | ||
| 23 | ladda="searchLoading" | ||
| 24 | type="text" | ||
| 25 | ng-model="fechaDesde" | ||
| 26 | ng-required="true" | ||
| 27 | uib-datepicker-popup="dd/MM/yyyy" | ||
| 28 | show-button-bar="false" | ||
| 29 | is-open="datepickerOpen" | ||
| 30 | on-open-focus="false" | ||
| 31 | ng-focus="datepickerOpen = true" | ||
| 32 | datepicker-options="dateOptions" | ||
| 33 | /> | ||
| 34 | </div> | ||
| 35 | <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small> | ||
| 36 | <div class="col-md-4 col-8 input-group mb-2"> | ||
| 37 | <div class="input-group-prepend"> | ||
| 38 | <div class="input-group-text form-control-sm"> | ||
| 39 | <i class="fa fa-calendar"></i> | ||
| 40 | </div> | ||
| 41 | </div> | ||
| 42 | <input | ||
| 43 | class="form-control form-control-sm" | ||
| 44 | id="inlineFormInputGroup" | ||
| 45 | ladda="searchLoading" | ||
| 46 | type="text" | ||
| 47 | ng-model="fechaHasta" | ||
| 48 | ng-required="true" | ||
| 49 | uib-datepicker-popup="dd/MM/yyyy" | ||
| 50 | show-button-bar="false" | ||
| 51 | is-open="datepicker2Open" | ||
| 52 | on-open-focus="false" | ||
| 53 | ng-focus="datepicker2Open = true" | ||
| 54 | /> | ||
| 55 | </div> | ||
| 56 | </div> | ||
| 57 | <div | ||
| 58 | ng-if="!buscar" | ||
| 59 | class="row"> | ||
| 60 | <div class="col-12"> | ||
| 61 | <div | ||
| 62 | class="gridInforme" | ||
| 63 | ui-grid="gridOptions" | ||
| 64 | ui-grid-exporter | ||
| 65 | ui-grid-resize-columns | ||
| 66 | ></div> | ||
| 67 | </div> | ||
| 68 | </div> | ||
| 69 | </div> | ||
| 70 | <div class="modal-footer py-1"> | ||
| 71 | <button | ||
| 72 | class="btn btn-sm btn-secondary" | ||
| 73 | type="button" | ||
| 74 | ng-click="cancel()" | ||
| 75 | ng-show="buscar">Cancelar</button> | ||
| 76 | <button | ||
| 77 | class="btn btn-sm btn-secondary" | ||
| 78 | type="button" | ||
| 79 | ng-click="generarInforme()" | ||
| 80 | ng-show="buscar">Generar</button> | ||
| 81 | <button | ||
| 82 | class="btn btn-sm btn-secondary" | ||
| 83 | type="button" | ||
| 84 | ng-click="volver()" | ||
| 85 | ng-hide="buscar">Volver</button> | ||
| 86 | </div> | ||
| 87 |