assign area using purok
parent
f73f8a03e1
commit
6dd9216af7
|
@ -36,7 +36,7 @@ class MyApp extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_appRouter = AppRouter();
|
_appRouter = AppRouter();
|
||||||
final mediaQueryData =
|
final mediaQueryData =
|
||||||
MediaQueryData.fromView(WidgetsBinding.instance.window);
|
MediaQueryData.fromWindow(WidgetsBinding.instance.window);
|
||||||
screenWidth = mediaQueryData.size.width;
|
screenWidth = mediaQueryData.size.width;
|
||||||
screenHeight = mediaQueryData.size.height;
|
screenHeight = mediaQueryData.size.height;
|
||||||
blockSizeHorizontal = screenWidth / 100;
|
blockSizeHorizontal = screenWidth / 100;
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final purok = purokFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:unit2/model/location/barangay.dart';
|
||||||
|
|
||||||
|
Purok purokFromJson(String str) => Purok.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String purokToJson(Purok data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class Purok {
|
||||||
|
final String code;
|
||||||
|
final String description;
|
||||||
|
final Barangay barangay;
|
||||||
|
|
||||||
|
Purok({
|
||||||
|
required this.code,
|
||||||
|
required this.description,
|
||||||
|
required this.barangay,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
||||||
|
code: json["code"],
|
||||||
|
description: json["description"],
|
||||||
|
barangay: Barangay.fromJson(json["barangay"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"code": code,
|
||||||
|
"description": description,
|
||||||
|
"barangay": barangay.toJson(),
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import 'barangay_assign_area.dart';
|
import 'barangay_assign_area.dart';
|
||||||
|
|
||||||
class Purok {
|
class PassCheckPurok {
|
||||||
final String? purokid;
|
final String? purokid;
|
||||||
final String? purokdesc;
|
final String? purokdesc;
|
||||||
final BaragayAssignArea? brgy;
|
final BaragayAssignArea? brgy;
|
||||||
|
@ -10,7 +10,7 @@ class Purok {
|
||||||
final bool? writelock;
|
final bool? writelock;
|
||||||
final dynamic recordsignature;
|
final dynamic recordsignature;
|
||||||
|
|
||||||
Purok({
|
PassCheckPurok({
|
||||||
required this.purokid,
|
required this.purokid,
|
||||||
required this.purokdesc,
|
required this.purokdesc,
|
||||||
required this.brgy,
|
required this.brgy,
|
||||||
|
@ -19,7 +19,7 @@ class Purok {
|
||||||
required this.recordsignature,
|
required this.recordsignature,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
factory PassCheckPurok.fromJson(Map<String, dynamic> json) => PassCheckPurok(
|
||||||
purokid: json["purokid"],
|
purokid: json["purokid"],
|
||||||
purokdesc: json["purokdesc"],
|
purokdesc: json["purokdesc"],
|
||||||
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),
|
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),
|
||||||
|
|
|
@ -16,12 +16,14 @@ import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/model/location/barangay.dart';
|
import 'package:unit2/model/location/barangay.dart';
|
||||||
import 'package:unit2/model/location/city.dart';
|
import 'package:unit2/model/location/city.dart';
|
||||||
import 'package:unit2/model/location/provinces.dart';
|
import 'package:unit2/model/location/provinces.dart';
|
||||||
|
import 'package:unit2/model/location/purok.dart';
|
||||||
import 'package:unit2/model/location/region.dart';
|
import 'package:unit2/model/location/region.dart';
|
||||||
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
|
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
|
||||||
import 'package:unit2/model/profile/assigned_area.dart';
|
import 'package:unit2/model/profile/assigned_area.dart';
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
import 'package:unit2/model/rbac/rbac_station.dart';
|
import 'package:unit2/model/rbac/rbac_station.dart';
|
||||||
import 'package:unit2/model/roles/pass_check/agency_area_type.dart';
|
import 'package:unit2/model/roles/pass_check/agency_area_type.dart';
|
||||||
|
import 'package:unit2/model/roles/pass_check/purok_assign_area.dart';
|
||||||
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
||||||
import 'package:unit2/model/utils/agency.dart';
|
import 'package:unit2/model/utils/agency.dart';
|
||||||
import 'package:unit2/model/utils/category.dart';
|
import 'package:unit2/model/utils/category.dart';
|
||||||
|
@ -57,6 +59,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
bool provinceAsyncCall = false;
|
bool provinceAsyncCall = false;
|
||||||
bool cityAsyncCall = false;
|
bool cityAsyncCall = false;
|
||||||
bool barangayAsyncCall = false;
|
bool barangayAsyncCall = false;
|
||||||
|
bool purokAsyncCall = false;
|
||||||
List<UserAssignedArea> userAssignedAreas = [];
|
List<UserAssignedArea> userAssignedAreas = [];
|
||||||
final bloc = BlocProvider.of<AssignAreaBloc>(context);
|
final bloc = BlocProvider.of<AssignAreaBloc>(context);
|
||||||
int? areaTypeId;
|
int? areaTypeId;
|
||||||
|
@ -72,6 +75,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
List<Province> provinces = [];
|
List<Province> provinces = [];
|
||||||
List<CityMunicipality> cities = [];
|
List<CityMunicipality> cities = [];
|
||||||
List<Barangay> barangays = [];
|
List<Barangay> barangays = [];
|
||||||
|
List<Purok> puroks = [];
|
||||||
Province? selectedProvince;
|
Province? selectedProvince;
|
||||||
CityMunicipality? selectedMunicipality;
|
CityMunicipality? selectedMunicipality;
|
||||||
Barangay? selectedBarangay;
|
Barangay? selectedBarangay;
|
||||||
|
@ -152,6 +156,44 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
//// purok
|
//// purok
|
||||||
} else if (e.name!.toLowerCase() ==
|
} else if (e.name!.toLowerCase() ==
|
||||||
"purok president") {
|
"purok president") {
|
||||||
|
try {
|
||||||
|
areaType = "purok";
|
||||||
|
areaTypeId = 2;
|
||||||
|
setState(() {
|
||||||
|
provinceAsyncCall = true;
|
||||||
|
});
|
||||||
|
provinces = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getProvinces(regionCode: "16");
|
||||||
|
setState(() {
|
||||||
|
provinceAsyncCall = false;
|
||||||
|
cityAsyncCall = true;
|
||||||
|
});
|
||||||
|
cities = await LocationUtils.instance
|
||||||
|
.getCities(
|
||||||
|
code: provinces[0].code!);
|
||||||
|
setState(() {
|
||||||
|
cityAsyncCall = false;
|
||||||
|
barangayAsyncCall = true;
|
||||||
|
});
|
||||||
|
barangays = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getBarangay(
|
||||||
|
code: cities[0].code!);
|
||||||
|
setState(() {
|
||||||
|
barangayAsyncCall = false;
|
||||||
|
purokAsyncCall = true;
|
||||||
|
});
|
||||||
|
puroks = await LocationUtils.instance
|
||||||
|
.getPurok(
|
||||||
|
barangay: barangays[0].code!);
|
||||||
|
setState(() {
|
||||||
|
purokAsyncCall = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
bloc.add(CallErrorState(
|
||||||
|
message: e.toString()));
|
||||||
|
}
|
||||||
//// station
|
//// station
|
||||||
} else if (e.name!.toLowerCase() == "qr code scanner" ||
|
} else if (e.name!.toLowerCase() == "qr code scanner" ||
|
||||||
e.name!.toLowerCase() ==
|
e.name!.toLowerCase() ==
|
||||||
|
@ -185,7 +227,6 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
bloc.add(CallErrorState(
|
bloc.add(CallErrorState(
|
||||||
message: e.toString()));
|
message: e.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//// agency-------------------------------
|
//// agency-------------------------------
|
||||||
} else if (e.name!.toLowerCase() ==
|
} else if (e.name!.toLowerCase() ==
|
||||||
"establishment point-person" ||
|
"establishment point-person" ||
|
||||||
|
@ -227,16 +268,13 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
itemHeight: 100,
|
itemHeight: 100,
|
||||||
suggestions: agencies
|
suggestions: agencies
|
||||||
.map((Agency agency) =>
|
.map((Agency agency) =>
|
||||||
SearchFieldListItem(
|
SearchFieldListItem(agency.name!,
|
||||||
agency.name!,
|
|
||||||
item: agency,
|
item: agency,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title:
|
title: AutoSizeText(
|
||||||
AutoSizeText(
|
|
||||||
agency.name!
|
agency.name!
|
||||||
.toUpperCase(),
|
.toUpperCase(),
|
||||||
minFontSize:
|
minFontSize: 12,
|
||||||
12,
|
|
||||||
),
|
),
|
||||||
subtitle: Text(agency
|
subtitle: Text(agency
|
||||||
.privateEntity ==
|
.privateEntity ==
|
||||||
|
@ -248,18 +286,13 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
: ""),
|
: ""),
|
||||||
)))
|
)))
|
||||||
.toList(),
|
.toList(),
|
||||||
validator: FormBuilderValidators
|
validator: FormBuilderValidators.required(
|
||||||
.required(
|
errorText: "This field is required"),
|
||||||
errorText:
|
|
||||||
"This field is required"),
|
|
||||||
searchInputDecoration:
|
searchInputDecoration:
|
||||||
normalTextFieldStyle(
|
normalTextFieldStyle("Agency *", "")
|
||||||
"Agency *", "")
|
|
||||||
.copyWith(
|
.copyWith(
|
||||||
suffixIcon:
|
suffixIcon: GestureDetector(
|
||||||
GestureDetector(
|
onTap: () => agencyFocusNode.unfocus(),
|
||||||
onTap: () => agencyFocusNode
|
|
||||||
.unfocus(),
|
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.arrow_drop_down,
|
Icons.arrow_drop_down,
|
||||||
),
|
),
|
||||||
|
@ -267,13 +300,12 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
////agency suggestion tap
|
////agency suggestion tap
|
||||||
onSuggestionTap: (agency) {
|
onSuggestionTap: (agency) {
|
||||||
setState(() {
|
setState(() {
|
||||||
areaId = agency.item!.id
|
areaId = agency.item!.id.toString();
|
||||||
.toString();
|
|
||||||
agencyFocusNode.unfocus();
|
agencyFocusNode.unfocus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
emptyWidget: const Text(
|
emptyWidget:
|
||||||
"No Result Found.."))
|
const Text("No Result Found.."))
|
||||||
//// station ------------------------------------------------
|
//// station ------------------------------------------------
|
||||||
: areaType == "station"
|
: areaType == "station"
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
|
@ -285,7 +317,8 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
child: ModalProgressHUD(
|
child: ModalProgressHUD(
|
||||||
inAsyncCall: agencyAsyncCall,
|
inAsyncCall:
|
||||||
|
agencyAsyncCall,
|
||||||
child: SearchField(
|
child: SearchField(
|
||||||
controller:
|
controller:
|
||||||
agencyController,
|
agencyController,
|
||||||
|
@ -295,31 +328,39 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
focusNode:
|
focusNode:
|
||||||
agencyFocusNode,
|
agencyFocusNode,
|
||||||
itemHeight: 100,
|
itemHeight: 100,
|
||||||
suggestions:
|
suggestions: agencies
|
||||||
agencies
|
.map((Agency
|
||||||
.map((Agency agency) => SearchFieldListItem(
|
agency) =>
|
||||||
|
SearchFieldListItem(
|
||||||
agency
|
agency
|
||||||
.name!,
|
.name!,
|
||||||
item:
|
item:
|
||||||
agency,
|
agency,
|
||||||
child:
|
child:
|
||||||
ListTile(
|
ListTile(
|
||||||
title: AutoSizeText(
|
title:
|
||||||
agency.name!.toUpperCase(),
|
AutoSizeText(
|
||||||
minFontSize: 12,
|
agency
|
||||||
|
.name!
|
||||||
|
.toUpperCase(),
|
||||||
|
minFontSize:
|
||||||
|
12,
|
||||||
),
|
),
|
||||||
subtitle: Text(agency.privateEntity == true
|
subtitle: Text(agency.privateEntity ==
|
||||||
|
true
|
||||||
? "Private"
|
? "Private"
|
||||||
: agency.privateEntity == false
|
: agency.privateEntity == false
|
||||||
? "Government"
|
? "Government"
|
||||||
: ""),
|
: ""),
|
||||||
)))
|
)))
|
||||||
.toList(),
|
.toList(),
|
||||||
validator: FormBuilderValidators
|
validator:
|
||||||
|
FormBuilderValidators
|
||||||
.required(
|
.required(
|
||||||
errorText:
|
errorText:
|
||||||
"This field is required"),
|
"This field is required"),
|
||||||
searchInputDecoration: normalTextFieldStyle(
|
searchInputDecoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
"Agency *",
|
"Agency *",
|
||||||
"")
|
"")
|
||||||
.copyWith(
|
.copyWith(
|
||||||
|
@ -328,8 +369,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
agencyFocusNode
|
agencyFocusNode
|
||||||
.unfocus(),
|
.unfocus(),
|
||||||
child:
|
child: const Icon(
|
||||||
const Icon(
|
|
||||||
Icons
|
Icons
|
||||||
.arrow_drop_down,
|
.arrow_drop_down,
|
||||||
),
|
),
|
||||||
|
@ -342,8 +382,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
.unfocus();
|
.unfocus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
emptyWidget:
|
emptyWidget: const Text(
|
||||||
const Text(
|
|
||||||
"No Result Found..")),
|
"No Result Found..")),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -354,36 +393,31 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 75,
|
height: 75,
|
||||||
child:
|
child: ModalProgressHUD(
|
||||||
ModalProgressHUD(
|
color: Colors.transparent,
|
||||||
color: Colors
|
|
||||||
.transparent,
|
|
||||||
inAsyncCall:
|
inAsyncCall:
|
||||||
stationAsyncCall,
|
stationAsyncCall,
|
||||||
child: FormBuilderDropdown<
|
child:
|
||||||
|
FormBuilderDropdown<
|
||||||
RbacStation>(
|
RbacStation>(
|
||||||
decoration: normalTextFieldStyle(
|
decoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
"Station",
|
"Station",
|
||||||
"Station"),
|
"Station"),
|
||||||
name:
|
name: "parent-stations",
|
||||||
"parent-stations",
|
items: stations.isEmpty
|
||||||
items: stations
|
|
||||||
.isEmpty
|
|
||||||
? []
|
? []
|
||||||
: stations
|
: stations.map((e) {
|
||||||
.map(
|
|
||||||
(e) {
|
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
value:
|
value: e,
|
||||||
e,
|
child: Text(e
|
||||||
child:
|
.stationName!),
|
||||||
Text(e.stationName!),
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged:
|
onChanged:
|
||||||
(RbacStation?
|
(RbacStation? e) {},
|
||||||
e) {},
|
validator:
|
||||||
validator: FormBuilderValidators
|
FormBuilderValidators
|
||||||
.required(
|
.required(
|
||||||
errorText:
|
errorText:
|
||||||
"This field is required"),
|
"This field is required"),
|
||||||
|
@ -397,6 +431,190 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
)
|
)
|
||||||
//// barangay ------------------------------------------------------------
|
//// barangay ------------------------------------------------------------
|
||||||
: areaType == 'barangay'
|
: areaType == 'barangay'
|
||||||
|
? SizedBox(
|
||||||
|
height: 300,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
//// PROVINCE DROPDOWN
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 60,
|
||||||
|
child: ModalProgressHUD(
|
||||||
|
color:
|
||||||
|
Colors.transparent,
|
||||||
|
inAsyncCall:
|
||||||
|
provinceAsyncCall,
|
||||||
|
child: DropdownButtonFormField<
|
||||||
|
Province?>(
|
||||||
|
autovalidateMode:
|
||||||
|
AutovalidateMode
|
||||||
|
.onUserInteraction,
|
||||||
|
validator: (value) =>
|
||||||
|
value == null
|
||||||
|
? 'required'
|
||||||
|
: null,
|
||||||
|
isExpanded: true,
|
||||||
|
// value: selectedProvince,
|
||||||
|
onChanged: (Province?
|
||||||
|
province) async {
|
||||||
|
setState(() {
|
||||||
|
selectedProvince =
|
||||||
|
province;
|
||||||
|
cityAsyncCall =
|
||||||
|
true;
|
||||||
|
});
|
||||||
|
cities = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getCities(
|
||||||
|
code: provinces[
|
||||||
|
0]
|
||||||
|
.code!);
|
||||||
|
setState(() {
|
||||||
|
cityAsyncCall =
|
||||||
|
false;
|
||||||
|
barangayAsyncCall =
|
||||||
|
true;
|
||||||
|
});
|
||||||
|
barangays = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getBarangay(
|
||||||
|
code: cities[
|
||||||
|
0]
|
||||||
|
.code!);
|
||||||
|
setState(() {
|
||||||
|
barangayAsyncCall =
|
||||||
|
false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: provinces
|
||||||
|
.isEmpty
|
||||||
|
? []
|
||||||
|
: provinces.map<
|
||||||
|
DropdownMenuItem<
|
||||||
|
Province>>((Province
|
||||||
|
province) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value:
|
||||||
|
province,
|
||||||
|
child:
|
||||||
|
FittedBox(
|
||||||
|
child:
|
||||||
|
Text(province.description!),
|
||||||
|
));
|
||||||
|
}).toList(),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
|
"Province*",
|
||||||
|
"Province")),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
//// CITIES DROPDOWN
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 60,
|
||||||
|
child: ModalProgressHUD(
|
||||||
|
color: Colors.white,
|
||||||
|
inAsyncCall:
|
||||||
|
cityAsyncCall,
|
||||||
|
child:
|
||||||
|
DropdownButtonFormField<
|
||||||
|
CityMunicipality>(
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators
|
||||||
|
.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
isExpanded: true,
|
||||||
|
onChanged:
|
||||||
|
(CityMunicipality?
|
||||||
|
city) async {
|
||||||
|
setState(() {
|
||||||
|
selectedMunicipality =
|
||||||
|
city;
|
||||||
|
barangayAsyncCall =
|
||||||
|
true;
|
||||||
|
});
|
||||||
|
barangays = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getBarangay(
|
||||||
|
code: selectedMunicipality!
|
||||||
|
.code!);
|
||||||
|
setState(() {
|
||||||
|
barangayAsyncCall =
|
||||||
|
false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
|
"Municipality*",
|
||||||
|
"Municipality"),
|
||||||
|
// value: selectedMunicipality,
|
||||||
|
items: cities.isEmpty
|
||||||
|
? []
|
||||||
|
: cities.map<
|
||||||
|
DropdownMenuItem<
|
||||||
|
CityMunicipality>>(
|
||||||
|
(CityMunicipality
|
||||||
|
c) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: c,
|
||||||
|
child: Text(
|
||||||
|
c.description!));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
////Barangay
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 60,
|
||||||
|
child: ModalProgressHUD(
|
||||||
|
color: Colors.white,
|
||||||
|
inAsyncCall:
|
||||||
|
barangayAsyncCall,
|
||||||
|
child:
|
||||||
|
DropdownButtonFormField<
|
||||||
|
Barangay>(
|
||||||
|
isExpanded: true,
|
||||||
|
onChanged: (Barangay?
|
||||||
|
baragay) {
|
||||||
|
areaId =
|
||||||
|
baragay!.code;
|
||||||
|
},
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
|
"Barangay*",
|
||||||
|
"Barangay"),
|
||||||
|
// value: selectedBarangay,
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators
|
||||||
|
.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
items: barangays
|
||||||
|
.isEmpty
|
||||||
|
? []
|
||||||
|
: barangays.map<
|
||||||
|
DropdownMenuItem<
|
||||||
|
Barangay>>((Barangay
|
||||||
|
barangay) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value:
|
||||||
|
barangay,
|
||||||
|
child: Text(
|
||||||
|
barangay
|
||||||
|
.description!));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
: //// Purok ------------------------------------------------------------
|
||||||
|
areaType == 'purok'
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
height: 300,
|
height: 300,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -416,8 +634,8 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
autovalidateMode:
|
autovalidateMode:
|
||||||
AutovalidateMode
|
AutovalidateMode
|
||||||
.onUserInteraction,
|
.onUserInteraction,
|
||||||
validator: (value) => value ==
|
validator: (value) =>
|
||||||
null
|
value == null
|
||||||
? 'required'
|
? 'required'
|
||||||
: null,
|
: null,
|
||||||
isExpanded:
|
isExpanded:
|
||||||
|
@ -426,8 +644,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
onChanged:
|
onChanged:
|
||||||
(Province?
|
(Province?
|
||||||
province) async {
|
province) async {
|
||||||
setState(
|
setState(() {
|
||||||
() {
|
|
||||||
selectedProvince =
|
selectedProvince =
|
||||||
province;
|
province;
|
||||||
cityAsyncCall =
|
cityAsyncCall =
|
||||||
|
@ -435,9 +652,10 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
});
|
});
|
||||||
cities = await LocationUtils
|
cities = await LocationUtils
|
||||||
.instance
|
.instance
|
||||||
.getCities(code: provinces[0].code!);
|
.getCities(
|
||||||
setState(
|
code:
|
||||||
() {
|
provinces[0].code!);
|
||||||
|
setState(() {
|
||||||
cityAsyncCall =
|
cityAsyncCall =
|
||||||
false;
|
false;
|
||||||
barangayAsyncCall =
|
barangayAsyncCall =
|
||||||
|
@ -445,21 +663,37 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
});
|
});
|
||||||
barangays = await LocationUtils
|
barangays = await LocationUtils
|
||||||
.instance
|
.instance
|
||||||
.getBarangay(code: cities[0].code!);
|
.getBarangay(
|
||||||
setState(
|
code:
|
||||||
() {
|
cities[0].code!);
|
||||||
|
setState(() {
|
||||||
barangayAsyncCall =
|
barangayAsyncCall =
|
||||||
false;
|
false;
|
||||||
|
purokAsyncCall =
|
||||||
|
true;
|
||||||
|
});
|
||||||
|
puroks = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getPurok(
|
||||||
|
barangay:
|
||||||
|
barangays[0].code!);
|
||||||
|
setState(() {
|
||||||
|
purokAsyncCall =
|
||||||
|
false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: provinces
|
items: provinces
|
||||||
.isEmpty
|
.isEmpty
|
||||||
? []
|
? []
|
||||||
: provinces.map<DropdownMenuItem<Province>>((Province
|
: provinces.map<
|
||||||
|
DropdownMenuItem<
|
||||||
|
Province>>((Province
|
||||||
province) {
|
province) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
value: province,
|
value:
|
||||||
child: FittedBox(
|
province,
|
||||||
|
child:
|
||||||
|
FittedBox(
|
||||||
child: Text(province.description!),
|
child: Text(province.description!),
|
||||||
));
|
));
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
@ -475,22 +709,20 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
height: 60,
|
height: 60,
|
||||||
child:
|
child:
|
||||||
ModalProgressHUD(
|
ModalProgressHUD(
|
||||||
color: Colors
|
color: Colors.white,
|
||||||
.white,
|
|
||||||
inAsyncCall:
|
inAsyncCall:
|
||||||
cityAsyncCall,
|
cityAsyncCall,
|
||||||
child: DropdownButtonFormField<
|
child: DropdownButtonFormField<
|
||||||
CityMunicipality>(
|
CityMunicipality>(
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators
|
||||||
|
.required(
|
||||||
errorText:
|
errorText:
|
||||||
"This field is required"),
|
"This field is required"),
|
||||||
isExpanded:
|
isExpanded: true,
|
||||||
true,
|
|
||||||
onChanged:
|
onChanged:
|
||||||
(CityMunicipality?
|
(CityMunicipality?
|
||||||
city) async {
|
city) async {
|
||||||
setState(
|
setState(() {
|
||||||
() {
|
|
||||||
selectedMunicipality =
|
selectedMunicipality =
|
||||||
city;
|
city;
|
||||||
barangayAsyncCall =
|
barangayAsyncCall =
|
||||||
|
@ -499,13 +731,24 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
barangays = await LocationUtils
|
barangays = await LocationUtils
|
||||||
.instance
|
.instance
|
||||||
.getBarangay(
|
.getBarangay(
|
||||||
code: selectedMunicipality!.code!);
|
code: selectedMunicipality!
|
||||||
setState(
|
.code!);
|
||||||
() {
|
setState(() {
|
||||||
barangayAsyncCall =
|
barangayAsyncCall =
|
||||||
false;
|
false;
|
||||||
|
purokAsyncCall = true;
|
||||||
|
});
|
||||||
|
puroks = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getPurok(
|
||||||
|
barangay:
|
||||||
|
barangays[0].code!);
|
||||||
|
|
||||||
|
setState((){
|
||||||
|
purokAsyncCall = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Municipality*",
|
"Municipality*",
|
||||||
"Municipality"),
|
"Municipality"),
|
||||||
|
@ -515,11 +758,14 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
? []
|
? []
|
||||||
: cities.map<
|
: cities.map<
|
||||||
DropdownMenuItem<
|
DropdownMenuItem<
|
||||||
CityMunicipality>>((CityMunicipality
|
CityMunicipality>>(
|
||||||
|
(CityMunicipality
|
||||||
c) {
|
c) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
value: c,
|
value:
|
||||||
child: Text(c.description!));
|
c,
|
||||||
|
child:
|
||||||
|
Text(c.description!));
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -527,32 +773,49 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
),
|
),
|
||||||
////Barangay
|
////Barangay
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 60,
|
height: 60,
|
||||||
child:
|
child:
|
||||||
ModalProgressHUD(
|
ModalProgressHUD(
|
||||||
color: Colors
|
color: Colors.white,
|
||||||
.white,
|
|
||||||
inAsyncCall:
|
inAsyncCall:
|
||||||
barangayAsyncCall,
|
barangayAsyncCall,
|
||||||
child: DropdownButtonFormField<
|
child:
|
||||||
|
DropdownButtonFormField<
|
||||||
Barangay>(
|
Barangay>(
|
||||||
isExpanded:
|
|
||||||
true,
|
isExpanded: true,
|
||||||
onChanged:
|
onChanged:
|
||||||
(Barangay?
|
(Barangay?
|
||||||
baragay) {
|
baragay)async {
|
||||||
areaId =
|
areaId =
|
||||||
baragay!
|
baragay!
|
||||||
.code;
|
.code;
|
||||||
|
|
||||||
|
setState((){
|
||||||
|
purokAsyncCall= true;
|
||||||
|
});
|
||||||
|
puroks = await LocationUtils
|
||||||
|
.instance
|
||||||
|
.getPurok(
|
||||||
|
barangay:
|
||||||
|
barangays[0].code!);
|
||||||
|
setState((){
|
||||||
|
purokAsyncCall = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
decoration: normalTextFieldStyle(
|
decoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
"Barangay*",
|
"Barangay*",
|
||||||
"Barangay"),
|
"Barangay"),
|
||||||
// value: selectedBarangay,
|
// value: selectedBarangay,
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators
|
||||||
|
.required(
|
||||||
errorText:
|
errorText:
|
||||||
"This field is required"),
|
"This field is required"),
|
||||||
|
|
||||||
|
|
||||||
items: barangays
|
items: barangays
|
||||||
.isEmpty
|
.isEmpty
|
||||||
? []
|
? []
|
||||||
|
@ -561,8 +824,60 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
|
||||||
Barangay>>((Barangay
|
Barangay>>((Barangay
|
||||||
barangay) {
|
barangay) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
value: barangay,
|
value:
|
||||||
child: Text(barangay.description!));
|
barangay,
|
||||||
|
child:
|
||||||
|
Text(barangay.description!));
|
||||||
|
}).toList(),
|
||||||
|
|
||||||
|
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
////Purok
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 60,
|
||||||
|
child:
|
||||||
|
ModalProgressHUD(
|
||||||
|
color: Colors.white,
|
||||||
|
inAsyncCall:
|
||||||
|
purokAsyncCall,
|
||||||
|
child:
|
||||||
|
DropdownButtonFormField<
|
||||||
|
Purok>(
|
||||||
|
isExpanded: true,
|
||||||
|
onChanged:
|
||||||
|
(Purok?
|
||||||
|
purok) {
|
||||||
|
areaId =
|
||||||
|
purok!.code;
|
||||||
|
},
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
|
"Purok*",
|
||||||
|
"Parangay"),
|
||||||
|
// value: selectedBarangay,
|
||||||
|
validator: FormBuilderValidators
|
||||||
|
.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
items: puroks
|
||||||
|
.isEmpty
|
||||||
|
? []
|
||||||
|
: puroks.map<
|
||||||
|
DropdownMenuItem<
|
||||||
|
Purok>>((Purok
|
||||||
|
purok) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value:
|
||||||
|
purok,
|
||||||
|
child:
|
||||||
|
Text(purok.description));
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -109,7 +109,7 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
if (state is VersionLoaded) {
|
if (state is VersionLoaded) {
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
if (state.versionInfo!.version != state.apkVersion) {
|
if (state.versionInfo?.version != state.apkVersion) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
|
|
@ -116,9 +116,9 @@ class PassCheckServices {
|
||||||
}
|
}
|
||||||
////PUROK
|
////PUROK
|
||||||
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
|
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
|
||||||
List<Purok> assignedArea = [];
|
List<PassCheckPurok> assignedArea = [];
|
||||||
data['data'][0]['assigned_area'].forEach((var element) {
|
data['data'][0]['assigned_area'].forEach((var element) {
|
||||||
Purok purok = Purok.fromJson(element['area']);
|
PassCheckPurok purok = PassCheckPurok.fromJson(element['area']);
|
||||||
assignedArea.add(purok);
|
assignedArea.add(purok);
|
||||||
});
|
});
|
||||||
statusResponse = assignedArea;
|
statusResponse = assignedArea;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:unit2/model/location/city.dart';
|
||||||
import 'package:unit2/model/location/country.dart';
|
import 'package:unit2/model/location/country.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:unit2/model/location/provinces.dart';
|
import 'package:unit2/model/location/provinces.dart';
|
||||||
|
import 'package:unit2/model/location/purok.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ class LocationUtils {
|
||||||
List<Country> countries = [];
|
List<Country> countries = [];
|
||||||
String path = Url.instance.getCounties();
|
String path = Url.instance.getCounties();
|
||||||
|
|
||||||
try{
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
@ -35,8 +36,8 @@ class LocationUtils {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
throw(e.toString());
|
throw (e.toString());
|
||||||
}
|
}
|
||||||
return countries;
|
return countries;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,7 @@ class LocationUtils {
|
||||||
List<Region> regions = [];
|
List<Region> regions = [];
|
||||||
String path = Url.instance.getRegions();
|
String path = Url.instance.getRegions();
|
||||||
|
|
||||||
try{
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
@ -57,8 +58,8 @@ class LocationUtils {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
throw(e.toString());
|
throw (e.toString());
|
||||||
}
|
}
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,7 @@ class LocationUtils {
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
if(response.statusCode == 200){
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if (data['data'] != null) {
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var province) {
|
data['data'].forEach((var province) {
|
||||||
|
@ -91,6 +92,7 @@ class LocationUtils {
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if (data['data'] != null) {
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var city) {
|
data['data'].forEach((var city) {
|
||||||
|
@ -98,6 +100,7 @@ class LocationUtils {
|
||||||
cities.add(cityMun);
|
cities.add(cityMun);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw (e.toString());
|
throw (e.toString());
|
||||||
}
|
}
|
||||||
|
@ -110,6 +113,7 @@ class LocationUtils {
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if (data['data'] != null) {
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var city) {
|
data['data'].forEach((var city) {
|
||||||
|
@ -117,28 +121,50 @@ class LocationUtils {
|
||||||
barangays.add(barangay);
|
barangays.add(barangay);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw (e.toString());
|
throw (e.toString());
|
||||||
}
|
}
|
||||||
return barangays;
|
return barangays;
|
||||||
}
|
}
|
||||||
Future<List<AddressCategory>>getAddressCategory()async{
|
|
||||||
|
Future<List<Purok>> getPurok({required String barangay}) async {
|
||||||
|
List<Purok> puroks = [];
|
||||||
|
String path = Url.instance.getPurok() + barangay;
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
if (data['data'] != null) {
|
||||||
|
data['data'].forEach((var purok) {
|
||||||
|
Purok newPurok = Purok.fromJson(purok);
|
||||||
|
puroks.add(newPurok);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw (e.toString());
|
||||||
|
}
|
||||||
|
return puroks;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<AddressCategory>> getAddressCategory() async {
|
||||||
List<AddressCategory> categories = [];
|
List<AddressCategory> categories = [];
|
||||||
String path = Url.instance.getAddressCategory();
|
String path = Url.instance.getAddressCategory();
|
||||||
try{
|
try {
|
||||||
http.Response response = await Request.instance.getRequest(path: path,param: {},headers:headers );
|
http.Response response = await Request.instance
|
||||||
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if(data['data'] != null){
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var cat){
|
data['data'].forEach((var cat) {
|
||||||
categories.add(AddressCategory.fromJson(cat));
|
categories.add(AddressCategory.fromJson(cat));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
categories;
|
categories;
|
||||||
return categories;
|
return categories;
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
throw e.toString();
|
throw e.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,6 +343,9 @@ class Url {
|
||||||
String getBarangays() {
|
String getBarangays() {
|
||||||
return "/api/web_app/location/barangay/";
|
return "/api/web_app/location/barangay/";
|
||||||
}
|
}
|
||||||
|
String getPurok(){
|
||||||
|
return "/api/web_app/location/purok/";
|
||||||
|
}
|
||||||
|
|
||||||
String getAddressCategory() {
|
String getAddressCategory() {
|
||||||
return "/api/jobnet_app/address_categories/";
|
return "/api/jobnet_app/address_categories/";
|
||||||
|
|
Loading…
Reference in New Issue