feat: Remove unused selectedProjectId from DailyTaskPlaningController and update AssignTaskBottomSheet to use ProjectController's selectedProjectId
This commit is contained in:
parent
4022197b7f
commit
5cf0202cc1
@ -11,7 +11,6 @@ final Logger log = Logger();
|
|||||||
|
|
||||||
class DailyTaskPlaningController extends GetxController {
|
class DailyTaskPlaningController extends GetxController {
|
||||||
List<ProjectModel> projects = [];
|
List<ProjectModel> projects = [];
|
||||||
String? selectedProjectId;
|
|
||||||
List<EmployeeModel> employees = [];
|
List<EmployeeModel> employees = [];
|
||||||
List<TaskPlanningDetailsModel> dailyTasks = [];
|
List<TaskPlanningDetailsModel> dailyTasks = [];
|
||||||
RxMap<String, RxBool> uploadingStates = <String, RxBool>{}.obs;
|
RxMap<String, RxBool> uploadingStates = <String, RxBool>{}.obs;
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:marco/helpers/widgets/my_button.dart';
|
|||||||
import 'package:marco/helpers/widgets/my_text.dart';
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
||||||
|
import 'package:marco/controller/project_controller.dart';
|
||||||
|
|
||||||
class AssignTaskBottomSheet extends StatefulWidget {
|
class AssignTaskBottomSheet extends StatefulWidget {
|
||||||
final String workLocation;
|
final String workLocation;
|
||||||
@ -34,6 +35,7 @@ class AssignTaskBottomSheet extends StatefulWidget {
|
|||||||
|
|
||||||
class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||||
final DailyTaskPlaningController controller = Get.find();
|
final DailyTaskPlaningController controller = Get.find();
|
||||||
|
final ProjectController projectController = Get.find();
|
||||||
final TextEditingController targetController = TextEditingController();
|
final TextEditingController targetController = TextEditingController();
|
||||||
final TextEditingController descriptionController = TextEditingController();
|
final TextEditingController descriptionController = TextEditingController();
|
||||||
String? selectedProjectId;
|
String? selectedProjectId;
|
||||||
@ -51,7 +53,8 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
selectedProjectId = controller.selectedProjectId;
|
selectedProjectId = projectController.selectedProjectId?.value;
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (selectedProjectId != null) {
|
if (selectedProjectId != null) {
|
||||||
controller.fetchEmployeesByProject(selectedProjectId!);
|
controller.fetchEmployeesByProject(selectedProjectId!);
|
||||||
@ -140,16 +143,13 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
),
|
),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
Container(
|
Container(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(maxHeight: 150),
|
||||||
maxHeight: 150,
|
|
||||||
),
|
|
||||||
child: _buildEmployeeList(),
|
child: _buildEmployeeList(),
|
||||||
),
|
),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (controller.selectedEmployees.isEmpty) {
|
if (controller.selectedEmployees.isEmpty) return Container();
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
@ -163,21 +163,23 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
if (!isSelected) return Container();
|
if (!isSelected) return Container();
|
||||||
|
|
||||||
return Chip(
|
return Chip(
|
||||||
label: Text(e.name,
|
label: Text(e.name,
|
||||||
style: const TextStyle(color: Colors.white)),
|
style: const TextStyle(color: Colors.white)),
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
const Color.fromARGB(255, 95, 132, 255),
|
const Color.fromARGB(255, 95, 132, 255),
|
||||||
deleteIcon:
|
deleteIcon:
|
||||||
const Icon(Icons.close, color: Colors.white),
|
const Icon(Icons.close, color: Colors.white),
|
||||||
onDeleted: () {
|
onDeleted: () {
|
||||||
controller.uploadingStates[e.id]?.value = false;
|
controller.uploadingStates[e.id]?.value = false;
|
||||||
controller.updateSelectedEmployees();
|
controller.updateSelectedEmployees();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
_buildTextField(
|
_buildTextField(
|
||||||
icon: Icons.track_changes,
|
icon: Icons.track_changes,
|
||||||
label: "Target for Today :",
|
label: "Target for Today :",
|
||||||
@ -187,6 +189,7 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
validatorType: "target",
|
validatorType: "target",
|
||||||
),
|
),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
|
|
||||||
_buildTextField(
|
_buildTextField(
|
||||||
icon: Icons.description,
|
icon: Icons.description,
|
||||||
label: "Description :",
|
label: "Description :",
|
||||||
@ -196,6 +199,7 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
validatorType: "description",
|
validatorType: "description",
|
||||||
),
|
),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
@ -225,7 +229,6 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final selectedRoleId = controller.selectedRoleId.value;
|
final selectedRoleId = controller.selectedRoleId.value;
|
||||||
|
|
||||||
final filteredEmployees = selectedRoleId == null
|
final filteredEmployees = selectedRoleId == null
|
||||||
? controller.employees
|
? controller.employees
|
||||||
: controller.employees
|
: controller.employees
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class DailyTaskPlaningFilter extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String? tempSelectedProjectId = controller.selectedProjectId;
|
String? tempSelectedProjectId = '654563563645';
|
||||||
bool showProjectList = false;
|
bool showProjectList = false;
|
||||||
|
|
||||||
final accessibleProjects = controller.projects
|
final accessibleProjects = controller.projects
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user