diff --git a/www/js/Controller/My_item/Myitems.js b/www/js/Controller/My_item/Myitems.js index 479332c..3cd4bd3 100644 --- a/www/js/Controller/My_item/Myitems.js +++ b/www/js/Controller/My_item/Myitems.js @@ -128,7 +128,7 @@ elephant.controller('MyitemsController', function($scope, $http, $timeout, $loca $scope.reApprove(dataString); hideSheet(); }else if(index == 1){ - $scope.deleteItem(dataString, item); + $scope.deleteGivenAway(dataString, item); hideSheet(); } } @@ -190,6 +190,22 @@ elephant.controller('MyitemsController', function($scope, $http, $timeout, $loca } } + //Function delete item which was given away + $scope.deleteGivenAway = function(dataString, item){ + var deleteItemSubmit = new Submitform(elephantData_URL.DELETE_GIVEN_AWAY_TYPE,elephantData_URL.DELETE_GIVEN_AWAY_URL,dataString,false); + deleteItemSubmit.ajaxSubmit(this); + + $scope.onSuccess = function(response){ + console.log(dataString); + var index = $scope.myitems.indexOf(item); + $scope.myitems.splice(index, 1); + } + + $scope.onError = function(response){ + UIfactory.showAlert('Success', 'Item have been deleted'); + } + } + $scope.$on('$ionicView.beforeEnter', function() { $scope.loadMore(); }); diff --git a/www/js/data.js b/www/js/data.js index 63dc2e3..6ff6db5 100644 --- a/www/js/data.js +++ b/www/js/data.js @@ -20,7 +20,9 @@ elephant.constant('elephantData_URL', { GIVEN_AWAY_ITEM: 'http://service.myelephant.xyz/givenaway.php', GIVEN_AWAY_TYPE: 'POST', RE_APPROVE_ITEM: 'http://service.myelephant.xyz/reapprove.php', - RE_APPROVE_TYPE: 'POST' + RE_APPROVE_TYPE: 'POST', + DELETE_GIVEN_AWAY_URL: 'http://service.myelephant.xyz/removegivenaway.php', + DELETE_GIVEN_AWAY_TYPE: 'POST' })