Browse Source

delete travel implemented

master
nau 8 years ago
parent
commit
bf29c64f9a
4 changed files with 33 additions and 11 deletions
  1. +3
    -1
      README.md
  2. +19
    -0
      www/js/controllers.js
  3. +4
    -4
      www/templates/travel.html
  4. +7
    -6
      www/templates/travels.html

+ 3
- 1
README.md

@ -1 +1,3 @@
# collectivecarApp
# collectivecarApp
server code: https://github.com/idoctnef/collectivecarServer

+ 19
- 0
www/js/controllers.js

@ -314,6 +314,9 @@ angular.module('starter.controllers', [])
})
.controller('TravelCtrl', function($scope, $stateParams, $http) {
if(localStorage.getItem('c_token')){// adding token to the headers
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token');
}
$scope.storageusername=localStorage.getItem("c_username");
$scope.travel="";
console.log($stateParams.travelId);
@ -329,6 +332,22 @@ angular.module('starter.controllers', [])
.then(function(result){
travels = result.data;
});
$scope.deleteTravel = function(){
console.log("delete travel: " + $stateParams.travelId);
$http({
url: urlapi + 'travels/' + $stateParams.travelId,
method: "DELETE"
})
.then(function(response) {
console.log(response);
},
function(response) { // optional
// failed
});
};
$scope.joinTravel = function(){
};
})
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout) {

+ 4
- 4
www/templates/travel.html

@ -34,12 +34,12 @@
<div ng-show="storageusername">
<p class='text-right' ng-show="storageusername!==travel.owner">
<a ng-show="travel.modality=='offering'" href="#" class="button button-calm o-pull-right">Ask to join</a>
<a ng-show="travel.modality=='asking'" href="#" class="button button-calm o-pull-right">Offer car</a>
<a ng-show="travel.modality=='package'" href="#" class="button button-calm o-pull-right">Offer car</a>
<a ng-show="travel.modality=='offering'" ng-click="joinTravel()" href="#" class="button button-calm o-pull-right">Ask to join</a>
<a ng-show="travel.modality=='asking'" ng-click="joinTravel()" href="#" class="button button-calm o-pull-right">Offer car</a>
<a ng-show="travel.modality=='package'" ng-click="joinTravel()" href="#" class="button button-calm o-pull-right">Offer car</a>
</p>
<p ng-show="storageusername==travel.owner" class="text-right">
<a href="#" class="button button-assertive o-pull-right">Delete</a>
<a href="#" ng-click="deleteTravel()" class="button button-assertive o-pull-right">Delete</a>
</p>
</div>
</div>

+ 7
- 6
www/templates/travels.html

@ -19,16 +19,17 @@
<a ng-repeat="travel in travels | orderBy: 'date' | filter: search" class="item item-avatar" href="#/app/travels/{{travel._id}}">
<img ng-src="img/{{travel.modality}}.png">
<h2>{{travel.title}}</h2>
<div class="item-note">
<div class="positive">{{travel.date | date:"dd/MM HH:mm a"}}</div>
<div class="badge badge-calm">{{travel.owner}}</div>
<div class="item-note text-right">
<div class="positive">{{travel.date | date:"dd/MM"}}</div>
<div class="positive">{{travel.date | date:"HH:mm"}}h</div>
<!--<div class="badge badge-calm">{{travel.owner}}</div>-->
</div>
<p>
{{travel.description}}
</p>
<p class="" ng-show="travel.modality=='offering'">nºseats: {{travel.seats}}</p>
<p class="" ng-show="travel.modality=='asking'">nºpeople: {{travel.seats}}</p>
<!--<p class="" ng-show="travel.modality=='offering'">nºseats: {{travel.seats}}</p>
<p class="" ng-show="travel.modality=='asking'">nºpeople: {{travel.seats}}</p>-->
<p class="">{{travel.from}} - {{travel.to}}</p>
</a>
</div>
</ion-content>

Loading…
Cancel
Save