Browse Source

travel accept join petition implemented

master
arnaucode 7 years ago
parent
commit
70db3f88b9
3 changed files with 47 additions and 18 deletions
  1. +24
    -2
      www/js/travel.js
  2. +21
    -15
      www/templates/travel.html
  3. +2
    -1
      www/templates/user.html

+ 24
- 2
www/js/travel.js

@ -3,6 +3,7 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet'])
.controller('TravelCtrl', function($scope, $stateParams, $http, .controller('TravelCtrl', function($scope, $stateParams, $http,
$ionicModal, $ionicLoading, $ionicPopup, $filter, $ionicModal, $ionicLoading, $ionicPopup, $filter,
leafletData, leafletBoundsHelpers) { leafletData, leafletBoundsHelpers) {
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
$scope.center= { $scope.center= {
/*lat: 0, /*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 */ /* adding comment */
$scope.doingNewComment=false; $scope.doingNewComment=false;
$scope.newComment={}; $scope.newComment={};
@ -166,12 +188,12 @@ console.log($scope.newComment);
$scope.userHasJoined = function(myArray, searchTerm) { $scope.userHasJoined = function(myArray, searchTerm) {
//console.log(myArray+", "+searchTerm+", "+property);
//console.log(myArray+", "+searchTerm);
if(myArray) if(myArray)
{ {
for(var i = 0, len = myArray.length; i < len; i++) { for(var i = 0, len = myArray.length; i < len; i++) {
//console.log(myArray[i] + " - " + searchTerm); //console.log(myArray[i] + " - " + searchTerm);
if (myArray[i] === searchTerm){
if (myArray[i]._id === searchTerm){
//console.log("i: " + i); //console.log("i: " + i);
return i; return i;
} }

+ 21
- 15
www/templates/travel.html

@ -26,16 +26,18 @@
<div ng-show="storageuser._id!=travel.user._id" class="text-right"> <div ng-show="storageuser._id!=travel.user._id" class="text-right">
<p class='text-right'> <p class='text-right'>
<div ng-show="userHasJoined(travel.joinPetitions, storageuser._id)==-1"> <div ng-show="userHasJoined(travel.joinPetitions, storageuser._id)==-1">
<md-button ng-show="travel.type=='offering'" ng-click="joinTravel()" class="o_purple300">{{'Ask_to_join' | translate}}</md-button>
<md-button ng-show="travel.type=='asking'" ng-click="joinTravel()" class="o_purple300">{{'Offer_car' | translate}}</md-button>
<md-button ng-show="travel.type=='package'" ng-click="joinTravel()" class="o_purple300">{{'Offer_car' | translate}}</md-button>
<div ng-show="userHasJoined(travel.joins, storageuser._id)==-1">
<md-button ng-show="travel.type=='offering'" ng-click="joinTravel()" class="o_purple300">{{'Ask_to_join' | translate}}</md-button>
<md-button ng-show="travel.type=='asking'" ng-click="joinTravel()" class="o_purple300">{{'Offer_car' | translate}}</md-button>
<md-button ng-show="travel.type=='package'" ng-click="joinTravel()" class="o_purple300">{{'Offer_car' | translate}}</md-button>
</div>
</div> </div>
<div ng-show="userHasJoined(travel.joinPetitions, storageuser._id)>-1"> <div ng-show="userHasJoined(travel.joinPetitions, storageuser._id)>-1">
<md-button ng-show="travel.type=='offering'" ng-click="unjoinTravel()" class="o_purple100">{{'Unjoin' | translate}}</md-button> <md-button ng-show="travel.type=='offering'" ng-click="unjoinTravel()" class="o_purple100">{{'Unjoin' | translate}}</md-button>
<md-button ng-show="travel.type=='asking'" ng-click="unjoinTravel()" class="o_purple100">{{'Unoffer_car' | translate}}</md-button> <md-button ng-show="travel.type=='asking'" ng-click="unjoinTravel()" class="o_purple100">{{'Unoffer_car' | translate}}</md-button>
<md-button ng-show="travel.type=='package'" ng-click="unjoinTravel()" class="o_purple100">{{'Unoffer_car' | translate}}</md-button> <md-button ng-show="travel.type=='package'" ng-click="unjoinTravel()" class="o_purple100">{{'Unoffer_car' | translate}}</md-button>
</div>
</div>
</p> </p>
</div> </div>
<div class="item item-icon-left"> <div class="item item-icon-left">
@ -51,9 +53,10 @@
<div class="item item-icon-left" ng-show="travel.package"> <div class="item item-icon-left" ng-show="travel.package">
<i class="icon ion-ios-box"></i> package <i class="icon ion-ios-box"></i> package
</div> </div>
<div class="item item-icon-left" ng-show="travel.user.telegram">
<a class="item item-icon-left" ng-show="travel.user.telegram"
ng-href="http://telegram.me/{{travel.user.telegram}}">
<i class="icon ion-paper-airplane"></i> @{{travel.user.telegram}} <i class="icon ion-paper-airplane"></i> @{{travel.user.telegram}}
</div>
</a>
<div class="item item-icon-left" ng-show="travel.user.phone"> <div class="item item-icon-left" ng-show="travel.user.phone">
<i class="icon ion-ios-telephone"></i> {{travel.user.phone}} <i class="icon ion-ios-telephone"></i> {{travel.user.phone}}
</div> </div>
@ -71,12 +74,15 @@
<div class="item item-icon-left"> <div class="item item-icon-left">
<i class="icon ion-ios-people"></i> <i class="icon ion-ios-people"></i>
<p>0/{{travel.seats}} seats</p>
<a ng-repeat="join in travel.joins" ng-href="#/app/users/{{join._id}}">
<img class="o_userImgCircularMini" ng-src="{{join.avatar}}"></img>
</a>
<!--<button class="o_floatRight button o_grey600" ng-show="travel.user._id==storageuser._id">
<i class="icon ion-edit"></i>
</button>-->
<p>{{travel.joins.length}}/{{travel.seats}} seats</p>
<a ng-repeat="join in travel.joins" ng-href="#/app/users/{{join._id}}">
<img class="o_userImgCircularMini" ng-src="{{join.avatar}}"></img>
</a>
</div> </div>
<div class="">
<div ng-show="travel.joinPetitions.length>0">
<p>Pendent petitions</p> <p>Pendent petitions</p>
<div class="row" ng-repeat="joinPetition in travel.joinPetitions"> <div class="row" ng-repeat="joinPetition in travel.joinPetitions">
<div class="col col-90"> <div class="col col-90">
@ -85,23 +91,23 @@
<h2>{{joinPetition.username}}</h2> <h2>{{joinPetition.username}}</h2>
</a> </a>
</div> </div>
<div class="col">
<div class="col" ng-show="travel.user._id==storageuser._id">
<button class="button button-small o_grey600"> <button class="button button-small o_grey600">
<i class="icon ion-close"></i> <i class="icon ion-close"></i>
</button><br> </button><br>
<button class="button button-small o_purple400">
<button class="button button-small o_purple400" ng-click="acceptJoin(joinPetition)">
<i class="icon ion-checkmark"></i> <i class="icon ion-checkmark"></i>
</button><br> </button><br>
</div> </div>
</div> </div>
</div> </div>
<div class="item item-body" ng-show="travel.joins[0]">
<!--<div class="item item-body" ng-show="travel.joins[0]">
{{'Joined_users' | translate}}:<br> {{'Joined_users' | translate}}:<br>
<a ng-repeat="join in travel.joins" ng-href="#/app/users/{{join.joinedUsername}}" class="button button-small button-dark"> <a ng-repeat="join in travel.joins" ng-href="#/app/users/{{join.joinedUsername}}" class="button button-small button-dark">
<img ng-src="img/avatars/{{join.joinedAvatar}}.png" class="o-img-joined" />{{join.joinedUsername}}<br> <img ng-src="img/avatars/{{join.joinedAvatar}}.png" class="o-img-joined" />{{join.joinedUsername}}<br>
</a> </a>
</div>
</div>-->
<div class="item item-body"> <div class="item item-body">
<div ng-show="travel.comments[0]"> <div ng-show="travel.comments[0]">
{{'Comments' | translate}}:<br> {{'Comments' | translate}}:<br>

+ 2
- 1
www/templates/user.html

@ -8,7 +8,8 @@
</div> </div>
<div class=""> <div class="">
<div class="row"> <div class="row">
<a class="tab-item" ng-show="user.telegram">
<a class="tab-item" ng-show="user.telegram"
ng-href="http://telegram.me/{{user.telegram}}">
<i class="icon ion-paper-airplane"></i> <i class="icon ion-paper-airplane"></i>
@{{user.telegram}} @{{user.telegram}}
</a> </a>

Loading…
Cancel
Save