2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 18:25:26 +00:00

Add actions to issue or cancel purchase orders (#313)

This commit is contained in:
Oliver
2023-04-11 22:52:27 +10:00
committed by GitHub
parent 164295c3e2
commit 943104f20c
4 changed files with 99 additions and 1 deletions

View File

@ -26,7 +26,7 @@ Future<void> confirmationDialog(String title, String text, {Color? color, IconDa
title: Text(title, style: TextStyle(color: color)),
leading: FaIcon(icon, color: color),
),
content: Text(text),
content: text.isEmpty ? Text(text) : null,
actions: [
TextButton(
child: Text(_reject),

View File

@ -1,5 +1,7 @@
import "package:flutter/material.dart";
import "package:flutter_speed_dial/flutter_speed_dial.dart";
import "package:font_awesome_flutter/font_awesome_flutter.dart";
import "package:inventree/widget/dialogs.dart";
import "package:one_context/one_context.dart";
import "package:inventree/api.dart";
@ -62,6 +64,72 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
return actions;
}
@override
List<SpeedDialChild> actionButtons(BuildContext context) {
List<SpeedDialChild> actions = [];
if (api.checkPermission("purchase_order", "add")) {
if (order.isPending) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.paperPlane, color: Colors.blue),
label: L10().issueOrder,
onTap: () async {
_issueOrder(context);
}
)
);
}
if (order.isOpen) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.circleXmark, color: Colors.red),
label: L10().cancelOrder,
onTap: () async {
_cancelOrder(context);
}
)
);
}
}
return actions;
}
/// Issue this order
Future<void> _issueOrder(BuildContext context) async {
confirmationDialog(
L10().issueOrder, "",
icon: FontAwesomeIcons.paperPlane,
color: Colors.blue,
acceptText: L10().issue,
onAccept: () async {
await order.issueOrder().then((dynamic) {
refresh(context);
});
}
);
}
/// Cancel this order
Future<void> _cancelOrder(BuildContext context) async {
confirmationDialog(
L10().cancelOrder, "",
icon: FontAwesomeIcons.circleXmark,
color: Colors.red,
acceptText: L10().cancel,
onAccept: () async {
await order.cancelOrder().then((dynamic) {
print("callback");
refresh(context);
});
}
);
}
@override
Future<void> request(BuildContext context) async {
await order.reload();