Commit 3ca56fdfad428e470ec02f102304acb9f44c219e
1 parent
f3b8d5407e
Exists in
master
parametro en ruta para identificar actividad
Showing
4 changed files
with
19 additions
and
8 deletions
Show diff stats
.jshintrc
| 1 | { | 1 | { |
| 2 | /* | 2 | /* |
| 3 | * ENVIRONMENTS | 3 | * ENVIRONMENTS |
| 4 | * ================= | 4 | * ================= |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | // Define globals exposed by modern browsers. | 7 | // Define globals exposed by modern browsers. |
| 8 | "browser": true, | 8 | "browser": true, |
| 9 | 9 | ||
| 10 | // Define globals exposed by jQuery. | 10 | // Define globals exposed by jQuery. |
| 11 | "jquery": true, | 11 | "jquery": true, |
| 12 | 12 | ||
| 13 | // Define globals exposed by Node.js. | 13 | // Define globals exposed by Node.js. |
| 14 | "node": true, | 14 | "node": true, |
| 15 | 15 | ||
| 16 | // Allow ES6. | 16 | // Allow ES6. |
| 17 | "esversion": 6, | 17 | "esversion": 6, |
| 18 | 18 | ||
| 19 | /* | 19 | /* |
| 20 | * ENFORCING OPTIONS | 20 | * ENFORCING OPTIONS |
| 21 | * ================= | 21 | * ================= |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | // Force all variable names to use either camelCase style or UPPER_CASE | 24 | // Force all variable names to use either camelCase style or UPPER_CASE |
| 25 | // with underscores. | 25 | // with underscores. |
| 26 | "camelcase": true, | 26 | "camelcase": true, |
| 27 | 27 | ||
| 28 | // Prohibit use of == and != in favor of === and !==. | 28 | // Prohibit use of == and != in favor of === and !==. |
| 29 | "eqeqeq": true, | 29 | "eqeqeq": true, |
| 30 | 30 | ||
| 31 | // Enforce tab width of 2 spaces. | 31 | // Enforce tab width of 2 spaces. |
| 32 | "indent": 4, | 32 | "indent": 4, |
| 33 | 33 | ||
| 34 | // Prohibit use of a variable before it is defined. | 34 | // Prohibit use of a variable before it is defined. |
| 35 | "latedef": false, | 35 | "latedef": false, |
| 36 | 36 | ||
| 37 | // Enforce line length to 100 characters | 37 | // Enforce line length to 100 characters |
| 38 | "maxlen": 100, | 38 | "maxlen": 100, |
| 39 | 39 | ||
| 40 | // Require capitalized names for constructor functions. | 40 | // Require capitalized names for constructor functions. |
| 41 | "newcap": true, | 41 | "newcap": true, |
| 42 | 42 | ||
| 43 | // Enforce use of single quotation marks for strings. | 43 | // Enforce use of single quotation marks for strings. |
| 44 | "quotmark": "single", | 44 | "quotmark": "single", |
| 45 | 45 | ||
| 46 | // Enforce placing 'use strict' at the top function scope | 46 | // Enforce placing 'use strict' at the top function scope |
| 47 | "strict": false, | 47 | "strict": false, |
| 48 | 48 | ||
| 49 | // Prohibit use of explicitly undeclared variables. | 49 | // Prohibit use of explicitly undeclared variables. |
| 50 | "undef": true, | 50 | "undef": true, |
| 51 | 51 | ||
| 52 | // Warn when variables are defined but never used. | 52 | // Warn when variables are defined but never used. |
| 53 | "unused": true, | 53 | "unused": true, |
| 54 | 54 | ||
| 55 | // Para que funcione en angular | 55 | // Para que funcione en angular |
| 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe", "L"], |
| 57 | /* | 57 | /* |
| 58 | * RELAXING OPTIONS | 58 | * RELAXING OPTIONS |
| 59 | * ================= | 59 | * ================= |
| 60 | */ | 60 | */ |
| 61 | 61 | ||
| 62 | // Suppress warnings about == null comparisons. | 62 | // Suppress warnings about == null comparisons. |
| 63 | "eqnull": true | 63 | "eqnull": true |
| 64 | } | 64 | } |
| 65 | 65 |
src/js/controller.js
| 1 | angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ | 1 | angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ |
| 2 | '$scope', 'focaAdminSeguimientoService', '$location', | 2 | '$scope', 'focaAdminSeguimientoService', '$location', '$routeParams', |
| 3 | function($scope, focaAdminSeguimientoService, $location) { | 3 | function($scope, focaAdminSeguimientoService, $location, $routeParams) { |
| 4 | $scope.actividad = ''; | ||
| 5 | |||
| 6 | if ($routeParams.parametro === 'nota-pedido') { | ||
| 7 | $scope.actividad = 'Nota de pedido'; | ||
| 8 | } | ||
| 9 | |||
| 10 | if ($routeParams.parametro === 'hoja-ruta') { | ||
| 11 | $scope.actividad = 'Entrega de producto'; | ||
| 12 | } | ||
| 13 | |||
| 14 | console.info($scope.actividad); | ||
| 4 | $scope.marcadores = []; | 15 | $scope.marcadores = []; |
| 16 | |||
| 5 | focaAdminSeguimientoService.obtenerActividad().then(function(datos) { | 17 | focaAdminSeguimientoService.obtenerActividad().then(function(datos) { |
| 6 | $scope.marcadores = datos.data; | 18 | $scope.marcadores = datos.data; |
| 7 | }); | 19 | }); |
| 20 | |||
| 8 | $scope.salir = function() { | 21 | $scope.salir = function() { |
| 9 | $location.path('/'); | 22 | $location.path('/'); |
| 10 | }; | 23 | }; |
| 11 | } | 24 | } |
| 12 | ]); | 25 | ]); |
| 13 | 26 |
src/js/osm-directive.js
| 1 | angular.module('focaAdminSeguimiento').directive('osm', function() { | 1 | angular.module('focaAdminSeguimiento').directive('osm', function() { |
| 2 | return { | 2 | return { |
| 3 | restrict: 'E', | 3 | restrict: 'E', |
| 4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
| 5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
| 6 | el.append(contenedor); | 6 | el.append(contenedor); |
| 7 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 7 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
| 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
| 9 | }, | 9 | }, |
| 10 | controller: ['$scope', '$filter', function($scope, $filter) { | 10 | controller: ['$scope', '$filter', function($scope, $filter) { |
| 11 | $scope.$watch('marcadores', function(valorNuevo) { | 11 | $scope.$watch('marcadores', function() { |
| 12 | marcadores = $scope.marcadores; | ||
| 13 | mapa = $scope.map; | ||
| 14 | angular.forEach($scope.marcadores, function(marcador) { | 12 | angular.forEach($scope.marcadores, function(marcador) { |
| 15 | L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) | 13 | L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) |
| 16 | .bindPopup( | 14 | .bindPopup( |
| 17 | "Actividad: " + marcador.actividad + '<br/>' + | 15 | 'Actividad: ' + marcador.actividad + '<br/>' + |
| 18 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + | 16 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + |
| 19 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + | 17 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + |
| 20 | marcador.observaciones | 18 | marcador.observaciones |
| 21 | ).openPopup(); | 19 | ).openPopup(); |
| 22 | }); | 20 | }); |
| 23 | }); | 21 | }); |
| 24 | }], | 22 | }], |
| 25 | scope: { | 23 | scope: { |
| 26 | latitud: '=', | 24 | latitud: '=', |
| 27 | longitud: '=', | 25 | longitud: '=', |
| 28 | zoom: '=', | 26 | zoom: '=', |
| 29 | marcadores: '=' | 27 | marcadores: '=' |
| 30 | } | 28 | } |
| 31 | }; | 29 | }; |
| 32 | }); | 30 | }); |
| 33 | 31 |
src/js/route.js
| 1 | angular.module('focaAdminSeguimiento') | 1 | angular.module('focaAdminSeguimiento') |
| 2 | .config(['$routeProvider', function($routeProvider) { | 2 | .config(['$routeProvider', function($routeProvider) { |
| 3 | $routeProvider.when('/admin-seguimiento', { | 3 | $routeProvider.when('/admin-seguimiento/:parametro', { |
| 4 | controller: 'focaAdminSeguimientoController', | 4 | controller: 'focaAdminSeguimientoController', |
| 5 | templateUrl: 'src/views/foca-admin-seguimiento.html' | 5 | templateUrl: 'src/views/foca-admin-seguimiento.html' |
| 6 | }); | 6 | }); |
| 7 | }]); | 7 | }]); |
| 8 | 8 |