From a5924134499882e37d6f9fd4620669d3f1cce91a Mon Sep 17 00:00:00 2001 From: tzw Date: Wed, 31 Jan 2024 17:54:22 +0630 Subject: [PATCH] update shipment filter --- lib/domain/constants.dart | 1 + lib/domain/entities/fcs_shipment.dart | 1 - lib/pages/fcs_shipment/fcs_shipment_list.dart | 26 ++++++-------- .../model/fcs_shipment_model.dart | 34 +++++++++++++++++-- .../widgets/local_popup_menu_button.dart | 15 ++++---- 5 files changed, 50 insertions(+), 27 deletions(-) diff --git a/lib/domain/constants.dart b/lib/domain/constants.dart index e962337..5173553 100644 --- a/lib/domain/constants.dart +++ b/lib/domain/constants.dart @@ -54,6 +54,7 @@ const fcs_shipment_processing_status = "processing"; const fcs_shipment_arrived_status = "arrived"; const fcs_shipment_invoiced_status = "invoiced"; const fcs_shipment_delivered_status = "delivered"; +const fcs_shipment_canceled_status = "canceled"; // Package status const package_received_status = "received"; diff --git a/lib/domain/entities/fcs_shipment.dart b/lib/domain/entities/fcs_shipment.dart index 4f015dd..933be02 100644 --- a/lib/domain/entities/fcs_shipment.dart +++ b/lib/domain/entities/fcs_shipment.dart @@ -59,7 +59,6 @@ class FcsShipment { 'cutoff_date': cutoffDate?.toUtc().toIso8601String(), 'shipment_type': shipType, 'arrival_date': arrivalDate?.toUtc().toIso8601String(), - 'departure_date': departureDate?.toUtc().toIso8601String(), 'consignee': consignee, 'port': port, 'destination': destination, diff --git a/lib/pages/fcs_shipment/fcs_shipment_list.dart b/lib/pages/fcs_shipment/fcs_shipment_list.dart index 894083b..d170022 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_list.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_list.dart @@ -44,29 +44,23 @@ class _FcsShipmentListState extends State { final popupMenu = LocalPopupMenuButton( popmenus: [ LocalPopupMenu( - id: 0, - text: "All", - selected: shipmentModel.selectedIndex == 0), + id: 0, text: "All", selected: shipmentModel.selectedIndex == 0), LocalPopupMenu( - id: 1, - text: "Pending", - selected: shipmentModel.selectedIndex == 1), + id: 1, text: "Pending", selected: shipmentModel.selectedIndex == 1), LocalPopupMenu( id: 2, text: "Processing", selected: shipmentModel.selectedIndex == 2), - LocalPopupMenu( - id: 3, - text: "Shipped", - selected: shipmentModel.selectedIndex == 3), - LocalPopupMenu( - id: 4, - text: "Arrived", - selected: shipmentModel.selectedIndex == 4), - LocalPopupMenu( + LocalPopupMenu( + id: 3, text: "Shipped", selected: shipmentModel.selectedIndex == 3), + LocalPopupMenu( + id: 4, text: "Arrived", selected: shipmentModel.selectedIndex == 4), + LocalPopupMenu( id: 5, text: "Invoiced", - selected: shipmentModel.selectedIndex == 5) + selected: shipmentModel.selectedIndex == 5), + LocalPopupMenu( + id: 6, text: "Canceled", selected: shipmentModel.selectedIndex == 6) ], popupMenuCallback: (p) { setState(() { diff --git a/lib/pages/fcs_shipment/model/fcs_shipment_model.dart b/lib/pages/fcs_shipment/model/fcs_shipment_model.dart index 26f501e..9d6a6d5 100644 --- a/lib/pages/fcs_shipment/model/fcs_shipment_model.dart +++ b/lib/pages/fcs_shipment/model/fcs_shipment_model.dart @@ -28,18 +28,48 @@ class FcsShipmentModel extends BaseModel { Query col = FirebaseFirestore.instance.collection(path); Query pageQuery = FirebaseFirestore.instance.collection(path); + // pending status if (index == 1) { - col = col.where("status", isEqualTo: fcs_shipment_confirmed_status); + col = col.where("status", isEqualTo: fcs_shipment_pending_status); pageQuery = - pageQuery.where("status", isEqualTo: fcs_shipment_confirmed_status); + pageQuery.where("status", isEqualTo: fcs_shipment_pending_status); } + // processing status if (index == 2) { + col = col.where("status", isEqualTo: fcs_shipment_processing_status); + pageQuery = + pageQuery.where("status", isEqualTo: fcs_shipment_processing_status); + } + + // shipped status + if (index == 3) { col = col.where("status", isEqualTo: fcs_shipment_shipped_status); pageQuery = pageQuery.where("status", isEqualTo: fcs_shipment_shipped_status); } + // arrived status + if (index == 4) { + col = col.where("status", isEqualTo: fcs_shipment_arrived_status); + pageQuery = + pageQuery.where("status", isEqualTo: fcs_shipment_arrived_status); + } + + // invoiced status + if (index == 5) { + col = col.where("status", isEqualTo: fcs_shipment_invoiced_status); + pageQuery = + pageQuery.where("status", isEqualTo: fcs_shipment_invoiced_status); + } + + // canceled status + if (index == 6) { + col = col.where("status", isEqualTo: fcs_shipment_canceled_status); + pageQuery = + pageQuery.where("status", isEqualTo: fcs_shipment_canceled_status); + } + pageQuery = pageQuery.orderBy("shipment_number", descending: true); fcsShipments?.close(); diff --git a/lib/pages/widgets/local_popup_menu_button.dart b/lib/pages/widgets/local_popup_menu_button.dart index 5c0eae1..1493eda 100644 --- a/lib/pages/widgets/local_popup_menu_button.dart +++ b/lib/pages/widgets/local_popup_menu_button.dart @@ -74,23 +74,22 @@ class _LocalPopupMenuButtonState extends State { //color: Colors.white, ), child: Stack( - fit: StackFit.expand, + alignment: Alignment.center, children: [ Icon( widget.buttonIcon ?? Icons.filter_list, color: Colors.white, ), - hightlight ? Positioned( - bottom: 0, + bottom: 15, right: 0, child: Container( width: 10, height: 10, decoration: new BoxDecoration( shape: BoxShape.circle, - color: secondaryColor, + color: secondaryColor, ), ), ) @@ -106,11 +105,12 @@ class _LocalPopupMenuButtonState extends State { choice.text != null ? Text(choice.text!, style: TextStyle( - fontSize: 13, + fontSize: 14, color: choice.enabled ? primaryColor : Colors.grey)) : LocalText(context, choice.textKey ?? "", - color: choice.enabled ? primaryColor : Colors.grey), + color: choice.enabled ? primaryColor : Colors.grey, + fontSize: 14), SizedBox( width: 10, ), @@ -119,8 +119,7 @@ class _LocalPopupMenuButtonState extends State { Icons.check, color: Colors.grey, ) - : Container( - ), + : Container(), ], ), );