Commit 6671d94ee741b7ffd06ee7052149051fb1c93ec0
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
filtro de fecha para modal See merge request modulos-npm/foca-modal-nota-pedido!8
Showing
3 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -9,7 +9,9 @@ angular.module('focaModalNotaPedido') |
9 | 9 | function($filter, $scope, $uibModalInstance, |
10 | 10 | focaModalNotaPedidoService, usadoPor |
11 | 11 | ) { |
12 | - | |
12 | + var fecha = new Date(); | |
13 | + $scope.fechaHasta = new Date(); | |
14 | + $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); | |
13 | 15 | $scope.filters = ''; |
14 | 16 | $scope.notasPedido = []; |
15 | 17 | $scope.primerBusqueda = false; |
... | ... | @@ -24,11 +26,32 @@ angular.module('focaModalNotaPedido') |
24 | 26 | //METODOS |
25 | 27 | $scope.busquedaPress = function(key) { |
26 | 28 | if (key === 13) { |
29 | + //TODO Validaciones con alertas | |
30 | + if(!$scope.fechaDesde) { | |
31 | + alert('INGRESE FECHA DESDE'); | |
32 | + return; | |
33 | + } | |
34 | + if(!$scope.fechaHasta) { | |
35 | + alert('INGRESE FECHA HASTA'); | |
36 | + return; | |
37 | + } | |
38 | + if($scope.fechaDesde > $scope.fechaHasta) { | |
39 | + alert('La fecha desde no puede ser mayor a la fecha hasta'); | |
40 | + return; | |
41 | + } | |
27 | 42 | $scope.searchLoading = true; |
28 | - focaModalNotaPedidoService.getNotasPedido(usadoPor).then(llenarDatos); | |
43 | + //TODO hacer filtro de fecha | |
44 | + focaModalNotaPedidoService | |
45 | + .getNotasPedido(usadoPor, $scope.fechaDesde.toISOString().split('.')[0], | |
46 | + $scope.fechaHasta.toISOString().split('.')[0]) | |
47 | + .then(llenarDatos); | |
29 | 48 | } |
30 | 49 | }; |
31 | 50 | function llenarDatos(res) { |
51 | + $scope.notasPedido = []; | |
52 | + $scope.filteredNotasPedido = []; | |
53 | + $scope.currentPageNotasPedido = []; | |
54 | + $scope.selectedNotaPedido = -1; | |
32 | 55 | $scope.searchLoading = false; |
33 | 56 | $scope.primerBusqueda = true; |
34 | 57 | $scope.notasPedido = res.data; |
src/js/service.js
... | ... | @@ -4,9 +4,10 @@ angular.module('focaModalNotaPedido') |
4 | 4 | 'API_ENDPOINT', |
5 | 5 | function($http, API_ENDPOINT) { |
6 | 6 | return { |
7 | - getNotasPedido: function(usadoPor) { | |
7 | + getNotasPedido: function(usadoPor, fechaDesde, fechaHasta) { | |
8 | 8 | var sinRemito = (usadoPor === 'remito' ? '/sin-remito' : ''); |
9 | - return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar' + sinRemito); | |
9 | + return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + | |
10 | + fechaHasta + sinRemito); | |
10 | 11 | } |
11 | 12 | }; |
12 | 13 | } |
src/views/foca-modal-nota-pedido.html
... | ... | @@ -3,10 +3,46 @@ |
3 | 3 | </div> |
4 | 4 | <div class="modal-body" id="modal-body"> |
5 | 5 | <div class="input-group"> |
6 | + <small class="col-2 text-left my-1">Fecha Desde</small> | |
7 | + <div class="input-group mb-2 col-4"> | |
8 | + <div class="input-group-prepend"> | |
9 | + <div class="input-group-text"> | |
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-2 text-left my-1">Fecha Hasta</small> | |
24 | + <div class="input-group mb-2 col-4"> | |
25 | + <div class="input-group-prepend"> | |
26 | + <div class="input-group-text"> | |
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"> | |
6 | 42 | <input |
7 | 43 | ladda="searchLoading" |
8 | 44 | type="text" |
9 | - class="form-control" | |
45 | + class="form-control form-control-sm" | |
10 | 46 | placeholder="Busqueda" |
11 | 47 | ng-model="filters" |
12 | 48 | ng-change="search()" |
... | ... | @@ -14,7 +50,7 @@ |
14 | 50 | ng-keypress="busquedaPress($event.keyCode)" |
15 | 51 | foca-focus="selectedNotaPedido == -1" |
16 | 52 | ng-focus="selectedNotaPedido = -1" |
17 | - > | |
53 | + /> | |
18 | 54 | <div class="input-group-append"> |
19 | 55 | <button |
20 | 56 | ladda="searchLoading" |