Worklist updates

faiz_marathon_signalR_critical
haroon amjad 2 years ago
parent b971795be9
commit 8b0bae0891

@ -81,8 +81,8 @@ class ApiClient {
} }
if (!kReleaseMode) { if (!kReleaseMode) {
print("Url:$url"); print("Url:$url");
var bodyJson = json.encode(jsonObject); // var bodyJson = json.encode(jsonObject);
print("body:$bodyJson"); // print("body:$bodyJson");
} }
var response = await postJsonForResponse(url, jsonObject, var response = await postJsonForResponse(url, jsonObject,
token: token, token: token,

@ -52,6 +52,10 @@ class Utils {
} }
} }
static Future delay(int millis) async {
return await Future.delayed(Duration(milliseconds: millis));
}
static void showLoading(BuildContext context) { static void showLoading(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
_isLoadingVisible = true; _isLoadingVisible = true;
@ -65,10 +69,6 @@ class Utils {
}); });
} }
static Future delay(int millis) async {
return await Future.delayed(Duration(milliseconds: millis));
}
static void hideLoading(BuildContext context) { static void hideLoading(BuildContext context) {
if (_isLoadingVisible) { if (_isLoadingVisible) {
_isLoadingVisible = false; _isLoadingVisible = false;

@ -134,15 +134,15 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
workListCounter = genericResponseModel?.pOPENNTFNUMBER ?? 0; workListCounter = genericResponseModel?.pOPENNTFNUMBER ?? 0;
itgFormsModel = await DashboardApiClient().getItgFormsPendingTask(); if (showLoading) Utils.hideLoading(context);
workListCounter = workListCounter + (itgFormsModel?.totalCount ?? 0);
GenericResponseModel? cocGenericResponseModel = await DashboardApiClient().getCOCNotifications(); GenericResponseModel? cocGenericResponseModel = await DashboardApiClient().getCOCNotifications();
cocCount = cocGenericResponseModel?.mohemmITGPendingTaskResponseItem; cocCount = cocGenericResponseModel?.mohemmITGPendingTaskResponseItem;
if (cocCount != null) { if (cocCount != null) {
cocFinalCount = (cocCount?.escalation ?? 0) + (cocCount?.waitingToClose ?? 0) + (cocCount?.waitingForAcceptance ?? 0) + (cocCount?.extendTATRequest ?? 0); cocFinalCount = (cocCount?.escalation ?? 0) + (cocCount?.waitingToClose ?? 0) + (cocCount?.waitingForAcceptance ?? 0) + (cocCount?.extendTATRequest ?? 0);
workListCounter += cocFinalCount; workListCounter += cocFinalCount;
} }
if (showLoading) Utils.hideLoading(context); itgFormsModel = await DashboardApiClient().getItgFormsPendingTask();
workListCounter = workListCounter + (itgFormsModel?.totalCount ?? 0);
notifyListeners(); notifyListeners();
} catch (ex) { } catch (ex) {
isWorkListLoading = false; isWorkListLoading = false;

@ -164,6 +164,7 @@ class _AppDrawerState extends State<AppDrawer> {
AppState().setPostParamsModel(obj!); AppState().setPostParamsModel(obj!);
Navigator.pop(context); Navigator.pop(context);
widget.onLanguageChange(); widget.onLanguageChange();
setState(() {});
} }
void performLogout() async { void performLogout() async {

@ -183,7 +183,6 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
), ),
), ),
), ),
10.height,
AppState().isArabic(context) AppState().isArabic(context)
? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1)
: getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1),
@ -194,7 +193,7 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
// // } // // }
// ), // ),
getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)),
16.height, // 8.height,
getOffersList.discount!.toText14(isBold: true, maxlines: 1), getOffersList.discount!.toText14(isBold: true, maxlines: 1),
10.height, 10.height,
Row( Row(
@ -211,9 +210,13 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
List<OffersListModel> results = []; List<OffersListModel> results = [];
if (enteredKeyword.isEmpty) { if (enteredKeyword.isEmpty) {
results = getOffersList; results = getOffersList;
} else {
if(AppState().isArabic(context)) {
results = getOffersList.where((offer) => offer.titleAR!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList();
} else { } else {
results = getOffersList.where((offer) => offer.title!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList(); results = getOffersList.where((offer) => offer.title!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList();
} }
}
setState(() { setState(() {
_foundOffersList = results; _foundOffersList = results;
}); });

@ -120,9 +120,8 @@ class _WorkListScreenState extends State<WorkListScreen> {
ItgFormsModel? itgFormsModel; ItgFormsModel? itgFormsModel;
int? itgRequestTypeIndex; int? itgRequestTypeIndex;
Future<void> getWorkList({bool showLoading = true}) async { Future<void> getWorkList({bool showLoading = true, bool callWorkList = true}) async {
try { try {
if (showLoading) Utils.showLoading(context);
if (workListItemTypes[workListItemIndex].key == "ITG") { if (workListItemTypes[workListItemIndex].key == "ITG") {
itgFormsModel = await WorkListApiClient().getITGTaskCountRequestType(); itgFormsModel = await WorkListApiClient().getITGTaskCountRequestType();
List<RequestDetails> requestAllList = []; List<RequestDetails> requestAllList = [];
@ -138,31 +137,36 @@ class _WorkListScreenState extends State<WorkListScreen> {
itgRequestTypeIndex = 0; itgRequestTypeIndex = 0;
} }
} else { } else {
if (showLoading) Utils.showLoading(context);
itgRequestTypeIndex = null; itgRequestTypeIndex = null;
if (callWorkList) {
workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, pNotificationType.toString()); workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, pNotificationType.toString());
AppState().setWorkList = workList; AppState().setWorkList = workList;
} }
if (showLoading) Utils.hideLoading(context); if (showLoading) Utils.hideLoading(context);
if (showLoading) setState(() {}); setState(() {});
}
} catch (ex) { } catch (ex) {
if (showLoading) Utils.hideLoading(context); if (showLoading) Utils.hideLoading(context);
if (showLoading) Utils.handleException(ex, context, null); if (showLoading) Utils.handleException(ex, context, null);
} }
} }
void _onRefresh() async { void _onRefresh({bool callWorkList = true}) async {
try { try {
_refreshController.refreshCompleted(); _refreshController.refreshCompleted();
Utils.showLoading(context); if(callWorkList) Utils.showLoading(context);
List dataOnRefresh = await Future.wait([ List dataOnRefresh = await Future.wait([
providerData.fetchWorkListCounter(context, showLoading: false), providerData.fetchWorkListCounter(context, showLoading: true).then((value) {
getWorkList(showLoading: false), setState(() {});
}),
getWorkList(showLoading: false, callWorkList: callWorkList),
]); ]);
calculateCounter(); calculateCounter();
Utils.hideLoading(context); if(callWorkList) Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (ex) { } catch (ex) {
Utils.hideLoading(context); if(callWorkList) Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }
@ -443,6 +447,7 @@ class _WorkListScreenState extends State<WorkListScreen> {
if (mounted) setState(() {}); if (mounted) setState(() {});
} }
} else { } else {
_onRefresh(callWorkList: false);
if (mounted) setState(() {}); if (mounted) setState(() {});
} }
}, },

@ -40,6 +40,7 @@ import 'package:mohem_flutter_app/widgets/dialogs/accept_reject_input_dialog.dar
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
class WorkListDetailScreen extends StatefulWidget { class WorkListDetailScreen extends StatefulWidget {
WorkListDetailScreen({Key? key}) : super(key: key); WorkListDetailScreen({Key? key}) : super(key: key);
@override @override
@ -98,6 +99,12 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") { if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") {
getUserInformation(); getUserInformation();
} }
getNotificationButtons();
notificationGetRespondAttributes();
getAttachments();
getActionHistory();
if (workListData!.iTEMTYPE == "HRSSA") { if (workListData!.iTEMTYPE == "HRSSA") {
if (workListData!.rEQUESTTYPE == "EIT") { if (workListData!.rEQUESTTYPE == "EIT") {
getEitNotificationBody(); getEitNotificationBody();
@ -130,8 +137,6 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
getPRNotification(); getPRNotification();
} }
notificationGetRespondAttributes();
// List dataToFetch = await Future.wait([ // List dataToFetch = await Future.wait([
// //
// WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!), // WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!),
@ -142,10 +147,6 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
// actionHistoryList = dataToFetch[1]; // actionHistoryList = dataToFetch[1];
// getAttachmentList = dataToFetch[2]; // getAttachmentList = dataToFetch[2];
getNotificationButtons();
getActionHistory();
getAttachments();
// if (notificationButtonsList.isNotEmpty) { // if (notificationButtonsList.isNotEmpty) {
// isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE"); // isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE");
// isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); // isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED");
@ -487,7 +488,6 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
builder: (cxt) => AcceptRejectInputDialog( builder: (cxt) => AcceptRejectInputDialog(
message: LocaleKeys.requestedItems.tr(), message: LocaleKeys.requestedItems.tr(),
notificationGetRespond: notificationNoteInput, notificationGetRespond: notificationNoteInput,
textEditingController: textEditingController,
onTap: (note) { onTap: (note) {
Map<String, dynamic> payload = { Map<String, dynamic> payload = {
"P_ACTION_MODE": actionMode, "P_ACTION_MODE": actionMode,
@ -503,7 +503,7 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
} }
], ],
}; };
if (actionMode == "APPROVED" || actionMode == "APPROVE") { if (actionMode == "APPROVED" || actionMode == "APPROVE" || actionMode == "CLOSE") {
performNotificationAction(payload); performNotificationAction(payload);
} else if (note.isNotEmpty && (actionMode != "APPROVED" || actionMode != "APPROVE")) { } else if (note.isNotEmpty && (actionMode != "APPROVED" || actionMode != "APPROVE")) {
performNotificationAction(payload); performNotificationAction(payload);
@ -540,34 +540,34 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
void getEitNotificationBody() async { void getEitNotificationBody() async {
try { try {
if (apiCallCount == 0) Utils.showLoading(context); // if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++; // apiCallCount++;
getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID);
apiCallCount--; // apiCallCount--;
if (apiCallCount == 0) { // if (apiCallCount == 0) {
Utils.hideLoading(context); // Utils.hideLoading(context);
setState(() {}); setState(() {});
} // }
} catch (ex) { } catch (ex) {
apiCallCount--; // apiCallCount--;
Utils.hideLoading(context); // Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }
void getUserInformation() async { void getUserInformation() async {
try { try {
if (apiCallCount == 0) Utils.showLoading(context); // if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++; // apiCallCount++;
memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!);
apiCallCount--; // apiCallCount--;
if (apiCallCount == 0) { // if (apiCallCount == 0) {
Utils.hideLoading(context); // Utils.hideLoading(context);
setState(() {}); setState(() {});
} // }
} catch (ex) { } catch (ex) {
apiCallCount--; // apiCallCount--;
Utils.hideLoading(context); // Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }
@ -608,17 +608,17 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
void getAbsenceNotificationBody() async { void getAbsenceNotificationBody() async {
try { try {
if (apiCallCount == 0) Utils.showLoading(context); // if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++; // apiCallCount++;
getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID);
apiCallCount--; // apiCallCount--;
if (apiCallCount == 0) { // if (apiCallCount == 0) {
Utils.hideLoading(context); // Utils.hideLoading(context);
setState(() {}); setState(() {});
} // }
} catch (ex) { } catch (ex) {
apiCallCount--; // apiCallCount--;
Utils.hideLoading(context); // Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }
@ -731,20 +731,20 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
void notificationGetRespondAttributes() async { void notificationGetRespondAttributes() async {
try { try {
if (apiCallCount == 0) Utils.showLoading(context); // if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++; // apiCallCount++;
getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!);
if (getNotificationRespondAttributes.isNotEmpty) { if (getNotificationRespondAttributes.isNotEmpty) {
notificationNoteInput = getNotificationRespondAttributes.first; notificationNoteInput = getNotificationRespondAttributes.first;
} }
apiCallCount--; // apiCallCount--;
if (apiCallCount == 0) { // if (apiCallCount == 0) {
Utils.hideLoading(context); // Utils.hideLoading(context);
setState(() {}); setState(() {});
} // }
} catch (ex) { } catch (ex) {
apiCallCount--; // apiCallCount--;
Utils.hideLoading(context); // Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }
@ -773,17 +773,17 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
void getActionHistory() async { void getActionHistory() async {
try { try {
if (apiCallCount == 0) Utils.showLoading(context); // if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++; // apiCallCount++;
actionHistoryList = await WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!); actionHistoryList = await WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!);
apiCallCount--; // apiCallCount--;
if (apiCallCount == 0) { // if (apiCallCount == 0) {
Utils.hideLoading(context); // Utils.hideLoading(context);
setState(() {}); setState(() {});
} // }
} catch (ex) { } catch (ex) {
apiCallCount--; // apiCallCount--;
Utils.hideLoading(context); // Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }

@ -15,9 +15,9 @@ class AcceptRejectInputDialog extends StatelessWidget {
final String? okTitle; final String? okTitle;
final NotificationGetRespondAttributesList? notificationGetRespond; final NotificationGetRespondAttributesList? notificationGetRespond;
final Function(String) onTap; final Function(String) onTap;
final TextEditingController textEditingController; // final TextEditingController textEditingController;
AcceptRejectInputDialog({Key? key, this.title, @required this.message, this.okTitle, required this.onTap, this.notificationGetRespond, required this.textEditingController}) : super(key: key); AcceptRejectInputDialog({Key? key, this.title, @required this.message, this.okTitle, required this.onTap, this.notificationGetRespond}) : super(key: key);
String note = ""; String note = "";

Loading…
Cancel
Save