diff --git a/app/www/js/controllers.js b/app/www/js/controllers.js index 5b26447..c90aea1 100644 --- a/app/www/js/controllers.js +++ b/app/www/js/controllers.js @@ -44,20 +44,25 @@ angular.module('starter.controllers', []) .controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout) { $scope.travels=""; - $http.get('http://localhost:3000/api/travels') - .success(function(data, status, headers,config){ - console.log('data success'); - console.log(data); // for browser console - $scope.travels = data; // for UI - }) - .error(function(data, status, headers,config){ - console.log('data error'); - }) - .then(function(result){ - travels = result.data; - }); + $scope.doRefresh = function() { + $http.get('http://localhost:3000/api/travels') + .success(function(data, status, headers,config){ + console.log('data success'); + console.log(data); // for browser console + $scope.travels = data; // for UI + $scope.$broadcast('scroll.refreshComplete');//refresher stop + }) + .error(function(data, status, headers,config){ + console.log('data error'); + $scope.$broadcast('scroll.refreshComplete');//refresher stop + }) + .then(function(result){ + travels = result.data; + }); + }; + $scope.newtravel={}; // Create the login modal that we will use later @@ -123,6 +128,37 @@ angular.module('starter.controllers', []) $scope.closeNewOfferingTravel(); }, 1000); }; + + $scope.doNewAskingTravel = function() { + console.log('Doing new travel', $scope.newtravel); + $scope.newtravel.icon="lorry"; + $scope.newtravel.generateddate=$scope.newtravel.date; + $scope.newtravel.owner="user"; + + $scope.newtravel.modality="asking"; + console.log($scope.newtravel); + $http({ + url: 'http://localhost:3000/api/travels', + method: "POST", + data: $scope.newtravel + }) + .then(function(response) { + // success + console.log("response: "); + console.log(response); + $scope.newtravel._id=response.data._id; + $scope.travels.push($scope.newtravel); + }, + function(response) { // optional + // failed + }); + + // Simulate a login delay. Remove this and replace with your login + // code if using a login system + $timeout(function() { + $scope.closeNewAskingTravel(); + }, 1000); + }; }) .controller('TravelCtrl', function($scope, $stateParams, $http) { diff --git a/app/www/templates/newaskingtravel.html b/app/www/templates/newaskingtravel.html index f18f0dc..088e8b2 100644 --- a/app/www/templates/newaskingtravel.html +++ b/app/www/templates/newaskingtravel.html @@ -23,12 +23,12 @@ - Can carry package + Need to carry package - - Collectivized car - - - diff --git a/app/www/templates/travel.html b/app/www/templates/travel.html index 64c820e..6e6bcda 100644 --- a/app/www/templates/travel.html +++ b/app/www/templates/travel.html @@ -10,12 +10,16 @@
{{travel.date | date:"dd/MM HH:mm a"}}

-
[periodic travel]
-
-
can carry package
+
+
can carry package
+
need to carry package
+

{{travel.from}} - {{travel.to}}

-

nº car seats: {{trave.seats}}

+

+

nº car seats: {{travel.seats}}
+
nº people: {{travel.seats}}
+

{{travel.description}}


@@ -26,7 +30,8 @@

- Ask to join + Ask to join + Offer car

diff --git a/app/www/templates/travels.html b/app/www/templates/travels.html index edb1019..eb22e31 100644 --- a/app/www/templates/travels.html +++ b/app/www/templates/travels.html @@ -1,18 +1,24 @@ - + +