From b5e96d3c0427b9d7f334d59b7eec3733a4a51dc8 Mon Sep 17 00:00:00 2001 From: risadmin_prod Date: Sat, 29 Mar 2025 09:29:40 +0000 Subject: [PATCH] build_app --- .../Builders/Services/BuilderService.java | 6 + .../forma/Controllers/TestmController.java | 88 ++ .../Testm_ListFilter1Controller.java | 24 + .../java/com/realnet/forma/Entity/Testm.java | 62 +- .../forma/Entity/Testm_ListFilter1.java | 14 + .../forma/Repository/TestmRepository.java | 22 + .../realnet/forma/Services/TestmService.java | 147 ++- .../Services/Testm_ListFilter1Service.java | 47 + .../authsec_mysql/mysql/wf_table/wf_table.sql | 2 +- .../Testm/TestmView/Testm_api_service.dart | 44 + .../TestmView/Testm_create_entity_screen.dart | 1058 ++++++++++++++++- .../TestmView/Testm_entity_list_screen.dart | 367 +++++- .../TestmView/Testm_update_entity_screen.dart | 727 ++++++++++- .../Testm/Testm_Repo/Testm_repo_screen.dart | 62 + .../Testm_view_model_screen.dart | 93 ++ .../lib/commans/widgets/custome_drawer.dart | 39 +- 16 files changed, 2680 insertions(+), 122 deletions(-) create mode 100644 testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/Testm_ListFilter1Controller.java create mode 100644 testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm_ListFilter1.java create mode 100644 testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/Testm_ListFilter1Service.java diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java index 6dec798..0921fb4 100644 --- a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java @@ -72,6 +72,12 @@ public class BuilderService { addCustomMenu( "Child", "Transcations"); +addCustomMenu( "Testm", "Transcations"); + + +addCustomMenu( "Child", "Transcations"); + + addCustomMenu( "Testm", "Transcations"); diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/TestmController.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/TestmController.java index 1bf6289..c096af5 100644 --- a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/TestmController.java +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/TestmController.java @@ -20,6 +20,28 @@ import com.realnet.forma.Services.TestmService ; + + + + + + + + + + + + + + + + + + + + + + @RequestMapping(value = "/Testm") @CrossOrigin("*") @RestController @@ -34,12 +56,56 @@ public class TestmController { + + + + + + + + + + + + + + + + + + + + + + @PostMapping("/Testm") public Testm Savedata(@RequestBody Testm data) { Testm save = Service.Savedata(data) ; + + + + + + + + + + + + + + + + + + + + + + System.out.println("data saved..." + save); return save; @@ -88,4 +154,26 @@ public class TestmController { + + + + + + + + + + + + + + + + + + + + + + } \ No newline at end of file diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/Testm_ListFilter1Controller.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/Testm_ListFilter1Controller.java new file mode 100644 index 0000000..54a72a2 --- /dev/null +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Controllers/Testm_ListFilter1Controller.java @@ -0,0 +1,24 @@ +package com.realnet.forma.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import com.realnet.forma.Entity.Testm_ListFilter1; +import com.realnet.forma.Services.Testm_ListFilter1Service ; +@RequestMapping(value = "/Testm_ListFilter1") +@RestController +public class Testm_ListFilter1Controller { + + @Autowired + private Testm_ListFilter1Service Service; + + @GetMapping("/Testm_ListFilter1") + public List getlist() { + List get = Service.getlistbuilder(); + return get; +} + @GetMapping("/Testm_ListFilter11") + public List getlistwithparam( ) { + List get = Service.getlistbuilderparam( ); + return get; +} +} \ No newline at end of file diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm.java index 3b9d9f9..80e0004 100644 --- a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm.java +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm.java @@ -6,7 +6,29 @@ import com.realnet.WhoColumn.Entity.Extension; import java.util.*; -import com.realnet.forma.Entity.Child; + + + + + + + + + + + + + + + + + + + + + + + @Entity @Data @@ -22,8 +44,42 @@ import com.realnet.forma.Entity.Child; private String namem; -@OneToOne( cascade=CascadeType.ALL) - private Child child; +private String selectsta; + +private String selectstamul; + +private Integer selectdya; +private String selectdyaname; + +private String selectdyamul; + +private Integer selectauto; +private String selectautotypename; + +private String selectautomul; + + + + + +private String bar_code; + + + + +private String qr_code; + + + + + + + +private int numbers; + +private int numberk; + +private String calculateadd; } diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm_ListFilter1.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm_ListFilter1.java new file mode 100644 index 0000000..97f1a72 --- /dev/null +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Entity/Testm_ListFilter1.java @@ -0,0 +1,14 @@ +package com.realnet.forma.Entity; + import lombok.*; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + @Data + public class Testm_ListFilter1 { + + private Integer id; + + + private String namem; +} diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Repository/TestmRepository.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Repository/TestmRepository.java index fbc94ef..72ee915 100644 --- a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Repository/TestmRepository.java +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Repository/TestmRepository.java @@ -12,6 +12,28 @@ import java.util.*; + + + + + + + + + + + + + + + + + + + + + + diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/TestmService.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/TestmService.java index c7a5dc2..8e4d4f0 100644 --- a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/TestmService.java +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/TestmService.java @@ -16,6 +16,34 @@ import com.realnet.users.entity1.AppUser; + + +import com.realnet.forma.Entity.Testm; +import com.realnet.forma.Services.TestmService; + + + + + +import com.realnet.forma.Entity.Testm; +import com.realnet.forma.Services.TestmService; + + + + + + + + + + + + + + + + + import org.springframework.stereotype.Service; @Service @@ -29,11 +57,75 @@ private TestmRepository Repository; + + +@Autowired + private TestmService selectdyaserv; + + + +@Autowired + private TestmService selectautoserv; + + + + + + + + + + + + + + + public Testm Savedata(Testm data) { + + + + +if (data.getSelectdya() != null) { + Testm get = selectdyaserv.getdetailsbyId(data.getSelectdya()); + data.setSelectdyaname(get.getNamem()); + + } + + + + + + + + +if (data.getSelectauto() != null) { + Testm get = selectautoserv.getdetailsbyId(data.getSelectauto()); + data.setSelectautotypename(get.getNamem()); + + } + + + + + + + + + + + + + + + + + + data.setUpdatedBy(getUser().getUserId()); data.setCreatedBy(getUser().getUserId()); data.setAccountId(getUser().getAccount().getAccount_id()); @@ -67,7 +159,38 @@ public Testm update(Testm data,Integer id) { Testm old = Repository.findById(id).get(); old.setNamem(data.getNamem()); -old.setChild(data.getChild()); +old.setSelectsta(data.getSelectsta()); + +old.setSelectstamul(data.getSelectstamul()); + +old.setSelectdya(data.getSelectdya()); + +old.setSelectdyamul(data.getSelectdyamul()); + +old.setSelectauto(data.getSelectauto()); + +old.setSelectautomul(data.getSelectautomul()); + + + +old.setBar_code(data.getBar_code()); + + + +old.setQr_code(data.getQr_code()); + + + + + + + + +old.setNumbers(data.getNumbers()); + +old.setNumberk(data.getNumberk()); + +old.setCalculateadd(data.getCalculateadd()); final Testm test = Repository.save(old); data.setUpdatedBy(getUser().getUserId()); @@ -76,6 +199,28 @@ final Testm test = Repository.save(old); + + + + + + + + + + + + + + + + + + + + + + public AppUser getUser() { AppUser user = userService.getLoggedInUser(); return user; diff --git a/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/Testm_ListFilter1Service.java b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/Testm_ListFilter1Service.java new file mode 100644 index 0000000..e18a9f1 --- /dev/null +++ b/testflutter26-back-b/authsec_springboot/backend/src/main/java/com/realnet/forma/Services/Testm_ListFilter1Service.java @@ -0,0 +1,47 @@ +package com.realnet.forma.Services; +import java.util.*; +import com.realnet.forma.Repository.TestmRepository; +import com.realnet.forma.Entity.Testm; + +import com.realnet.forma.Entity.Testm_ListFilter1; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + +@Service + public class Testm_ListFilter1Service { +@Autowired +private TestmRepository Repository; + + + + + public List getlistbuilder() { + List list= Repository.findAll(); + ArrayList l = new ArrayList<>(); + for (Testm data : list) { +{ +Testm_ListFilter1 dummy = new Testm_ListFilter1(); + dummy.setId(data.getId()); + dummy.setNamem(data.getNamem()); + l.add(dummy); +} +} +return l;} + + + + public List getlistbuilderparam( ) { + List list= Repository.findAll(); + ArrayList l = new ArrayList<>(); + for (Testm data : list) { +{ +Testm_ListFilter1 dummy = new Testm_ListFilter1(); + dummy.setId(data.getId()); + dummy.setNamem(data.getNamem()); + l.add(dummy); +} +} +return l;} +} \ No newline at end of file diff --git a/testflutter26-db-d/authsec_mysql/mysql/wf_table/wf_table.sql b/testflutter26-db-d/authsec_mysql/mysql/wf_table/wf_table.sql index 0edfa59..7ec0056 100755 --- a/testflutter26-db-d/authsec_mysql/mysql/wf_table/wf_table.sql +++ b/testflutter26-db-d/authsec_mysql/mysql/wf_table/wf_table.sql @@ -1,4 +1,4 @@ -CREATE TABLE db.Testm(id BIGINT NOT NULL AUTO_INCREMENT, onetoone VARCHAR(400), namem VARCHAR(400), PRIMARY KEY (id)); +CREATE TABLE db.Testm(id BIGINT NOT NULL AUTO_INCREMENT, selectdya int, numbers int, selectdyamul VARCHAR(400), calculateadd VARCHAR(400), valuell VARCHAR(400), selectstamul VARCHAR(400), bar_code VARCHAR(400), selectauto int, selectautomul VARCHAR(400), qr_code VARCHAR(400), numberk int, namem VARCHAR(400), datagg VARCHAR(400), selectsta VARCHAR(400), PRIMARY KEY (id)); CREATE TABLE db.Child(id BIGINT NOT NULL AUTO_INCREMENT, namemmm VARCHAR(400), PRIMARY KEY (id)); diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_api_service.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_api_service.dart index 9009c9d..3d8974b 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_api_service.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_api_service.dart @@ -55,6 +55,28 @@ Future>> getAllWithPagination( + + + + + + + + + + + + + + + + + + + + + + Future updateEntity( int entityId, Map entity) async { try { @@ -77,4 +99,26 @@ Future>> getAllWithPagination( + + + + + + + + + + + + + + + + + + + + + + } \ No newline at end of file diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_create_entity_screen.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_create_entity_screen.dart index 05c9cec..08c4faa 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_create_entity_screen.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_create_entity_screen.dart @@ -39,6 +39,28 @@ import '../../../../Reuseable/reusable_dropdown_field.dart'; + + + + + + + + + + + + + + + + + + + + + + class testmCreateEntityScreen extends StatefulWidget { const testmCreateEntityScreen({super.key}); @@ -53,35 +75,403 @@ final Map formData = {}; final TextEditingController namemController = TextEditingController(); - Widget buildFormField(String fieldOption) { + String? dropdownValueselectsta; + List staticOptionsselectsta = [ + + +'q', + + + +'b', + + +]; + +Widget _buildDropdownselectsta(String label, List options, String? value, void Function(String?) onChanged) { return Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: Card( - elevation: 4, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - child: Padding( - padding: const EdgeInsets.all(12.0), - child: TextFormField( - decoration: InputDecoration( - labelText: fieldOption, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - onSaved: (value) { - if (formData['child'] == null) { - formData['child'] = {}; - } - formData['child'][fieldOption] = value; - }, - ), - ), + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration(labelText: label, + border: OutlineInputBorder(), +), + value: value, + onChanged: onChanged, + items: options.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), ), ); } + List selectedselectstamul = []; + List selectstamulList = [ + + + ' q ', + + + + ' b ', + + + + ' c ', + + + ]; + + Widget _buildMultiSelectDropdownselectstamul(String label, List options, List values, void Function(List) onChanged) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: MultiSelectDialogField( + items: options.map((e) => MultiSelectItem(e, e)).toList(), + listType: MultiSelectListType.CHIP, + initialValue: values, + onConfirm: onChanged, + decoration: BoxDecoration( + border: Border.all(color: Colors.teal), + borderRadius: BorderRadius.circular(4), + ), + title: Text(label), + ), + ); + } + +List> selectdyaItems = []; + var selectedselectdyaValue = ''; // Use nullable type Future _load + + List selectdyamulItems = []; + List selectedselectdyamulValue = []; + + TextEditingController selectdyamulController = TextEditingController(); + GlobalKey> selectdyamulkey = GlobalKey(); +Future> _loadselectdyamulItems() async { + try { +final provider = + Provider.of(context, listen: false); + + final selectTdata = await provider.getselectdyamul(); + print('selectdyamul data is : $selectTdata'); + + if (selectTdata != null && selectTdata.isNotEmpty) { + + + + + List datareturned = []; + selectTdata.forEach((element) { +if (element['namem'] != null) + + datareturned.add(element['namem']); + }); + + + return datareturned; + } else { + print('selectdyamul data is null or empty'); + return []; + } + } catch (e) { + print('Failed to load selectdyamul items: $e'); + return []; + } + } + + +List> selectautoItems = []; + int? selectedselectautoId; // to store selected state id + + String selectedselectautoValue = ''; // Use nullable type Future _load + + TextEditingController selectautoController = TextEditingController(); + GlobalKey> selectautokey = GlobalKey(); +Future>> _loadselectautoItems() async { +final provider = + Provider.of(context, listen: false); + try { + final selectTdata = await provider.getselectauto(); + print('selectauto data is : $selectTdata'); + + if (selectTdata != null &&selectTdata.isNotEmpty) { + + + + + selectautoItems = selectTdata; + + + + return selectautoItems; + } else { + print('selectauto data is null or empty'); + return []; + } + } catch (e) { + print('Failed to load selectauto items: $e'); + return []; + } + } + + + List selectautomulItems = []; + List selectedselectautomulValue = []; + + TextEditingController selectautomulController = TextEditingController(); + GlobalKey> selectautomulkey = GlobalKey(); +Future> _loadselectautomulItems() async { +final provider = + Provider.of(context, listen: false); + + try { + final selectTdata = await provider.getselectautomul(); + print('selectautomul data is : $selectTdata'); + + if (selectTdata != null && selectTdata.isNotEmpty) { + + + + + List datareturned = []; + selectTdata.forEach((element) { +if (element['namem'] != null) + datareturned.add(element['namem']); + }); + + + return datareturned; + } else { + print('selectautomul data is null or empty'); + return []; + } + } catch (e) { + print('Failed to load selectautomul items: $e'); + return []; + } + } + + final TextEditingController fieldggController = TextEditingController(); + + + late Future>> _valuelldataFuture; // Data from fetchData + + Future>> valuellfetchData() async { + + final resp = await apiService.getEntities(); + + if (resp != null) { + return resp; + } else { + throw Exception('Failed to load data: '); + } + + } + + + void showvaluellDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return SingleChildScrollView( + child: AlertDialog( + title: const Text('Select a record'), + content: FutureBuilder>>( + future: _valuelldataFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center(child: Text('No data available..')); + } else { +final List columnsToShow = [ + + + + + 'namem', + + + ]; + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columnSpacing: 30, + headingRowColor: MaterialStateColor.resolveWith( + (states) => Colors.blue.shade100), + dataRowColor: MaterialStateColor.resolveWith( + (states) => Colors.white), + dividerThickness: 0.5, + columns: columnsToShow + .map( + (key) => DataColumn( + label: Text( + key, + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 16), + ), + ), + ) + .toList(), + rows: snapshot.data!.map((item) { + return DataRow( + cells: columnsToShow.map((key) { + return DataCell( + Text( + item[key].toString(), + style: const TextStyle(fontSize: 14), + ), + onTap: () { + setState(() { + + + namemController.text = item['namem'] ?? ''; + + + // Add more fields as needed + }); + Navigator.pop(context); + }, + ); + }).toList()); + }).toList(), + ), + ); + } + }, + ), + actions: [ + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + }, + ); + } + + + late Future>> _dataggdataFuture; // Data from fetchData + + Future>> dataggfetchData() async { + +final provider = + Provider.of(context, listen: false); + final resp = await provider.getdataggGrid(); + + if (resp != null) { + return resp; + } else { + throw Exception('Failed to load data: '); + } + + } + + final TextEditingController numbersController = TextEditingController(); + + + final TextEditingController numberkController = TextEditingController(); + + + + + String calculateaddOperator = '+'; + String calculateaddresult = ''; + + final List calculateaddoperators = ['+', '-', '*', '/']; + + void calculatecalculateaddResult() { + int calculation; + switch (calculateaddOperator) { + case '+': + calculation = + + +int.parse(numbersController.text) + + + + + +int.parse(numberkController.text) + + + + +0; + + + break; + case '-': + calculation = + + +int.parse(numbersController.text) - + + + +int.parse(numberkController.text) - + + +0; + break; + case '*': + calculation = + + +int.parse(numbersController.text) * + + + +int.parse(numberkController.text) * + + +1; + break; + case '/': + if ( + + +int.parse(numbersController.text)== 0 || + + + +int.parse(numberkController.text)== 0 || + + + + +1 != 1) { + calculateaddresult = 'Division by zero error'; + return; + } + calculation = ( + + +int.parse(numbersController.text) / + + + +int.parse(numberkController.text) / + + + +1).toInt(); + break; + default: + calculation = 0; + } + setState(() { + calculateaddresult = 'Result: $calculation'; + }); + } + @override void initState() { super.initState(); @@ -90,6 +480,39 @@ final Map formData = {}; + + + provider.getselectdya().then((value) { + setState(() { + selectdyaItems = value; // ✅ Update list only when data is fetched + }); + + print('Updated selectdyaItems: $selectdyaItems'); + }).catchError((error) { + print('Error fetching data: $error'); + }); + + + + + + + + + + + _valuelldataFuture = valuellfetchData(); // Initialize _dataFuture with the function + + + _dataggdataFuture = dataggfetchData(); // Initialize _dataFuture with the function + + + + + + + + } @@ -114,6 +537,35 @@ final Map formData = {}; + + + + + + + + + + + + + actions: [ + IconButton( + icon: const Icon(Icons.grid_on), + onPressed: () { + showvaluellDialog(context); + }, + ), + ], + + + + + + + + + ), body: SingleChildScrollView( child: Padding( @@ -133,33 +585,433 @@ final Map formData = {}; SizedBox(height: 16), -Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox( - height: 20, - child: Text( - 'Child', + _buildDropdownselectsta('selectsta', staticOptionsselectsta, dropdownValueselectsta, (value) { + setState(() { + dropdownValueselectsta = value; + formData['selectsta'] = dropdownValueselectsta; + + }); + }), + const SizedBox(height: 16), + + + _buildMultiSelectDropdownselectstamul('Select selectstamul', selectstamulList, selectedselectstamul, (values) { + setState(() { + selectedselectstamul = values; + formData['selectstamul'] = selectedselectstamul.toString(); + }); + }), + + + ReusableDropdownField( + label: "Select dynmi", + options: selectdyaItems, // Your dynamic list + + + + valueField: 'id', // ✅ API response key for ID + uiField: 'namem', // ✅ API response key for Name + + + + + value: selectedselectdyaValue, + onChanged: (newValue) { + setState(() { + selectedselectdyaValue = newValue!; + }); + }, + onSaved: (newValue) { + formData['selectdya'] = selectedselectdyaValue?.isEmpty ?? true + ? 'no value' + : newValue!; + }, + ), + const SizedBox(width: 16), + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "selectdyamul", style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF4A4A4A), // BlueGray900 color ), ), - ), - const SizedBox(height: 16), // Add space between elements - - - - buildFormField('namemmm'), - - - - ], + SizedBox(height: 10), + FutureBuilder>( + future: _loadselectdyamulItems(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + final selectdyamulItems = snapshot.data ?? []; + return Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } else { + return selectdyamulItems.where((String option) { + return option.toLowerCase().contains(textEditingValue.text.toLowerCase()); + }); + } + }, + onSelected: (String selection) { + setState(() { + if (selectedselectdyamulValue.contains(selection)) { + selectedselectdyamulValue.remove(selection); + } else { + selectedselectdyamulValue.add(selection); + } + formData['selectdyamul'] = selectedselectdyamulValue.join(','); + }); + }, + fieldViewBuilder: (BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted) { + return TextField( + controller: textEditingController, + focusNode: focusNode, + decoration: InputDecoration( + hintText: "Enter selectdyamul", + filled: true, + fillColor: Colors.grey[200], + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide.none, + ), + contentPadding: EdgeInsets.symmetric( + vertical: 15, horizontal: 20), + ), + ); + }, + ); + } else { + return Center(child: CircularProgressIndicator()); + } + }, + ), + SizedBox(height: 16), + Text( + 'Selected Values:', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + Wrap( + spacing: 8.0, + children: selectedselectdyamulValue.map((value) { + return Chip( + label: Text(value), + deleteIcon: Icon(Icons.clear), + onDeleted: () { + setState(() { + selectedselectdyamulValue.remove(value); + formData['selectdyamul'] = selectedselectdyamulValue.join(','); + }); + }, + ); + }).toList(), + ), + ], + ), ), - ), + + FutureBuilder>>( + future: _loadselectautoItems(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } + + final selectauto = snapshot.data ?? []; + final fieldNameItems = selectauto + .map((e) => e['name']) + .where((name) => name != null) + .cast() + .toList(); + + return Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } else { + return fieldNameItems.where((String option) { + return option.toLowerCase().contains( + textEditingValue.text.toLowerCase()); + }); + } + }, + onSelected: (String selection) { + setState(() { + + + selectedselectautoValue = selection; + selectedselectautoId = selectauto.firstWhere((element) => + element['namem'] == selection)['id']; + + + formData['selectauto'] = selectedselectautoId; + }); + }, + fieldViewBuilder: (BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted) { + return TextFormField( + controller: textEditingController, + focusNode: focusNode, + decoration: InputDecoration( + contentPadding: + const EdgeInsets.symmetric(horizontal: 16.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide( + color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide( + color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide( + color: Colors.deepPurpleAccent, width: 2), + ), + hintText: 'Select selectauto', + hintStyle: TextStyle(color: Colors.grey[600]), + ), + ); + }, + ); + } else if (snapshot.connectionState == + ConnectionState.waiting) { + return CircularProgressIndicator(); + } else { + return Text('Loading...'); + } + }, + ), + const SizedBox(height: 16), + Text('Selected Value: $selectedselectautoValue'), + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "selectautomul", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF4A4A4A), // BlueGray900 color + ), + ), + SizedBox(height: 10), + FutureBuilder>( + future: _loadselectautomulItems(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + final selectautomulItems = snapshot.data ?? []; + return Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } else { + return selectautomulItems.where((String option) { + return option.toLowerCase().contains(textEditingValue.text.toLowerCase()); + }); + } + }, + onSelected: (String selection) { + setState(() { + if (selectedselectautomulValue.contains(selection)) { + selectedselectautomulValue.remove(selection); + } else { + selectedselectautomulValue.add(selection); + } + formData['selectautomul'] = selectedselectautomulValue.join(','); + }); + }, + fieldViewBuilder: (BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted) { + return TextField( + controller: textEditingController, + focusNode: focusNode, + decoration: InputDecoration( + hintText: "Enter selectautomul", + filled: true, + fillColor: Colors.grey[200], + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide.none, + ), + contentPadding: EdgeInsets.symmetric( + vertical: 15, horizontal: 20), + ), + ); + }, + ); + } else { + return Center(child: CircularProgressIndicator()); + } + }, + ), + SizedBox(height: 16), + Text( + 'Selected Values:', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + Wrap( + spacing: 8.0, + children: selectedselectautomulValue.map((value) { + return Chip( + label: Text(value), + deleteIcon: Icon(Icons.clear), + onDeleted: () { + setState(() { + selectedselectautomulValue.remove(value); + formData['selectautomul'] = selectedselectautomulValue.join(','); + }); + }, + ); + }).toList(), + ), + ], + ), + ), + +Container( + padding: EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(8.0), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 4, + offset: Offset(0, 2), + ), + ], + ), + child: Column( + children: [ + Text( + "Fieldgg", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 16), + + +ReusableTextField( + onSaved:(value) => formData['bar_code'] = value , + label:"Enter Bar_code", + // ValidationProperties +), + + SizedBox(height: 16), + + + +ReusableTextField( + onSaved:(value) => formData['qr_code'] = value , + label:"Enter Qr_code", + // ValidationProperties +), + + SizedBox(height: 16), + + + SizedBox(height: 16), + ], + ), +), +const SizedBox(height: 16), + + + + + + +ReusableTextField( + controller: numbersController, + + onSaved:(value) => formData['numbers'] = value , + label: "Enter Numbers", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // ValidationProperties +), + +SizedBox(height: 16), + +ReusableTextField( + controller: numberkController, + + onSaved:(value) => formData['numberk'] = value , + label: "Enter Numberk", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // ValidationProperties +), + +SizedBox(height: 16), + + + const SizedBox(height: 8.0), + DropdownButtonFormField( + value: calculateaddOperator, + items: calculateaddoperators.map((String operator) { + return DropdownMenuItem( + value: operator, + child: Text(operator), + ); + }).toList(), + onChanged: (value) { + setState(() { + calculateaddOperator = value!; + print(calculateaddOperator.toString()); + print("value-- $value"); + }); + }, + decoration: const InputDecoration(labelText: 'Operator'), + ), + const SizedBox(height: 20.0), + ElevatedButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + _formKey.currentState?.save(); // Save the form fields + + } + calculatecalculateaddResult(); + setState(() { + + }); + }, + child: const Text('Calculate'), + ), + const SizedBox(height: 20.0), + Text(calculateaddresult,style: TextStyle(color: Colors.black),), const SizedBox(width: 8), CustomButton( @@ -173,6 +1025,28 @@ Padding( + + + + + + + + + + + + + + + + + + + + + + try { print(formData); @@ -181,6 +1055,28 @@ Padding( + + + + + + + + + + + + + + + + + + + + + + Navigator.pop(context); @@ -211,6 +1107,74 @@ Padding( + + + + + + + + + + + + + + + SizedBox(height: 16), + +FutureBuilder>>( + future: _dataggdataFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center(child: Text('No data available..')); + } else { + final keys = snapshot.data!.first.keys.toList(); + + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columnSpacing: 30, + headingRowColor: MaterialStateColor.resolveWith((states) => Colors.blue.shade100), + dataRowColor: MaterialStateColor.resolveWith((states) => Colors.white), + dividerThickness: 0.5, + columns: keys.map( + (key) => DataColumn( + label: Text( + key, + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ), + ), + ) + .toList(), + rows: snapshot.data!.map((item) { + return DataRow(cells: keys.map((key) { + return DataCell( + Text( + item[key].toString(), + style: const TextStyle(fontSize: 14), + ), + ); + }).toList()); + }).toList(), + ), + ); + } + }, + ), + SizedBox(height: 16), + + + + + + + + ], ), ), diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_entity_list_screen.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_entity_list_screen.dart index 529524c..ceeea52 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_entity_list_screen.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_entity_list_screen.dart @@ -53,6 +53,28 @@ class _testm_entity_list_screenState extends State { + + + + + + + + + + + + + + + + + + + + + + Future fetchwithoutpaging() async { try { final provider = @@ -178,7 +200,79 @@ Future fetchEntities() async { - entity['child'].toString().toLowerCase().contains(keyword.toLowerCase()) + entity['selectsta'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['selectstamul'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['selectdya'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['selectdyamul'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['selectautotypename'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['selectautomul'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + entity['bar_code'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + + entity['qr_code'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + + + + entity['datagg'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['numbers'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['numberk'].toString().toLowerCase().contains(keyword.toLowerCase()) + + ).toList(); @@ -259,6 +353,28 @@ onTapArrowleft1(BuildContext context) { + + + + + + + + + + + + + + + + + + + + + + ], ), ], ), @@ -516,6 +632,255 @@ onTapArrowleft1(BuildContext context) { ), + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectsta : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectsta'].toString() ?? 'No selectsta Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectstamul : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectstamul'].toString() ?? 'No selectstamul Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectdya : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectdya'].toString() ?? 'No selectdya Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectdyamul : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectdyamul'].toString() ?? 'No selectdyamul Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectauto : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectautotypename'] ?? 'No selectauto Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectautomul : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectautomul'].toString() ?? 'No selectautomul Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Bar_code : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['bar_code'].toString() ?? 'No Bar_code Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Qr_code : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['qr_code'].toString() ?? 'No Qr_code Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Numbers : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['numbers'].toString() ?? 'No Numbers Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Numberk : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['numberk'].toString() ?? 'No Numberk Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_update_entity_screen.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_update_entity_screen.dart index 1768797..43f5fff 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_update_entity_screen.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/TestmView/Testm_update_entity_screen.dart @@ -38,39 +38,203 @@ class _testmUpdateEntityScreenState extends State { -Widget buildFormField(String fieldOption) { + + var selectedselectsta; // Initialize with the default value \n); + List selectstaList = [ + + + 'q', + + + + + 'b', + + + + ]; + +Widget _buildDropdownselectsta(String label, List options, String? value, void Function(String?) onChanged) { return Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: Card( - elevation: 4, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - child: Padding( - padding: const EdgeInsets.all(12.0), - child: TextFormField( - initialValue: widget.entity['child'] != null && - widget.entity['child'][fieldOption] != null - ? widget.entity['child'][fieldOption] - : '', - decoration: InputDecoration( - labelText: fieldOption, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - ), - ), -onSaved: (value) { - if (widget.entity['child'] == null) { - widget.entity['child'] = {}; - } - widget.entity['child'][fieldOption] = value; - }, - ), - ), - ), - ); + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration(labelText: label, + border: OutlineInputBorder(), +), + value: value, + onChanged: onChanged, + items: options.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ); } + List selectedselectstamul = []; + List selectstamulList = [ + + + 'q', + + + + 'b', + + + + 'c', + + + ]; + +Widget _buildDropdownselectstamul( + String label, + List options, + String? selectedValue, + String fieldName, + void Function(String?) onChanged, +) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + border: OutlineInputBorder(), + ), + value: selectedValue, + items: options.map((String option) { + return DropdownMenuItem( + value: option, + child: Text(option), + ); + }).toList(), + onChanged: onChanged, + onSaved: (value) { + // Save selected value to entity or form data + widget.entity['selectstamul'] = value; + }, + ), + ); +} + + +List> selectdyaItems = []; + var selectedselectdyaValue; + +List selectdyamulItems = []; + List selectedselectdyamulValue = []; + + TextEditingController selectdyamulController = TextEditingController(); + + GlobalKey> selectdyamulkey = GlobalKey(); + +Future> _loadselectdyamulItems() async { +final provider = + Provider.of(context, listen: false); + try { + final selectTdata = await provider.getselectdyamul(); + print('selectdyamul data is : $selectTdata'); + + if (selectTdata != null && selectTdata.isNotEmpty) { + List datareturned = []; + + + selectTdata.forEach((element) { +if (element['namem'] != null) + + datareturned.add(element['namem']); + }); + + + return datareturned; + } else { + print('selectdyamul data is null or empty'); + return []; + } + } catch (e) { + print('Failed to load selectdyamul items: $e'); + return []; + } +} + + + List> selectautoItems = []; + int? selectedselectautoId; // to store selected state id + + String selectedselectautoValue = ''; // Use nullable type Future _load + + TextEditingController selectautoController = TextEditingController(); + GlobalKey> selectautokey = GlobalKey(); + Future>> _loadselectautoItems() async { +final provider = + Provider.of(context, listen: false); + + try { + final selectTdata = await provider.getselectauto(); + print('selectauto data is : $selectTdata'); + + if (selectTdata != null && selectTdata.isNotEmpty) { + selectautoItems = selectTdata; + + print('data ret $selectautoItems'); + return selectautoItems; + } else { + print('selectauto data is null or empty'); + return []; + } + } catch (e) { + print('Failed to load selectauto items: $e'); + return []; + } + } + +List selectautomulItems = []; + List selectedselectautomulValue = []; + + TextEditingController selectautomulController = TextEditingController(); + GlobalKey> selectautomulkey = GlobalKey(); +Future> _loadselectautomulItems() async { +final provider = + Provider.of(context, listen: false); + try { + final selectTdata = await provider.getselectautomul(); + print('selectautomul data is : $selectTdata'); + + if (selectTdata != null && selectTdata.isNotEmpty) { + List datareturned = []; + + + selectTdata.forEach((element) { +if (element['namem'] != null) + datareturned.add(element['namem']); + }); + + + return datareturned; + } else { + print('selectautomul data is null or empty'); + return []; + } + } catch (e) { + print('Failed to load selectautomul items: $e'); + return []; + } +} + + + + + + + + + + + + @override @@ -79,6 +243,60 @@ onSaved: (value) { final provider = Provider.of(context, listen: false); + selectedselectsta = widget.entity['selectsta'] ?? selectstaList[0] ; // Initialize with the default value + + print(json.decode(widget.entity['selectstamul'])['selectstamul'].toString()); + selectedselectstamul= json.decode(widget.entity['selectstamul'])['selectstamul']; + print('selected selectstamulis ... $selectedselectstamul'); + + provider.getselectdya().then((value) { + setState(() { + selectdyaItems = value; // ✅ Update list only when data is fetched + selectedselectdyaValue = widget.entity['selectdya'] ?? null; + + // ✅ Fetch the stored ID and convert it to a String + var entityValue = widget.entity['selectdya']; + if (entityValue != null) { + selectedselectdyaValue = entityValue.toString(); + } else { + selectedselectdyaValue = null; + } + + }); + + print('Updated selectdyaItems: $selectdyaItems'); + print('Selected Value: $selectedselectdyaValue'); + + }).catchError((error) { + print('Error fetching data: $error'); + }); + +String? selectdyamulString = widget.entity['selectdyamul']; +if (selectdyamulString != null) { + + selectdyamulString = selectdyamulString.substring(0, selectdyamulString.length); +selectedselectdyamulValue = selectdyamulString.split(', '); +} + +selectedselectautoValue = widget.entity['selectautoname']?? 'no data' ; + + String? selectautomulString = widget.entity['selectautomul']; + +if (selectautomulString != null) { + selectautomulString = selectautomulString.substring(0, selectautomulString.length ); +selectedselectautomulValue = selectautomulString.split(', '); +} + + + + + + + + + + + } @@ -105,6 +323,28 @@ onSaved: (value) { + + + + + + + + + + + + + + + + + + + + + + ], ), body: SingleChildScrollView( @@ -127,32 +367,373 @@ onSaved: (value) { SizedBox(height: 16), -Padding( - padding: const EdgeInsets.all(16.0), - child: Column( + + + _buildDropdownselectsta( + 'selectsta', + selectstaList, + selectedselectsta, + (value) { + setState(() { + selectedselectsta = value; + widget.entity['selectsta'] = value; // Save selected value to entity + }); + }, + ), + + + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildDropdownselectstamul( + 'Select selectstamul', + selectstamulList, + widget.entity['selectstamul'], // Use entity for initial values + 'fieldName', // fieldName used to identify the value in state + (value) { + setState(() { + widget.entity['selectstamul'] = value; // Save selected values to entity + }); + }, + ), + SizedBox(height: 16), + ElevatedButton( + onPressed: () { + // Handle save/update logic + print('Updated values: ${widget.entity['selectstamul']}'); + }, + child: Text('Save'), + ), + ], + ), + + + ReusableDropdownField( + label: "Select dynmi", + options: selectdyaItems, // Your dynamic list + + + + valueField: 'id', // ✅ API response key for ID + uiField: 'namem', // ✅ API response key for Name + + + + + value: selectedselectdyaValue, + onChanged: (newValue) { + setState(() { + selectedselectdyaValue = newValue!; + }); + }, + onSaved: (newValue) { + widget.entity['selectdya'] = selectedselectdyaValue?.isEmpty ?? true + ? 'no value' + : newValue!; + }, + ), + const SizedBox(width: 16), + +FutureBuilder>( + future: _loadselectdyamulItems(), + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + final selectdyamulItems = snapshot.data ?? []; + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox( - height: 20, - child: Text( - 'Child', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), + Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } else { + List matches = []; + matches.addAll(selectdyamulItems); + matches.retainWhere((s) => + s.toLowerCase().contains(textEditingValue.text.toLowerCase())); + return matches; + } + }, + onSelected: (String selection) { + setState(() { + if (selectedselectdyamulValue.contains(selection)) { + selectedselectdyamulValue.remove(selection); + } else { + selectedselectdyamulValue.add(selection); + } + widget.entity['selectdyamul'] = selectedselectdyamulValue.join(','); + }); + }, ), - const SizedBox(height: 16), // Add space between elements - - - - buildFormField('namemmm'), - - + SizedBox(height: 16), + Text(selectedselectdyamulValue.join(',')), ], + ); + } else { + return Center(child: CircularProgressIndicator()); + } + }, +), + + + FutureBuilder>>( + future: _loadselectautoItems(), + builder: (context, + AsyncSnapshot>> snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } + + final selectauto = snapshot.data ?? []; + final fieldNameItems = selectauto + + + .map((e) => e['name']) + + + .where((name) => name != null) + .cast() + .toList(); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Autocomplete( + optionsBuilder: + (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } else { + List matches = []; + matches.addAll(fieldNameItems); + matches.retainWhere((s) => s + .toLowerCase() + .contains( + textEditingValue.text.toLowerCase())); + return matches; + } + }, + onSelected: (String selection) { + setState(() { + selectedselectautoValue = selection; + + selectedselectautoId = selectauto.firstWhere( + (element) => + + + element['namem'] == selection)['id']; + + + widget.entity['selectauto'] = + selectedselectautoId; + }); + }, + fieldViewBuilder: (BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted) { + return TextFormField( + controller: textEditingController, + focusNode: focusNode, + decoration: InputDecoration( + contentPadding: const EdgeInsets.symmetric( + horizontal: 16.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide( + color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide( + color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide( + color: Colors.deepPurpleAccent, + width: 2), + ), + hintText: 'Select selectauto', + hintStyle: TextStyle(color: Colors.grey[600]), + ), + ); + }, + ), + SizedBox(height: 16), + Text( + 'Selected Value: ${selectedselectautoValue.isNotEmpty ? selectedselectautoValue : "None"}'), + ], + ); + } else { + return Center(child: CircularProgressIndicator()); + } + }, + ), + +FutureBuilder>( + future: _loadselectautomulItems(), + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + final selectautomulItems = snapshot.data ?? []; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } else { + List matches = []; + matches.addAll(selectautomulItems); + matches.retainWhere((s) => + s.toLowerCase().contains(textEditingValue.text.toLowerCase())); + return matches; + } + }, + onSelected: (String selection) { + setState(() { + if (selectedselectautomulValue.contains(selection)) { + selectedselectautomulValue.remove(selection); + } else { + selectedselectautomulValue.add(selection); + } + widget.entity['selectautomul'] = selectedselectautomulValue.join(','); + }); + }, + ), + SizedBox(height: 16), + Text(selectedselectautomulValue.join(',')), + ], + ); + } else { + return Center(child: CircularProgressIndicator()); + } + }, +), + + +Container( + padding: EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(8.0), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 4, + offset: Offset(0, 2), ), - ), + ], + ), + child: Column( + children: [ + Text( + "Fieldgg", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 16), + + + + SizedBox(height: 16), + TextFormField( + initialValue: widget.entity['bar_code'], + decoration: InputDecoration( + labelText: 'fieldgg bar_code', + ), + onChanged: (value) { + setState(() { + widget.entity['bar_code'] = value; + }); + }, + ), + + + + SizedBox(height: 16), + TextFormField( + initialValue: widget.entity['qr_code'], + decoration: InputDecoration( + labelText: 'fieldgg qr_code', + ), + onChanged: (value) { + setState(() { + widget.entity['qr_code'] = value; + }); + }, + ), + + + SizedBox(height: 16), + ], + ), +), +const SizedBox(height: 16), + + + + Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + + ElevatedButton( + onPressed: () { + // Save changes logic here + + + Navigator.pop(context); + // Implement API call to update data + }, + child: Text('Save'), + ), + ], + ), + ), + + + + ReusableTextField( + initialValue: widget.entity['numbers'].toString(), + onSaved: (value) => widget.entity['numbers']= value, + label: "Enter Numbers", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + + ReusableTextField( + initialValue: widget.entity['numberk'].toString(), + onSaved: (value) => widget.entity['numberk']= value, + label: "Enter Numberk", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + + CustomButton( @@ -166,6 +747,28 @@ Padding( + + + + + + + + + + + + + + + + + + + + + + try { await provider.updateEntity( @@ -175,6 +778,28 @@ Padding( + + + + + + + + + + + + + + + + + + + + + + Navigator.pop(context); diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_Repo/Testm_repo_screen.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_Repo/Testm_repo_screen.dart index a911882..1528c40 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_Repo/Testm_repo_screen.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_Repo/Testm_repo_screen.dart @@ -63,4 +63,66 @@ class TestmRepoScreen { + + + Future getselectdya() async { + try { + String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1"; + final response = await _helper.getGetApiResponse(apiUrl); + return response; + } catch (e) { + throw Exception('Failed to Get: $e'); + } + } + + Future getselectdyamul() async { + try { + String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1"; + final response = await _helper.getGetApiResponse(apiUrl); + return response; + } catch (e) { + throw Exception('Failed to Get: $e'); + } + } + + Future getselectauto() async { + try { + String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1"; + final response = await _helper.getGetApiResponse(apiUrl); + return response; + } catch (e) { + throw Exception('Failed to Get: $e'); + } + } + + Future getselectautomul() async { + try { + String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1"; + final response = await _helper.getGetApiResponse(apiUrl); + return response; + } catch (e) { + throw Exception('Failed to Get: $e'); + } + } + + + + + + Future getdataggGrid() async { + try { + String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1"; + final response = await _helper.getGetApiResponse(apiUrl); + return response; + } catch (e) { + throw Exception('Failed to Upload datagg: $e'); + } + } + + + + + + + } diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_viewModel/Testm_view_model_screen.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_viewModel/Testm_view_model_screen.dart index 25a9f2c..edf4717 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_viewModel/Testm_view_model_screen.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/Entity/forma/Testm/Testm_viewModel/Testm_view_model_screen.dart @@ -102,4 +102,97 @@ class TestmViewModelScreen extends ChangeNotifier{ + + +List> selectdyaItems = []; + + Future>> getselectdya() async { + + try { + final value = await repo.getselectdya(); + selectdyaItems = (value as List) + .map((item) => item as Map) + .toList(); + + return selectdyaItems; + } catch (e) { + throw Exception('Failed to get all: $e'); + } + } + +List> selectdyamulItems = []; + + Future>> getselectdyamul() async { + + try { + final value = await repo.getselectdyamul(); + selectdyamulItems = (value as List) + .map((item) => item as Map) + .toList(); + + return selectdyamulItems; + } catch (e) { + throw Exception('Failed to get all: $e'); + } + } + +List> selectautoItems = []; + + Future>> getselectauto() async { + + try { + final value = await repo.getselectauto(); + selectautoItems = (value as List) + .map((item) => item as Map) + .toList(); + + return selectautoItems; + } catch (e) { + throw Exception('Failed to get all: $e'); + } + } + +List> selectautomulItems = []; + + Future>> getselectautomul() async { + + try { + final value = await repo.getselectautomul(); + selectautomulItems = (value as List) + .map((item) => item as Map) + .toList(); + + return selectautomulItems; + } catch (e) { + throw Exception('Failed to get all: $e'); + } + } + + + + + + late List> dataggdataFuture = + []; // Data from fetchData + + Future>> getdataggGrid() async { + + try { + final value = await repo.getdataggGrid(); + dataggdataFuture = (value as List) + .map((item) => item as Map) + .toList(); + + return dataggdataFuture; + } catch (e) { + throw Exception('Failed to get all: $e'); + } + } + + + + + + + } \ No newline at end of file diff --git a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart index 3cda430..e49cecc 100644 --- a/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart +++ b/testflutter26-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart @@ -1,5 +1,6 @@ -import '../../Entity/forma/Testm/TestmView/Testm_entity_list_screen.dart'; -import '../../Entity/forma/Testm/Testm_viewModel/Testm_view_model_screen.dart'; + +import '../../Entity/forma/Testm/TestmView/Testm_entity_list_screen.dart'; +import '../../Entity/forma/Testm/Testm_viewModel/Testm_view_model_screen.dart'; import 'package:base_project/utils/image_constant.dart'; import 'package:base_project/commans/widgets/custome_drawe_item.dart'; @@ -73,22 +74,24 @@ Navigator.pushNamed(context, RouteNames.changePasswordView); ), // NEW MENU -DrawerItem( - color: AppColors.primary, - icon: Icons.chat_bubble, - title: 'Testm', - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ChangeNotifierProvider( - create: (context) => TestmViewModelScreen(), - child: testm_entity_list_screen(), - ), - ), - ); - }, - ), + + +DrawerItem( +color: AppColors.primary, +icon: Icons.chat_bubble, +title: 'Testm', +onTap: () { +Navigator.push( +context, +MaterialPageRoute( +builder: (context) => ChangeNotifierProvider( +create: (context) => TestmViewModelScreen(), +child: testm_entity_list_screen(), +), +), +); +}, +), DrawerItem(