Merge pull request 'feat: Refactor project ID handling and enhance CommentTaskBottomSheet integration' (#49) from Vaibhav_Task-#515 into main
Reviewed-on: #49
This commit is contained in:
commit
099edd3884
@ -53,7 +53,7 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
selectedProjectId = projectController.selectedProjectId?.value;
|
||||
selectedProjectId = projectController.selectedProjectId.value;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (selectedProjectId != null) {
|
||||
@ -147,7 +147,6 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
child: _buildEmployeeList(),
|
||||
),
|
||||
MySpacing.height(8),
|
||||
|
||||
Obx(() {
|
||||
if (controller.selectedEmployees.isEmpty) return Container();
|
||||
|
||||
@ -179,7 +178,6 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
_buildTextField(
|
||||
icon: Icons.track_changes,
|
||||
label: "Target for Today :",
|
||||
@ -189,7 +187,6 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
validatorType: "target",
|
||||
),
|
||||
MySpacing.height(24),
|
||||
|
||||
_buildTextField(
|
||||
icon: Icons.description,
|
||||
label: "Description :",
|
||||
@ -199,7 +196,6 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
validatorType: "description",
|
||||
),
|
||||
MySpacing.height(24),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
|
@ -12,15 +12,21 @@ import 'package:marco/helpers/widgets/my_team_model_sheet.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:marco/helpers/widgets/image_viewer_dialog.dart';
|
||||
import 'dart:io';
|
||||
import 'package:marco/model/dailyTaskPlaning/create_task_botom_sheet.dart';
|
||||
|
||||
class CommentTaskBottomSheet extends StatefulWidget {
|
||||
final Map<String, dynamic> taskData;
|
||||
final VoidCallback? onCommentSuccess;
|
||||
|
||||
final String taskDataId;
|
||||
final String workAreaId;
|
||||
final String activityId;
|
||||
const CommentTaskBottomSheet({
|
||||
super.key,
|
||||
required this.taskData,
|
||||
this.onCommentSuccess,
|
||||
required this.taskDataId,
|
||||
required this.workAreaId,
|
||||
required this.activityId,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -128,17 +134,72 @@ class _CommentTaskBottomSheetState extends State<CommentTaskBottomSheet>
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
MyText.titleMedium(
|
||||
"Comment Task",
|
||||
fontWeight: 600,
|
||||
fontSize: 18,
|
||||
MySpacing.height(12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
MyText.titleMedium(
|
||||
"Comment Task",
|
||||
fontWeight: 600,
|
||||
fontSize: 18,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Second row: Right-aligned "+ Create Task" button
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showCreateTaskBottomSheet(
|
||||
workArea:
|
||||
widget.taskData['location'] ?? '',
|
||||
activity:
|
||||
widget.taskData['activity'] ?? '',
|
||||
completedWork:
|
||||
widget.taskData['completedWork'] ??
|
||||
'',
|
||||
unit: widget.taskData['unit'] ?? '',
|
||||
onCategoryChanged: (category) {
|
||||
debugPrint(
|
||||
"Category changed to: $category");
|
||||
},
|
||||
parentTaskId: widget.taskDataId,
|
||||
plannedTask: int.tryParse(
|
||||
widget.taskData['plannedWork'] ??
|
||||
'0') ??
|
||||
0,
|
||||
activityId: widget.activityId,
|
||||
workAreaId: widget.workAreaId,
|
||||
onSubmit: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blueAccent.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: MyText.bodySmall(
|
||||
"+ Create Task",
|
||||
fontWeight: 600,
|
||||
color: Colors.blueAccent,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
MySpacing.height(24),
|
||||
buildRow(
|
||||
"Assigned By",
|
||||
controller.basicValidator
|
||||
|
@ -72,6 +72,9 @@ class TaskActionButtons {
|
||||
required BuildContext context,
|
||||
required dynamic task,
|
||||
required VoidCallback refreshCallback,
|
||||
required String parentTaskID,
|
||||
required String activityId,
|
||||
required String workAreaId,
|
||||
}) {
|
||||
return OutlinedButton.icon(
|
||||
icon: const Icon(Icons.comment, size: 18, color: Colors.blueAccent),
|
||||
@ -82,7 +85,8 @@ class TaskActionButtons {
|
||||
textStyle: const TextStyle(fontSize: 14),
|
||||
),
|
||||
onPressed: () {
|
||||
final taskData = _prepareTaskData(task: task, completed: task.completedTask.toInt());
|
||||
final taskData =
|
||||
_prepareTaskData(task: task, completed: task.completedTask.toInt());
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
@ -90,6 +94,9 @@ class TaskActionButtons {
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (_) => CommentTaskBottomSheet(
|
||||
taskData: taskData,
|
||||
taskDataId: parentTaskID,
|
||||
workAreaId: workAreaId,
|
||||
activityId: activityId,
|
||||
onCommentSuccess: () {
|
||||
refreshCallback();
|
||||
Navigator.of(context).pop();
|
||||
|
@ -44,29 +44,23 @@ class _DailyProgressReportScreenState extends State<DailyProgressReportScreen>
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final initialProjectId = projectController.selectedProjectId?.value;
|
||||
if (initialProjectId != null) {
|
||||
final initialProjectId = projectController.selectedProjectId.value;
|
||||
if (initialProjectId.isNotEmpty) {
|
||||
dailyTaskController.selectedProjectId = initialProjectId;
|
||||
dailyTaskController.fetchTaskData(initialProjectId);
|
||||
}
|
||||
|
||||
final selectedProjectIdRx = projectController.selectedProjectId;
|
||||
if (selectedProjectIdRx != null) {
|
||||
ever<String?>(
|
||||
selectedProjectIdRx,
|
||||
(newProjectId) async {
|
||||
if (newProjectId != null &&
|
||||
newProjectId != dailyTaskController.selectedProjectId) {
|
||||
dailyTaskController.selectedProjectId = newProjectId;
|
||||
await dailyTaskController.fetchTaskData(newProjectId);
|
||||
dailyTaskController.update(['daily_progress_report_controller']);
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
debugPrint(
|
||||
"Warning: selectedProjectId is null, skipping listener setup.");
|
||||
}
|
||||
ever<String>(
|
||||
projectController.selectedProjectId,
|
||||
(newProjectId) async {
|
||||
if (newProjectId.isNotEmpty &&
|
||||
newProjectId != dailyTaskController.selectedProjectId) {
|
||||
dailyTaskController.selectedProjectId = newProjectId;
|
||||
await dailyTaskController.fetchTaskData(newProjectId);
|
||||
dailyTaskController.update(['daily_progress_report_controller']);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -486,6 +480,9 @@ class _DailyProgressReportScreenState extends State<DailyProgressReportScreen>
|
||||
TaskActionButtons.commentButton(
|
||||
context: context,
|
||||
task: task,
|
||||
parentTaskID: parentTaskID,
|
||||
workAreaId: workAreaId.toString(),
|
||||
activityId: activityId.toString(),
|
||||
refreshCallback: _refreshData,
|
||||
),
|
||||
],
|
||||
|
@ -33,23 +33,20 @@ class _DailyTaskPlaningScreenState extends State<DailyTaskPlaningScreen>
|
||||
super.initState();
|
||||
|
||||
// Initial fetch if a project is already selected
|
||||
final projectId = projectController.selectedProjectId?.value;
|
||||
if (projectId != null) {
|
||||
final projectId = projectController.selectedProjectId.value;
|
||||
if (projectId.isNotEmpty) {
|
||||
dailyTaskPlaningController.fetchTaskData(projectId);
|
||||
}
|
||||
|
||||
// Reactive fetch on project ID change
|
||||
final selectedProject = projectController.selectedProjectId;
|
||||
if (selectedProject != null) {
|
||||
ever<String?>(
|
||||
selectedProject,
|
||||
(newProjectId) {
|
||||
if (newProjectId != null) {
|
||||
dailyTaskPlaningController.fetchTaskData(newProjectId);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
ever<String>(
|
||||
projectController.selectedProjectId,
|
||||
(newProjectId) {
|
||||
if (newProjectId.isNotEmpty) {
|
||||
dailyTaskPlaningController.fetchTaskData(newProjectId);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -128,8 +125,8 @@ class _DailyTaskPlaningScreenState extends State<DailyTaskPlaningScreen>
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
onTap: () async {
|
||||
final projectId =
|
||||
projectController.selectedProjectId?.value;
|
||||
if (projectId != null) {
|
||||
projectController.selectedProjectId.value;
|
||||
if (projectId.isNotEmpty) {
|
||||
try {
|
||||
await dailyTaskPlaningController
|
||||
.fetchTaskData(projectId);
|
||||
@ -430,7 +427,8 @@ class _DailyTaskPlaningScreenState extends State<DailyTaskPlaningScreen>
|
||||
onPressed: () {
|
||||
final pendingTask =
|
||||
(planned - completed)
|
||||
.clamp(0, planned).toInt();
|
||||
.clamp(0, planned)
|
||||
.toInt();
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
|
Loading…
x
Reference in New Issue
Block a user