device transfer added in filters

main_design2.0
Sikander Saleem 2 years ago
parent cfa749ab74
commit 9101783703

@ -29,13 +29,13 @@ class AllRequestsProvider extends ChangeNotifier {
AllRequestsAndCount calendarRequests; AllRequestsAndCount calendarRequests;
final pageItemNumber = 10; final pageItemNumber = 10;
int pageNum=1; int pageNum = 1;
bool nextPage = true; bool nextPage = true;
void reset() { void reset() {
allRequestsAndCount?.requestsDetails?.clear(); allRequestsAndCount?.requestsDetails?.clear();
allRequestsAndCount = null; allRequestsAndCount = null;
pageNum=1; pageNum = 1;
nextPage = true; nextPage = true;
stateCode = null; stateCode = null;
} }
@ -48,12 +48,21 @@ class AllRequestsProvider extends ChangeNotifier {
getCompletedRequests(); getCompletedRequests();
} }
SearchAllRequestsModel searchedModel;
Future<int> getAllRequests(BuildContext context, {int typeTransaction, SearchAllRequestsModel search}) async { Future<int> getAllRequests(BuildContext context, {int typeTransaction, SearchAllRequestsModel search}) async {
if (isAllLoading == true) return -2; if (isAllLoading == true) return -2;
isAllLoading = true; isAllLoading = true;
if (allRequestsAndCount == null) notifyListeners(); if (allRequestsAndCount == null) notifyListeners();
Response response; Response response;
try { try {
if (search != null) {
searchedModel = search;
} else if (searchedModel != null) {
search = searchedModel;
} else {
searchedModel = null;
}
final type = typeTransaction == null final type = typeTransaction == null
? search?.typeTransaction == null || search.typeTransaction.isEmpty ? search?.typeTransaction == null || search.typeTransaction.isEmpty
? [1, 2, 3, 4] ? [1, 2, 3, 4]
@ -65,8 +74,8 @@ class AllRequestsProvider extends ChangeNotifier {
"statusTransaction": status, "statusTransaction": status,
"priority": [0, 1], "priority": [0, 1],
"displayData": [], "displayData": [],
"pageNumber" : pageNum++, "pageNumber": pageNum++,
"pageSize" : pageItemNumber, "pageSize": pageItemNumber,
if (search?.requestNumber?.value?.isNotEmpty ?? false) "requestNumber": search.requestNumber.value, if (search?.requestNumber?.value?.isNotEmpty ?? false) "requestNumber": search.requestNumber.value,
if (search?.assetName?.value?.isNotEmpty ?? false) "assetName": search.assetName.value, if (search?.assetName?.value?.isNotEmpty ?? false) "assetName": search.assetName.value,
if (search?.assetNo?.value?.isNotEmpty ?? false) "assetNumber": search.assetNo.value, if (search?.assetNo?.value?.isNotEmpty ?? false) "assetNumber": search.assetNo.value,
@ -82,7 +91,7 @@ class AllRequestsProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
if (allRequestsAndCount == null) { if (allRequestsAndCount == null) {
allRequestsAndCount = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); allRequestsAndCount = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
} else{ } else {
allRequestsAndCount.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); allRequestsAndCount.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
} }
if (allRequestsAndCount.requestsDetails.length >= pageItemNumber) { if (allRequestsAndCount.requestsDetails.length >= pageItemNumber) {
@ -140,7 +149,8 @@ class AllRequestsProvider extends ChangeNotifier {
Future<int> getHighPriorityRequests() async { Future<int> getHighPriorityRequests() async {
if (isHighPriorityLoading == true) return -2; if (isHighPriorityLoading == true) return -2;
isHighPriorityLoading = true; notifyListeners(); isHighPriorityLoading = true;
notifyListeners();
if (highPriorityRequests == null) notifyListeners(); if (highPriorityRequests == null) notifyListeners();
Response response; Response response;
try { try {
@ -183,7 +193,7 @@ class AllRequestsProvider extends ChangeNotifier {
stateCode = response.statusCode; stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
notifyListeners(); notifyListeners();
} }
isOverdueLoading = false; isOverdueLoading = false;

@ -56,8 +56,9 @@ class _AllRequestsFilterPageState extends State<AllRequestsFilterPage> {
} }
final types = { final types = {
context.translation.serviceRequest: 1, context.translation.serviceRequest: 1,
context.translation.preventiveMaintenance: 4,
context.translation.gasRefill: 2, context.translation.gasRefill: 2,
context.translation.deviceTransfer: 3,
context.translation.preventiveMaintenance: 4,
}; };
final statuses = { final statuses = {
context.translation.allRequests: 0, context.translation.allRequests: 0,
@ -78,6 +79,7 @@ class _AllRequestsFilterPageState extends State<AllRequestsFilterPage> {
context.translation.reset, context.translation.reset,
style: AppTextStyles.bodyText2.copyWith(color: AppColor.blueStatus(context)), style: AppTextStyles.bodyText2.copyWith(color: AppColor.blueStatus(context)),
).paddingAll(8).onPress(() { ).paddingAll(8).onPress(() {
Provider.of<AllRequestsProvider>(context, listen: false).searchedModel = null;
setState(() { setState(() {
search.statuses?.clear(); search.statuses?.clear();
search.typeTransaction?.clear(); search.typeTransaction?.clear();
@ -164,6 +166,7 @@ class _AllRequestsFilterPageState extends State<AllRequestsFilterPage> {
if (search.startDate != null) search.endDate ??= DateTime.now(); if (search.startDate != null) search.endDate ??= DateTime.now();
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
requestsProvider.reset(); requestsProvider.reset();
requestsProvider.searchedModel = search;
await requestsProvider.getAllRequests(context, search: search); await requestsProvider.getAllRequests(context, search: search);
Navigator.pop(context); Navigator.pop(context);
Navigator.of(context).pop(search); Navigator.of(context).pop(search);

Loading…
Cancel
Save