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),
|
title: Text(x.id),
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
builder: (context) => ActiveFlowPage(x),
|
builder: (context) =>
|
||||||
|
ActiveFlowPage(x, widget.info),
|
||||||
))))
|
))))
|
||||||
.toList()),
|
.toList()),
|
||||||
);
|
);
|
||||||
|
@ -235,8 +236,9 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
||||||
class CreateFlowPage extends StatefulWidget {
|
class CreateFlowPage extends StatefulWidget {
|
||||||
final API.FlowInfo info;
|
final API.FlowInfo info;
|
||||||
final Function refresh;
|
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
|
@override
|
||||||
State<CreateFlowPage> createState() => _CreateFlowPageState();
|
State<CreateFlowPage> createState() => _CreateFlowPageState();
|
||||||
|
@ -246,14 +248,31 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
||||||
List<API.Transaction> depends = [];
|
List<API.Transaction> depends = [];
|
||||||
|
|
||||||
void _create(BuildContext context) {
|
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
|
||||||
.API()
|
.API()
|
||||||
.startFlow(widget.info.id, input: depends.map((x) => x.uuid).toList())
|
.startFlow(widget.info.id, input: depends.map((x) => x.uuid).toList())
|
||||||
.then((flowID) {
|
.then((flowID) {
|
||||||
widget.refresh();
|
widget.refresh();
|
||||||
API.API().getFlow(flowID).then((flow) {
|
API.API().getFlow(flowID).then((flow) {
|
||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||||
MaterialPageRoute(builder: (context) => ActiveFlowPage(flow)));
|
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")),
|
appBar: AppBar(title: Text("Create new ${widget.info.name} Flow")),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
// todo : flow continuation overview
|
||||||
buildInputSelection(context),
|
buildInputSelection(context),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Card(
|
Card(
|
||||||
|
@ -352,23 +372,88 @@ class TransactionSelectPage extends StatelessWidget {
|
||||||
|
|
||||||
class ActiveFlowPage extends StatelessWidget {
|
class ActiveFlowPage extends StatelessWidget {
|
||||||
final API.Flow flow;
|
final API.Flow flow;
|
||||||
|
final API.FlowInfo info;
|
||||||
|
|
||||||
const ActiveFlowPage(this.flow, {super.key});
|
const ActiveFlowPage(this.flow, this.info, {super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
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(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Text("ID: ${flow.id}"),
|
Text("ID: ${flow.id}"),
|
||||||
Text("Started since: ${tsFormat(flow.started)}"),
|
Text("Started since: ${tsFormat(flow.started)}"),
|
||||||
...flow.input!.map((x) => Text("Input: $x")).toList(),
|
...flow.input!.map((x) => Text("Input: $x")).toList(),
|
||||||
if (flow.done != null) ...[
|
if (flow.done != null) ...[
|
||||||
Text("Ended: ${tsFormat(flow.done!.ended)}"),
|
Text("Ended: ${tsFormat(flow.done!.ended)}"),
|
||||||
if (flow.done!.next != null) Text("Next: ${flow.done!.next!}"),
|
if (flow.done!.next != null) Text("Next: ${flow.done!.next!}"),
|
||||||
...flow.done!.produced!.map((x) => Text("Produced: $x")).toList(),
|
...flow.done!.produced!.map((x) => Text("Produced: $x")).toList(),
|
||||||
]
|
],
|
||||||
],
|
|
||||||
));
|
const Divider(),
|
||||||
|
// todo : show notes
|
||||||
|
],
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue