From 46d3a3b674531a541ed6eac6ddcdc810c147988c Mon Sep 17 00:00:00 2001 From: arnaucode Date: Mon, 30 Jan 2017 12:42:24 +0100 Subject: [PATCH] decline join travel and leave travel implemented --- www/js/travel.js | 41 +++++++++++++++++++++++++++++++++++++++ www/templates/travel.html | 8 ++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/www/js/travel.js b/www/js/travel.js index 8006a24..fb7c4f3 100644 --- a/www/js/travel.js +++ b/www/js/travel.js @@ -125,6 +125,27 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet']) }); }; + $scope.declineJoin = function(joinPetition){ + $http({ + url: urlapi + 'travels/declineJoin/'+ $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 + }); + }; + $scope.acceptJoin = function(joinPetition){ $http({ url: urlapi + 'travels/acceptJoin/'+ $stateParams.travelid, @@ -146,6 +167,26 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet']) }); }; + $scope.leaveTravel = function(){ + $http({ + url: urlapi + 'travels/leave/'+ $stateParams.travelid, + method: "POST", + data: {} + }) + .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; + } + }, + function(response) { // optional + // failed + }); + }; + /* adding comment */ $scope.doingNewComment=false; $scope.newComment={}; diff --git a/www/templates/travel.html b/www/templates/travel.html index 9e2aef3..89d218d 100644 --- a/www/templates/travel.html +++ b/www/templates/travel.html @@ -1,5 +1,9 @@ + +

@@ -60,7 +64,7 @@

- {{'Leave' | translate}} + {{'Leave' | translate}} {{'Leave' | translate}} {{'Leave' | translate}}
@@ -97,7 +101,7 @@
-