arnaucube
arnaucube/commonroutesAppPublic Self-hosted repository
decline join travel and leave travel implemented
arnaucode idoctnef@openmailbox.org
Mon, 30 Jan 2017 12:42:24 +0100
commit

46d3a3b674531a541ed6eac6ddcdc810c147988c

parent

2a02e38df2b53d8e3934b929094d4008b4717528

2 files changed, 47 insertions(+), 2 deletions(-)

jump to
M www/js/travel.js → www/js/travel.js

@@ -125,6 +125,27 @@ // failed

}); }; + $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,

@@ -139,6 +160,26 @@ $ionicLoading.show({template: 'Error on unjoin', noBackdrop: true, duration: 2000});

}else{ $scope.travel=data.data; console.log("success"); + } + }, + function(response) { // optional + // failed + }); + }; + + $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
M www/templates/travel.html → www/templates/travel.html

@@ -1,5 +1,9 @@

<ion-view view-title="{{'Travel' | translate}}"> <ion-content class="has-footer"> + <ion-refresher + pulling-text="{{'Pull_to_refresh' | translate}}..." + on-refresh="doRefresh()"> + </ion-refresher> <div class="item item-icon-left"> <div class="item-note"> <p>

@@ -60,7 +64,7 @@ <md-button ng-show="travel.type=='package'" ng-click="unjoinTravel()" class="o_purple100">{{'Unoffer_car' | translate}}</md-button>

</div> <div ng-show="userHasJoined(travel.joins, storageuser._id)>-1"> - <md-button ng-show="travel.type=='offering'" ng-click="" class="o_bRed">{{'Leave' | translate}}</md-button> + <md-button ng-show="travel.type=='offering'" ng-click="leaveTravel()" class="o_bRed">{{'Leave' | translate}}</md-button> <md-button ng-show="travel.type=='asking'" ng-click="" class="o_purple100">{{'Leave' | translate}}</md-button> <md-button ng-show="travel.type=='package'" ng-click="" class="o_purple100">{{'Leave' | translate}}</md-button> </div>

@@ -97,7 +101,7 @@ <h2>{{joinPetition.username}}</h2>

</a> </div> <div class="col" ng-show="travel.user._id==storageuser._id"> - <button class="button button-small o_grey600"> + <button class="button button-small o_grey600" ng-click="declineJoin(joinPetition)"> <i class="icon ion-close"></i> </button><br> <button class="button button-small o_purple400" ng-click="acceptJoin(joinPetition)">