diff --git a/resources/mappy_board/js/main.js b/resources/mappy_board/js/main.js index 90f074c..2bc8590 100644 --- a/resources/mappy_board/js/main.js +++ b/resources/mappy_board/js/main.js @@ -1,5 +1,7 @@ var emptyCollectionOrder; var aMark; +var viewsManager; + $(document).ready(function(){ $('.btn-sideBar-SubMenu').on('click', function(){ var SubMenu=$(this).next('ul'); @@ -58,11 +60,17 @@ $(document).ready(function(){ emptyCollectionOrder=new Dialog($('#Dialog-Help')); - $('.viewSideBar').on('click', changeToMap); + viewsManager=new ViewsManager($('.navbar-text'), $('#mapMain'),$('.makeACollectionOrder'),$('.historyOfCollectionOrders')); + + + $('.viewSideBar').on('click', function(){viewsManager.changeToMap()}); - $('.collectionOrderSideBar').on('click', changeToCollectionOrder); + $('.collectionOrderSideBar').on('click', function(){viewsManager.changeToCollectionOrder()}); + + $('.historySideBar').on('click', function(){viewsManager.changeToHistory()}); + + $('.doOne').on('click', function(){viewsManager.changeToCollectionOrder()}); - $('.historySideBar').on('click', changeToHistory); }); (function($){ $('.loading').show(); @@ -87,29 +95,43 @@ $(document).ready(function(){ }); })(jQuery); -function changeToMap() +class ViewsManager { - $('.navbar-text').text("ÓRDENES DE RECOLECCIÓN"); - $('.makeACollectionOrder').hide(300); - $('.historyOfCollectionOrders').hide(300); - $('#mapMain').show(300); -} + constructor(navbar, map, createOrderForm, history) + { + this.map=map; + this.createOrderForm=createOrderForm; + this.history=history; + this.navbar=navbar; + } + + changeToMap() + { + this.navbar.text("ÓRDENES DE RECOLECCIÓN"); + this.createOrderForm.hide(300); + this.history.hide(300); + this.map.show(300); + } + + changeToCollectionOrder() + { + this.navbar.text("CREAR ORDEN DE RECOLECCIÓN"); + this.map.hide(300); + this.history.hide(300); + this.createOrderForm.show(300); + } + + changeToHistory() + { + this.navbar.text("ÓRDENES EN CURSO"); + this.map.hide(300); + this.createOrderForm.hide(300); + this.history.show(300); + } -function changeToCollectionOrder() -{ - $('.navbar-text').text("CREAR ORDEN DE RECOLECCIÓN"); - $('#mapMain').hide(300); - $('.historyOfCollectionOrders').hide(300); - $('.makeACollectionOrder').show(300); -} -function changeToHistory() -{ - $('.navbar-text').text("ÓRDENES EN CURSO"); - $('#mapMain').hide(300); - $('.makeACollectionOrder').hide(300); - $('.historyOfCollectionOrders').show(300); } + $(".formCollection").submit(async function() { var form = $(this); diff --git a/resources/mappy_board/js/map.js b/resources/mappy_board/js/map.js index 6036b9a..48b83ef 100644 --- a/resources/mappy_board/js/map.js +++ b/resources/mappy_board/js/map.js @@ -66,12 +66,3 @@ function onMapClick(e) { $('#latitude').val(latitude); $('#longitude').val(longitude); } - -async function prueba() -{ - $.get(location.protocol + '//nominatim.openstreetmap.org/search?format=json&q='+"Universidad Católica Andrés Bello", function(data){ - console.log(data); - }); -} - -prueba(); \ No newline at end of file