delete single entry function added

This commit is contained in:
nico
2024-05-01 15:34:16 +02:00
parent ea01ba3cdc
commit b6dc991f99
5 changed files with 51 additions and 23 deletions

View File

@@ -1,9 +1,8 @@
todo:
im englischen abändern
einzelnen eintrag löschen
sandorte ansehen in karte (extra tab)
Platzierung garnix als standart aber pflichtfeld
fix send file to server
im englischen abändern
keine ahnung obs funktioniert:
TEST SEND FILE TO SERVER FUNCTION
@@ -11,6 +10,7 @@ eintrg in db wenn http response (in sent column)
not to do:
einzelnen eintrag löschen
zurückfeld in datenansicht
maybe auch vorschläge aus templates in dropdown menüs anzeigen
ausvon und ausbis fixen (falsches datum übergeben (20000-01-01))

View File

@@ -1 +0,0 @@
,nico,nico-end,01.05.2024 00:11,file:///home/nico/.config/libreoffice/7.3.1;

View File

@@ -92,5 +92,6 @@
"savefilefailed": "Fehler. Bitte nochmal versuchen",
"justplace": "Standort",
"justsave": "Nur speichern",
"finishedentrie": "Bereits fertiger Eintrag"
"finishedentrie": "Bereits fertiger Eintrag",
"justdelete": "Löschen"
}

View File

@@ -447,6 +447,11 @@
"finishedentrie": "Already finished entrie",
"@finishedentrie": {
"description": "already finished entrie options dialog header"
},
"justdelete": "Delete",
"@justdelete": {
"description": "just delete action pane label"
}
}

View File

@@ -2,6 +2,7 @@ import 'package:fforte/addCam/add_cam_main.dart';
import 'package:fforte/other/db_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
// * Site that shows all entries in the databases
class ViewCams extends StatefulWidget {
@@ -59,6 +60,13 @@ class _ViewCamsState extends State<ViewCams> {
});
}
void delSinglePlace(int id) async {
DBHelper().deletePlace(id.toString());
setState(() {
place = DBHelper().getPlace();
});
}
void delAllTemplates() async {
return showDialog(
context: context,
@@ -116,6 +124,7 @@ class _ViewCamsState extends State<ViewCams> {
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
List<Map<String,dynamic>> placeList = List.of(snapshot.data!);
return Scaffold(
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.delete),
@@ -146,27 +155,41 @@ class _ViewCamsState extends State<ViewCams> {
),
Expanded(
child: ListView.builder(
itemCount: snapshot.data!.length,
itemCount: placeList.length,
itemBuilder: (context, index) {
Map<String, dynamic> place =
snapshot.data![index];
return ListTile(
title: Text('Standort ${index + 1}'),
subtitle: Text(
'ID: ${place['CID']} DATUM: ${place['Datum']}'),
trailing: Checkbox(
value: place['Sent'] == 0 ? false : true,
onChanged: null,
Map<String, dynamic> place = snapshot.data![index];
return Slidable(
startActionPane: ActionPane(
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (context) {
delSinglePlace(place['ID'.toString()]);
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
icon: Icons.delete,
label: AppLocalizations.of(context)!.justdelete,
)
]),
child: ListTile(
title: Text('Standort ${index + 1}'),
subtitle: Text(
'ID: ${place['ID']} DATUM: ${place['Datum']}'),
trailing: Checkbox(
value: place['Sent'] == 0 ? false : true,
onChanged: null,
),
onTap: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddCamMain(
isFinished: true,
existingData: place,
)));
},
),
onTap: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddCamMain(
isFinished: true,
existingData: place,
)));
},
);
},
))