Merge pull request 'sorted the log view and removed close button' (#13) from Task-#188 into main
Reviewed-on: #13
This commit is contained in:
commit
c8e6cc211f
@ -268,12 +268,20 @@ class AttendanceController extends GetxController {
|
|||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
attendenceLogsView =
|
attendenceLogsView = response
|
||||||
response.map((json) => AttendanceLogViewModel.fromJson(json)).toList();
|
.map((json) => AttendanceLogViewModel.fromJson(json))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Sort by activityTime field (latest first)
|
||||||
|
attendenceLogsView.sort((a, b) {
|
||||||
|
if (a.activityTime == null || b.activityTime == null) return 0; // Handle null values if any
|
||||||
|
return b.activityTime!.compareTo(a.activityTime!); // Sort descending (latest first)
|
||||||
|
});
|
||||||
|
|
||||||
log.i("Attendance log view fetched for ID: $id");
|
log.i("Attendance log view fetched for ID: $id");
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
log.e("Failed to fetch attendance log view for ID $id");
|
log.e("Failed to fetch attendance log view for ID $id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -462,8 +462,19 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
MyText.titleMedium("Attendance Log Details",
|
Row(
|
||||||
fontWeight: 700),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
MyText.titleMedium(
|
||||||
|
"Attendance Log Details",
|
||||||
|
fontWeight: 700,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
if (attendanceController
|
if (attendanceController
|
||||||
.attendenceLogsView.isNotEmpty) ...[
|
.attendenceLogsView.isNotEmpty) ...[
|
||||||
@ -602,14 +613,6 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text("Close"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -872,10 +875,13 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
label: MyText.labelLarge('Action', color: contentTheme.primary)),
|
label: MyText.labelLarge('Action', color: contentTheme.primary)),
|
||||||
];
|
];
|
||||||
|
|
||||||
final rows = attendanceController.regularizationLogs
|
final rows =
|
||||||
.mapIndexed((index, log) {
|
attendanceController.regularizationLogs.mapIndexed((index, log) {
|
||||||
final uniqueLogKey = '${log.id}-${log.employeeId}'; // Unique key for each log
|
final uniqueLogKey =
|
||||||
final isUploading = attendanceController.uploadingStates[uniqueLogKey]?.value ?? false; // Check the upload state
|
'${log.id}-${log.employeeId}'; // Unique key for each log
|
||||||
|
final isUploading =
|
||||||
|
attendanceController.uploadingStates[uniqueLogKey]?.value ??
|
||||||
|
false; // Check the upload state
|
||||||
|
|
||||||
return DataRow(cells: [
|
return DataRow(cells: [
|
||||||
DataCell(
|
DataCell(
|
||||||
@ -939,13 +945,16 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
: () async {
|
: () async {
|
||||||
if (attendanceController.selectedProjectId == null) {
|
if (attendanceController.selectedProjectId == null) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text("Please select a project first")),
|
const SnackBar(
|
||||||
|
content: Text("Please select a project first")),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceController.uploadingStates[uniqueLogKey]?.value = true; // Start loading
|
attendanceController.uploadingStates[uniqueLogKey]
|
||||||
final success = await attendanceController.captureAndUploadAttendance(
|
?.value = true; // Start loading
|
||||||
|
final success = await attendanceController
|
||||||
|
.captureAndUploadAttendance(
|
||||||
log.id,
|
log.id,
|
||||||
log.employeeId,
|
log.employeeId,
|
||||||
attendanceController.selectedProjectId!,
|
attendanceController.selectedProjectId!,
|
||||||
@ -972,18 +981,21 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
attendanceController.selectedProjectId!);
|
attendanceController.selectedProjectId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceController.uploadingStates[uniqueLogKey]?.value = false; // End loading
|
attendanceController.uploadingStates[uniqueLogKey]
|
||||||
|
?.value = false; // End loading
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AttendanceActionColors
|
backgroundColor:
|
||||||
.colors[ButtonActions.approve],
|
AttendanceActionColors.colors[ButtonActions.approve],
|
||||||
padding: const EdgeInsets.symmetric(
|
padding:
|
||||||
vertical: 4, horizontal: 6),
|
const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
|
||||||
minimumSize: const Size(60, 20),
|
minimumSize: const Size(60, 20),
|
||||||
textStyle: const TextStyle(fontSize: 12),
|
textStyle: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: isUploading
|
child: isUploading
|
||||||
? const CircularProgressIndicator(strokeWidth: 2) // Show loading indicator while uploading
|
? const CircularProgressIndicator(
|
||||||
|
strokeWidth:
|
||||||
|
2) // Show loading indicator while uploading
|
||||||
: const Text("Approve"),
|
: const Text("Approve"),
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -997,14 +1009,17 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
: () async {
|
: () async {
|
||||||
if (attendanceController.selectedProjectId == null) {
|
if (attendanceController.selectedProjectId == null) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text("Please select a project first")),
|
const SnackBar(
|
||||||
|
content: Text("Please select a project first")),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceController.uploadingStates[uniqueLogKey]?.value = true; // Start loading
|
attendanceController.uploadingStates[uniqueLogKey]
|
||||||
|
?.value = true; // Start loading
|
||||||
|
|
||||||
final success = await attendanceController.captureAndUploadAttendance(
|
final success = await attendanceController
|
||||||
|
.captureAndUploadAttendance(
|
||||||
log.id,
|
log.id,
|
||||||
log.employeeId,
|
log.employeeId,
|
||||||
attendanceController.selectedProjectId!,
|
attendanceController.selectedProjectId!,
|
||||||
@ -1031,26 +1046,28 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
attendanceController.selectedProjectId!);
|
attendanceController.selectedProjectId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceController.uploadingStates[uniqueLogKey]?.value = false; // End loading
|
attendanceController.uploadingStates[uniqueLogKey]
|
||||||
|
?.value = false; // End loading
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
AttendanceActionColors.colors[ButtonActions.reject],
|
AttendanceActionColors.colors[ButtonActions.reject],
|
||||||
padding: const EdgeInsets.symmetric(
|
padding:
|
||||||
vertical: 4, horizontal: 6),
|
const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
|
||||||
minimumSize: const Size(60, 20),
|
minimumSize: const Size(60, 20),
|
||||||
textStyle: const TextStyle(fontSize: 12),
|
textStyle: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: isUploading
|
child: isUploading
|
||||||
? const CircularProgressIndicator(strokeWidth: 2) // Show loading indicator while uploading
|
? const CircularProgressIndicator(
|
||||||
|
strokeWidth:
|
||||||
|
2) // Show loading indicator while uploading
|
||||||
: const Text("Reject"),
|
: const Text("Reject"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
})
|
}).toList();
|
||||||
.toList();
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -1077,5 +1094,5 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user