oauth2 state of mind

This commit is contained in:
mr
2026-03-06 10:26:00 +01:00
parent deaaf28a3c
commit b16104bb6a
28 changed files with 628 additions and 367 deletions

View File

@@ -0,0 +1,86 @@
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/core/services/specialized_services/workflow_service.dart';
import 'package:oc_front/models/resources/workflow_event.dart';
// ignore: must_be_immutable
class WorkflowEventFormsWidget extends StatefulWidget {
WorkflowEventItem item;
Dashboard dash;
String elementID;
WorkflowEventFormsWidget({
super.key,
required this.item,
required this.dash,
required this.elementID,
});
@override WorkflowEventFormsWidgetState createState() => WorkflowEventFormsWidgetState();
}
class WorkflowEventFormsWidgetState extends State<WorkflowEventFormsWidget> {
final WorflowService _service = WorflowService();
Future<List<DropdownMenuItem<String>>> _loadWorkflows() async {
List<DropdownMenuItem<String>> items = [];
await _service.all(null).then((response) {
if (response.data != null) {
for (var entry in response.data!.values) {
final id = entry["id"]?.toString() ?? "";
final name = entry["name"]?.toString() ?? id;
if (id.isEmpty) continue;
items.add(DropdownMenuItem<String>(value: id, child: Text(name, overflow: TextOverflow.ellipsis)));
}
}
});
return items;
}
@override Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 8),
child: Text("Workflow cible", style: TextStyle(fontSize: 12, color: Colors.grey)),
),
FutureBuilder<List<DropdownMenuItem<String>>>(
future: _loadWorkflows(),
builder: (context, snapshot) {
final items = snapshot.data ?? [];
final current = items.any((e) => e.value == widget.item.workflowExecutionId)
? widget.item.workflowExecutionId
: null;
return DropdownButtonFormField<String>(
isExpanded: true,
value: current,
hint: const Text("Sélectionner un workflow...", style: TextStyle(fontSize: 12)),
style: const TextStyle(fontSize: 12, color: Colors.black, overflow: TextOverflow.ellipsis),
decoration: const InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: "workflow",
labelStyle: TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
items: items,
onChanged: (value) {
if (value == null) return;
setState(() {
widget.item.workflowExecutionId = value;
widget.item.id = value;
});
widget.dash.notifyListeners();
},
);
},
),
],
),
);
}
}