Löschfunktion vollständigimplementiert.

This commit is contained in:
2016-02-03 13:51:17 +01:00
parent 5b51b8b31f
commit 4fdd18bb11
26 changed files with 232 additions and 62 deletions

View File

@@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile,$ionicLoading,$state,$http,$filter) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile,$ionicLoading,$state,$filter) {
$scope.preis="";
$scope.name="";
@@ -375,23 +375,11 @@ $scope.show = function() {
* Rosen konsuieren ENDE
*/
})
.controller('BuysCtrl', function($scope, $database,$location,$ionicModal,$ionicLoading,$timeout) {
.controller('BuysCtrl', function($scope, $database,$location,$ionicModal,$ionicLoading,$timeout,$cordovaFile,$ionicPopup) {
/*
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
if ($location.path() == "/tab/buys") {
$scope.show($ionicLoading);
$timeout(fill_list, 1000);
}
});
*/
$scope.$on( "$ionicView.enter", function( scopes, states ) {
$scope.show($ionicLoading);
@@ -425,6 +413,48 @@ $scope.show = function() {
};
$scope.deleteBuy = function(id,imagefile) {
$ionicPopup.confirm({
title: 'System-Hinweis',
template: 'Möchten Sie das Bild wirklich löschen?'
})
.then(function(res) {
if (res) {
//Dateien Löschen im Programmpfad
$cordovaFile.removeFile(cordova.file.applicationStorageDirectory, imagefile)
.then(function (success) {
// success
}, function (error) {
// error
});
//Dateien Löschen im Public-Programmpfad
$cordovaFile.removeFile(cordova.file.externalRootDirectory + "/WolleRosenKaufen", imagefile)
.then(function (success) {
// success
}, function (error) {
// error
});
//Datenbank-eintrag löschen
$database.deleteBuy(id);
$scope.show($ionicLoading);
$timeout(fill_list, 300);
}
});
}
$scope.showImages = function(imagesrc) {
$scope.imagesrc=imagesrc;
$scope.showModal('templates/image-popover.html');

View File

@@ -71,6 +71,16 @@ angular.module('starter.services', [])
console.error(error);
});
},
deleteBuy: function(id) {
query="DELETE FROM buys WHERE ID = ?;";
return $cordovaSQLite.execute(self.db,query,[id]).
then(function(result) {
console.log("Gelöscht");
query=null;
}, function(error) {
console.error(error);
});
},
getAllBuys: function(){
var ArrayQ=[];
query="SELECT * FROM buys order by id DESC";
@@ -79,6 +89,7 @@ angular.module('starter.services', [])
for(j=0;j<result.rows.length;j++){
var List={};
//console.log(result.rows.item(j));
List.id=result.rows.item(j).id;
List.name=result.rows.item(j).Name;
List.bild=result.rows.item(j).Bild;
List.bildtext=result.rows.item(j).Bildtext;