flow updates
This commit is contained in:
parent
cc78c3e1be
commit
f1abe6572d
1 changed files with 101 additions and 16 deletions
|
@ -214,7 +214,8 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
|||
title: Text(x.id),
|
||||
onTap: () =>
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(x),
|
||||
builder: (context) =>
|
||||
ActiveFlowPage(x, widget.info),
|
||||
))))
|
||||
.toList()),
|
||||
);
|
||||
|
@ -235,8 +236,9 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
|||
class CreateFlowPage extends StatefulWidget {
|
||||
final API.FlowInfo info;
|
||||
final Function refresh;
|
||||
final API.Flow? previousFlow;
|
||||
|
||||
const CreateFlowPage(this.info, this.refresh, {super.key});
|
||||
const CreateFlowPage(this.info, this.refresh, {this.previousFlow, super.key});
|
||||
|
||||
@override
|
||||
State<CreateFlowPage> createState() => _CreateFlowPageState();
|
||||
|
@ -246,14 +248,31 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
|||
List<API.Transaction> depends = [];
|
||||
|
||||
void _create(BuildContext context) {
|
||||
if (widget.previousFlow != null) {
|
||||
API
|
||||
.API()
|
||||
.continueFlow(widget.previousFlow!.id,
|
||||
input: depends.map((x) => x.uuid).toList())
|
||||
.then((x) {
|
||||
API.API().getFlow(x).then((flow) {
|
||||
API.API().getFlowInfo(flow.kind).then((info) {
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(flow, info),
|
||||
));
|
||||
});
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
API
|
||||
.API()
|
||||
.startFlow(widget.info.id, input: depends.map((x) => x.uuid).toList())
|
||||
.then((flowID) {
|
||||
widget.refresh();
|
||||
API.API().getFlow(flowID).then((flow) {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (context) => ActiveFlowPage(flow)));
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(flow, widget.info)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -293,6 +312,7 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
|||
appBar: AppBar(title: Text("Create new ${widget.info.name} Flow")),
|
||||
body: Column(
|
||||
children: [
|
||||
// todo : flow continuation overview
|
||||
buildInputSelection(context),
|
||||
const Divider(),
|
||||
Card(
|
||||
|
@ -352,23 +372,88 @@ class TransactionSelectPage extends StatelessWidget {
|
|||
|
||||
class ActiveFlowPage extends StatelessWidget {
|
||||
final API.Flow flow;
|
||||
final API.FlowInfo info;
|
||||
|
||||
const ActiveFlowPage(this.flow, {super.key});
|
||||
const ActiveFlowPage(this.flow, this.info, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(info.name),
|
||||
actions: [
|
||||
// todo : end flow
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
if (info.produces?.isNotEmpty ?? false) {
|
||||
// todo : show end screen with produce
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// simple dialog
|
||||
var confirm = await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text('This will delete the flow.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirm) {
|
||||
await API
|
||||
.API()
|
||||
.endFlow(flow.id)
|
||||
.then((x) => Navigator.of(context).pop());
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.stop)),
|
||||
// todo : continue next flow
|
||||
if (info.next != null)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
API.API().getFlowInfo(info.next!).then((newInfo) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CreateFlowPage(
|
||||
newInfo,
|
||||
() {},
|
||||
previousFlow: flow,
|
||||
);
|
||||
},
|
||||
));
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.arrow_forward)),
|
||||
|
||||
// todo : add notes to flow
|
||||
IconButton(onPressed: () {}, icon: const Icon(Icons.note))
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Text("ID: ${flow.id}"),
|
||||
Text("Started since: ${tsFormat(flow.started)}"),
|
||||
...flow.input!.map((x) => Text("Input: $x")).toList(),
|
||||
if (flow.done != null) ...[
|
||||
Text("Ended: ${tsFormat(flow.done!.ended)}"),
|
||||
if (flow.done!.next != null) Text("Next: ${flow.done!.next!}"),
|
||||
...flow.done!.produced!.map((x) => Text("Produced: $x")).toList(),
|
||||
]
|
||||
],
|
||||
));
|
||||
children: [
|
||||
Text("ID: ${flow.id}"),
|
||||
Text("Started since: ${tsFormat(flow.started)}"),
|
||||
...flow.input!.map((x) => Text("Input: $x")).toList(),
|
||||
if (flow.done != null) ...[
|
||||
Text("Ended: ${tsFormat(flow.done!.ended)}"),
|
||||
if (flow.done!.next != null) Text("Next: ${flow.done!.next!}"),
|
||||
...flow.done!.produced!.map((x) => Text("Produced: $x")).toList(),
|
||||
],
|
||||
|
||||
const Divider(),
|
||||
// todo : show notes
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue