update shipment type
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../../../domain/entities/shipment_type.dart';
|
||||
import '../../../pagination/paginator_listener.dart';
|
||||
|
||||
class FcsShipmentModel extends BaseModel {
|
||||
@@ -15,6 +16,9 @@ class FcsShipmentModel extends BaseModel {
|
||||
bool isLoading = false;
|
||||
int selectedIndex = 0;
|
||||
|
||||
List<ShipmentType> shipmentTypes = [];
|
||||
StreamSubscription<QuerySnapshot>? _shipmentTypeListener;
|
||||
|
||||
onChanged(int index) {
|
||||
selectedIndex = index;
|
||||
loadFcsShipments(selectedIndex);
|
||||
@@ -132,11 +136,35 @@ class FcsShipmentModel extends BaseModel {
|
||||
|
||||
void initUser(user) {
|
||||
super.initUser(user);
|
||||
_loadShipmentTypes();
|
||||
}
|
||||
|
||||
@override
|
||||
logout() async {
|
||||
fcsShipments?.close();
|
||||
_shipmentTypeListener?.cancel();
|
||||
shipmentTypes.clear();
|
||||
}
|
||||
|
||||
Future<void> _loadShipmentTypes() async {
|
||||
try {
|
||||
_shipmentTypeListener = FirebaseFirestore.instance
|
||||
.collection(
|
||||
"/$config_collection/$setting_doc_id/$shipment_type_collection")
|
||||
.snapshots()
|
||||
.listen((QuerySnapshot snapshot) {
|
||||
shipmentTypes.clear();
|
||||
shipmentTypes = snapshot.docs.map((documentSnapshot) {
|
||||
var privilege = ShipmentType.fromMap(
|
||||
documentSnapshot.data() as Map<String, dynamic>,
|
||||
documentSnapshot.id);
|
||||
return privilege;
|
||||
}).toList();
|
||||
notifyListeners();
|
||||
});
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> create(FcsShipment fcsShipment) {
|
||||
@@ -163,6 +191,10 @@ class FcsShipmentModel extends BaseModel {
|
||||
return Services.instance.fcsShipmentService.invoiceFcsShipment(id);
|
||||
}
|
||||
|
||||
Future<void> cancel(String id) {
|
||||
return Services.instance.fcsShipmentService.cancelFcsShipment(id);
|
||||
}
|
||||
|
||||
Future<String> report(FcsShipment fcsShipment) {
|
||||
return Services.instance.fcsShipmentService.report(fcsShipment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user