Commit dc17cb33d1788da8d44b9bfc1355f2feab72c45a

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master

See merge request !4
... ... @@ -0,0 +1,38 @@
  1 +<html ng-app="focaModalPuntoDescarga">
  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/leaflet/dist/leaflet.css" rel="stylesheet"/>
  9 + <style>
  10 + osm>div {
  11 + width: 100%;
  12 + height: 576px;
  13 + }
  14 + </style>
  15 +
  16 + <!--VENDOR JS-->
  17 + <script src="node_modules/jquery/dist/jquery.min.js"></script>
  18 + <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
  19 + <script src="node_modules/angular/angular.min.js"></script>
  20 + <script src="node_modules/angular-route/angular-route.min.js"></script>
  21 + <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script>
  22 + <script src="node_modules/leaflet/dist/leaflet.js"></script>
  23 +
  24 + <!-- BUILD -->
  25 + <script src="src/js/app.js"></script>
  26 + <script src="src/js/controller.js"></script>
  27 + <script src="src/js/route.js"></script>
  28 + <script src="src/js/service.js"></script>
  29 + <script src="src/js/osm-directive.js"></script>
  30 + <!-- /BUILD -->
  31 +
  32 + <!-- CONFIG PARA DEVELOP -->
  33 + <script src="src/etc/develop.js"></script>
  34 + </head>
  35 + <body>
  36 + <div ng-view class="container-fluid"></div>
  37 + </body>
  38 +</html>
... ... @@ -56,6 +56,7 @@
56 56 "jquery": "^3.3.1",
57 57 "jshint": "^2.9.6",
58 58 "ladda": "^1.0.6",
  59 + "leaflet": "^1.3.4",
59 60 "pre-commit": "^1.2.2",
60 61 "pump": "^3.0.0",
61 62 "ui-bootstrap4": "^3.0.5"
src/js/controller.js
... ... @@ -17,7 +17,9 @@ angular.module(&#39;focaModalPuntoDescarga&#39;)
17 17 $scope.puntoDescarga = {
18 18 id: 0,
19 19 id_cliente: filters.idCliente,
20   - id_da_config_0: filters.idDomicilio
  20 + id_da_config_0: filters.idDomicilio,
  21 + latitud: -32.89214159952345,
  22 + longitud: -68.84572999101856
21 23 };
22 24 $scope.articulos = angular.copy(filters.articulos);
23 25 $scope.articulos.map(function(articulo) {
src/js/osm-directive.js
... ... @@ -0,0 +1,39 @@
  1 +angular.module('focaLogisticaPedidoRuta').directive('osmPuntoDescarga', function() {
  2 + return {
  3 + restrict: 'E',
  4 + link: function(scope, el, attrs) {
  5 + var contenedor = document.createElement('div');
  6 + contenedor.className = 'w-100 h-50 mt-3';
  7 + el.append(contenedor);
  8 + scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom);
  9 + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
  10 + },
  11 + controller: ['$scope', '$timeout', function($scope, $timeout) {
  12 + //resuelve bug mapa gris en modales
  13 + $timeout(function() {
  14 + $scope.map.invalidateSize();
  15 + }, 1000);
  16 +
  17 + $scope.markers = [];
  18 + $scope.$watchGroup(['latitud', 'longitud'], function() {
  19 + for(var i in $scope.markers) {
  20 + $scope.map.removeLayer($scope.markers[i]);
  21 + }
  22 + $scope.markers.push(
  23 + L.marker([$scope.latitud, $scope.longitud], {draggable:'true'})
  24 + .addTo($scope.map)
  25 + .on('dragend', function() {
  26 + $scope.latitud = this.getLatLng().lat;
  27 + $scope.longitud = this.getLatLng().lng;
  28 + $scope.$apply();
  29 + })
  30 + );
  31 + });
  32 + }],
  33 + scope: {
  34 + latitud: '=',
  35 + longitud: '=',
  36 + zoom: '='
  37 + }
  38 + };
  39 +});
src/views/modal-punto-descarga.html
1 1 <div class="modal-header d-flex">
2 2 <h5 class="modal-title my-1" ng-hide="ingreso || cargaArticulos">Búsqueda de puntos de descarga</h5>
3 3 <h5 class="modal-title my-1" ng-show="ingreso">Crear punto de descarga</h5>
4   - <h5 class="modal-title my-1" ng-show="cargaArticulos">Cargar articulos en puntos de descarga</h5>
  4 + <h5 class="modal-title my-1" ng-show="cargaArticulos">Cargar artículos en puntos de descarga</h5>
5 5 <button
6 6 class="btn btn-primary"
7 7 ng-click="ingreso = true"
... ... @@ -23,7 +23,7 @@
23 23 </tr>
24 24 </thead>
25 25 <tbody>
26   - <tr ng-show="puntosDescarga.length == 0">
  26 + <tr ng-show="!puntosDescarga.length">
27 27 <td colspan="3">
28 28 No se encontraron resultados.
29 29 </td>
... ... @@ -65,44 +65,11 @@
65 65 </tr>
66 66 </tbody>
67 67 </table>
68   - <form ng-show="ingreso">
69   - <div class="row">
70   - <div class="col-6">
71   - <label>Latitud</label>
72   - <input
73   - type="text"
74   - class="form-control form-control-sm"
75   - ng-model="puntoDescarga.latitud"
76   - ng-required="true"
77   - />
78   - </div>
79   - <div class="col-6">
80   - <label>Longitud</label>
81   - <input
82   - type="text"
83   - class="form-control form-control-sm"
84   - ng-model="puntoDescarga.longitud"
85   - ng-required="true"
86   - />
87   - </div>
88   - </div>
89   - <div class="row">
90   - <div class="col-12">
91   - <label>Descripción</label>
92   - <textarea
93   - class="form-control form-control-sm text-uppercase"
94   - cols="30"
95   - rows="5"
96   - ng-model="puntoDescarga.descripcion">
97   - </textarea>
98   - </div>
99   - </div>
100   - </form>
101 68 <div ng-show="cargaArticulos">
102   - <div ng-show="articulos.length === 0">
  69 + <div ng-show="!articulos.length">
103 70 <h6>No existen articulos para agregar</h6>
104 71 </div>
105   - <div ng-show="articulos.length > 0">
  72 + <div ng-show="articulos.length">
106 73 <div class="row">
107 74 <div class="col-12">
108 75 <table class="table table-sm">
... ... @@ -198,6 +165,43 @@
198 165 </div>
199 166 </div>
200 167 </div>
  168 + <form ng-show="ingreso">
  169 + <div class="row">
  170 + <div class="col-12">
  171 + <label>Descripción</label>
  172 + <input
  173 + type="text"
  174 + class="form-control form-control-sm"
  175 + ng-model="puntoDescarga.descripcion"
  176 + uppercase-only>
  177 + </div>
  178 + </div>
  179 + <div class="row">
  180 + <div class="col-6">
  181 + <label>Latitud</label>
  182 + <input
  183 + type="text"
  184 + class="form-control form-control-sm"
  185 + ng-model="puntoDescarga.latitud"
  186 + ng-required="true"
  187 + />
  188 + </div>
  189 + <div class="col-6">
  190 + <label>Longitud</label>
  191 + <input
  192 + type="text"
  193 + class="form-control form-control-sm"
  194 + ng-model="puntoDescarga.longitud"
  195 + ng-required="true"
  196 + />
  197 + </div>
  198 + </div>
  199 + <osm-punto-descarga
  200 + latitud="puntoDescarga.latitud"
  201 + longitud="puntoDescarga.longitud"
  202 + zoom="14"
  203 + />
  204 + </form>
201 205 </div>
202 206 <div class="modal-footer">
203 207 <button