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: todo:
im englischen abändern
einzelnen eintrag löschen
sandorte ansehen in karte (extra tab) sandorte ansehen in karte (extra tab)
Platzierung garnix als standart aber pflichtfeld Platzierung garnix als standart aber pflichtfeld
fix send file to server fix send file to server
im englischen abändern
keine ahnung obs funktioniert: keine ahnung obs funktioniert:
TEST SEND FILE TO SERVER FUNCTION TEST SEND FILE TO SERVER FUNCTION
@@ -11,6 +10,7 @@ eintrg in db wenn http response (in sent column)
not to do: not to do:
einzelnen eintrag löschen
zurückfeld in datenansicht zurückfeld in datenansicht
maybe auch vorschläge aus templates in dropdown menüs anzeigen maybe auch vorschläge aus templates in dropdown menüs anzeigen
ausvon und ausbis fixen (falsches datum übergeben (20000-01-01)) 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", "savefilefailed": "Fehler. Bitte nochmal versuchen",
"justplace": "Standort", "justplace": "Standort",
"justsave": "Nur speichern", "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": "Already finished entrie",
"@finishedentrie": { "@finishedentrie": {
"description": "already finished entrie options dialog header" "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:fforte/other/db_helper.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.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 // * Site that shows all entries in the databases
class ViewCams extends StatefulWidget { 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 { void delAllTemplates() async {
return showDialog( return showDialog(
context: context, context: context,
@@ -116,6 +124,7 @@ class _ViewCamsState extends State<ViewCams> {
} else if (snapshot.hasError) { } else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}'); return Text('Error: ${snapshot.error}');
} else { } else {
List<Map<String,dynamic>> placeList = List.of(snapshot.data!);
return Scaffold( return Scaffold(
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
child: const Icon(Icons.delete), child: const Icon(Icons.delete),
@@ -146,27 +155,41 @@ class _ViewCamsState extends State<ViewCams> {
), ),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: snapshot.data!.length, itemCount: placeList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
Map<String, dynamic> place = Map<String, dynamic> place = snapshot.data![index];
snapshot.data![index]; return Slidable(
return ListTile( startActionPane: ActionPane(
title: Text('Standort ${index + 1}'), motion: const ScrollMotion(),
subtitle: Text( children: [
'ID: ${place['CID']} DATUM: ${place['Datum']}'), SlidableAction(
trailing: Checkbox( onPressed: (context) {
value: place['Sent'] == 0 ? false : true, delSinglePlace(place['ID'.toString()]);
onChanged: null, },
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,
)));
},
); );
}, },
)) ))