From 70db3f88b9584e30cff231f09b3bf65c15f88332 Mon Sep 17 00:00:00 2001 From: arnaucode Date: Sun, 29 Jan 2017 18:19:41 +0100 Subject: [PATCH] travel accept join petition implemented --- www/js/travel.js | 26 ++++++++++++++++++++++++-- www/templates/travel.html | 36 +++++++++++++++++++++--------------- www/templates/user.html | 3 ++- 3 files changed, 47 insertions(+), 18 deletions(-) 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.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 @@