Commit 12e8d01218ffad2cbc745b0bc4aa311d71527b23
Exists in
master
Merge branch 'master' into 'master'
Master (pmarco) See merge request modulos-npm/foca-modal-proveedor!5
Showing
10 changed files
Show diff stats
README.md
gulpfile.js
... | ... | @@ -17,14 +17,19 @@ var paths = { |
17 | 17 | dist: 'dist/' |
18 | 18 | }; |
19 | 19 | |
20 | -gulp.task('templates', function() { | |
20 | +gulp.task('clean', function() { | |
21 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
22 | + .pipe(clean()); | |
23 | +}); | |
24 | + | |
25 | +gulp.task('templates', ['clean'], function() { | |
21 | 26 | return pump( |
22 | 27 | [ |
23 | 28 | gulp.src(paths.srcViews), |
24 | 29 | replace('views/', ''), |
25 | 30 | htmlmin(), |
26 | 31 | templateCache('views.js', { |
27 | - module: 'focaModalPetroleras', | |
32 | + module: 'focaModalProveedor', | |
28 | 33 | root: '' |
29 | 34 | }), |
30 | 35 | gulp.dest(paths.tmp) |
... | ... | @@ -39,11 +44,11 @@ gulp.task('uglify', ['templates'], function() { |
39 | 44 | paths.srcJS, |
40 | 45 | 'tmp/views.js' |
41 | 46 | ]), |
42 | - concat('foca-modal-petroleras.js'), | |
47 | + concat('foca-modal-proveedor.js'), | |
43 | 48 | replace('src/views/', ''), |
44 | 49 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), |
45 | 50 | gulp.dest(paths.tmp), |
46 | - rename('foca-modal-petroleras.min.js'), | |
51 | + rename('foca-modal-proveedor.min.js'), | |
47 | 52 | uglify(), |
48 | 53 | gulp.dest(paths.dist) |
49 | 54 | ] |
... | ... | @@ -75,4 +80,8 @@ gulp.task('clean-post-install', function() { |
75 | 80 | .pipe(clean()); |
76 | 81 | }); |
77 | 82 | |
78 | -gulp.task('default', ['webserver']); | |
79 | 83 | \ No newline at end of file |
84 | +gulp.task('default', ['webserver']); | |
85 | + | |
86 | +gulp.task('watch', function() { | |
87 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | |
88 | +}); |
index.html
1 | -<html ng-app="focaModalPetroleras"> | |
1 | +<html ng-app="focaModalProveedores"> | |
2 | 2 | |
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8" /> |
... | ... | @@ -26,16 +26,16 @@ |
26 | 26 | <script src="src/etc/develop.js"></script> |
27 | 27 | |
28 | 28 | <script type="text/javascript"> |
29 | - angular.module('focaModalPetroleras') | |
29 | + angular.module('focaModalProveedor') | |
30 | 30 | .controller('controller', ['$uibModal', '$timeout', function ($uibModal, $timeout) { |
31 | 31 | openModal(); |
32 | 32 | |
33 | 33 | function openModal() { |
34 | 34 | var modalInstance = $uibModal.open( |
35 | 35 | { |
36 | - ariaLabelledBy: 'Busqueda de Petroleras', | |
37 | - templateUrl: 'src/views/modal-petroleras.html', | |
38 | - controller: 'modalPetrolerasCtrl', | |
36 | + ariaLabelledBy: 'Busqueda de Proveedores', | |
37 | + templateUrl: 'src/views/modal-proveedor.html', | |
38 | + controller: 'focaModalProveedorCtrl', | |
39 | 39 | size: 'lg' |
40 | 40 | } |
41 | 41 | ); |
package.json
1 | 1 | { |
2 | - "name": "foca-modal-petroleras", | |
2 | + "name": "foca-modal-proveedor", | |
3 | 3 | "version": "0.0.2", |
4 | - "description": "Modal para seleccionar petroleras", | |
4 | + "description": "Modal para seleccionar proveedores", | |
5 | 5 | "scripts": { |
6 | 6 | "test": "echo \"Error: no test specified\" && exit 1", |
7 | 7 | "gulp-pre-commit": "gulp pre-commit", |
8 | 8 | "compile": "gulp uglify", |
9 | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | - "install-dev": "npm install angular bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean jshint pump gulp-connect gulp-uglify jasmine-core pre-commit gulp-angular-templatecache ui-bootstrap4 git+https://192.168.0.11/modulos-npm/foca-directivas" | |
10 | + "install-dev": "npm install angular bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean jshint pump gulp-connect gulp-uglify jasmine-core pre-commit gulp-angular-templatecache ui-bootstrap4 git+https://debo.suite.repo/modulos-npm/foca-directivas" | |
11 | 11 | }, |
12 | 12 | "pre-commit": [ |
13 | 13 | "gulp-pre-commit" |
14 | 14 | ], |
15 | 15 | "repository": { |
16 | 16 | "type": "git", |
17 | - "url": "https://192.168.0.11/modulos-npm/foca-modal-petroleras" | |
17 | + "url": "https://debo.suite.repo/modulos-npm/foca-modal-proveedor" | |
18 | 18 | }, |
19 | 19 | "author": "Nicolás Guarnieri", |
20 | 20 | "license": "ISC", |
... | ... | @@ -34,12 +34,12 @@ |
34 | 34 | "gulp-uglify": "^3.0.1", |
35 | 35 | "jquery": "^3.3.1", |
36 | 36 | "pump": "^3.0.0", |
37 | - "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas" | |
37 | + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas" | |
38 | 38 | }, |
39 | 39 | "devDependencies": { |
40 | 40 | "angular": "^1.7.5", |
41 | 41 | "bootstrap": "^4.1.3", |
42 | - "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas", | |
42 | + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", | |
43 | 43 | "font-awesome": "^4.7.0", |
44 | 44 | "gulp": "^3.9.1", |
45 | 45 | "gulp-angular-templatecache": "^2.2.1", |
src/etc/develop.js.ejemplo
src/js/app.js
src/js/controller.js
1 | -angular.module('focaModalPetroleras') | |
2 | - .controller('modalPetrolerasCtrl', [ | |
1 | +angular.module('focaModalProveedor') | |
2 | + .controller('focaModalProveedorCtrl', [ | |
3 | 3 | '$filter', |
4 | 4 | '$scope', |
5 | 5 | '$uibModalInstance', |
6 | - 'focaPetrolerasService', | |
7 | - function ($filter, $scope, $uibModalInstance, focaPetrolerasService) { | |
6 | + 'focaModalProveedorService', | |
7 | + function ($filter, $scope, $uibModalInstance, focaModalProveedorService) { | |
8 | 8 | var json = {razonCuitCod: ''}; |
9 | 9 | |
10 | - focaPetrolerasService.getPetroleras(json).then( | |
10 | + focaModalProveedorService.getProveedores(json).then( | |
11 | 11 | function (res) { |
12 | 12 | for (var i = res.data.length - 1; i >= 0; i--) { |
13 | 13 | if (res.data[i].COD === 0) { |
... | ... | @@ -15,24 +15,24 @@ angular.module('focaModalPetroleras') |
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
18 | - $scope.petroleras = res.data; | |
18 | + $scope.proveedores = res.data; | |
19 | 19 | $scope.search(); |
20 | 20 | }); |
21 | 21 | |
22 | 22 | // pagination |
23 | 23 | $scope.numPerPage = 10; |
24 | 24 | $scope.currentPage = 1; |
25 | - $scope.filteredPetroleras = []; | |
26 | - $scope.currentPagePetroleras = []; | |
27 | - $scope.selectedPetroleras = -1; | |
25 | + $scope.filteredProveedores = []; | |
26 | + $scope.currentPageProveedores = []; | |
27 | + $scope.selectedProveedores = -1; | |
28 | 28 | |
29 | 29 | $scope.search = function () { |
30 | - $scope.filteredPetroleras = $filter('filter')( | |
31 | - $scope.petroleras, {$: $scope.filters} | |
30 | + $scope.filteredProveedores = $filter('filter')( | |
31 | + $scope.proveedores, {$: $scope.filters} | |
32 | 32 | ); |
33 | 33 | |
34 | 34 | $scope.lastPage = Math.ceil( |
35 | - $scope.filteredPetroleras.length / $scope.numPerPage | |
35 | + $scope.filteredProveedores.length / $scope.numPerPage | |
36 | 36 | ); |
37 | 37 | |
38 | 38 | $scope.resetPage(); |
... | ... | @@ -49,12 +49,12 @@ angular.module('focaModalPetroleras') |
49 | 49 | var end = start + $scope.numPerPage; |
50 | 50 | $scope.paginas = []; |
51 | 51 | $scope.paginas = calcularPages(page); |
52 | - $scope.currentPagePetroleras = $scope.filteredPetroleras.slice(start, end); | |
52 | + $scope.currentPageProveedores = $scope.filteredProveedores.slice(start, end); | |
53 | 53 | $scope.currentPage = page; |
54 | 54 | }; |
55 | 55 | |
56 | - $scope.select = function(petrolera) { | |
57 | - $uibModalInstance.close(petrolera); | |
56 | + $scope.select = function(proveedor) { | |
57 | + $uibModalInstance.close(proveedor); | |
58 | 58 | }; |
59 | 59 | |
60 | 60 | $scope.cancel = function() { |
... | ... | @@ -73,7 +73,7 @@ angular.module('focaModalPetroleras') |
73 | 73 | } |
74 | 74 | }; |
75 | 75 | |
76 | - $scope.itemPetrolera = function(key) { | |
76 | + $scope.itemProveedor = function(key) { | |
77 | 77 | if (key === 38) { |
78 | 78 | anterior(key); |
79 | 79 | } |
... | ... | @@ -122,20 +122,20 @@ angular.module('focaModalPetroleras') |
122 | 122 | } |
123 | 123 | |
124 | 124 | function primera() { |
125 | - $scope.selectedPetroleras = 0; | |
125 | + $scope.selectedProveedores = 0; | |
126 | 126 | } |
127 | 127 | |
128 | 128 | function anterior() { |
129 | - if ($scope.selectedPetroleras === 0 && $scope.currentPage > 1) { | |
129 | + if ($scope.selectedProveedores === 0 && $scope.currentPage > 1) { | |
130 | 130 | retrocederPagina(); |
131 | 131 | } else { |
132 | - $scope.selectedPetroleras--; | |
132 | + $scope.selectedProveedores--; | |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | function siguiente() { |
137 | - if ($scope.selectedPetroleras < $scope.currentPagePetroleras.length - 1 ) { | |
138 | - $scope.selectedPetroleras++; | |
137 | + if ($scope.selectedProveedores < $scope.currentPageProveedores.length - 1 ) { | |
138 | + $scope.selectedProveedores++; | |
139 | 139 | } else { |
140 | 140 | avanzarPagina(); |
141 | 141 | } |
... | ... | @@ -144,14 +144,14 @@ angular.module('focaModalPetroleras') |
144 | 144 | function retrocederPagina() { |
145 | 145 | if ($scope.currentPage > 1) { |
146 | 146 | $scope.selectPage($scope.currentPage - 1); |
147 | - $scope.selectedPetroleras = $scope.numPerPage - 1; | |
147 | + $scope.selectedProveedores = $scope.numPerPage - 1; | |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | function avanzarPagina() { |
152 | 152 | if ($scope.currentPage < $scope.lastPage) { |
153 | 153 | $scope.selectPage($scope.currentPage + 1); |
154 | - $scope.selectedPetroleras = 0; | |
154 | + $scope.selectedProveedores = 0; | |
155 | 155 | } |
156 | 156 | } |
157 | 157 | }] |
src/js/service.js
1 | -angular.module('focaModalPetroleras') | |
2 | - .service('focaPetrolerasService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | |
1 | +angular.module('focaModalProveedor') | |
2 | + .service('focaModalProveedorService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | |
3 | 3 | return { |
4 | - getPetroleras: function(json) { | |
5 | - return $http.post(API_ENDPOINT.URL + '/petroleras', json); | |
4 | + getProveedores: function(json) { | |
5 | + return $http.post(API_ENDPOINT.URL + '/proveedor', json); | |
6 | 6 | } |
7 | 7 | }; |
8 | 8 | }]); |
src/views/modal-petroleras.html
... | ... | @@ -1,81 +0,0 @@ |
1 | -<div class="modal-header"> | |
2 | - <h3 class="modal-title">Búsqueda de Petrolera</h3> | |
3 | -</div> | |
4 | -<div class="modal-body" id="modal-body"> | |
5 | - <div class="input-group mb-3"> | |
6 | - <input | |
7 | - type="text" | |
8 | - class="form-control" | |
9 | - placeholder="Busqueda" | |
10 | - ng-model="filters" | |
11 | - ng-change="search()" | |
12 | - ng-keydown="busquedaDown($event.keyCode)" | |
13 | - ng-keypress="busquedaPress($event.keyCode)" | |
14 | - foca-focus="selectedPetroleras == -1" | |
15 | - ng-focus="selectedPetroleras = -1" | |
16 | - > | |
17 | - <table class="table table-striped table-sm"> | |
18 | - <thead> | |
19 | - <tr> | |
20 | - <th>Código</th> | |
21 | - <th>Nombre</th> | |
22 | - <th>CUIT</th> | |
23 | - <th></th> | |
24 | - </tr> | |
25 | - </thead> | |
26 | - <tbody> | |
27 | - <tr ng-repeat="(key, petrolera) in currentPagePetroleras"> | |
28 | - <td ng-bind="petrolera.COD"></td> | |
29 | - <td ng-bind="petrolera.NOM"></td> | |
30 | - <td ng-bind="petrolera.CUIT"></td> | |
31 | - <td> | |
32 | - <button | |
33 | - type="button" | |
34 | - class="btn p-2 float-right" | |
35 | - ng-class="{ | |
36 | - 'btn-secondary': selectedPetroleras != key, | |
37 | - 'btn-primary': selectedPetroleras == key | |
38 | - }" | |
39 | - ng-click="select(petrolera)" | |
40 | - foca-focus="selectedPetroleras == {{key}}" | |
41 | - ng-keydown="itemPetrolera($event.keyCode)" | |
42 | - > | |
43 | - <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
44 | - </button> | |
45 | - </td> | |
46 | - </tr> | |
47 | - </tbody> | |
48 | - </table> | |
49 | - <nav> | |
50 | - <ul class="pagination justify-content-end"> | |
51 | - <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
52 | - <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
53 | - <span aria-hidden="true">«</span> | |
54 | - <span class="sr-only">Anterior</span> | |
55 | - </a> | |
56 | - </li> | |
57 | - <li | |
58 | - class="page-item" | |
59 | - ng-repeat="pagina in paginas" | |
60 | - ng-class="{'active': pagina == currentPage}" | |
61 | - > | |
62 | - <a | |
63 | - class="page-link" | |
64 | - href="#" | |
65 | - ng-click="selectPage(pagina)" | |
66 | - ng-bind="pagina" | |
67 | - ></a> | |
68 | - </li> | |
69 | - <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
70 | - <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
71 | - <span aria-hidden="true">»</span> | |
72 | - <span class="sr-only">Siguiente</span> | |
73 | - </a> | |
74 | - </li> | |
75 | - </ul> | |
76 | - </nav> | |
77 | - </div> | |
78 | -</div> | |
79 | -<div class="modal-footer"> | |
80 | - <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
81 | -</div> |
src/views/modal-proveedor.html
... | ... | @@ -0,0 +1,81 @@ |
1 | +<div class="modal-header py-1"> | |
2 | + <h5 class="modal-title">Búsqueda de Proveedor</h5> | |
3 | +</div> | |
4 | +<div class="modal-body" id="modal-body"> | |
5 | + <div class="input-group"> | |
6 | + <input | |
7 | + type="text" | |
8 | + class="form-control" | |
9 | + placeholder="Busqueda" | |
10 | + ng-model="filters" | |
11 | + ng-change="search()" | |
12 | + ng-keydown="busquedaDown($event.keyCode)" | |
13 | + ng-keypress="busquedaPress($event.keyCode)" | |
14 | + foca-focus="selectedProveedores == -1" | |
15 | + ng-focus="selectedProveedores = -1" | |
16 | + > | |
17 | + <table class="table table-striped table-sm"> | |
18 | + <thead> | |
19 | + <tr> | |
20 | + <th>Código</th> | |
21 | + <th>Nombre</th> | |
22 | + <th>CUIT</th> | |
23 | + <th></th> | |
24 | + </tr> | |
25 | + </thead> | |
26 | + <tbody> | |
27 | + <tr ng-repeat="(key, proveedor) in currentPageProveedores"> | |
28 | + <td ng-bind="proveedor.COD"></td> | |
29 | + <td ng-bind="proveedor.NOM"></td> | |
30 | + <td ng-bind="proveedor.CUIT"></td> | |
31 | + <td> | |
32 | + <button | |
33 | + type="button" | |
34 | + class="btn btn-xs p-1 float-right" | |
35 | + ng-class="{ | |
36 | + 'btn-secondary': selectedProveedores != key, | |
37 | + 'btn-primary': selectedProveedores == key | |
38 | + }" | |
39 | + ng-click="select(proveedor)" | |
40 | + foca-focus="selectedProveedores == {{key}}" | |
41 | + ng-keydown="itemProveedor($event.keyCode)" | |
42 | + > | |
43 | + <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
44 | + </button> | |
45 | + </td> | |
46 | + </tr> | |
47 | + </tbody> | |
48 | + </table> | |
49 | + <nav> | |
50 | + <ul class="pagination pagination-sm justify-content-end mb-0"> | |
51 | + <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
52 | + <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
53 | + <span aria-hidden="true">«</span> | |
54 | + <span class="sr-only">Anterior</span> | |
55 | + </a> | |
56 | + </li> | |
57 | + <li | |
58 | + class="page-item" | |
59 | + ng-repeat="pagina in paginas" | |
60 | + ng-class="{'active': pagina == currentPage}" | |
61 | + > | |
62 | + <a | |
63 | + class="page-link" | |
64 | + href="#" | |
65 | + ng-click="selectPage(pagina)" | |
66 | + ng-bind="pagina" | |
67 | + ></a> | |
68 | + </li> | |
69 | + <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
70 | + <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
71 | + <span aria-hidden="true">»</span> | |
72 | + <span class="sr-only">Siguiente</span> | |
73 | + </a> | |
74 | + </li> | |
75 | + </ul> | |
76 | + </nav> | |
77 | + </div> | |
78 | +</div> | |
79 | +<div class="modal-footer py-1"> | |
80 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
81 | +</div> |