|
|
|
|
@ -40,12 +40,24 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
stateCode = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void resetRequestsApiData() {
|
|
|
|
|
highPriorityRequests = null;
|
|
|
|
|
overdueRequests = null;
|
|
|
|
|
openRequests = null;
|
|
|
|
|
inProgressRequests = null;
|
|
|
|
|
completedRequests = null;
|
|
|
|
|
pageNum = 1;
|
|
|
|
|
nextPage = true;
|
|
|
|
|
stateCode = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getRequests() {
|
|
|
|
|
getHighPriorityRequests();
|
|
|
|
|
getOverdueRequests();
|
|
|
|
|
getOpenRequests();
|
|
|
|
|
getInProgressRequests();
|
|
|
|
|
getCompletedRequests();
|
|
|
|
|
resetRequestsApiData();
|
|
|
|
|
getHighPriorityRequests(pagination: true);
|
|
|
|
|
getOverdueRequests(pagination: true);
|
|
|
|
|
getOpenRequests(pagination: true);
|
|
|
|
|
getInProgressRequests(pagination: true);
|
|
|
|
|
getCompletedRequests(pagination: true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SearchAllRequestsModel searchedModel;
|
|
|
|
|
@ -147,11 +159,13 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<int> getHighPriorityRequests() async {
|
|
|
|
|
Future<int> getHighPriorityRequests({bool pagination = false}) async {
|
|
|
|
|
if (isHighPriorityLoading == true) return -2;
|
|
|
|
|
isHighPriorityLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (highPriorityRequests == null) notifyListeners();
|
|
|
|
|
|
|
|
|
|
if (highPriorityRequests == null || pagination) {
|
|
|
|
|
isHighPriorityLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
Map<String, dynamic> body = {
|
|
|
|
|
@ -160,11 +174,30 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"priority": [1],
|
|
|
|
|
"displayData": []
|
|
|
|
|
};
|
|
|
|
|
if (pagination) {
|
|
|
|
|
body["pageNumber"] = 0;
|
|
|
|
|
body["pageSize"] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
body["pageNumber"] = pageNum++;
|
|
|
|
|
body["pageSize"] = pageItemNumber;
|
|
|
|
|
}
|
|
|
|
|
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
|
|
|
|
|
stateCode = response.statusCode;
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
if (highPriorityRequests == null) {
|
|
|
|
|
highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
} else {
|
|
|
|
|
highPriorityRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
|
|
|
|
|
}
|
|
|
|
|
if (highPriorityRequests.requestsDetails.length >= pageItemNumber) {
|
|
|
|
|
nextPage = true;
|
|
|
|
|
} else {
|
|
|
|
|
nextPage = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else {
|
|
|
|
|
allRequestsAndCount = null;
|
|
|
|
|
}
|
|
|
|
|
isHighPriorityLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -177,10 +210,12 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<int> getOverdueRequests() async {
|
|
|
|
|
Future<int> getOverdueRequests({bool pagination = false}) async {
|
|
|
|
|
if (isOverdueLoading == true) return -2;
|
|
|
|
|
isOverdueLoading = true;
|
|
|
|
|
if (overdueRequests == null) notifyListeners();
|
|
|
|
|
if (overdueRequests == null || pagination) {
|
|
|
|
|
isOverdueLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
Map<String, dynamic> body = {
|
|
|
|
|
@ -189,12 +224,30 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"priority": [],
|
|
|
|
|
"displayData": [1]
|
|
|
|
|
};
|
|
|
|
|
if (pagination) {
|
|
|
|
|
body["pageNumber"] = 0;
|
|
|
|
|
body["pageSize"] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
body["pageNumber"] = pageNum++;
|
|
|
|
|
body["pageSize"] = pageItemNumber;
|
|
|
|
|
}
|
|
|
|
|
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
|
|
|
|
|
|
|
|
|
|
stateCode = response.statusCode;
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
if (overdueRequests == null) {
|
|
|
|
|
overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
} else {
|
|
|
|
|
overdueRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
|
|
|
|
|
}
|
|
|
|
|
if (overdueRequests.requestsDetails.length >= pageItemNumber) {
|
|
|
|
|
nextPage = true;
|
|
|
|
|
} else {
|
|
|
|
|
nextPage = false;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else {
|
|
|
|
|
allRequestsAndCount = null;
|
|
|
|
|
}
|
|
|
|
|
isOverdueLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -207,10 +260,16 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<int> getOpenRequests() async {
|
|
|
|
|
Future<int> getOpenRequests({bool pagination = false, bool reset = false}) async {
|
|
|
|
|
if (isOpenLoading == true) return -2;
|
|
|
|
|
isOpenLoading = true;
|
|
|
|
|
if (openRequests == null) notifyListeners();
|
|
|
|
|
if (reset) {
|
|
|
|
|
openRequests = null;
|
|
|
|
|
pageNum = 1;
|
|
|
|
|
}
|
|
|
|
|
if (openRequests == null || pagination) {
|
|
|
|
|
isOpenLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
bool isEngineer = ApiManager.instance.user.type == UsersTypes.engineer;
|
|
|
|
|
@ -220,12 +279,30 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"priority": [],
|
|
|
|
|
"displayData": []
|
|
|
|
|
};
|
|
|
|
|
if (pagination) {
|
|
|
|
|
body["pageNumber"] = 0;
|
|
|
|
|
body["pageSize"] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
body["pageNumber"] = pageNum++;
|
|
|
|
|
body["pageSize"] = pageItemNumber;
|
|
|
|
|
}
|
|
|
|
|
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
|
|
|
|
|
|
|
|
|
|
stateCode = response.statusCode;
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
openRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
if (openRequests == null) {
|
|
|
|
|
openRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
} else {
|
|
|
|
|
openRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
|
|
|
|
|
}
|
|
|
|
|
if (openRequests.requestsDetails.length >= pageItemNumber) {
|
|
|
|
|
nextPage = true;
|
|
|
|
|
} else {
|
|
|
|
|
nextPage = false;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else {
|
|
|
|
|
allRequestsAndCount = null;
|
|
|
|
|
}
|
|
|
|
|
isOpenLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -238,10 +315,16 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<int> getInProgressRequests() async {
|
|
|
|
|
Future<int> getInProgressRequests({bool pagination = false, bool reset = false}) async {
|
|
|
|
|
if (isInProgressLoading == true) return -2;
|
|
|
|
|
isInProgressLoading = true;
|
|
|
|
|
if (inProgressRequests == null) notifyListeners();
|
|
|
|
|
if (reset) {
|
|
|
|
|
inProgressRequests = null;
|
|
|
|
|
pageNum = 1;
|
|
|
|
|
}
|
|
|
|
|
if (inProgressRequests == null || pagination) {
|
|
|
|
|
isInProgressLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
Map<String, dynamic> body = {
|
|
|
|
|
@ -250,12 +333,30 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"priority": [],
|
|
|
|
|
"displayData": []
|
|
|
|
|
};
|
|
|
|
|
if (pagination) {
|
|
|
|
|
body["pageNumber"] = 0;
|
|
|
|
|
body["pageSize"] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
body["pageNumber"] = pageNum++;
|
|
|
|
|
body["pageSize"] = pageItemNumber;
|
|
|
|
|
}
|
|
|
|
|
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
|
|
|
|
|
|
|
|
|
|
stateCode = response.statusCode;
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
inProgressRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
if (inProgressRequests == null) {
|
|
|
|
|
inProgressRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
} else {
|
|
|
|
|
inProgressRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
|
|
|
|
|
}
|
|
|
|
|
if (inProgressRequests.requestsDetails.length >= pageItemNumber) {
|
|
|
|
|
nextPage = true;
|
|
|
|
|
} else {
|
|
|
|
|
nextPage = false;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else {
|
|
|
|
|
allRequestsAndCount = null;
|
|
|
|
|
}
|
|
|
|
|
isInProgressLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -268,10 +369,16 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<int> getCompletedRequests() async {
|
|
|
|
|
Future<int> getCompletedRequests({bool pagination = false, bool reset = false}) async {
|
|
|
|
|
if (isCompleteLoading == true) return -2;
|
|
|
|
|
isCompleteLoading = true;
|
|
|
|
|
if (completedRequests == null) notifyListeners();
|
|
|
|
|
if (reset) {
|
|
|
|
|
completedRequests = null;
|
|
|
|
|
pageNum = 1;
|
|
|
|
|
}
|
|
|
|
|
if (completedRequests == null || pagination) {
|
|
|
|
|
isCompleteLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
Map<String, dynamic> body = {
|
|
|
|
|
@ -280,12 +387,30 @@ class AllRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"priority": [],
|
|
|
|
|
"displayData": []
|
|
|
|
|
};
|
|
|
|
|
if (pagination) {
|
|
|
|
|
body["pageNumber"] = 0;
|
|
|
|
|
body["pageSize"] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
body["pageNumber"] = pageNum++;
|
|
|
|
|
body["pageSize"] = pageItemNumber;
|
|
|
|
|
}
|
|
|
|
|
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
|
|
|
|
|
|
|
|
|
|
stateCode = response.statusCode;
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
completedRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
if (completedRequests == null) {
|
|
|
|
|
completedRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
|
|
|
|
|
} else {
|
|
|
|
|
completedRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
|
|
|
|
|
}
|
|
|
|
|
if (completedRequests.requestsDetails.length >= pageItemNumber) {
|
|
|
|
|
nextPage = true;
|
|
|
|
|
} else {
|
|
|
|
|
nextPage = false;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else {
|
|
|
|
|
allRequestsAndCount = null;
|
|
|
|
|
}
|
|
|
|
|
isCompleteLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|