From e78d6dd0edf34ab5814dab3bad02555154495a99 Mon Sep 17 00:00:00 2001 From: arnaucode Date: Mon, 26 Jun 2017 15:36:37 +0200 Subject: [PATCH] delete event --- www/js/app.js | 2 +- www/js/event.js | 35 ++++++++++++++++++++++++++++++++++- www/templates/event.html | 27 ++++++++++++++++++--------- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index bda4a20..b30b754 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1,5 +1,5 @@ //var urlapi = "http://localhost:3000/api/"; -var urlapi = "http://192.168.1.35:3001/api/"; +var urlapi = "http://192.168.1.38:3001/api/"; diff --git a/www/js/event.js b/www/js/event.js index 949c41f..35b4a59 100644 --- a/www/js/event.js +++ b/www/js/event.js @@ -1,7 +1,7 @@ angular.module('app.event', ['pascalprecht.translate', 'ui-leaflet']) .controller('EventCtrl', function($scope, $http, $ionicModal, - $stateParams, $timeout, $ionicLoading, $filter, + $stateParams, $timeout, $ionicLoading, $filter, $ionicPopup, leafletData, leafletBoundsHelpers, $cordovaSocialSharing) { @@ -68,4 +68,37 @@ angular.module('app.event', ['pascalprecht.translate', 'ui-leaflet']) // An error occured. Show a message to the user }); }; + + + + $scope.deleteEvent = function(){ + var confirmPopup = $ionicPopup.confirm({ + title: 'Deleting event', + template: 'Are you sure you want to delete '+ $scope.event.title+'?' + }); + confirmPopup.then(function(res) { + if(res) { + console.log('You are sure'); + console.log("delete travel: " + $stateParams.eventid); + $http({ + url: urlapi + '/events/id/' + $stateParams.eventid, + method: "DELETE" + }) + .then(function(response) { + console.log(response); + $scope.events=response.data; + /*localStorage.setItem('c_travels', JSON.stringify($scope.travels)); + localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));*/ + $ionicLoading.show({ template: 'Event deleted', noBackdrop: true, duration: 2000 }); + window.location.href="#/app/main"; + }, + function(response) { // optional + // failed + $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); + }); + } else { + console.log('You are not sure'); + } + }); + }; }); diff --git a/www/templates/event.html b/www/templates/event.html index cb8f5b7..0dae86f 100644 --- a/www/templates/event.html +++ b/www/templates/event.html @@ -5,25 +5,34 @@

{{event.user.username}}

{{event.user.shortDescription}}

+
+

+ + + + +

+
-
{{event.date | date: 'HH:mm, dd/MM/yyyy'}}
-

{{event.title}}

-

{{event.description}}

-

- +

{{event.date | date: 'HH:mm, dd/MM/yyyy'}}
+

{{event.title}}

+

{{event.description}}

+

+ {{category.name}} -

-
+

+

Place: {{event.location.direction}}

- + Share