|
|
@@ -11,6 +11,7 @@ import 'package:go_router/go_router.dart';
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
import 'package:jiffy/jiffy.dart';
|
|
|
import 'package:linear_progress_bar/linear_progress_bar.dart';
|
|
|
+import 'package:multi_select_flutter/multi_select_flutter.dart';
|
|
|
import 'package:tp5/core/core.dart';
|
|
|
import 'package:tp5/csv/csv_data.dart';
|
|
|
import 'package:tp5/csv/data.dart';
|
|
|
@@ -45,6 +46,24 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
@override
|
|
|
void initState() {
|
|
|
Future.delayed(Duration.zero, () {
|
|
|
+ if (widget.params.tlc != null) {
|
|
|
+ final qualif = ref.read(dataProvider).qualif;
|
|
|
+ collegeSelected = qualif
|
|
|
+ .where((e) => e.tlc == widget.params.tlc)
|
|
|
+ .map((e) => e.college ?? "")
|
|
|
+ .toSet()
|
|
|
+ .toList();
|
|
|
+ acSelected = qualif
|
|
|
+ .where((e) => e.tlc == widget.params.tlc)
|
|
|
+ .map((e) => e.ac ?? "")
|
|
|
+ .toSet()
|
|
|
+ .toList();
|
|
|
+ baseSelected = qualif
|
|
|
+ .where((e) => e.tlc == widget.params.tlc)
|
|
|
+ .map((e) => e.base ?? "")
|
|
|
+ .toSet()
|
|
|
+ .toList();
|
|
|
+ }
|
|
|
crewPnlegLoad();
|
|
|
});
|
|
|
super.initState();
|
|
|
@@ -182,7 +201,8 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
}
|
|
|
|
|
|
_notifiedCrew() {
|
|
|
- final qualif = ref.watch(qualifProvider(CrewFilter()));
|
|
|
+ // final qualif = ref.watch(qualifProvider(CrewFilter()));
|
|
|
+ final qualif = ref.watch(dataProvider).qualif;
|
|
|
|
|
|
return WCadre(
|
|
|
titleright: crewPnlegLoading
|
|
|
@@ -229,7 +249,10 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
(e) => e["college"].toString(), collegeSort)
|
|
|
.map<Widget>((e) {
|
|
|
final x = crewPnleg.elementAt(e["index"] as int);
|
|
|
- final pn = qualif.firstWhereOrNull((e) => e.tlc == x.tlc);
|
|
|
+ // final pn = qualif.firstWhereOrNull((e) => e.tlc == x.tlc);
|
|
|
+ final pn = (qualif.firstWhereOrNull(
|
|
|
+ (e) => (e.tlc == x.tlc) && (e.ac == x.actype)) ??
|
|
|
+ qualif.firstWhereOrNull((e) => e.tlc == x.tlc));
|
|
|
return WCrew(
|
|
|
college: pn?.college,
|
|
|
mle: x.tlc,
|
|
|
@@ -243,8 +266,30 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ List<String> collegeSelected = [];
|
|
|
+ List<String> acSelected = [];
|
|
|
+ List<String> baseSelected = [];
|
|
|
+
|
|
|
_stdbyCrew() {
|
|
|
- final qualif = ref.watch(qualifProvider(CrewFilter()));
|
|
|
+ // final qualif = ref.watch(qualifProvider(CrewFilter()));
|
|
|
+ final qualif = ref.watch(dataProvider).qualif;
|
|
|
+ final tlcs = crewPnleg.map((e) => e.tlc).toSet();
|
|
|
+ final pairs = qualif
|
|
|
+ .where((e) => tlcs.contains(e.tlc))
|
|
|
+ .map((e) => "${e.college},${e.ac},${e.base}")
|
|
|
+ .toSet()
|
|
|
+ .map((e) => e.split(","))
|
|
|
+ .toList();
|
|
|
+ final List<String> pnfilterd = qualif
|
|
|
+ .where((q) =>
|
|
|
+ ((collegeSelected.isEmpty || collegeSelected.contains(q.college)) &&
|
|
|
+ (acSelected.isEmpty || acSelected.contains(q.ac)) &&
|
|
|
+ (baseSelected.isEmpty || baseSelected.contains(q.base))))
|
|
|
+ .map((e) => e.tlc ?? "")
|
|
|
+ .toSet()
|
|
|
+ .toList();
|
|
|
+ final List<Pnleg> crewPnlegFiltered =
|
|
|
+ crewPnleg.where((e) => pnfilterd.contains(e.tlc)).toList();
|
|
|
return WCadre(
|
|
|
titleright: crewPnlegLoading
|
|
|
? Padding(
|
|
|
@@ -267,18 +312,138 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
? const Text("No data found !")
|
|
|
: Column(
|
|
|
children: [
|
|
|
+ MyRow(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
+ children: [
|
|
|
+ Gap(5),
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ const Text('College:', style: TextStyle(fontSize: 11)),
|
|
|
+ Text("(${(collegeSelected.length)})",
|
|
|
+ style: TextStyle(fontSize: 11))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Gap(5),
|
|
|
+ MultiSelectChipDisplay(
|
|
|
+ colorator: (value) => (collegeSelected.contains(value))
|
|
|
+ ? Colors.green[800]
|
|
|
+ : Colors.grey[900],
|
|
|
+ //chipColor: Colors.blue[900],
|
|
|
+ icon: null,
|
|
|
+ textStyle: TextStyle(fontSize: 9, color: Colors.white),
|
|
|
+ scrollBar: HorizontalScrollBar(),
|
|
|
+ scroll: true,
|
|
|
+ items: pairs
|
|
|
+ .map((e) => e[0])
|
|
|
+ .sortedByCompare((e) => e, collegeSort)
|
|
|
+ .toSet()
|
|
|
+ .map((e) => MultiSelectItem(e, "$e"))
|
|
|
+ .toList(),
|
|
|
+ onTap: (value) {
|
|
|
+ setState(() {
|
|
|
+ if (collegeSelected.contains(value)) {
|
|
|
+ collegeSelected.remove(value);
|
|
|
+ } else {
|
|
|
+ collegeSelected.add(value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ MyRow(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
+ children: [
|
|
|
+ Gap(5),
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ const Text('ACs:', style: TextStyle(fontSize: 11)),
|
|
|
+ Text("(${(acSelected.length)})",
|
|
|
+ style: TextStyle(fontSize: 11))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Gap(5),
|
|
|
+ MultiSelectChipDisplay(
|
|
|
+ colorator: (value) => (acSelected.contains(value))
|
|
|
+ ? Colors.green[800]
|
|
|
+ : Colors.grey[900],
|
|
|
+ //chipColor: Colors.blue[900],
|
|
|
+ icon: null,
|
|
|
+ textStyle: TextStyle(fontSize: 9, color: Colors.white),
|
|
|
+ scrollBar: HorizontalScrollBar(),
|
|
|
+ scroll: true,
|
|
|
+ items: pairs
|
|
|
+ .map((e) => e[1])
|
|
|
+ .sortedByCompare((e) => e, acSort)
|
|
|
+ .toSet()
|
|
|
+ .map((e) => MultiSelectItem(e, "$e"))
|
|
|
+ .toList(),
|
|
|
+ onTap: (value) {
|
|
|
+ setState(() {
|
|
|
+ if (acSelected.contains(value)) {
|
|
|
+ acSelected.remove(value);
|
|
|
+ } else {
|
|
|
+ acSelected.add(value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ MyRow(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
+ children: [
|
|
|
+ const Gap(5),
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ const Text('Base:', style: TextStyle(fontSize: 11)),
|
|
|
+ Text("(${(baseSelected.length)})",
|
|
|
+ style: TextStyle(fontSize: 11))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const Gap(5),
|
|
|
+ MultiSelectChipDisplay(
|
|
|
+ colorator: (value) => (baseSelected.contains(value))
|
|
|
+ ? Colors.green[800]
|
|
|
+ : Colors.grey[900],
|
|
|
+ //chipColor: Colors.blue[900],
|
|
|
+ icon: null,
|
|
|
+ textStyle: TextStyle(fontSize: 9, color: Colors.white),
|
|
|
+ scrollBar: HorizontalScrollBar(),
|
|
|
+ scroll: true,
|
|
|
+ items: pairs
|
|
|
+ .map((e) => e[2])
|
|
|
+ .sortedByCompare((e) => e, baseSort)
|
|
|
+ .toSet()
|
|
|
+ .map((e) => MultiSelectItem(e, "$e"))
|
|
|
+ .toList(),
|
|
|
+ onTap: (value) {
|
|
|
+ setState(() {
|
|
|
+ if (baseSelected.contains(value)) {
|
|
|
+ baseSelected.remove(value);
|
|
|
+ } else {
|
|
|
+ baseSelected.add(value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
child: Column(
|
|
|
- children: crewPnleg
|
|
|
+ children: crewPnlegFiltered
|
|
|
.mapIndexed((int i, leg) {
|
|
|
// print(leg);
|
|
|
return {
|
|
|
"index": i,
|
|
|
"college": (qualif
|
|
|
- .firstWhereOrNull((e) => e.tlc == leg.tlc)
|
|
|
- ?.college ??
|
|
|
- "--"),
|
|
|
+ .where((e) => e.tlc == leg.tlc)
|
|
|
+ .map((e) => e.college)
|
|
|
+ .sortedByCompare(
|
|
|
+ (e) => e ?? "", collegeSort))
|
|
|
+ .firstOrNull ??
|
|
|
+ "--",
|
|
|
// "jdep": (leg.jdep?.millisecondsSinceEpoch ?? 0)
|
|
|
"jdep": (leg.label ?? "0")
|
|
|
};
|
|
|
@@ -290,9 +455,13 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
],
|
|
|
jdepcollegeSort)
|
|
|
.map<Widget>((e) {
|
|
|
- final x = crewPnleg.elementAt(e["index"] as int);
|
|
|
- final pn =
|
|
|
- qualif.firstWhereOrNull((e) => e.tlc == x.tlc);
|
|
|
+ final x =
|
|
|
+ crewPnlegFiltered.elementAt(e["index"] as int);
|
|
|
+ // final pn =
|
|
|
+ // qualif.firstWhereOrNull((e) => e.tlc == x.tlc);
|
|
|
+ final pn = (qualif.firstWhereOrNull((e) =>
|
|
|
+ (e.tlc == x.tlc) && (e.ac == x.actype)) ??
|
|
|
+ qualif.firstWhereOrNull((e) => e.tlc == x.tlc));
|
|
|
return Row(
|
|
|
children: [
|
|
|
Text("${e["jdep"]}"),
|
|
|
@@ -315,6 +484,7 @@ class _DutyinfoPageState extends ConsumerState<DutyinfoPage> {
|
|
|
|
|
|
class DutyinfoParams {
|
|
|
const DutyinfoParams({
|
|
|
+ this.tlc,
|
|
|
this.sameday = false,
|
|
|
this.date,
|
|
|
this.start,
|
|
|
@@ -326,6 +496,7 @@ class DutyinfoParams {
|
|
|
this.dep,
|
|
|
this.des,
|
|
|
});
|
|
|
+ final String? tlc;
|
|
|
final bool sameday;
|
|
|
final Jiffy? start;
|
|
|
final Jiffy? end;
|
|
|
@@ -343,8 +514,32 @@ int collegeSort(String a, String b) {
|
|
|
final order = ['CP', 'FO', 'PU', 'SE', 'ST', 'JU'];
|
|
|
|
|
|
// Get the index of each element in the order list
|
|
|
- final indexA = order.indexOf(a);
|
|
|
- final indexB = order.indexOf(b);
|
|
|
+ final indexA = !order.contains(a) ? 99 : order.indexOf(a);
|
|
|
+ final indexB = !order.contains(b) ? 99 : order.indexOf(b);
|
|
|
+
|
|
|
+ // Compare based on the index
|
|
|
+ return indexA.compareTo(indexB);
|
|
|
+}
|
|
|
+
|
|
|
+int acSort(String a, String b) {
|
|
|
+ // Define the order based on your requirements
|
|
|
+ final order = ['320', '330', '32N', '319', '32T'];
|
|
|
+
|
|
|
+ // Get the index of each element in the order list
|
|
|
+ final indexA = !order.contains(a) ? 99 : order.indexOf(a);
|
|
|
+ final indexB = !order.contains(b) ? 99 : order.indexOf(b);
|
|
|
+
|
|
|
+ // Compare based on the index
|
|
|
+ return indexA.compareTo(indexB);
|
|
|
+}
|
|
|
+
|
|
|
+int baseSort(String a, String b) {
|
|
|
+ // Define the order based on your requirements
|
|
|
+ final order = ['TUN', 'MIR', 'DJE'];
|
|
|
+
|
|
|
+ // Get the index of each element in the order list
|
|
|
+ final indexA = !order.contains(a) ? 99 : order.indexOf(a);
|
|
|
+ final indexB = !order.contains(b) ? 99 : order.indexOf(b);
|
|
|
|
|
|
// Compare based on the index
|
|
|
return indexA.compareTo(indexB);
|