Commit 02169c94c81be47861e385508dde987174189ccd

Authored by Eric Fernandez
0 parents
Exists in master

first commit

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 Busqueda de Hojas de ruta
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');
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: 'focaModalHojaRuta',
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-hoja-ruta.js'),
47 replace('src/views/', ''),
48 uglify(),
49 replace('["ui.bootstrap","angular-ladda","focaDirectivas","focaFiltros"]', '[]'),
50 gulp.dest(paths.tmp),
51 rename('foca-modal-hoja-ruta.min.js'),
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-remito/dist'));
91 });
92
93 gulp.task('watchAndCopy', function() {
94 gulp.watch([paths.srcJS, paths.srcViews], ['copy'])
95 });
96
File was created 1 <html ng-app="focaModalHojaRuta">
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 <script src="node_modules/foca-filtros/dist/foca-filtros.min.js"></script>
21
22 <!-- BUILD -->
23 <script src="src/js/app.js"></script>
24 <script src="src/js/controller.js"></script>
25 <script src="src/js/service.js"></script>
26
27 <!-- /BUILD -->
28
29 <!-- CONFIG PARA DEVELOP -->
30 <script src="src/etc/develop.js"></script>
31 <script type="text/javascript">
32 angular.module('focaModalHojaRuta')
33 .controller('controller', [
34 '$scope',
35 '$uibModal',
36 '$timeout',
37 function($scope, $uibModal, $timeout) {
38 openModal();
39
40 function openModal() {
41 var modalInstance = $uibModal.open(
42 {
43 ariaLabelledBy: 'Busqueda de Remito',
44 templateUrl: 'src/views/foca-modal-hoja-ruta.html',
45 controller: 'focaModalHojaRutaController',
46 size: 'lg',
47 resolve: {
48 parametroRemito: {
49 idLista: -1,
50 cotizacion: 1,
51 simbolo:'$'
52 }
53 }
54 }
55 );
56
57 modalInstance.result.then(
58 function (selectedItem) {
59 console.info(selectedItem);
60 $timeout(openModal, 500);
61 }, function () {
62 console.info('modal-component dismissed at: ' + new Date());
63 $timeout(openModal, 500);
64 }
65 );
66 }
67 }
68 ]);
69 </script>
70 </head>
71 <body ng-controller="controller">
72 </body>
73 </html>
74
File was created 1 {
2 "name": "foca-modal-hoja-ruta",
3 "version": "0.0.1",
4 "description": "Modal para seleccion hoja de ruta",
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": "http://git.focasoftware.com/efernandez/foca-modal-hoja-ruta.git"
18 },
19 "author": "Foca Software",
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 "foca-filtros": "git+http://git.focasoftware.com/npm/foca-filtros.git",
44 "font-awesome": "^4.7.0",
45 "gulp": "^3.9.1",
46 "gulp-angular-templatecache": "^2.2.5",
47 "gulp-clean": "^0.4.0",
48 "gulp-concat": "^2.6.1",
49 "gulp-connect": "^5.7.0",
50 "gulp-htmlmin": "^5.0.1",
51 "gulp-jshint": "^2.1.0",
52 "gulp-rename": "^1.4.0",
53 "gulp-replace": "^1.0.0",
54 "gulp-uglify": "^3.0.1",
55 "jasmine-core": "^3.3.0",
56 "jquery": "^3.3.1",
57 "jshint": "^2.9.7",
58 "ladda": "1.0.6",
59 "pre-commit": "^1.2.2",
60 "pump": "^3.0.0",
61 "ui-bootstrap4": "^3.0.5"
62 }
63 }
64
src/etc/develop.js.ejemplo
File was created 1 angular.module('focaModalHojaRuta')
2 .constant("API_ENDPOINT", {
3 'URL': '//127.0.0.1:9000'
4 });
5
File was created 1 angular.module('focaModalHojaRuta',[
2 'ui.bootstrap',
3 'angular-ladda',
4 'focaDirectivas',
5 'focaFiltros'
6 ]);
7
src/js/controller.js
File was created 1 angular.module('focaModalHojaRuta')
2 .controller('focaModalHojaRutaController',
3 [
4 '$filter',
5 '$scope',
6 '$uibModalInstance',
7 'focaModalHojaRutaService',
8 function($filter, $scope, $uibModalInstance, focaModalHojaRutaService) {
9 var fecha = new Date();
10 $scope.fechaHasta = new Date();
11 $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1));
12 $scope.filters = '';
13 $scope.HojaRuta = [];
14 $scope.primerBusqueda = false;
15 $scope.searchLoading = false;
16 // pagination
17 $scope.numPerPage = 10;
18 $scope.currentPage = 1;
19 $scope.filteredHojaRuta = [];
20 $scope.currentPageHojaRuta = [];
21 $scope.selectedHojaRuta = -1;
22
23 //METODOS
24 $scope.busquedaPress = function(key) {
25 if (key === 13) {
26 //TODO Validaciones con alertas de foca
27 if(!$scope.fechaDesde) {
28 alert('INGRESE FECHA DESDE');
29 return;
30 }
31 if(!$scope.fechaHasta) {
32 alert('INGRESE FECHA HASTA');
33 return;
34 }
35 if($scope.fechaDesde > $scope.fechaHasta) {
36 alert('La fecha desde no puede ser mayor a la fecha hasta');
37 return;
38 }
39 $scope.searchLoading = true;
40 //TODO: usar filtros en vez de toISOString
41 focaModalHojaRutaService
42 .getHojasRuta($scope.fechaDesde.toISOString().split('.')[0],
43 $scope.fechaHasta.toISOString().split('.')[0])
44 .then(llenarDatos);
45 }
46 };
47 function llenarDatos(res) {
48 $scope.HojaRuta = [];
49 $scope.filteredHojaRuta = [];
50 $scope.currentPageHojaRuta = [];
51 $scope.selectedHojaRuta = -1;
52 $scope.searchLoading = false;
53 $scope.primerBusqueda = true;
54 $scope.HojaRuta = res.data;
55 $scope.search();
56 primera();
57 }
58 $scope.search = function() {
59 if($scope.HojaRuta.length > 0) {
60 $scope.filteredHojaRuta = $filter('filter')(
61 $scope.HojaRuta,
62 {$: $scope.filters}
63 );
64
65 $scope.lastPage = Math.ceil(
66 $scope.filteredHojaRuta.length / $scope.numPerPage
67 );
68
69 $scope.resetPage();
70 }
71 };
72
73 $scope.resetPage = function() {
74 $scope.currentPage = 1;
75 $scope.selectPage(1);
76 };
77
78 $scope.selectPage = function(page) {
79 var start = (page - 1) * $scope.numPerPage;
80 var end = start + $scope.numPerPage;
81 $scope.paginas = [];
82 $scope.paginas = calcularPages(page);
83 $scope.currentPageHojaRuta = $scope.filteredHojaRuta.slice(start, end);
84 $scope.currentPage = page;
85 };
86
87 $scope.select = function(remito) {
88 $uibModalInstance.close(remito);
89 };
90
91 $scope.cancel = function() {
92 $uibModalInstance.dismiss('cancel');
93 };
94
95 $scope.busquedaDown = function(key) {
96 if (key === 40) {
97 primera(key);
98 }
99 };
100
101 $scope.itemRemito = function(key) {
102 if (key === 38) {
103 anterior(key);
104 }
105
106 if (key === 40) {
107 siguiente(key);
108 }
109
110 if (key === 37) {
111 retrocederPagina();
112 }
113
114 if (key === 39) {
115 avanzarPagina();
116 }
117 };
118
119 function calcularPages(paginaActual) {
120 var paginas = [];
121 paginas.push(paginaActual);
122
123 if (paginaActual - 1 > 1) {
124
125 paginas.unshift(paginaActual - 1);
126 if (paginaActual - 2 > 1) {
127 paginas.unshift(paginaActual - 2);
128 }
129 }
130
131 if (paginaActual + 1 < $scope.lastPage) {
132 paginas.push(paginaActual + 1);
133 if (paginaActual + 2 < $scope.lastPage) {
134 paginas.push(paginaActual + 2);
135 }
136 }
137
138 if (paginaActual !== 1) {
139 paginas.unshift(1);
140 }
141
142 if (paginaActual !== $scope.lastPage) {
143 paginas.push($scope.lastPage);
144 }
145
146 return paginas;
147 }
148
149 function primera() {
150 $scope.selectedHojaRuta = 0;
151 }
152
153 function anterior() {
154 if ($scope.selectedHojaRuta === 0 && $scope.currentPage > 1) {
155 retrocederPagina();
156 } else {
157 $scope.selectedHojaRuta--;
158 }
159 }
160
161 function siguiente() {
162 if ($scope.selectedHojaRuta < $scope.currentPageHojaRuta.length - 1 ) {
163 $scope.selectedHojaRuta++;
164 } else {
165 avanzarPagina();
166 }
167 }
168
169 function retrocederPagina() {
170 if ($scope.currentPage > 1) {
171 $scope.selectPage($scope.currentPage - 1);
172 $scope.selectedHojaRuta = $scope.numPerPage - 1;
173 }
174 }
175
176 function avanzarPagina() {
177 if ($scope.currentPage < $scope.lastPage) {
178 $scope.selectPage($scope.currentPage + 1);
179 $scope.selectedHojaRuta = 0;
180 }
181 }
182 }
183 ]
184 );
185
File was created 1 angular.module('focaModalHojaRuta')
2 .service('focaModalHojaRutaService', [
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/' + fechaDesde + '/' +
9 fechaHasta);
10 }
11 };
12 }
13 ]);
14
src/views/foca-modal-hoja-ruta.html
File was created 1 <div class="modal-header py-1">
2 <h5 class="modal-title">Busqueda de Hoja ruta</h5>
3 </div>
4 <div class="modal-body" id="modal-body">
5 <div class="input-group row">
6 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small>
7 <div class="col-md-4 col-8 input-group mb-2">
8 <div class="input-group-prepend">
9 <div class="input-group-text form-control-sm">
10 <i class="fa fa-calendar"></i>
11 </div>
12 </div>
13 <input
14 class="form-control form-control-sm"
15 id="inlineFormInputGroup"
16 ladda="searchLoading"
17 type="date"
18 ng-model="fechaDesde"
19 hasta-hoy
20 ng-required="true"
21 />
22 </div>
23 <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small>
24 <div class="col-md-4 col-8 input-group mb-2">
25 <div class="input-group-prepend">
26 <div class="input-group-text form-control-sm">
27 <i class="fa fa-calendar"></i>
28 </div>
29 </div>
30 <input
31 class="form-control form-control-sm"
32 id="inlineFormInputGroup"
33 ladda="searchLoading"
34 type="date"
35 ng-model="fechaHasta"
36 ng-required="true"
37 hasta-hoy
38 />
39 </div>
40 </div>
41 <div class="input-group">
42 <input
43 ladda="searchLoading"
44 type="text"
45 class="form-control form-control-sm"
46 placeholder="Razón social"
47 ng-model="filters"
48 ng-change="search()"
49 ng-keydown="busquedaDown($event.keyCode)"
50 ng-keypress="busquedaPress($event.keyCode)"
51 foca-focus="selectedHojaRuta == -1"
52 ng-focus="selectedHojaRuta = -1"
53 teclado-virtual
54 >
55 <div class="input-group-append">
56 <button
57 ladda="searchLoading"
58 class="btn btn-outline-secondary"
59 type="button"
60 ng-click="busquedaPress(13)"
61 >
62 <i class="fa fa-search" aria-hidden="true"></i>
63 </button>
64 </div>
65 </div>
66 <table ng-show="primerBusqueda" class="table table-striped table-sm">
67 <thead>
68 <tr>
69 <th>#</th>
70 <th>Fecha</th>
71 <th>Transportista</th>
72 </tr>
73 </thead>
74 <tbody>
75 <tr ng-show="currentPageHojaRuta.length == 0 && primerBusqueda">
76 <td colspan="5">
77 No se encontraron resultados.
78 </td>
79 </tr>
80 <tr class="selectable"
81 ng-repeat="(key, hojaRuta) in currentPageHojaRuta"
82 ng-click="select(hojaRuta)">
83 <td ng-bind="[hojaRuta.sucursal, hojaRuta.numeroHojaRuta] | comprobante"></td>
84 <td ng-bind="hojaRuta.fechaCreacion | date : 'dd/MM/yyyy'"></td>
85 <td ng-bind="hojaRuta.transportista.NOM"></td>
86 <td>
87 <button
88 type="button"
89 class="btn btn-xs p-1 float-right"
90 ng-class="{
91 'btn-secondary': selectedHojaRuta != key,
92 'btn-primary': selectedHojaRuta == key
93 }"
94 foca-focus="selectedHojaRuta == {{key}}"
95 ng-keydown="itemRemito($event.keyCode)"
96 >
97 <i class="fa fa-arrow-right" aria-hidden="true"></i>
98 </button>
99 </td>
100 </tr>
101 </tbody>
102 </table>
103 <nav ng-show="currentPageHojaRuta.length > 0 && primerBusqueda">
104 <ul class="pagination pagination-sm justify-content mb-0">
105 <li class="page-item" ng-class="{'disabled': currentPage == 1}">
106 <a
107 class="page-link"
108 href="javascript:void();"
109 ng-click="selectPage(currentPage - 1)"
110 >
111 <span aria-hidden="true">&laquo;</span>
112 <span class="sr-only">Anterior</span>
113 </a>
114 </li>
115 <li
116 class="page-item"
117 ng-repeat="pagina in paginas"
118 ng-class="{'active': pagina == currentPage}"
119 >
120 <a
121 class="page-link"
122 href="javascript:void();"
123 ng-click="selectPage(pagina)"
124 ng-bind="pagina"
125 ></a>
126 </li>
127 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}">
128 <a
129 class="page-link"
130 href="javascript:void();"
131 ng-click="selectPage(currentPage + 1)"
132 >
133 <span aria-hidden="true">&raquo;</span>
134 <span class="sr-only">Siguiente</span>
135 </a>
136 </li>
137 </ul>
138 </nav>
139 </div>
140 <div class="modal-footer py-1">
141 <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
142 </div>
143