build_app
This commit is contained in:
parent
8959533ba9
commit
2159ad3ce5
@ -69,6 +69,21 @@ public class BuilderService {
|
||||
executeDump(true);
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
addCustomMenu( "Custom_setting","Custom_setting", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Vehicle_add_on","Vehicle_add_on", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Car_category","Car_category", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Office","Office", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Feature","Feature", "Transcations");
|
||||
|
||||
|
||||
|
||||
System.out.println("dashboard and menu inserted...");
|
||||
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Car_category;
|
||||
import com.realnet.taxi_rental.Services.Car_categoryService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Car_category")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Car_categoryController {
|
||||
@Autowired
|
||||
private Car_categoryService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Car_category")
|
||||
public Car_category Savedata(@RequestBody Car_category data) {
|
||||
Car_category save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Car_category/{id}")
|
||||
public Car_category update(@RequestBody Car_category data,@PathVariable Integer id ) {
|
||||
Car_category update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Car_category/getall/page")
|
||||
public Page<Car_category> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Car_category> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Car_category")
|
||||
public List<Car_category> getdetails() {
|
||||
List<Car_category> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Car_category")
|
||||
public List<Car_category> getallwioutsec() {
|
||||
List<Car_category> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Car_category/{id}")
|
||||
public Car_category getdetailsbyId(@PathVariable Integer id ) {
|
||||
Car_category get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Car_category/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting;
|
||||
import com.realnet.taxi_rental.Services.Custom_settingService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Custom_setting")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Custom_settingController {
|
||||
@Autowired
|
||||
private Custom_settingService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Custom_setting")
|
||||
public Custom_setting Savedata(@RequestBody Custom_setting data) {
|
||||
Custom_setting save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Custom_setting/{id}")
|
||||
public Custom_setting update(@RequestBody Custom_setting data,@PathVariable Integer id ) {
|
||||
Custom_setting update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Custom_setting/getall/page")
|
||||
public Page<Custom_setting> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Custom_setting> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Custom_setting")
|
||||
public List<Custom_setting> getdetails() {
|
||||
List<Custom_setting> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Custom_setting")
|
||||
public List<Custom_setting> getallwioutsec() {
|
||||
List<Custom_setting> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Custom_setting/{id}")
|
||||
public Custom_setting getdetailsbyId(@PathVariable Integer id ) {
|
||||
Custom_setting get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Custom_setting/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Feature;
|
||||
import com.realnet.taxi_rental.Services.FeatureService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Feature")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class FeatureController {
|
||||
@Autowired
|
||||
private FeatureService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Feature")
|
||||
public Feature Savedata(@RequestBody Feature data) {
|
||||
Feature save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Feature/{id}")
|
||||
public Feature update(@RequestBody Feature data,@PathVariable Integer id ) {
|
||||
Feature update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Feature/getall/page")
|
||||
public Page<Feature> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Feature> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Feature")
|
||||
public List<Feature> getdetails() {
|
||||
List<Feature> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Feature")
|
||||
public List<Feature> getallwioutsec() {
|
||||
List<Feature> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Feature/{id}")
|
||||
public Feature getdetailsbyId(@PathVariable Integer id ) {
|
||||
Feature get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Feature/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Office;
|
||||
import com.realnet.taxi_rental.Services.OfficeService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Office")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class OfficeController {
|
||||
@Autowired
|
||||
private OfficeService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Office")
|
||||
public Office Savedata(@RequestBody Office data) {
|
||||
Office save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Office/{id}")
|
||||
public Office update(@RequestBody Office data,@PathVariable Integer id ) {
|
||||
Office update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Office/getall/page")
|
||||
public Page<Office> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Office> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Office")
|
||||
public List<Office> getdetails() {
|
||||
List<Office> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Office")
|
||||
public List<Office> getallwioutsec() {
|
||||
List<Office> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Office/{id}")
|
||||
public Office getdetailsbyId(@PathVariable Integer id ) {
|
||||
Office get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Office/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on;
|
||||
import com.realnet.taxi_rental.Services.Vehicle_add_onService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Vehicle_add_on")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Vehicle_add_onController {
|
||||
@Autowired
|
||||
private Vehicle_add_onService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Vehicle_add_on")
|
||||
public Vehicle_add_on Savedata(@RequestBody Vehicle_add_on data) {
|
||||
Vehicle_add_on save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Vehicle_add_on/{id}")
|
||||
public Vehicle_add_on update(@RequestBody Vehicle_add_on data,@PathVariable Integer id ) {
|
||||
Vehicle_add_on update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Vehicle_add_on/getall/page")
|
||||
public Page<Vehicle_add_on> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Vehicle_add_on> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Vehicle_add_on")
|
||||
public List<Vehicle_add_on> getdetails() {
|
||||
List<Vehicle_add_on> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Vehicle_add_on")
|
||||
public List<Vehicle_add_on> getallwioutsec() {
|
||||
List<Vehicle_add_on> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Vehicle_add_on/{id}")
|
||||
public Vehicle_add_on getdetailsbyId(@PathVariable Integer id ) {
|
||||
Vehicle_add_on get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Vehicle_add_on/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Car_category;
|
||||
import com.realnet.taxi_rental.Services.Car_categoryService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Car_category")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_Car_categoryController {
|
||||
@Autowired
|
||||
private Car_categoryService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Car_category")
|
||||
public Car_category Savedata(@RequestBody Car_category data) {
|
||||
Car_category save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Car_category/{id}")
|
||||
public Car_category update(@RequestBody Car_category data,@PathVariable Integer id ) {
|
||||
Car_category update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Car_category/getall/page")
|
||||
public Page<Car_category> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Car_category> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Car_category")
|
||||
public List<Car_category> getdetails() {
|
||||
List<Car_category> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Car_category")
|
||||
public List<Car_category> getallwioutsec() {
|
||||
List<Car_category> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Car_category/{id}")
|
||||
public Car_category getdetailsbyId(@PathVariable Integer id ) {
|
||||
Car_category get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Car_category/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting;
|
||||
import com.realnet.taxi_rental.Services.Custom_settingService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Custom_setting")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_Custom_settingController {
|
||||
@Autowired
|
||||
private Custom_settingService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Custom_setting")
|
||||
public Custom_setting Savedata(@RequestBody Custom_setting data) {
|
||||
Custom_setting save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Custom_setting/{id}")
|
||||
public Custom_setting update(@RequestBody Custom_setting data,@PathVariable Integer id ) {
|
||||
Custom_setting update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Custom_setting/getall/page")
|
||||
public Page<Custom_setting> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Custom_setting> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Custom_setting")
|
||||
public List<Custom_setting> getdetails() {
|
||||
List<Custom_setting> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Custom_setting")
|
||||
public List<Custom_setting> getallwioutsec() {
|
||||
List<Custom_setting> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Custom_setting/{id}")
|
||||
public Custom_setting getdetailsbyId(@PathVariable Integer id ) {
|
||||
Custom_setting get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Custom_setting/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Feature;
|
||||
import com.realnet.taxi_rental.Services.FeatureService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Feature")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_FeatureController {
|
||||
@Autowired
|
||||
private FeatureService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Feature")
|
||||
public Feature Savedata(@RequestBody Feature data) {
|
||||
Feature save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Feature/{id}")
|
||||
public Feature update(@RequestBody Feature data,@PathVariable Integer id ) {
|
||||
Feature update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Feature/getall/page")
|
||||
public Page<Feature> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Feature> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Feature")
|
||||
public List<Feature> getdetails() {
|
||||
List<Feature> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Feature")
|
||||
public List<Feature> getallwioutsec() {
|
||||
List<Feature> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Feature/{id}")
|
||||
public Feature getdetailsbyId(@PathVariable Integer id ) {
|
||||
Feature get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Feature/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Office;
|
||||
import com.realnet.taxi_rental.Services.OfficeService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Office")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_OfficeController {
|
||||
@Autowired
|
||||
private OfficeService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Office")
|
||||
public Office Savedata(@RequestBody Office data) {
|
||||
Office save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Office/{id}")
|
||||
public Office update(@RequestBody Office data,@PathVariable Integer id ) {
|
||||
Office update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Office/getall/page")
|
||||
public Page<Office> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Office> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Office")
|
||||
public List<Office> getdetails() {
|
||||
List<Office> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Office")
|
||||
public List<Office> getallwioutsec() {
|
||||
List<Office> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Office/{id}")
|
||||
public Office getdetailsbyId(@PathVariable Integer id ) {
|
||||
Office get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Office/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on;
|
||||
import com.realnet.taxi_rental.Services.Vehicle_add_onService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Vehicle_add_on")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_Vehicle_add_onController {
|
||||
@Autowired
|
||||
private Vehicle_add_onService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Vehicle_add_on")
|
||||
public Vehicle_add_on Savedata(@RequestBody Vehicle_add_on data) {
|
||||
Vehicle_add_on save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Vehicle_add_on/{id}")
|
||||
public Vehicle_add_on update(@RequestBody Vehicle_add_on data,@PathVariable Integer id ) {
|
||||
Vehicle_add_on update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Vehicle_add_on/getall/page")
|
||||
public Page<Vehicle_add_on> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Vehicle_add_on> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Vehicle_add_on")
|
||||
public List<Vehicle_add_on> getdetails() {
|
||||
List<Vehicle_add_on> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Vehicle_add_on")
|
||||
public List<Vehicle_add_on> getallwioutsec() {
|
||||
List<Vehicle_add_on> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Vehicle_add_on/{id}")
|
||||
public Vehicle_add_on getdetailsbyId(@PathVariable Integer id ) {
|
||||
Vehicle_add_on get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Vehicle_add_on/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Car_category extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Custom_setting extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
private int yound_driver_surcharge;
|
||||
|
||||
private int free_km;
|
||||
|
||||
private int extra_km_charge;
|
||||
|
||||
private int gst_rate;
|
||||
|
||||
private int pst_rate;
|
||||
|
||||
private int age_threshold;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Feature extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Office extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Vehicle_add_on extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
private String icon;
|
||||
|
||||
private int price_per_day;
|
||||
|
||||
private int price_per_trip;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Car_category;
|
||||
|
||||
@Repository
|
||||
public interface Car_categoryRepository extends JpaRepository<Car_category, Integer> {
|
||||
|
||||
@Query(value = "select * from car_category where created_by=?1", nativeQuery = true)
|
||||
List<Car_category> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from car_category where created_by=?1", nativeQuery = true)
|
||||
Page<Car_category> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting;
|
||||
|
||||
@Repository
|
||||
public interface Custom_settingRepository extends JpaRepository<Custom_setting, Integer> {
|
||||
|
||||
@Query(value = "select * from custom_setting where created_by=?1", nativeQuery = true)
|
||||
List<Custom_setting> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from custom_setting where created_by=?1", nativeQuery = true)
|
||||
Page<Custom_setting> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Feature;
|
||||
|
||||
@Repository
|
||||
public interface FeatureRepository extends JpaRepository<Feature, Integer> {
|
||||
|
||||
@Query(value = "select * from feature where created_by=?1", nativeQuery = true)
|
||||
List<Feature> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from feature where created_by=?1", nativeQuery = true)
|
||||
Page<Feature> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Office;
|
||||
|
||||
@Repository
|
||||
public interface OfficeRepository extends JpaRepository<Office, Integer> {
|
||||
|
||||
@Query(value = "select * from office where created_by=?1", nativeQuery = true)
|
||||
List<Office> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from office where created_by=?1", nativeQuery = true)
|
||||
Page<Office> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on;
|
||||
|
||||
@Repository
|
||||
public interface Vehicle_add_onRepository extends JpaRepository<Vehicle_add_on, Integer> {
|
||||
|
||||
@Query(value = "select * from vehicle_add_on where created_by=?1", nativeQuery = true)
|
||||
List<Vehicle_add_on> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from vehicle_add_on where created_by=?1", nativeQuery = true)
|
||||
Page<Vehicle_add_on> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.Car_categoryRepository;
|
||||
import com.realnet.taxi_rental.Entity.Car_category
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Car_categoryService {
|
||||
@Autowired
|
||||
private Car_categoryRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Car_category Savedata(Car_category data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Car_category save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Car_category> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Car_category> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Car_category> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Car_category getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Car_category update(Car_category data,Integer id) {
|
||||
Car_category old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
final Car_category test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,153 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.Custom_settingRepository;
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Custom_settingService {
|
||||
@Autowired
|
||||
private Custom_settingRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Custom_setting Savedata(Custom_setting data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Custom_setting save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Custom_setting> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Custom_setting> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Custom_setting> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Custom_setting getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Custom_setting update(Custom_setting data,Integer id) {
|
||||
Custom_setting old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
old.setYound_driver_surcharge(data.getYound_driver_surcharge());
|
||||
|
||||
old.setFree_km(data.getFree_km());
|
||||
|
||||
old.setExtra_km_charge(data.getExtra_km_charge());
|
||||
|
||||
old.setGst_rate(data.getGst_rate());
|
||||
|
||||
old.setPst_rate(data.getPst_rate());
|
||||
|
||||
old.setAge_threshold(data.getAge_threshold());
|
||||
|
||||
final Custom_setting test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,93 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.FeatureRepository;
|
||||
import com.realnet.taxi_rental.Entity.Feature
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FeatureService {
|
||||
@Autowired
|
||||
private FeatureRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Feature Savedata(Feature data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Feature save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Feature> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Feature> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Feature> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Feature getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Feature update(Feature data,Integer id) {
|
||||
Feature old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
final Feature test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,93 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.OfficeRepository;
|
||||
import com.realnet.taxi_rental.Entity.Office
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class OfficeService {
|
||||
@Autowired
|
||||
private OfficeRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Office Savedata(Office data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Office save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Office> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Office> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Office> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Office getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Office update(Office data,Integer id) {
|
||||
Office old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
final Office test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.Vehicle_add_onRepository;
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Vehicle_add_onService {
|
||||
@Autowired
|
||||
private Vehicle_add_onRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Vehicle_add_on Savedata(Vehicle_add_on data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Vehicle_add_on save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Vehicle_add_on> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Vehicle_add_on> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Vehicle_add_on> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Vehicle_add_on getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Vehicle_add_on update(Vehicle_add_on data,Integer id) {
|
||||
Vehicle_add_on old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
old.setIcon(data.getIcon());
|
||||
|
||||
old.setPrice_per_day(data.getPrice_per_day());
|
||||
|
||||
old.setPrice_per_trip(data.getPrice_per_trip());
|
||||
|
||||
final Vehicle_add_on test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
10
tesitest1-fdb-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
10
tesitest1-fdb-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE fdb.Feature(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE fdb.Office(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE fdb.Car_category(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE fdb.Vehicle_add_on(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), icon VARCHAR(400), price_per_day int, price_per_trip int, name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE fdb.Custom_setting(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), pst_rate int, age_threshold int, free_km int, gst_rate int, yound_driver_surcharge int, extra_km_charge int, name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class Car_categoryApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Car_category/Car_category');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Car_category/Car_category/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Car_category/Car_category', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Car_category/Car_category/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Car_category/Car_category/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Car_category_viewModel/Car_category_view_model_screen.dart';
|
||||
import 'Car_category_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Car_categoryCreateEntityScreen extends StatefulWidget {
|
||||
const Car_categoryCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_Car_categoryCreateEntityScreenState createState() => _Car_categoryCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _Car_categoryCreateEntityScreenState extends State<Car_categoryCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Car_categoryViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: Car_categoryFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Car_category',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Car_category_viewModel/Car_category_view_model_screen.dart';
|
||||
import 'Car_category_update_entity_screen.dart';
|
||||
|
||||
class Car_categoryDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const Car_categoryDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<Car_categoryDetailsScreen> createState() => _Car_categoryDetailsScreenState();
|
||||
}
|
||||
|
||||
class _Car_categoryDetailsScreenState extends State<Car_categoryDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Car_categoryViewModelScreen(),
|
||||
child: Car_categoryUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Car_category?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Car_categoryViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Car_category',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Car_category_create_entity_screen.dart';
|
||||
import 'Car_category_update_entity_screen.dart';
|
||||
import '../Car_category_viewModel/Car_category_view_model_screen.dart';
|
||||
import 'Car_category_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Car_category_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Car_category_entity_list_screenState createState() => _Car_category_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Car_category_entity_list_screenState extends State<Car_category_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Car_categoryViewModelScreen(),
|
||||
child: const Car_categoryCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Car_categoryViewModelScreen(),
|
||||
child: Car_categoryUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Car_categoryViewModelScreen(),
|
||||
child: Car_categoryDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Car_category?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Car_categoryViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchcar_category(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Car_category',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Car_category_viewModel/Car_category_view_model_screen.dart';/// Field definitions for Car_category entity
|
||||
/// This defines the structure and validation for Car_category forms
|
||||
class Car_categoryFields {
|
||||
/// Get field definitions for Car_category entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Car_category_viewModel/Car_category_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Car_category_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class Car_categoryUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
Car_categoryUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_Car_categoryUpdateEntityScreenState createState() => _Car_categoryUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _Car_categoryUpdateEntityScreenState extends State<Car_categoryUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Car_categoryViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = Car_categoryFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Car_category',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<Car_categoryViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class Car_categoryRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Car_category/Car_category';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,305 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Car_category_Repo/Car_category_repo_screen.dart';
|
||||
|
||||
class Car_categoryViewModelScreen extends ChangeNotifier{
|
||||
final Car_categoryRepoScreen repo = Car_categoryRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _car_categoryList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get car_categoryList => _car_categoryList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get car_category list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_car_categoryList = response.data ?? [];
|
||||
_filteredList = List.from(_car_categoryList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch car_category list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch car_category list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get car_category list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_car_categoryList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_car_categoryList = newItems;
|
||||
} else {
|
||||
_car_categoryList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_car_categoryList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Car_category list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch car_category list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create Car_category
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'car_category created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Car_category');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Car_category',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create car_category: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Car_category: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update car_category
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Car_category updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _car_categoryList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_car_categoryList[index] = response.data!;
|
||||
_filteredList = List.from(_car_categoryList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Car_category');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Car_category',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update car_category: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Car_category: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete car_category
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Car_category deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_car_categoryList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_car_categoryList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Car_category');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Car_category',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete car_category: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Car_category: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search car_category
|
||||
void searchcar_category(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_car_categoryList);
|
||||
} else {
|
||||
_filteredList = _car_categoryList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_car_categoryList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class Custom_settingApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Custom_setting/Custom_setting');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Custom_setting/Custom_setting/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Custom_setting/Custom_setting', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Custom_setting/Custom_setting/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Custom_setting/Custom_setting/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
import 'Custom_setting_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Custom_settingCreateEntityScreen extends StatefulWidget {
|
||||
const Custom_settingCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_Custom_settingCreateEntityScreenState createState() => _Custom_settingCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _Custom_settingCreateEntityScreenState extends State<Custom_settingCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Custom_settingViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: Custom_settingFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Custom_setting',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
import 'Custom_setting_update_entity_screen.dart';
|
||||
|
||||
class Custom_settingDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const Custom_settingDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<Custom_settingDetailsScreen> createState() => _Custom_settingDetailsScreenState();
|
||||
}
|
||||
|
||||
class _Custom_settingDetailsScreenState extends State<Custom_settingDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: Custom_settingUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Custom_setting?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Custom_settingViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Custom_setting',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'yound_driver_surcharge', 'label': 'yound driver surcharge', 'type': 'number'},
|
||||
|
||||
{'key': 'free_km', 'label': 'free km', 'type': 'number'},
|
||||
|
||||
{'key': 'extra_km_charge', 'label': 'Extra km charge', 'type': 'number'},
|
||||
|
||||
{'key': 'gst_rate', 'label': 'GST rate', 'type': 'number'},
|
||||
|
||||
{'key': 'pst_rate', 'label': 'PST rate', 'type': 'number'},
|
||||
|
||||
{'key': 'age_threshold', 'label': 'Age Threshold', 'type': 'number'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Custom_setting_create_entity_screen.dart';
|
||||
import 'Custom_setting_update_entity_screen.dart';
|
||||
import '../Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
import 'Custom_setting_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Custom_setting_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Custom_setting_entity_list_screenState createState() => _Custom_setting_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Custom_setting_entity_list_screenState extends State<Custom_setting_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: const Custom_settingCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: Custom_settingUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: Custom_settingDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Custom_setting?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Custom_settingViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchcustom_setting(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Custom_setting',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'yound_driver_surcharge', 'label': 'yound driver surcharge', 'type': 'number'},
|
||||
|
||||
{'key': 'free_km', 'label': 'free km', 'type': 'number'},
|
||||
|
||||
{'key': 'extra_km_charge', 'label': 'Extra km charge', 'type': 'number'},
|
||||
|
||||
{'key': 'gst_rate', 'label': 'GST rate', 'type': 'number'},
|
||||
|
||||
{'key': 'pst_rate', 'label': 'PST rate', 'type': 'number'},
|
||||
|
||||
{'key': 'age_threshold', 'label': 'Age Threshold', 'type': 'number'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,130 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Custom_setting_viewModel/Custom_setting_view_model_screen.dart';/// Field definitions for Custom_setting entity
|
||||
/// This defines the structure and validation for Custom_setting forms
|
||||
class Custom_settingFields {
|
||||
/// Get field definitions for Custom_setting entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'yound_driver_surcharge',
|
||||
label: 'yound driver surcharge',
|
||||
hint: 'Enter yound driver surcharge',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'free_km',
|
||||
label: 'free km',
|
||||
hint: 'Enter free km',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'extra_km_charge',
|
||||
label: 'Extra km charge',
|
||||
hint: 'Enter Extra km charge',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'gst_rate',
|
||||
label: 'GST rate',
|
||||
hint: 'Enter GST rate',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'pst_rate',
|
||||
label: 'PST rate',
|
||||
hint: 'Enter PST rate',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'age_threshold',
|
||||
label: 'Age Threshold',
|
||||
hint: 'Enter Age Threshold',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Custom_setting_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class Custom_settingUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
Custom_settingUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_Custom_settingUpdateEntityScreenState createState() => _Custom_settingUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _Custom_settingUpdateEntityScreenState extends State<Custom_settingUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Custom_settingViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = Custom_settingFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Custom_setting',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<Custom_settingViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class Custom_settingRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Custom_setting/Custom_setting';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,401 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Custom_setting_Repo/Custom_setting_repo_screen.dart';
|
||||
|
||||
class Custom_settingViewModelScreen extends ChangeNotifier{
|
||||
final Custom_settingRepoScreen repo = Custom_settingRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _custom_settingList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get custom_settingList => _custom_settingList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get custom_setting list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_custom_settingList = response.data ?? [];
|
||||
_filteredList = List.from(_custom_settingList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch custom_setting list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch custom_setting list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get custom_setting list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_custom_settingList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_custom_settingList = newItems;
|
||||
} else {
|
||||
_custom_settingList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_custom_settingList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Custom_setting list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch custom_setting list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create Custom_setting
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'custom_setting created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Custom_setting');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Custom_setting',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create custom_setting: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Custom_setting: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update custom_setting
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Custom_setting updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _custom_settingList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_custom_settingList[index] = response.data!;
|
||||
_filteredList = List.from(_custom_settingList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Custom_setting');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Custom_setting',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update custom_setting: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Custom_setting: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete custom_setting
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Custom_setting deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_custom_settingList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_custom_settingList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Custom_setting');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Custom_setting',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete custom_setting: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Custom_setting: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search custom_setting
|
||||
void searchcustom_setting(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_custom_settingList);
|
||||
} else {
|
||||
_filteredList = _custom_settingList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['yound_driver_surcharge']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['free_km']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['extra_km_charge']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['gst_rate']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['pst_rate']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['age_threshold']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_custom_settingList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class FeatureApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Feature/Feature');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Feature/Feature/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Feature/Feature', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Feature/Feature/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Feature/Feature/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Feature_viewModel/Feature_view_model_screen.dart';
|
||||
import 'Feature_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class FeatureCreateEntityScreen extends StatefulWidget {
|
||||
const FeatureCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_FeatureCreateEntityScreenState createState() => _FeatureCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _FeatureCreateEntityScreenState extends State<FeatureCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<FeatureViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: FeatureFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Feature',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Feature_viewModel/Feature_view_model_screen.dart';
|
||||
import 'Feature_update_entity_screen.dart';
|
||||
|
||||
class FeatureDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const FeatureDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<FeatureDetailsScreen> createState() => _FeatureDetailsScreenState();
|
||||
}
|
||||
|
||||
class _FeatureDetailsScreenState extends State<FeatureDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => FeatureViewModelScreen(),
|
||||
child: FeatureUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Feature?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<FeatureViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Feature',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Feature_create_entity_screen.dart';
|
||||
import 'Feature_update_entity_screen.dart';
|
||||
import '../Feature_viewModel/Feature_view_model_screen.dart';
|
||||
import 'Feature_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Feature_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Feature_entity_list_screenState createState() => _Feature_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Feature_entity_list_screenState extends State<Feature_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => FeatureViewModelScreen(),
|
||||
child: const FeatureCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => FeatureViewModelScreen(),
|
||||
child: FeatureUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => FeatureViewModelScreen(),
|
||||
child: FeatureDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Feature?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<FeatureViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchfeature(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Feature',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Feature_viewModel/Feature_view_model_screen.dart';/// Field definitions for Feature entity
|
||||
/// This defines the structure and validation for Feature forms
|
||||
class FeatureFields {
|
||||
/// Get field definitions for Feature entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Feature_viewModel/Feature_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Feature_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class FeatureUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
FeatureUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_FeatureUpdateEntityScreenState createState() => _FeatureUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _FeatureUpdateEntityScreenState extends State<FeatureUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<FeatureViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = FeatureFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Feature',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<FeatureViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class FeatureRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Feature/Feature';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,305 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Feature_Repo/Feature_repo_screen.dart';
|
||||
|
||||
class FeatureViewModelScreen extends ChangeNotifier{
|
||||
final FeatureRepoScreen repo = FeatureRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _featureList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get featureList => _featureList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get feature list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_featureList = response.data ?? [];
|
||||
_filteredList = List.from(_featureList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch feature list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch feature list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get feature list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_featureList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_featureList = newItems;
|
||||
} else {
|
||||
_featureList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_featureList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Feature list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch feature list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create Feature
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'feature created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Feature');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Feature',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create feature: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Feature: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update feature
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Feature updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _featureList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_featureList[index] = response.data!;
|
||||
_filteredList = List.from(_featureList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Feature');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Feature',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update feature: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Feature: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete feature
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Feature deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_featureList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_featureList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Feature');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Feature',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete feature: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Feature: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search feature
|
||||
void searchfeature(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_featureList);
|
||||
} else {
|
||||
_filteredList = _featureList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_featureList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class OfficeApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Office/Office');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Office/Office/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Office/Office', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Office/Office/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Office/Office/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Office_viewModel/Office_view_model_screen.dart';
|
||||
import 'Office_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class OfficeCreateEntityScreen extends StatefulWidget {
|
||||
const OfficeCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_OfficeCreateEntityScreenState createState() => _OfficeCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _OfficeCreateEntityScreenState extends State<OfficeCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<OfficeViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: OfficeFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Office',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Office_viewModel/Office_view_model_screen.dart';
|
||||
import 'Office_update_entity_screen.dart';
|
||||
|
||||
class OfficeDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const OfficeDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<OfficeDetailsScreen> createState() => _OfficeDetailsScreenState();
|
||||
}
|
||||
|
||||
class _OfficeDetailsScreenState extends State<OfficeDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => OfficeViewModelScreen(),
|
||||
child: OfficeUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Office?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<OfficeViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Office',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Office_create_entity_screen.dart';
|
||||
import 'Office_update_entity_screen.dart';
|
||||
import '../Office_viewModel/Office_view_model_screen.dart';
|
||||
import 'Office_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Office_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Office_entity_list_screenState createState() => _Office_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Office_entity_list_screenState extends State<Office_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => OfficeViewModelScreen(),
|
||||
child: const OfficeCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => OfficeViewModelScreen(),
|
||||
child: OfficeUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => OfficeViewModelScreen(),
|
||||
child: OfficeDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Office?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<OfficeViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchoffice(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Office',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Office_viewModel/Office_view_model_screen.dart';/// Field definitions for Office entity
|
||||
/// This defines the structure and validation for Office forms
|
||||
class OfficeFields {
|
||||
/// Get field definitions for Office entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Office_viewModel/Office_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Office_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class OfficeUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
OfficeUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_OfficeUpdateEntityScreenState createState() => _OfficeUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _OfficeUpdateEntityScreenState extends State<OfficeUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<OfficeViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = OfficeFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Office',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<OfficeViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class OfficeRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Office/Office';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,305 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Office_Repo/Office_repo_screen.dart';
|
||||
|
||||
class OfficeViewModelScreen extends ChangeNotifier{
|
||||
final OfficeRepoScreen repo = OfficeRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _officeList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get officeList => _officeList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get office list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_officeList = response.data ?? [];
|
||||
_filteredList = List.from(_officeList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch office list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch office list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get office list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_officeList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_officeList = newItems;
|
||||
} else {
|
||||
_officeList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_officeList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Office list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch office list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create Office
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'office created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Office');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Office',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create office: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Office: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update office
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Office updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _officeList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_officeList[index] = response.data!;
|
||||
_filteredList = List.from(_officeList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Office');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Office',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update office: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Office: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete office
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Office deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_officeList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_officeList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Office');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Office',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete office: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Office: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search office
|
||||
void searchoffice(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_officeList);
|
||||
} else {
|
||||
_filteredList = _officeList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_officeList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class Vehicle_add_onApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Vehicle_add_on/Vehicle_add_on');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Vehicle_add_on/Vehicle_add_on/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Vehicle_add_on/Vehicle_add_on', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Vehicle_add_on/Vehicle_add_on/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Vehicle_add_on/Vehicle_add_on/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';
|
||||
import 'Vehicle_add_on_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Vehicle_add_onCreateEntityScreen extends StatefulWidget {
|
||||
const Vehicle_add_onCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_Vehicle_add_onCreateEntityScreenState createState() => _Vehicle_add_onCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _Vehicle_add_onCreateEntityScreenState extends State<Vehicle_add_onCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Vehicle_add_onViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: Vehicle_add_onFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Vehicle_add_on',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';
|
||||
import 'Vehicle_add_on_update_entity_screen.dart';
|
||||
|
||||
class Vehicle_add_onDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const Vehicle_add_onDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<Vehicle_add_onDetailsScreen> createState() => _Vehicle_add_onDetailsScreenState();
|
||||
}
|
||||
|
||||
class _Vehicle_add_onDetailsScreenState extends State<Vehicle_add_onDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Vehicle_add_onViewModelScreen(),
|
||||
child: Vehicle_add_onUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Vehicle_add_on?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Vehicle_add_onViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Vehicle_add_on',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'icon', 'label': 'Icon', 'type': 'text'},
|
||||
|
||||
{'key': 'price_per_day', 'label': 'Price Per Day', 'type': 'number'},
|
||||
|
||||
{'key': 'price_per_trip', 'label': 'Price Per Trip', 'type': 'number'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,155 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Vehicle_add_on_create_entity_screen.dart';
|
||||
import 'Vehicle_add_on_update_entity_screen.dart';
|
||||
import '../Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';
|
||||
import 'Vehicle_add_on_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Vehicle_add_on_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Vehicle_add_on_entity_list_screenState createState() => _Vehicle_add_on_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Vehicle_add_on_entity_list_screenState extends State<Vehicle_add_on_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Vehicle_add_onViewModelScreen(),
|
||||
child: const Vehicle_add_onCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Vehicle_add_onViewModelScreen(),
|
||||
child: Vehicle_add_onUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Vehicle_add_onViewModelScreen(),
|
||||
child: Vehicle_add_onDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Vehicle_add_on?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Vehicle_add_onViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchvehicle_add_on(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Vehicle_add_on',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'icon', 'label': 'Icon', 'type': 'text'},
|
||||
|
||||
{'key': 'price_per_day', 'label': 'Price Per Day', 'type': 'number'},
|
||||
|
||||
{'key': 'price_per_trip', 'label': 'Price Per Trip', 'type': 'number'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';/// Field definitions for Vehicle_add_on entity
|
||||
/// This defines the structure and validation for Vehicle_add_on forms
|
||||
class Vehicle_add_onFields {
|
||||
/// Get field definitions for Vehicle_add_on entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'icon',
|
||||
label: 'Icon',
|
||||
hint: 'Enter Icon',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'price_per_day',
|
||||
label: 'Price Per Day',
|
||||
hint: 'Enter Price Per Day',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
// Number Fields
|
||||
NumberField(
|
||||
fieldKey: 'price_per_trip',
|
||||
label: 'Price Per Trip',
|
||||
hint: 'Enter Price Per Trip',
|
||||
isRequired: false,
|
||||
min: 0,
|
||||
decimalPlaces: 0,
|
||||
),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Vehicle_add_on_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class Vehicle_add_onUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
Vehicle_add_onUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_Vehicle_add_onUpdateEntityScreenState createState() => _Vehicle_add_onUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _Vehicle_add_onUpdateEntityScreenState extends State<Vehicle_add_onUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<Vehicle_add_onViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = Vehicle_add_onFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Vehicle_add_on',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<Vehicle_add_onViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class Vehicle_add_onRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Vehicle_add_on/Vehicle_add_on';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,353 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Vehicle_add_on_Repo/Vehicle_add_on_repo_screen.dart';
|
||||
|
||||
class Vehicle_add_onViewModelScreen extends ChangeNotifier{
|
||||
final Vehicle_add_onRepoScreen repo = Vehicle_add_onRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _vehicle_add_onList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get vehicle_add_onList => _vehicle_add_onList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get vehicle_add_on list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_vehicle_add_onList = response.data ?? [];
|
||||
_filteredList = List.from(_vehicle_add_onList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch vehicle_add_on list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch vehicle_add_on list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get vehicle_add_on list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_vehicle_add_onList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_vehicle_add_onList = newItems;
|
||||
} else {
|
||||
_vehicle_add_onList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_vehicle_add_onList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Vehicle_add_on list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch vehicle_add_on list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create Vehicle_add_on
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'vehicle_add_on created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Vehicle_add_on');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Vehicle_add_on',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create vehicle_add_on: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Vehicle_add_on: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update vehicle_add_on
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Vehicle_add_on updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _vehicle_add_onList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_vehicle_add_onList[index] = response.data!;
|
||||
_filteredList = List.from(_vehicle_add_onList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Vehicle_add_on');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Vehicle_add_on',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update vehicle_add_on: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Vehicle_add_on: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete vehicle_add_on
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Vehicle_add_on deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_vehicle_add_onList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_vehicle_add_onList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Vehicle_add_on');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Vehicle_add_on',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete vehicle_add_on: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Vehicle_add_on: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search vehicle_add_on
|
||||
void searchvehicle_add_on(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_vehicle_add_onList);
|
||||
} else {
|
||||
_filteredList = _vehicle_add_onList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['icon']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['price_per_day']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['price_per_trip']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_vehicle_add_onList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,3 +1,18 @@
|
||||
import '../../Entity/taxi_rental/Custom_setting/Custom_settingView/Custom_setting_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Custom_setting/Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/taxi_rental/Vehicle_add_on/Vehicle_add_onView/Vehicle_add_on_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Vehicle_add_on/Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/taxi_rental/Car_category/Car_categoryView/Car_category_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Car_category/Car_category_viewModel/Car_category_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/taxi_rental/Office/OfficeView/Office_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Office/Office_viewModel/Office_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/taxi_rental/Feature/FeatureView/Feature_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Feature/Feature_viewModel/Feature_view_model_screen.dart';
|
||||
|
||||
import 'package:base_project/core/constants/ui_constants.dart';
|
||||
import 'package:base_project/core/theme/color_scheme.dart';
|
||||
import 'package:base_project/routes/route_names.dart';
|
||||
@ -88,6 +103,91 @@ class _HomeViewState extends State<HomeView> with TickerProviderStateMixin {
|
||||
// NEW ITEMS
|
||||
|
||||
// NEW MENU
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Custom_setting Management',
|
||||
subtitle: 'Manage Custom_setting entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: Custom_setting_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Vehicle_add_on Management',
|
||||
subtitle: 'Manage Vehicle_add_on entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Vehicle_add_onViewModelScreen(),
|
||||
child: Vehicle_add_on_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Car_category Management',
|
||||
subtitle: 'Manage Car_category entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Car_categoryViewModelScreen(),
|
||||
child: Car_category_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Office Management',
|
||||
subtitle: 'Manage Office entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => OfficeViewModelScreen(),
|
||||
child: Office_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Feature Management',
|
||||
subtitle: 'Manage Feature entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => FeatureViewModelScreen(),
|
||||
child: Feature_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user