Commit 401c68dfde0af67f20824fbec8410ba236c3a681

Authored by Pablo Marco del Pont
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master

See merge request modulos-npm/foca-admin-seguimiento!5
src/js/controller.js
... ... @@ -13,26 +13,45 @@ angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoControll
13 13 $scope.actividad = 'Entrega de producto';
14 14 }
15 15  
16   - $scope.general = true;
17   -
18   - console.info($scope.actividad);
  16 + $scope.idUsuario = 0;
19 17 $scope.marcadores = [];
20   -
21   - focaAdminSeguimientoService.obtenerActividad().then(function(datos) {
22   - $scope.marcadores = datos.data;
23   - });
  18 + getSeguimiento();
24 19  
25 20 $scope.general = function() {
26   - $scope.general = true;
  21 + $scope.idUsuario = 0;
  22 + getSeguimiento();
27 23 };
28 24  
29 25 $scope.individual = function() {
30   - $scope.general = false;
31   -
  26 + $scope.idUsuario = -1;
32 27 };
33 28  
34 29 $scope.salir = function() {
35 30 $location.path('/');
36 31 };
  32 +
  33 + $scope.search = function(key) {
  34 + if (key === 13) {
  35 + $scope.idUsuario = $scope.idUsuarioInput;
  36 + getSeguimiento();
  37 + }
  38 + };
  39 +
  40 + $scope.fecha = function() {
  41 + getSeguimiento();
  42 + };
  43 +
  44 + function getSeguimiento () {
  45 + var datos = {
  46 + actividad: $scope.actividad,
  47 + idUsuario: $scope.idUsuario,
  48 + fechaDesde: $scope.now,
  49 + fechaHasta: $scope.now
  50 + };
  51 +
  52 + focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) {
  53 + $scope.marcadores = datos.data;
  54 + });
  55 + }
37 56 }
38 57 ]);
src/js/osm-directive.js
... ... @@ -8,15 +8,23 @@ angular.module('focaAdminSeguimiento').directive('osm', function() {
8 8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
9 9 },
10 10 controller: ['$scope', '$filter', function($scope, $filter) {
  11 + $scope.markers = [];
11 12 $scope.$watch('marcadores', function() {
  13 + for(var i in $scope.markers) {
  14 + $scope.map.removeLayer($scope.markers[i]);
  15 + }
  16 +
  17 + $scope.markers = [];
12 18 angular.forEach($scope.marcadores, function(marcador) {
13   - L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
  19 + $scope.markers.push(
  20 + L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
14 21 .bindPopup(
15 22 'Actividad: ' + marcador.actividad + '<br/>' +
16 23 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') +
17 24 ' ' + marcador.fecha.slice(11,19) + '<br/>' +
18 25 marcador.observaciones
19   - ).openPopup();
  26 + ).openPopup()
  27 + );
20 28 });
21 29 });
22 30 }],
... ... @@ -3,8 +3,8 @@ angular.module(&#39;focaAdminSeguimiento&#39;)
3 3 'focaAdminSeguimientoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT
4 4 ) {
5 5 return {
6   - obtenerActividad: function() {
7   - return $http.get(API_ENDPOINT.URL + '/seguimiento');
  6 + obtenerActividad: function(parametros) {
  7 + return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros);
8 8 }
9 9 };
10 10 }]);
src/views/foca-admin-seguimiento.html
... ... @@ -14,20 +14,32 @@
14 14 ng-model="now"
15 15 class="btn col-12 my-1"
16 16 foca-focus="true"
  17 + ng-blur="fecha()"
17 18 hasta-hoy
18 19 />
19 20 <button
20 21 type="button"
21   - ng-class="{'active': general}"
  22 + ng-class="{'active': idUsuario == 0}"
22 23 class="btn col-12 my-1"
23 24 ng-click="general()"
24 25 >General</button>
25 26 <button
26 27 type="button"
27   - ng-class="{'active': !general}"
  28 + ng-class="{'active': idUsuario != 0}"
28 29 class="btn col-12 my-1"
29 30 ng-click="individual()"
30 31 >Individual</button>
  32 + <div class="form-group">
  33 + <input
  34 + type="text"
  35 + placeholder="Vendedor"
  36 + class="form-control"
  37 + ng-model="idUsuarioInput"
  38 + ng-show="idUsuario == -1"
  39 + ng-keypress="search($event.keyCode)"
  40 + foca-focus="idUsuario == -1"
  41 + >
  42 + </div>
31 43 <button
32 44 type="button"
33 45 class="btn col-12 my-1 boton-salir"