Track Asset Transfer [Most Recent]

main_design2.0
zaid_daoud 2 years ago
parent 232713f841
commit fd439a4f46

@ -83,7 +83,6 @@ class DeviceTransferProvider extends ChangeNotifier {
List<DeviceTransfer> itemsPage = listJson.map((request) => DeviceTransfer.fromJson(request)).toList(); List<DeviceTransfer> itemsPage = listJson.map((request) => DeviceTransfer.fromJson(request)).toList();
items ??= []; items ??= [];
items.addAll(itemsPage.toSet().toList()); items.addAll(itemsPage.toSet().toList());
sortMostRecent(items, deviceTransferSearch.mostRecent);
notifyListeners(); notifyListeners();
if (itemsPage.length == pageItemNumber) { if (itemsPage.length == pageItemNumber) {
nextPage = true; nextPage = true;
@ -102,13 +101,6 @@ class DeviceTransferProvider extends ChangeNotifier {
} }
} }
void sortMostRecent(List<DeviceTransfer> transfer, bool mostRecent) {
if (mostRecent != null) {
transfer.sort((prev, next) =>
(mostRecent ?? false) ? DateTime.tryParse(next.createdOn).compareTo(DateTime.tryParse(prev.createdOn)) : DateTime.tryParse(prev.createdOn).compareTo(DateTime.tryParse(next.createdOn)));
}
}
Future<DeviceTransfer> getRequestById({int assetTransferId}) async { Future<DeviceTransfer> getRequestById({int assetTransferId}) async {
Response response; Response response;
try { try {

@ -22,7 +22,7 @@ class DeviceTransferSearch {
this.department, this.department,
this.room, this.room,
this.title, this.title,
this.mostRecent, this.mostRecent = true,
}); });
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -33,6 +33,9 @@ class DeviceTransferSearch {
if (device != null) { if (device != null) {
search["assetId"] = device.id; search["assetId"] = device.id;
} }
if (mostRecent != null) {
search["mostRecent"] = mostRecent;
}
if (hospital?.id != null) { if (hospital?.id != null) {
search["destSiteId"] = hospital.id; search["destSiteId"] = hospital.id;
} }

@ -179,7 +179,7 @@ class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> wi
), ),
SizedBox(height: 16.0 * AppStyle.getScaleFactor(context)), SizedBox(height: 16.0 * AppStyle.getScaleFactor(context)),
Visibility( Visibility(
visible: _search.toMap().isNotEmpty, visible: (_search.toMap()?.remove("mostRecent"))?.isNotEmpty,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: AButton( child: AButton(

Loading…
Cancel
Save