|
|
|
@ -5,6 +5,7 @@ import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
|
|
|
|
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
|
|
|
|
import 'package:test_sa/dashboard_latest/widgets/request_category_list.dart';
|
|
|
|
import 'package:test_sa/dashboard_latest/widgets/request_category_list.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/extensions/enum_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
@ -78,13 +79,26 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
|
|
|
|
|
|
|
|
|
|
|
|
// Reload data with new sort order
|
|
|
|
// Reload data with new sort order
|
|
|
|
dashboardProvider.resetRequestDataList();
|
|
|
|
dashboardProvider.resetRequestDataList();
|
|
|
|
if (dashboardProvider.currentListIndex == null) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (dashboardProvider.listIndex.isEmpty) {
|
|
|
|
|
|
|
|
// No category selected - do nothing or could reload default
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (dashboardProvider.listIndex.length == 1 && dashboardProvider.isUnassignedTab(dashboardProvider.listIndex[0])) {
|
|
|
|
|
|
|
|
// UnAssigned only - check by requestType, not by index
|
|
|
|
|
|
|
|
int index = dashboardProvider.listIndex[0];
|
|
|
|
dashboardProvider.getRequestDetail(
|
|
|
|
dashboardProvider.getRequestDetail(
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
showLoader: true,
|
|
|
|
showLoader: true,
|
|
|
|
status: tabs[dashboardProvider.currentListIndex!].tag,
|
|
|
|
status: tabs[index].tag,
|
|
|
|
tabId: tabs[dashboardProvider.currentListIndex!].id,
|
|
|
|
tabId: tabs[index].id,
|
|
|
|
|
|
|
|
isAscending: isAscending,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Multiple categories - call multi-filter API
|
|
|
|
|
|
|
|
dashboardProvider.getMultiSelectCategoryRequests(
|
|
|
|
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
|
|
|
|
showLoader: true,
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
isAscending: isAscending,
|
|
|
|
isAscending: isAscending,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -180,26 +194,51 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
|
|
|
|
// ],
|
|
|
|
// ],
|
|
|
|
// ).paddingOnly(start: 16, end: 16)
|
|
|
|
// ).paddingOnly(start: 16, end: 16)
|
|
|
|
// : context.translation.allWorkOrder.heading4(context).paddingOnly(start: 16, end: 16),
|
|
|
|
// : context.translation.allWorkOrder.heading4(context).paddingOnly(start: 16, end: 16),
|
|
|
|
(dashboardProvider.currentListIndex == null)
|
|
|
|
(dashboardProvider.listIndex.isEmpty)
|
|
|
|
? Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
|
|
|
|
? Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
|
|
|
|
return RequestItemViewList(
|
|
|
|
return RequestItemViewList(
|
|
|
|
snapshot.allRequestsAndCount?.requestsDetails ?? [],
|
|
|
|
snapshot.allRequestsAndCount?.requestsDetails ?? [],
|
|
|
|
snapshot.isAllLoading,
|
|
|
|
snapshot.isAllLoading,
|
|
|
|
|
|
|
|
disableScroll: true,
|
|
|
|
key: ValueKey('request_list_'), // Key changes on every tab click
|
|
|
|
key: ValueKey('request_list_'), // Key changes on every tab click
|
|
|
|
);
|
|
|
|
);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
: dashboardProvider.isDetailLoading
|
|
|
|
: dashboardProvider.listIndex.length == 1 && dashboardProvider.isUnassignedTab(dashboardProvider.listIndex[0])
|
|
|
|
? Column(
|
|
|
|
// UnAssigned selected (check by requestType, not by index) - show requestDetailList
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
? dashboardProvider.isDetailLoading
|
|
|
|
children: List.generate(3, (index) {
|
|
|
|
? Column(
|
|
|
|
return Padding(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight, horizontal: 0),
|
|
|
|
children: List.generate(3, (index) {
|
|
|
|
child: const SizedBox().toRequestShimmer(context, dashboardProvider.isDetailLoading),
|
|
|
|
return Padding(
|
|
|
|
);
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight, horizontal: 0),
|
|
|
|
})).paddingOnly(start: 16, end: 16, top: 16)
|
|
|
|
child: const SizedBox().toRequestShimmer(context, dashboardProvider.isDetailLoading),
|
|
|
|
: (dashboardProvider.requestDetailList == null || dashboardProvider.requestDetailList?.data?.isEmpty == true)
|
|
|
|
);
|
|
|
|
? const NoDataFound().paddingOnly(top: 80).center
|
|
|
|
})).paddingOnly(start: 16, end: 16, top: 16)
|
|
|
|
: RequestCategoryList(dashboardProvider.requestDetailList?.data ?? <Data>[], dashboardProvider.isDetailLoading, dashboardProvider.requestDetailList?.totalRows ?? 0),
|
|
|
|
: (dashboardProvider.requestDetailList == null || dashboardProvider.requestDetailList?.data?.isEmpty == true)
|
|
|
|
|
|
|
|
? const NoDataFound().paddingOnly(top: 80).center
|
|
|
|
|
|
|
|
: RequestCategoryList(dashboardProvider.requestDetailList?.data ?? <Data>[], dashboardProvider.isDetailLoading, dashboardProvider.requestDetailList?.totalRows ?? 0)
|
|
|
|
|
|
|
|
// Multi-select categories - show allRequestsAndCount
|
|
|
|
|
|
|
|
: Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
|
|
|
|
|
|
|
|
if (snapshot.isMultiFilterLoading) {
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
|
|
|
|
children: List.generate(3, (index) {
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight, horizontal: 0),
|
|
|
|
|
|
|
|
child: const SizedBox().toRequestShimmer(context, snapshot.isMultiFilterLoading),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
})).paddingOnly(start: 16, end: 16, top: 16);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (snapshot.allRequestsAndCount == null || snapshot.allRequestsAndCount?.requestsDetails?.isEmpty == true) {
|
|
|
|
|
|
|
|
return const NoDataFound().paddingOnly(top: 80).center;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return RequestItemViewList(
|
|
|
|
|
|
|
|
snapshot.allRequestsAndCount?.requestsDetails ?? [],
|
|
|
|
|
|
|
|
snapshot.isMultiFilterLoading,
|
|
|
|
|
|
|
|
disableScroll: true,
|
|
|
|
|
|
|
|
key: ValueKey('multi_filter_list_${dashboardProvider.listIndex.join("_")}'),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -277,23 +316,47 @@ class _RequestCategoryFragmentState extends State<RequestCategoryFragment> with
|
|
|
|
width: itemWidth, // Use responsive width
|
|
|
|
width: itemWidth, // Use responsive width
|
|
|
|
child: RequestTypeButton(
|
|
|
|
child: RequestTypeButton(
|
|
|
|
label: tabs[index].label,
|
|
|
|
label: tabs[index].label,
|
|
|
|
loading: requestsProvider.isDetailLoading && requestsProvider.currentListIndex == index,
|
|
|
|
loading: requestsProvider.isDetailLoading && requestsProvider.listIndex.contains(index),
|
|
|
|
isSelected: requestsProvider.currentListIndex == index,
|
|
|
|
isSelected: requestsProvider.listIndex.contains(index),
|
|
|
|
count: requestsProvider.getStatusCount(tabs[index].requestType),
|
|
|
|
count: requestsProvider.getStatusCount(tabs[index].requestType),
|
|
|
|
onPressed: () async {
|
|
|
|
onPressed: () async {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
isAscending = false;
|
|
|
|
isAscending = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if this is UnAssigned tab (index 0 for engineer)
|
|
|
|
|
|
|
|
bool isUnassignedTab = tabs[index].requestType == RequestTypeEnum.unassigned;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update selection state
|
|
|
|
requestsProvider.currentListIndex = index;
|
|
|
|
requestsProvider.currentListIndex = index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Reset data
|
|
|
|
requestsProvider.resetRequestDataList();
|
|
|
|
requestsProvider.resetRequestDataList();
|
|
|
|
requestsProvider.getRequestDetail(
|
|
|
|
Provider.of<AllRequestsProvider>(context, listen: false).reset();
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
|
|
|
|
showLoader: true,
|
|
|
|
// If deselected (listIndex is now empty), show default data
|
|
|
|
status: tabs[index].tag,
|
|
|
|
if (requestsProvider.listIndex.isEmpty) {
|
|
|
|
tabId: tabs[index].id,
|
|
|
|
Provider.of<AllRequestsProvider>(context, listen: false).getAllRequests(context);
|
|
|
|
isHighPriority: tabs[index].isHighPriority,
|
|
|
|
return;
|
|
|
|
isOverdue: tabs[index].isOverDue,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// If UnAssigned is selected, call its separate API
|
|
|
|
|
|
|
|
if (isUnassignedTab) {
|
|
|
|
|
|
|
|
requestsProvider.getRequestDetail(
|
|
|
|
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
|
|
|
|
showLoader: true,
|
|
|
|
|
|
|
|
status: tabs[index].tag,
|
|
|
|
|
|
|
|
tabId: tabs[index].id,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Multiple categories selected - call multi-filter API
|
|
|
|
|
|
|
|
requestsProvider.getMultiSelectCategoryRequests(
|
|
|
|
|
|
|
|
usersType: userType ?? UsersTypes.normal_user,
|
|
|
|
|
|
|
|
showLoader: true,
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
isAscending: isAscending,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
icon: tabs[index].icon,
|
|
|
|
icon: tabs[index].icon,
|
|
|
|
iconColor: tabs[index].iconColor,
|
|
|
|
iconColor: tabs[index].iconColor,
|
|
|
|
|