diff --git a/www/js/travel.js b/www/js/travel.js index a1d8dc0..8006a24 100644 --- a/www/js/travel.js +++ b/www/js/travel.js @@ -3,6 +3,7 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet']) .controller('TravelCtrl', function($scope, $stateParams, $http, $ionicModal, $ionicLoading, $ionicPopup, $filter, leafletData, leafletBoundsHelpers) { + $scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata")); $scope.center= { /*lat: 0, @@ -124,6 +125,27 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet']) }); }; + $scope.acceptJoin = function(joinPetition){ + $http({ + url: urlapi + 'travels/acceptJoin/'+ $stateParams.travelid, + method: "POST", + data: {userid: joinPetition._id} + }) + .then(function(data) { + console.log("data: "); + console.log(data); + if(data.success==false){ + $ionicLoading.show({template: 'Error on unjoin', noBackdrop: true, duration: 2000}); + }else{ + $scope.travel=data.data; + console.log("success"); + } + }, + function(response) { // optional + // failed + }); + }; + /* adding comment */ $scope.doingNewComment=false; $scope.newComment={}; @@ -166,12 +188,12 @@ console.log($scope.newComment); $scope.userHasJoined = function(myArray, searchTerm) { - //console.log(myArray+", "+searchTerm+", "+property); + //console.log(myArray+", "+searchTerm); if(myArray) { for(var i = 0, len = myArray.length; i < len; i++) { //console.log(myArray[i] + " - " + searchTerm); - if (myArray[i] === searchTerm){ + if (myArray[i]._id === searchTerm){ //console.log("i: " + i); return i; } diff --git a/www/templates/travel.html b/www/templates/travel.html index 12908eb..773e7e7 100644 --- a/www/templates/travel.html +++ b/www/templates/travel.html @@ -26,16 +26,18 @@

- {{'Ask_to_join' | translate}} - {{'Offer_car' | translate}} - {{'Offer_car' | translate}} +
+ {{'Ask_to_join' | translate}} + {{'Offer_car' | translate}} + {{'Offer_car' | translate}} +
{{'Unjoin' | translate}} {{'Unoffer_car' | translate}} {{'Unoffer_car' | translate}} -
+

@@ -51,9 +53,10 @@
package
-
+ @{{travel.user.telegram}} -
+
{{travel.user.phone}}
@@ -71,12 +74,15 @@
-

0/{{travel.seats}} seats

- - - + +

{{travel.joins.length}}/{{travel.seats}} seats

+ + +
-
+

Pendent petitions

@@ -85,23 +91,23 @@

{{joinPetition.username}}

-
+

-
-
+
{{'Comments' | translate}}:
diff --git a/www/templates/user.html b/www/templates/user.html index 0e41f64..7af54f2 100644 --- a/www/templates/user.html +++ b/www/templates/user.html @@ -8,7 +8,8 @@