From 1810e315a937a3627fb642251ff4e9e11905b2d9 Mon Sep 17 00:00:00 2001 From: idoctnef Date: Thu, 6 Oct 2016 15:20:38 +0200 Subject: [PATCH] join inside the travel model --- www/js/controllers.js | 37 +++++-------------------------------- www/templates/travel.html | 12 ++++++------ 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index 207321e..ca37ec0 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -384,37 +384,10 @@ angular.module('starter.controllers', ['pascalprecht.translate']) $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token'); } $scope.storageusername=localStorage.getItem("c_username"); - $scope.travel=""; console.log($stateParams.travelId); - /*$http.get(urlapi + 'travels/'+$stateParams.travelId) - .success(function(data, status, headers,config){ - console.log('data success'); - console.log(data); // for browser console - $scope.travel = data; // for UI - console.log("b"); - console.log($scope.travel); - }) - .error(function(data, status, headers,config){ - console.log('data error'); - }) - .then(function(result){ - travel = result.data; - });*/ $scope.travels= JSON.parse(localStorage.getItem('c_travels')); $scope.travel = $filter('filter')($scope.travels, $stateParams.travelId, true)[0]; - $scope.joins=""; - $http.get(urlapi + 'travels/join/'+$stateParams.travelId) - .success(function(data, status, headers,config){ - console.log('data success'); - console.log(data); // for browser console - $scope.joins = data; // for UI - }) - .error(function(data, status, headers,config){ - console.log('data error'); - }) - .then(function(result){ - joins = result.data; - }); + $http.get(urlapi + 'travels/comment/'+$stateParams.travelId) .success(function(data, status, headers,config){ console.log(data); // for browser console @@ -456,13 +429,13 @@ angular.module('starter.controllers', ['pascalprecht.translate']) }; $scope.joinTravel = function(){ $scope.newjoin={ - travelId: $stateParams.travelId, + //travelId: $stateParams.travelId, joinedUserId: localStorage.getItem("c_userid"), joinedUsername: localStorage.getItem("c_username"), joinedAvatar: localStorage.getItem("c_avatar") }; $http({ - url: urlapi + 'travels/join/' + $stateParams.travelId, + url: urlapi + 'travels/'+ $stateParams.travelId+'/join', method: "POST", data: $scope.newjoin }) @@ -485,7 +458,7 @@ angular.module('starter.controllers', ['pascalprecht.translate']) joinedAvatar: localStorage.getItem("c_avatar") }; $http({ - url: urlapi + 'travels/unjoin/' + $stateParams.travelId, + url: urlapi + 'travels/'+ $stateParams.travelId+'/unjoin', method: "POST", data: $scope.unjoin }) @@ -540,7 +513,7 @@ console.log($scope.newComment); $scope.arrayObjectIndexOf = function(myArray, searchTerm, property) { - console.log(myArray+", "+searchTerm+", "+property); + //console.log(myArray+", "+searchTerm+", "+property); if(myArray) { for(var i = 0, len = myArray.length; i < len; i++) { diff --git a/www/templates/travel.html b/www/templates/travel.html index a937734..0844218 100644 --- a/www/templates/travel.html +++ b/www/templates/travel.html @@ -49,15 +49,15 @@
-
-

-

+
+

+

{{'Ask_to_join' | translate}} {{'Offer_car' | translate}} {{'Offer_car' | translate}}
-
+
-
+
{{'Joined_users' | translate}}:
- + {{join.joinedUsername}}