Merge pull request 'Issue_10_10_2025' (#75) from Issue_10_10_2025 into main
Reviewed-on: #75
This commit is contained in:
commit
706881d08d
@ -10,7 +10,7 @@ class AddContactController extends GetxController {
|
|||||||
final RxList<String> tags = <String>[].obs;
|
final RxList<String> tags = <String>[].obs;
|
||||||
|
|
||||||
final RxString selectedCategory = ''.obs;
|
final RxString selectedCategory = ''.obs;
|
||||||
final RxString selectedBucket = ''.obs;
|
final RxList<String> selectedBuckets = <String>[].obs;
|
||||||
final RxString selectedProject = ''.obs;
|
final RxString selectedProject = ''.obs;
|
||||||
|
|
||||||
final RxList<String> enteredTags = <String>[].obs;
|
final RxList<String> enteredTags = <String>[].obs;
|
||||||
@ -50,7 +50,7 @@ class AddContactController extends GetxController {
|
|||||||
void resetForm() {
|
void resetForm() {
|
||||||
selectedCategory.value = '';
|
selectedCategory.value = '';
|
||||||
selectedProject.value = '';
|
selectedProject.value = '';
|
||||||
selectedBucket.value = '';
|
selectedBuckets.clear();
|
||||||
enteredTags.clear();
|
enteredTags.clear();
|
||||||
filteredSuggestions.clear();
|
filteredSuggestions.clear();
|
||||||
filteredOrgSuggestions.clear();
|
filteredOrgSuggestions.clear();
|
||||||
@ -100,7 +100,21 @@ class AddContactController extends GetxController {
|
|||||||
isSubmitting.value = true;
|
isSubmitting.value = true;
|
||||||
|
|
||||||
final categoryId = categoriesMap[selectedCategory.value];
|
final categoryId = categoriesMap[selectedCategory.value];
|
||||||
final bucketId = bucketsMap[selectedBucket.value];
|
final bucketIds = selectedBuckets
|
||||||
|
.map((name) => bucketsMap[name])
|
||||||
|
.whereType<String>()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (bucketIds.isEmpty) {
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Missing Buckets",
|
||||||
|
message: "Please select at least one bucket.",
|
||||||
|
type: SnackbarType.warning,
|
||||||
|
);
|
||||||
|
isSubmitting.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final projectIds = selectedProjects
|
final projectIds = selectedProjects
|
||||||
.map((name) => projectsMap[name])
|
.map((name) => projectsMap[name])
|
||||||
.whereType<String>()
|
.whereType<String>()
|
||||||
@ -126,10 +140,10 @@ class AddContactController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedBucket.value.trim().isEmpty || bucketId == null) {
|
if (selectedBuckets.isEmpty) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Missing Bucket",
|
title: "Missing Bucket",
|
||||||
message: "Please select a bucket.",
|
message: "Please select at least one bucket.",
|
||||||
type: SnackbarType.warning,
|
type: SnackbarType.warning,
|
||||||
);
|
);
|
||||||
isSubmitting.value = false;
|
isSubmitting.value = false;
|
||||||
@ -151,7 +165,7 @@ class AddContactController extends GetxController {
|
|||||||
if (selectedCategory.value.isNotEmpty && categoryId != null)
|
if (selectedCategory.value.isNotEmpty && categoryId != null)
|
||||||
"contactCategoryId": categoryId,
|
"contactCategoryId": categoryId,
|
||||||
if (projectIds.isNotEmpty) "projectIds": projectIds,
|
if (projectIds.isNotEmpty) "projectIds": projectIds,
|
||||||
"bucketIds": [bucketId],
|
"bucketIds": bucketIds,
|
||||||
if (enteredTags.isNotEmpty) "tags": tagObjects,
|
if (enteredTags.isNotEmpty) "tags": tagObjects,
|
||||||
if (emails.isNotEmpty) "contactEmails": emails,
|
if (emails.isNotEmpty) "contactEmails": emails,
|
||||||
if (phones.isNotEmpty) "contactPhones": phones,
|
if (phones.isNotEmpty) "contactPhones": phones,
|
||||||
|
@ -32,16 +32,20 @@ class DirectoryController extends GetxController {
|
|||||||
|
|
||||||
// -------------------- COMMENTS HANDLING --------------------
|
// -------------------- COMMENTS HANDLING --------------------
|
||||||
|
|
||||||
RxList<DirectoryComment> getCommentsForContact(String contactId, {bool active = true}) {
|
RxList<DirectoryComment> getCommentsForContact(String contactId,
|
||||||
|
{bool active = true}) {
|
||||||
return active
|
return active
|
||||||
? activeCommentsMap[contactId] ?? <DirectoryComment>[].obs
|
? activeCommentsMap[contactId] ?? <DirectoryComment>[].obs
|
||||||
: inactiveCommentsMap[contactId] ?? <DirectoryComment>[].obs;
|
: inactiveCommentsMap[contactId] ?? <DirectoryComment>[].obs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> fetchCommentsForContact(String contactId, {bool active = true}) async {
|
Future<void> fetchCommentsForContact(String contactId,
|
||||||
|
{bool active = true}) async {
|
||||||
try {
|
try {
|
||||||
final data = await ApiService.getDirectoryComments(contactId, active: active);
|
final data =
|
||||||
var comments = data?.map((e) => DirectoryComment.fromJson(e)).toList() ?? [];
|
await ApiService.getDirectoryComments(contactId, active: active);
|
||||||
|
var comments =
|
||||||
|
data?.map((e) => DirectoryComment.fromJson(e)).toList() ?? [];
|
||||||
|
|
||||||
// ✅ Deduplicate by ID before storing
|
// ✅ Deduplicate by ID before storing
|
||||||
final Map<String, DirectoryComment> uniqueMap = {
|
final Map<String, DirectoryComment> uniqueMap = {
|
||||||
@ -51,12 +55,15 @@ class DirectoryController extends GetxController {
|
|||||||
..sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
..sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
activeCommentsMap[contactId] = <DirectoryComment>[].obs..assignAll(comments);
|
activeCommentsMap[contactId] = <DirectoryComment>[].obs
|
||||||
|
..assignAll(comments);
|
||||||
} else {
|
} else {
|
||||||
inactiveCommentsMap[contactId] = <DirectoryComment>[].obs..assignAll(comments);
|
inactiveCommentsMap[contactId] = <DirectoryComment>[].obs
|
||||||
|
..assignAll(comments);
|
||||||
}
|
}
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
logSafe("Error fetching ${active ? 'active' : 'inactive'} comments: $e", level: LogLevel.error);
|
logSafe("Error fetching ${active ? 'active' : 'inactive'} comments: $e",
|
||||||
|
level: LogLevel.error);
|
||||||
logSafe(stack.toString(), level: LogLevel.debug);
|
logSafe(stack.toString(), level: LogLevel.debug);
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
@ -99,8 +106,8 @@ class DirectoryController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final success =
|
final success = await ApiService.updateContactComment(
|
||||||
await ApiService.updateContactComment(comment.id, comment.note, comment.contactId);
|
comment.id, comment.note, comment.contactId);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
await fetchCommentsForContact(comment.contactId, active: true);
|
await fetchCommentsForContact(comment.contactId, active: true);
|
||||||
@ -206,6 +213,67 @@ class DirectoryController extends GetxController {
|
|||||||
logSafe("Bucket fetch error: $e", level: LogLevel.error);
|
logSafe("Bucket fetch error: $e", level: LogLevel.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// -------------------- CONTACT DELETION / RESTORE --------------------
|
||||||
|
|
||||||
|
Future<void> deleteContact(String contactId) async {
|
||||||
|
try {
|
||||||
|
final success = await ApiService.deleteDirectoryContact(contactId);
|
||||||
|
if (success) {
|
||||||
|
// Refresh contacts after deletion
|
||||||
|
await fetchContacts(active: true);
|
||||||
|
await fetchContacts(active: false);
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Deleted",
|
||||||
|
message: "Contact deleted successfully.",
|
||||||
|
type: SnackbarType.success,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Error",
|
||||||
|
message: "Failed to delete contact.",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e, stack) {
|
||||||
|
logSafe("Delete contact failed: $e", level: LogLevel.error);
|
||||||
|
logSafe(stack.toString(), level: LogLevel.debug);
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Error",
|
||||||
|
message: "Something went wrong while deleting contact.",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> restoreContact(String contactId) async {
|
||||||
|
try {
|
||||||
|
final success = await ApiService.restoreDirectoryContact(contactId);
|
||||||
|
if (success) {
|
||||||
|
// Refresh contacts after restore
|
||||||
|
await fetchContacts(active: true);
|
||||||
|
await fetchContacts(active: false);
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Restored",
|
||||||
|
message: "Contact restored successfully.",
|
||||||
|
type: SnackbarType.success,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Error",
|
||||||
|
message: "Failed to restore contact.",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e, stack) {
|
||||||
|
logSafe("Restore contact failed: $e", level: LogLevel.error);
|
||||||
|
logSafe(stack.toString(), level: LogLevel.debug);
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Error",
|
||||||
|
message: "Something went wrong while restoring contact.",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> fetchContacts({bool active = true}) async {
|
Future<void> fetchContacts({bool active = true}) async {
|
||||||
try {
|
try {
|
||||||
@ -282,7 +350,8 @@ class DirectoryController extends GetxController {
|
|||||||
return categoryMatch && bucketMatch && searchMatch;
|
return categoryMatch && bucketMatch && searchMatch;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
filteredContacts.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
|
filteredContacts
|
||||||
|
.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleCategory(String categoryId) {
|
void toggleCategory(String categoryId) {
|
||||||
|
@ -9,11 +9,11 @@ import 'package:marco/model/employees/employee_model.dart';
|
|||||||
|
|
||||||
class DailyTaskPlanningController extends GetxController {
|
class DailyTaskPlanningController extends GetxController {
|
||||||
List<ProjectModel> projects = [];
|
List<ProjectModel> projects = [];
|
||||||
List<EmployeeModel> employees = [];
|
RxList<EmployeeModel> employees = <EmployeeModel>[].obs;
|
||||||
List<TaskPlanningDetailsModel> dailyTasks = [];
|
|
||||||
|
|
||||||
RxMap<String, RxBool> uploadingStates = <String, RxBool>{}.obs;
|
|
||||||
RxList<EmployeeModel> selectedEmployees = <EmployeeModel>[].obs;
|
RxList<EmployeeModel> selectedEmployees = <EmployeeModel>[].obs;
|
||||||
|
List<EmployeeModel> allEmployeesCache = [];
|
||||||
|
List<TaskPlanningDetailsModel> dailyTasks = [];
|
||||||
|
RxMap<String, RxBool> uploadingStates = <String, RxBool>{}.obs;
|
||||||
|
|
||||||
MyFormValidator basicValidator = MyFormValidator();
|
MyFormValidator basicValidator = MyFormValidator();
|
||||||
List<Map<String, dynamic>> roles = [];
|
List<Map<String, dynamic>> roles = [];
|
||||||
@ -27,17 +27,10 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
fetchRoles();
|
fetchRoles();
|
||||||
_initializeDefaults();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _initializeDefaults() {
|
|
||||||
fetchProjects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String? formFieldValidator(String? value, {required String fieldType}) {
|
String? formFieldValidator(String? value, {required String fieldType}) {
|
||||||
if (value == null || value.trim().isEmpty) {
|
if (value == null || value.trim().isEmpty) return 'This field is required';
|
||||||
return 'This field is required';
|
|
||||||
}
|
|
||||||
if (fieldType == "target" && int.tryParse(value.trim()) == null) {
|
if (fieldType == "target" && int.tryParse(value.trim()) == null) {
|
||||||
return 'Please enter a valid number';
|
return 'Please enter a valid number';
|
||||||
}
|
}
|
||||||
@ -48,9 +41,8 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateSelectedEmployees() {
|
void updateSelectedEmployees() {
|
||||||
final selected =
|
selectedEmployees.value =
|
||||||
employees.where((e) => uploadingStates[e.id]?.value == true).toList();
|
employees.where((e) => uploadingStates[e.id]?.value == true).toList();
|
||||||
selectedEmployees.value = selected;
|
|
||||||
logSafe("Updated selected employees", level: LogLevel.debug);
|
logSafe("Updated selected employees", level: LogLevel.debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +69,8 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
required String description,
|
required String description,
|
||||||
required List<String> taskTeam,
|
required List<String> taskTeam,
|
||||||
DateTime? assignmentDate,
|
DateTime? assignmentDate,
|
||||||
|
String? organizationId,
|
||||||
|
String? serviceId,
|
||||||
}) async {
|
}) async {
|
||||||
isAssigningTask.value = true;
|
isAssigningTask.value = true;
|
||||||
logSafe("Starting assign task...", level: LogLevel.info);
|
logSafe("Starting assign task...", level: LogLevel.info);
|
||||||
@ -87,6 +81,8 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
description: description,
|
description: description,
|
||||||
taskTeam: taskTeam,
|
taskTeam: taskTeam,
|
||||||
assignmentDate: assignmentDate,
|
assignmentDate: assignmentDate,
|
||||||
|
organizationId: organizationId,
|
||||||
|
serviceId: serviceId,
|
||||||
);
|
);
|
||||||
|
|
||||||
isAssigningTask.value = false;
|
isAssigningTask.value = false;
|
||||||
@ -110,70 +106,42 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> fetchProjects() async {
|
|
||||||
isFetchingProjects.value = true;
|
|
||||||
try {
|
|
||||||
final response = await ApiService.getProjects();
|
|
||||||
if (response?.isEmpty ?? true) {
|
|
||||||
logSafe("No project data found or API call failed",
|
|
||||||
level: LogLevel.warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
projects = response!.map((json) => ProjectModel.fromJson(json)).toList();
|
|
||||||
logSafe("Projects fetched: ${projects.length} projects loaded",
|
|
||||||
level: LogLevel.info);
|
|
||||||
update();
|
|
||||||
} catch (e, stack) {
|
|
||||||
logSafe("Error fetching projects",
|
|
||||||
level: LogLevel.error, error: e, stackTrace: stack);
|
|
||||||
} finally {
|
|
||||||
isFetchingProjects.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fetch Infra details and then tasks per work area
|
/// Fetch Infra details and then tasks per work area
|
||||||
Future<void> fetchTaskData(String? projectId, {String? serviceId}) async {
|
Future<void> fetchTaskData(String? projectId, {String? serviceId}) async {
|
||||||
if (projectId == null) {
|
if (projectId == null) return;
|
||||||
logSafe("Project ID is null", level: LogLevel.warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isFetchingTasks.value = true;
|
isFetchingTasks.value = true;
|
||||||
try {
|
try {
|
||||||
// Fetch infra details
|
final infraResponse = await ApiService.getInfraDetails(
|
||||||
final infraResponse = await ApiService.getInfraDetails(projectId);
|
projectId,
|
||||||
|
serviceId: serviceId,
|
||||||
|
);
|
||||||
final infraData = infraResponse?['data'] as List<dynamic>?;
|
final infraData = infraResponse?['data'] as List<dynamic>?;
|
||||||
|
|
||||||
if (infraData == null || infraData.isEmpty) {
|
if (infraData == null || infraData.isEmpty) {
|
||||||
logSafe("No infra data found for project $projectId",
|
|
||||||
level: LogLevel.warning);
|
|
||||||
dailyTasks = [];
|
dailyTasks = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map infra to dailyTasks structure
|
|
||||||
dailyTasks = infraData.map((buildingJson) {
|
dailyTasks = infraData.map((buildingJson) {
|
||||||
final building = Building(
|
final building = Building(
|
||||||
id: buildingJson['id'],
|
id: buildingJson['id'],
|
||||||
name: buildingJson['buildingName'],
|
name: buildingJson['buildingName'],
|
||||||
description: buildingJson['description'],
|
description: buildingJson['description'],
|
||||||
floors: (buildingJson['floors'] as List<dynamic>).map((floorJson) {
|
floors: (buildingJson['floors'] as List<dynamic>)
|
||||||
return Floor(
|
.map((floorJson) => Floor(
|
||||||
id: floorJson['id'],
|
id: floorJson['id'],
|
||||||
floorName: floorJson['floorName'],
|
floorName: floorJson['floorName'],
|
||||||
workAreas:
|
workAreas: (floorJson['workAreas'] as List<dynamic>)
|
||||||
(floorJson['workAreas'] as List<dynamic>).map((areaJson) {
|
.map((areaJson) => WorkArea(
|
||||||
return WorkArea(
|
id: areaJson['id'],
|
||||||
id: areaJson['id'],
|
areaName: areaJson['areaName'],
|
||||||
areaName: areaJson['areaName'],
|
workItems: [],
|
||||||
workItems: [], // Will fill after tasks API
|
))
|
||||||
);
|
.toList(),
|
||||||
}).toList(),
|
))
|
||||||
);
|
.toList(),
|
||||||
}).toList(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return TaskPlanningDetailsModel(
|
return TaskPlanningDetailsModel(
|
||||||
id: building.id,
|
id: building.id,
|
||||||
name: building.name,
|
name: building.name,
|
||||||
@ -186,50 +154,39 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
// Fetch tasks for each work area, passing serviceId only if selected
|
|
||||||
await Future.wait(dailyTasks
|
await Future.wait(dailyTasks
|
||||||
.expand((task) => task.buildings)
|
.expand((task) => task.buildings)
|
||||||
.expand((b) => b.floors)
|
.expand((b) => b.floors)
|
||||||
.expand((f) => f.workAreas)
|
.expand((f) => f.workAreas)
|
||||||
.map((area) async {
|
.map((area) async {
|
||||||
try {
|
try {
|
||||||
final taskResponse = await ApiService.getWorkItemsByWorkArea(
|
final taskResponse =
|
||||||
area.id,
|
await ApiService.getWorkItemsByWorkArea(area.id, serviceId: serviceId);
|
||||||
// serviceId: serviceId, // <-- only pass if not null
|
|
||||||
);
|
|
||||||
final taskData = taskResponse?['data'] as List<dynamic>? ?? [];
|
final taskData = taskResponse?['data'] as List<dynamic>? ?? [];
|
||||||
|
area.workItems.addAll(taskData.map((taskJson) => WorkItemWrapper(
|
||||||
area.workItems.addAll(taskData.map((taskJson) {
|
workItemId: taskJson['id'],
|
||||||
return WorkItemWrapper(
|
workItem: WorkItem(
|
||||||
workItemId: taskJson['id'],
|
id: taskJson['id'],
|
||||||
workItem: WorkItem(
|
activityMaster: taskJson['activityMaster'] != null
|
||||||
id: taskJson['id'],
|
? ActivityMaster.fromJson(taskJson['activityMaster'])
|
||||||
activityMaster: taskJson['activityMaster'] != null
|
: null,
|
||||||
? ActivityMaster.fromJson(taskJson['activityMaster'])
|
workCategoryMaster: taskJson['workCategoryMaster'] != null
|
||||||
: null,
|
? WorkCategoryMaster.fromJson(taskJson['workCategoryMaster'])
|
||||||
workCategoryMaster: taskJson['workCategoryMaster'] != null
|
: null,
|
||||||
? WorkCategoryMaster.fromJson(
|
plannedWork: (taskJson['plannedWork'] as num?)?.toDouble(),
|
||||||
taskJson['workCategoryMaster'])
|
completedWork: (taskJson['completedWork'] as num?)?.toDouble(),
|
||||||
: null,
|
todaysAssigned: (taskJson['todaysAssigned'] as num?)?.toDouble(),
|
||||||
plannedWork: (taskJson['plannedWork'] as num?)?.toDouble(),
|
description: taskJson['description'] as String?,
|
||||||
completedWork: (taskJson['completedWork'] as num?)?.toDouble(),
|
taskDate: taskJson['taskDate'] != null
|
||||||
todaysAssigned:
|
? DateTime.tryParse(taskJson['taskDate'])
|
||||||
(taskJson['todaysAssigned'] as num?)?.toDouble(),
|
: null,
|
||||||
description: taskJson['description'] as String?,
|
),
|
||||||
taskDate: taskJson['taskDate'] != null
|
)));
|
||||||
? DateTime.tryParse(taskJson['taskDate'])
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}));
|
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
logSafe("Error fetching tasks for work area ${area.id}",
|
logSafe("Error fetching tasks for work area ${area.id}",
|
||||||
level: LogLevel.error, error: e, stackTrace: stack);
|
level: LogLevel.error, error: e, stackTrace: stack);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
logSafe("Fetched infra and tasks for project $projectId",
|
|
||||||
level: LogLevel.info);
|
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
logSafe("Error fetching daily task data",
|
logSafe("Error fetching daily task data",
|
||||||
level: LogLevel.error, error: e, stackTrace: stack);
|
level: LogLevel.error, error: e, stackTrace: stack);
|
||||||
@ -239,42 +196,68 @@ class DailyTaskPlanningController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> fetchEmployeesByProject(String? projectId) async {
|
Future<void> fetchEmployeesByProjectService({
|
||||||
if (projectId == null || projectId.isEmpty) {
|
required String projectId,
|
||||||
logSafe("Project ID is required but was null or empty",
|
String? serviceId,
|
||||||
level: LogLevel.error);
|
String? organizationId,
|
||||||
return;
|
}) async {
|
||||||
}
|
isFetchingEmployees.value = true;
|
||||||
|
|
||||||
isFetchingEmployees.value = true;
|
|
||||||
try {
|
try {
|
||||||
final response = await ApiService.getAllEmployeesByProject(projectId);
|
final response = await ApiService.getEmployeesByProjectService(
|
||||||
|
projectId,
|
||||||
|
serviceId: serviceId ?? '',
|
||||||
|
organizationId: organizationId ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
if (response != null && response.isNotEmpty) {
|
if (response != null && response.isNotEmpty) {
|
||||||
employees =
|
employees.assignAll(response.map((json) => EmployeeModel.fromJson(json)));
|
||||||
response.map((json) => EmployeeModel.fromJson(json)).toList();
|
|
||||||
for (var emp in employees) {
|
if (serviceId == null && organizationId == null) {
|
||||||
uploadingStates[emp.id] = false.obs;
|
allEmployeesCache = List.from(employees);
|
||||||
}
|
}
|
||||||
logSafe(
|
|
||||||
"Employees fetched: ${employees.length} for project $projectId",
|
final currentEmployeeIds = employees.map((e) => e.id).toSet();
|
||||||
level: LogLevel.info,
|
|
||||||
);
|
uploadingStates.removeWhere((key, _) => !currentEmployeeIds.contains(key));
|
||||||
|
employees.forEach((emp) {
|
||||||
|
uploadingStates.putIfAbsent(emp.id, () => false.obs);
|
||||||
|
});
|
||||||
|
|
||||||
|
selectedEmployees.removeWhere((e) => !currentEmployeeIds.contains(e.id));
|
||||||
|
|
||||||
|
logSafe("Employees fetched: ${employees.length}", level: LogLevel.info);
|
||||||
} else {
|
} else {
|
||||||
employees = [];
|
employees.clear();
|
||||||
|
uploadingStates.clear();
|
||||||
|
selectedEmployees.clear();
|
||||||
logSafe(
|
logSafe(
|
||||||
"No employees found for project $projectId",
|
serviceId != null || organizationId != null
|
||||||
|
? "Filtered employees empty"
|
||||||
|
: "No employees found",
|
||||||
level: LogLevel.warning,
|
level: LogLevel.warning,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
logSafe(
|
logSafe("Error fetching employees", level: LogLevel.error, error: e, stackTrace: stack);
|
||||||
"Error fetching employees for project $projectId",
|
|
||||||
level: LogLevel.error,
|
if (serviceId == null && organizationId == null && allEmployeesCache.isNotEmpty) {
|
||||||
error: e,
|
employees.assignAll(allEmployeesCache);
|
||||||
stackTrace: stack,
|
|
||||||
);
|
final cachedEmployeeIds = employees.map((e) => e.id).toSet();
|
||||||
|
uploadingStates.removeWhere((key, _) => !cachedEmployeeIds.contains(key));
|
||||||
|
employees.forEach((emp) {
|
||||||
|
uploadingStates.putIfAbsent(emp.id, () => false.obs);
|
||||||
|
});
|
||||||
|
|
||||||
|
selectedEmployees.removeWhere((e) => !cachedEmployeeIds.contains(e.id));
|
||||||
|
} else {
|
||||||
|
employees.clear();
|
||||||
|
uploadingStates.clear();
|
||||||
|
selectedEmployees.clear();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
isFetchingEmployees.value = false;
|
isFetchingEmployees.value = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
66
lib/controller/tenant/all_organization_controller.dart
Normal file
66
lib/controller/tenant/all_organization_controller.dart
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:marco/helpers/services/app_logger.dart';
|
||||||
|
import 'package:marco/helpers/services/api_service.dart';
|
||||||
|
import 'package:marco/model/all_organization_model.dart';
|
||||||
|
|
||||||
|
class AllOrganizationController extends GetxController {
|
||||||
|
RxList<AllOrganization> organizations = <AllOrganization>[].obs;
|
||||||
|
Rxn<AllOrganization> selectedOrganization = Rxn<AllOrganization>();
|
||||||
|
final isLoadingOrganizations = false.obs;
|
||||||
|
|
||||||
|
String? passedOrgId;
|
||||||
|
|
||||||
|
AllOrganizationController({this.passedOrgId});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
fetchAllOrganizations();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> fetchAllOrganizations() async {
|
||||||
|
try {
|
||||||
|
isLoadingOrganizations.value = true;
|
||||||
|
|
||||||
|
final response = await ApiService.getAllOrganizations();
|
||||||
|
if (response != null && response.data.data.isNotEmpty) {
|
||||||
|
organizations.value = response.data.data;
|
||||||
|
|
||||||
|
// Select organization based on passed ID, or fallback to first
|
||||||
|
if (passedOrgId != null) {
|
||||||
|
selectedOrganization.value =
|
||||||
|
organizations.firstWhere(
|
||||||
|
(org) => org.id == passedOrgId,
|
||||||
|
orElse: () => organizations.first,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
selectedOrganization.value ??= organizations.first;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
organizations.clear();
|
||||||
|
selectedOrganization.value = null;
|
||||||
|
}
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
logSafe(
|
||||||
|
"Failed to fetch organizations: $e",
|
||||||
|
level: LogLevel.error,
|
||||||
|
error: e,
|
||||||
|
stackTrace: stackTrace,
|
||||||
|
);
|
||||||
|
organizations.clear();
|
||||||
|
selectedOrganization.value = null;
|
||||||
|
} finally {
|
||||||
|
isLoadingOrganizations.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectOrganization(AllOrganization? org) {
|
||||||
|
selectedOrganization.value = org;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearSelection() {
|
||||||
|
selectedOrganization.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get currentSelection => selectedOrganization.value?.name ?? "All Organizations";
|
||||||
|
}
|
@ -22,6 +22,7 @@ class ApiEndpoints {
|
|||||||
|
|
||||||
// Employee Screen API Endpoints
|
// Employee Screen API Endpoints
|
||||||
static const String getAllEmployeesByProject = "/employee/list";
|
static const String getAllEmployeesByProject = "/employee/list";
|
||||||
|
static const String getAllEmployeesByOrganization = "/project/get/task/team";
|
||||||
static const String getAllEmployees = "/employee/list";
|
static const String getAllEmployees = "/employee/list";
|
||||||
static const String getEmployeesWithoutPermission = "/employee/basic";
|
static const String getEmployeesWithoutPermission = "/employee/basic";
|
||||||
static const String getRoles = "/roles/jobrole";
|
static const String getRoles = "/roles/jobrole";
|
||||||
@ -53,6 +54,8 @@ class ApiEndpoints {
|
|||||||
static const String getDirectoryOrganization = "/directory/organization";
|
static const String getDirectoryOrganization = "/directory/organization";
|
||||||
static const String createContact = "/directory";
|
static const String createContact = "/directory";
|
||||||
static const String updateContact = "/directory";
|
static const String updateContact = "/directory";
|
||||||
|
static const String deleteContact = "/directory";
|
||||||
|
static const String restoreContact = "/directory/note";
|
||||||
static const String getDirectoryNotes = "/directory/notes";
|
static const String getDirectoryNotes = "/directory/notes";
|
||||||
static const String updateDirectoryNotes = "/directory/note";
|
static const String updateDirectoryNotes = "/directory/note";
|
||||||
static const String createBucket = "/directory/bucket";
|
static const String createBucket = "/directory/bucket";
|
||||||
@ -94,5 +97,7 @@ class ApiEndpoints {
|
|||||||
|
|
||||||
static const String getAssignedOrganizations =
|
static const String getAssignedOrganizations =
|
||||||
"/project/get/assigned/organization";
|
"/project/get/assigned/organization";
|
||||||
|
static const getAllOrganizations = "/organization/list";
|
||||||
|
|
||||||
static const String getAssignedServices = "/Project/get/assigned/services";
|
static const String getAssignedServices = "/Project/get/assigned/services";
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import 'package:marco/model/attendance/organization_per_project_list_model.dart'
|
|||||||
import 'package:marco/model/tenant/tenant_services_model.dart';
|
import 'package:marco/model/tenant/tenant_services_model.dart';
|
||||||
import 'package:marco/model/dailyTaskPlanning/daily_task_model.dart';
|
import 'package:marco/model/dailyTaskPlanning/daily_task_model.dart';
|
||||||
import 'package:marco/model/dailyTaskPlanning/daily_progress_report_filter_response_model.dart';
|
import 'package:marco/model/dailyTaskPlanning/daily_progress_report_filter_response_model.dart';
|
||||||
|
import 'package:marco/model/all_organization_model.dart';
|
||||||
|
|
||||||
class ApiService {
|
class ApiService {
|
||||||
static const bool enableLogs = true;
|
static const bool enableLogs = true;
|
||||||
@ -321,6 +322,32 @@ class ApiService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<AllOrganizationListResponse?> getAllOrganizations() async {
|
||||||
|
final endpoint = "${ApiEndpoints.getAllOrganizations}";
|
||||||
|
try {
|
||||||
|
final response = await _getRequest(endpoint);
|
||||||
|
|
||||||
|
if (response == null) {
|
||||||
|
logSafe("All Organizations request failed: null response",
|
||||||
|
level: LogLevel.error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final jsonResponse =
|
||||||
|
_parseResponseForAllData(response, label: "All Organizations");
|
||||||
|
|
||||||
|
if (jsonResponse != null) {
|
||||||
|
return AllOrganizationListResponse.fromJson(jsonResponse);
|
||||||
|
}
|
||||||
|
} catch (e, stack) {
|
||||||
|
logSafe("Exception during getAllOrganizations: $e",
|
||||||
|
level: LogLevel.error);
|
||||||
|
logSafe("StackTrace: $stack", level: LogLevel.debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//// Get Services assigned to a Project
|
//// Get Services assigned to a Project
|
||||||
static Future<ServiceListResponse?> getAssignedServices(
|
static Future<ServiceListResponse?> getAssignedServices(
|
||||||
String projectId) async {
|
String projectId) async {
|
||||||
@ -1786,6 +1813,52 @@ class ApiService {
|
|||||||
return data is List ? data : null;
|
return data is List ? data : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deletes a directory contact (sets active=false)
|
||||||
|
static Future<bool> deleteDirectoryContact(String contactId) async {
|
||||||
|
final endpoint = "${ApiEndpoints.updateContact}/$contactId/";
|
||||||
|
final queryParams = {'active': 'false'};
|
||||||
|
|
||||||
|
final uri = Uri.parse("${ApiEndpoints.baseUrl}$endpoint")
|
||||||
|
.replace(queryParameters: queryParams);
|
||||||
|
|
||||||
|
_log("Deleting directory contact at $uri");
|
||||||
|
|
||||||
|
final response = await _deleteRequest(
|
||||||
|
"$endpoint?active=false",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response != null && response.statusCode == 200) {
|
||||||
|
_log("Contact deleted successfully: ${response.body}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_log("Failed to delete contact: ${response?.body}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Restores a directory contact (sets active=true)
|
||||||
|
static Future<bool> restoreDirectoryContact(String contactId) async {
|
||||||
|
final endpoint = "${ApiEndpoints.updateContact}/$contactId/";
|
||||||
|
final queryParams = {'active': 'true'};
|
||||||
|
|
||||||
|
final uri = Uri.parse("${ApiEndpoints.baseUrl}$endpoint")
|
||||||
|
.replace(queryParameters: queryParams);
|
||||||
|
|
||||||
|
_log("Restoring directory contact at $uri");
|
||||||
|
|
||||||
|
final response = await _deleteRequest(
|
||||||
|
"$endpoint?active=true",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response != null && response.statusCode == 200) {
|
||||||
|
_log("Contact restored successfully: ${response.body}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_log("Failed to restore contact: ${response?.body}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<bool> updateContact(
|
static Future<bool> updateContact(
|
||||||
String contactId, Map<String, dynamic> payload) async {
|
String contactId, Map<String, dynamic> payload) async {
|
||||||
try {
|
try {
|
||||||
@ -2056,6 +2129,36 @@ class ApiService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetches employees by projectId, serviceId, and organizationId
|
||||||
|
static Future<List<dynamic>?> getEmployeesByProjectService(
|
||||||
|
String projectId, {
|
||||||
|
String? serviceId,
|
||||||
|
String? organizationId,
|
||||||
|
}) async {
|
||||||
|
if (projectId.isEmpty) {
|
||||||
|
throw ArgumentError('projectId must not be empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct query parameters only if non-empty
|
||||||
|
final queryParams = <String, String>{};
|
||||||
|
if (serviceId != null && serviceId.isNotEmpty) {
|
||||||
|
queryParams['serviceId'] = serviceId;
|
||||||
|
}
|
||||||
|
if (organizationId != null && organizationId.isNotEmpty) {
|
||||||
|
queryParams['organizationId'] = organizationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
final endpoint = "${ApiEndpoints.getAllEmployeesByOrganization}/$projectId";
|
||||||
|
|
||||||
|
final response = await _getRequest(endpoint, queryParams: queryParams);
|
||||||
|
|
||||||
|
if (response != null) {
|
||||||
|
return _parseResponse(response, label: 'Employees by Project Service');
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Future<List<dynamic>?> getAllEmployees(
|
static Future<List<dynamic>?> getAllEmployees(
|
||||||
{String? organizationId}) async {
|
{String? organizationId}) async {
|
||||||
var endpoint = ApiEndpoints.getAllEmployees;
|
var endpoint = ApiEndpoints.getAllEmployees;
|
||||||
@ -2159,7 +2262,7 @@ class ApiService {
|
|||||||
|
|
||||||
static Future<List<TaskModel>?> getDailyTasks(
|
static Future<List<TaskModel>?> getDailyTasks(
|
||||||
String projectId, {
|
String projectId, {
|
||||||
Map<String, dynamic>? filter, // <-- New: combined filter
|
Map<String, dynamic>? filter,
|
||||||
int pageNumber = 1,
|
int pageNumber = 1,
|
||||||
int pageSize = 20,
|
int pageSize = 20,
|
||||||
}) async {
|
}) async {
|
||||||
@ -2238,9 +2341,14 @@ class ApiService {
|
|||||||
return response.statusCode == 200 && json['success'] == true;
|
return response.statusCode == 200 && json['success'] == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch infra details for a given project
|
/// Fetch infra details for a project, optionally filtered by service
|
||||||
static Future<Map<String, dynamic>?> getInfraDetails(String projectId) async {
|
static Future<Map<String, dynamic>?> getInfraDetails(String projectId,
|
||||||
final endpoint = "/project/infra-details/$projectId";
|
{String? serviceId}) async {
|
||||||
|
String endpoint = "/project/infra-details/$projectId";
|
||||||
|
|
||||||
|
if (serviceId != null && serviceId.isNotEmpty) {
|
||||||
|
endpoint += "?serviceId=$serviceId";
|
||||||
|
}
|
||||||
|
|
||||||
final res = await _getRequest(endpoint);
|
final res = await _getRequest(endpoint);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
@ -2253,10 +2361,14 @@ class ApiService {
|
|||||||
as Map<String, dynamic>?;
|
as Map<String, dynamic>?;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch work items for a given work area
|
/// Fetch work items for a given work area, optionally filtered by service
|
||||||
static Future<Map<String, dynamic>?> getWorkItemsByWorkArea(
|
static Future<Map<String, dynamic>?> getWorkItemsByWorkArea(String workAreaId,
|
||||||
String workAreaId) async {
|
{String? serviceId}) async {
|
||||||
final endpoint = "/project/tasks/$workAreaId";
|
String endpoint = "/project/tasks/$workAreaId";
|
||||||
|
|
||||||
|
if (serviceId != null && serviceId.isNotEmpty) {
|
||||||
|
endpoint += "?serviceId=$serviceId";
|
||||||
|
}
|
||||||
|
|
||||||
final res = await _getRequest(endpoint);
|
final res = await _getRequest(endpoint);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
@ -2275,12 +2387,16 @@ class ApiService {
|
|||||||
required String description,
|
required String description,
|
||||||
required List<String> taskTeam,
|
required List<String> taskTeam,
|
||||||
DateTime? assignmentDate,
|
DateTime? assignmentDate,
|
||||||
|
String? organizationId,
|
||||||
|
String? serviceId,
|
||||||
}) async {
|
}) async {
|
||||||
final body = {
|
final body = {
|
||||||
"workItemId": workItemId,
|
"workItemId": workItemId,
|
||||||
"plannedTask": plannedTask,
|
"plannedTask": plannedTask,
|
||||||
"description": description,
|
"description": description,
|
||||||
"taskTeam": taskTeam,
|
"taskTeam": taskTeam,
|
||||||
|
"organizationId": organizationId,
|
||||||
|
"serviceId": serviceId,
|
||||||
"assignmentDate":
|
"assignmentDate":
|
||||||
(assignmentDate ?? DateTime.now()).toUtc().toIso8601String(),
|
(assignmentDate ?? DateTime.now()).toUtc().toIso8601String(),
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ void showAppSnackbar({
|
|||||||
snackPosition: SnackPosition.BOTTOM,
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
margin: const EdgeInsets.all(16),
|
margin: const EdgeInsets.all(16),
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
duration: const Duration(seconds: 3),
|
duration: const Duration(minutes: 1),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
iconData,
|
iconData,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
82
lib/helpers/widgets/tenant/all_organization_selector.dart
Normal file
82
lib/helpers/widgets/tenant/all_organization_selector.dart
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:marco/controller/tenant/all_organization_controller.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
|
import 'package:marco/model/all_organization_model.dart';
|
||||||
|
|
||||||
|
class AllOrganizationListView extends StatelessWidget {
|
||||||
|
final AllOrganizationController controller;
|
||||||
|
|
||||||
|
/// Optional callback when an organization is tapped
|
||||||
|
final void Function(AllOrganization)? onTapOrganization;
|
||||||
|
|
||||||
|
const AllOrganizationListView({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
this.onTapOrganization,
|
||||||
|
});
|
||||||
|
|
||||||
|
Widget _loadingPlaceholder() {
|
||||||
|
return ListView.separated(
|
||||||
|
itemCount: 5,
|
||||||
|
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 150,
|
||||||
|
height: 14,
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Obx(() {
|
||||||
|
if (controller.isLoadingOrganizations.value) {
|
||||||
|
return _loadingPlaceholder();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controller.organizations.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: MyText.bodyMedium(
|
||||||
|
"No organizations found",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView.separated(
|
||||||
|
itemCount: controller.organizations.length,
|
||||||
|
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final org = controller.organizations[index];
|
||||||
|
return ListTile(
|
||||||
|
title: Text(org.name),
|
||||||
|
onTap: () {
|
||||||
|
if (onTapOrganization != null) {
|
||||||
|
onTapOrganization!(org);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
184
lib/model/all_organization_model.dart
Normal file
184
lib/model/all_organization_model.dart
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
class AllOrganizationListResponse {
|
||||||
|
final bool success;
|
||||||
|
final String message;
|
||||||
|
final OrganizationData data;
|
||||||
|
final dynamic errors;
|
||||||
|
final int statusCode;
|
||||||
|
final String timestamp;
|
||||||
|
|
||||||
|
AllOrganizationListResponse({
|
||||||
|
required this.success,
|
||||||
|
required this.message,
|
||||||
|
required this.data,
|
||||||
|
this.errors,
|
||||||
|
required this.statusCode,
|
||||||
|
required this.timestamp,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory AllOrganizationListResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return AllOrganizationListResponse(
|
||||||
|
success: json['success'] ?? false,
|
||||||
|
message: json['message'] ?? '',
|
||||||
|
data: json['data'] != null
|
||||||
|
? OrganizationData.fromJson(json['data'])
|
||||||
|
: OrganizationData(currentPage: 0, totalPages: 0, totalEntities: 0, data: []),
|
||||||
|
errors: json['errors'],
|
||||||
|
statusCode: json['statusCode'] ?? 0,
|
||||||
|
timestamp: json['timestamp'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'success': success,
|
||||||
|
'message': message,
|
||||||
|
'data': data.toJson(),
|
||||||
|
'errors': errors,
|
||||||
|
'statusCode': statusCode,
|
||||||
|
'timestamp': timestamp,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OrganizationData {
|
||||||
|
final int currentPage;
|
||||||
|
final int totalPages;
|
||||||
|
final int totalEntities;
|
||||||
|
final List<AllOrganization> data;
|
||||||
|
|
||||||
|
OrganizationData({
|
||||||
|
required this.currentPage,
|
||||||
|
required this.totalPages,
|
||||||
|
required this.totalEntities,
|
||||||
|
required this.data,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OrganizationData.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OrganizationData(
|
||||||
|
currentPage: json['currentPage'] ?? 0,
|
||||||
|
totalPages: json['totalPages'] ?? 0,
|
||||||
|
totalEntities: json['totalEntities'] ?? 0,
|
||||||
|
data: (json['data'] as List<dynamic>?)
|
||||||
|
?.map((e) => AllOrganization.fromJson(e))
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'currentPage': currentPage,
|
||||||
|
'totalPages': totalPages,
|
||||||
|
'totalEntities': totalEntities,
|
||||||
|
'data': data.map((e) => e.toJson()).toList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AllOrganization {
|
||||||
|
final String id;
|
||||||
|
final String name;
|
||||||
|
final String email;
|
||||||
|
final String contactPerson;
|
||||||
|
final String address;
|
||||||
|
final String contactNumber;
|
||||||
|
final int sprid;
|
||||||
|
final String? logoImage;
|
||||||
|
final String createdAt;
|
||||||
|
final User? createdBy;
|
||||||
|
final User? updatedBy;
|
||||||
|
final String? updatedAt;
|
||||||
|
final bool isActive;
|
||||||
|
|
||||||
|
AllOrganization({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.email,
|
||||||
|
required this.contactPerson,
|
||||||
|
required this.address,
|
||||||
|
required this.contactNumber,
|
||||||
|
required this.sprid,
|
||||||
|
this.logoImage,
|
||||||
|
required this.createdAt,
|
||||||
|
this.createdBy,
|
||||||
|
this.updatedBy,
|
||||||
|
this.updatedAt,
|
||||||
|
required this.isActive,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory AllOrganization.fromJson(Map<String, dynamic> json) {
|
||||||
|
return AllOrganization(
|
||||||
|
id: json['id'] ?? '',
|
||||||
|
name: json['name'] ?? '',
|
||||||
|
email: json['email'] ?? '',
|
||||||
|
contactPerson: json['contactPerson'] ?? '',
|
||||||
|
address: json['address'] ?? '',
|
||||||
|
contactNumber: json['contactNumber'] ?? '',
|
||||||
|
sprid: json['sprid'] ?? 0,
|
||||||
|
logoImage: json['logoImage'],
|
||||||
|
createdAt: json['createdAt'] ?? '',
|
||||||
|
createdBy: json['createdBy'] != null ? User.fromJson(json['createdBy']) : null,
|
||||||
|
updatedBy: json['updatedBy'] != null ? User.fromJson(json['updatedBy']) : null,
|
||||||
|
updatedAt: json['updatedAt'],
|
||||||
|
isActive: json['isActive'] ?? false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'email': email,
|
||||||
|
'contactPerson': contactPerson,
|
||||||
|
'address': address,
|
||||||
|
'contactNumber': contactNumber,
|
||||||
|
'sprid': sprid,
|
||||||
|
'logoImage': logoImage,
|
||||||
|
'createdAt': createdAt,
|
||||||
|
'createdBy': createdBy?.toJson(),
|
||||||
|
'updatedBy': updatedBy?.toJson(),
|
||||||
|
'updatedAt': updatedAt,
|
||||||
|
'isActive': isActive,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class User {
|
||||||
|
final String id;
|
||||||
|
final String firstName;
|
||||||
|
final String lastName;
|
||||||
|
final String photo;
|
||||||
|
final String jobRoleId;
|
||||||
|
final String jobRoleName;
|
||||||
|
|
||||||
|
User({
|
||||||
|
required this.id,
|
||||||
|
required this.firstName,
|
||||||
|
required this.lastName,
|
||||||
|
required this.photo,
|
||||||
|
required this.jobRoleId,
|
||||||
|
required this.jobRoleName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory User.fromJson(Map<String, dynamic> json) {
|
||||||
|
return User(
|
||||||
|
id: json['id'] ?? '',
|
||||||
|
firstName: json['firstName'] ?? '',
|
||||||
|
lastName: json['lastName'] ?? '',
|
||||||
|
photo: json['photo'] ?? '',
|
||||||
|
jobRoleId: json['jobRoleId'] ?? '',
|
||||||
|
jobRoleName: json['jobRoleName'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'firstName': firstName,
|
||||||
|
'lastName': lastName,
|
||||||
|
'photo': photo,
|
||||||
|
'jobRoleId': jobRoleId,
|
||||||
|
'jobRoleName': jobRoleName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -2,10 +2,16 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:marco/controller/task_Planning/daily_task_Planning_controller.dart';
|
import 'package:marco/controller/task_Planning/daily_task_Planning_controller.dart';
|
||||||
import 'package:marco/controller/project_controller.dart';
|
import 'package:marco/controller/project_controller.dart';
|
||||||
|
import 'package:marco/controller/tenant/organization_selection_controller.dart';
|
||||||
|
import 'package:marco/controller/tenant/service_controller.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
import 'package:marco/helpers/widgets/my_text.dart';
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
||||||
import 'package:marco/helpers/utils/base_bottom_sheet.dart';
|
import 'package:marco/helpers/utils/base_bottom_sheet.dart';
|
||||||
|
import 'package:marco/helpers/widgets/tenant/organization_selector.dart';
|
||||||
|
import 'package:marco/helpers/widgets/tenant/service_selector.dart';
|
||||||
|
import 'package:marco/model/attendance/organization_per_project_list_model.dart';
|
||||||
|
import 'package:marco/model/tenant/tenant_services_model.dart';
|
||||||
|
|
||||||
class AssignTaskBottomSheet extends StatefulWidget {
|
class AssignTaskBottomSheet extends StatefulWidget {
|
||||||
final String workLocation;
|
final String workLocation;
|
||||||
@ -36,24 +42,46 @@ class AssignTaskBottomSheet extends StatefulWidget {
|
|||||||
class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||||
final DailyTaskPlanningController controller = Get.find();
|
final DailyTaskPlanningController controller = Get.find();
|
||||||
final ProjectController projectController = Get.find();
|
final ProjectController projectController = Get.find();
|
||||||
|
|
||||||
|
final OrganizationController orgController = Get.put(OrganizationController());
|
||||||
|
final ServiceController serviceController = Get.put(ServiceController());
|
||||||
|
|
||||||
final TextEditingController targetController = TextEditingController();
|
final TextEditingController targetController = TextEditingController();
|
||||||
final TextEditingController descriptionController = TextEditingController();
|
final TextEditingController descriptionController = TextEditingController();
|
||||||
final ScrollController _employeeListScrollController = ScrollController();
|
final ScrollController _employeeListScrollController = ScrollController();
|
||||||
|
|
||||||
String? selectedProjectId;
|
String? selectedProjectId;
|
||||||
|
Organization? selectedOrganization;
|
||||||
|
Service? selectedService;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
selectedProjectId = projectController.selectedProjectId.value;
|
selectedProjectId = projectController.selectedProjectId.value;
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
if (selectedProjectId != null) {
|
if (selectedProjectId != null) {
|
||||||
controller.fetchEmployeesByProject(selectedProjectId!);
|
await orgController.fetchOrganizations(selectedProjectId!);
|
||||||
|
_resetSelections();
|
||||||
|
await _fetchEmployeesAndTasks();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _resetSelections() {
|
||||||
|
controller.selectedEmployees.clear();
|
||||||
|
controller.uploadingStates.forEach((key, value) => value.value = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchEmployeesAndTasks() async {
|
||||||
|
await controller.fetchEmployeesByProjectService(
|
||||||
|
projectId: selectedProjectId!,
|
||||||
|
serviceId: selectedService?.id,
|
||||||
|
organizationId: selectedOrganization?.id,
|
||||||
|
);
|
||||||
|
await controller.fetchTaskData(selectedProjectId, serviceId: selectedService?.id);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_employeeListScrollController.dispose();
|
_employeeListScrollController.dispose();
|
||||||
@ -77,12 +105,47 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_infoRow(Icons.location_on, "Work Location",
|
// Organization Selector
|
||||||
"${widget.buildingName} > ${widget.floorName} > ${widget.workAreaName} > ${widget.activityName}"),
|
SizedBox(
|
||||||
Divider(),
|
height: 50,
|
||||||
_infoRow(Icons.pending_actions, "Pending Task of Activity",
|
child: OrganizationSelector(
|
||||||
"${widget.pendingTask}"),
|
controller: orgController,
|
||||||
Divider(),
|
onSelectionChanged: (org) async {
|
||||||
|
setState(() => selectedOrganization = org);
|
||||||
|
_resetSelections();
|
||||||
|
if (selectedProjectId != null) await _fetchEmployeesAndTasks();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(12),
|
||||||
|
|
||||||
|
// Service Selector
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
child: ServiceSelector(
|
||||||
|
controller: serviceController,
|
||||||
|
onSelectionChanged: (service) async {
|
||||||
|
setState(() => selectedService = service);
|
||||||
|
_resetSelections();
|
||||||
|
if (selectedProjectId != null) await _fetchEmployeesAndTasks();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
|
||||||
|
// Work Location Info
|
||||||
|
_infoRow(
|
||||||
|
Icons.location_on,
|
||||||
|
"Work Location",
|
||||||
|
"${widget.buildingName} > ${widget.floorName} > ${widget.workAreaName} > ${widget.activityName}",
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
|
||||||
|
// Pending Task Info
|
||||||
|
_infoRow(Icons.pending_actions, "Pending Task", "${widget.pendingTask}"),
|
||||||
|
const Divider(),
|
||||||
|
|
||||||
|
// Role Selector
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: _onRoleMenuPressed,
|
onTap: _onRoleMenuPressed,
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -94,21 +157,34 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
|
// Employee List
|
||||||
Container(
|
Container(
|
||||||
constraints: const BoxConstraints(maxHeight: 150),
|
constraints: const BoxConstraints(maxHeight: 180),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
child: _buildEmployeeList(),
|
child: _buildEmployeeList(),
|
||||||
),
|
),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
|
// Selected Employees Chips
|
||||||
_buildSelectedEmployees(),
|
_buildSelectedEmployees(),
|
||||||
|
MySpacing.height(8),
|
||||||
|
|
||||||
|
// Target Input
|
||||||
_buildTextField(
|
_buildTextField(
|
||||||
icon: Icons.track_changes,
|
icon: Icons.track_changes,
|
||||||
label: "Target for Today :",
|
label: "Target for Today :",
|
||||||
controller: targetController,
|
controller: targetController,
|
||||||
hintText: "Enter target",
|
hintText: "Enter target",
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||||
validatorType: "target",
|
validatorType: "target",
|
||||||
),
|
),
|
||||||
MySpacing.height(24),
|
MySpacing.height(16),
|
||||||
|
|
||||||
|
// Description Input
|
||||||
_buildTextField(
|
_buildTextField(
|
||||||
icon: Icons.description,
|
icon: Icons.description,
|
||||||
label: "Description :",
|
label: "Description :",
|
||||||
@ -122,8 +198,7 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onRoleMenuPressed() {
|
void _onRoleMenuPressed() {
|
||||||
final RenderBox overlay =
|
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
|
||||||
final Size screenSize = overlay.size;
|
final Size screenSize = overlay.size;
|
||||||
|
|
||||||
showMenu(
|
showMenu(
|
||||||
@ -144,56 +219,24 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
if (value != null) controller.onRoleSelected(value == 'all' ? null : value);
|
||||||
controller.onRoleSelected(value == 'all' ? null : value);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmployeeList() {
|
Widget _buildEmployeeList() {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
if (controller.isFetchingTasks.value) {
|
if (controller.isFetchingEmployees.value) {
|
||||||
// Skeleton loader instead of CircularProgressIndicator
|
return Center(child: CircularProgressIndicator());
|
||||||
return ListView.separated(
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: 5, // show 5 skeleton rows
|
|
||||||
separatorBuilder: (_, __) => const SizedBox(height: 4),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 8),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey.shade300,
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
height: 14,
|
|
||||||
color: Colors.grey.shade300,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedRoleId = controller.selectedRoleId.value;
|
final filteredEmployees = controller.selectedRoleId.value == null
|
||||||
final filteredEmployees = selectedRoleId == null
|
|
||||||
? controller.employees
|
? controller.employees
|
||||||
: controller.employees
|
: controller.employees
|
||||||
.where((e) => e.jobRoleID.toString() == selectedRoleId)
|
.where((e) => e.jobRoleID.toString() == controller.selectedRoleId.value)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (filteredEmployees.isEmpty) {
|
if (filteredEmployees.isEmpty) {
|
||||||
return const Text("No employees found for selected role.");
|
return Center(child: Text("No employees available for selected role."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scrollbar(
|
return Scrollbar(
|
||||||
@ -201,43 +244,32 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
controller: _employeeListScrollController,
|
controller: _employeeListScrollController,
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: filteredEmployees.length,
|
itemCount: filteredEmployees.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final employee = filteredEmployees[index];
|
final employee = filteredEmployees[index];
|
||||||
final rxBool = controller.uploadingStates[employee.id];
|
final rxBool = controller.uploadingStates[employee.id];
|
||||||
|
|
||||||
return Obx(() => Padding(
|
return Obx(() => ListTile(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
dense: true,
|
||||||
child: Row(
|
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
children: [
|
leading: Checkbox(
|
||||||
Checkbox(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
|
||||||
shape: RoundedRectangleBorder(
|
value: rxBool?.value ?? false,
|
||||||
borderRadius: BorderRadius.circular(4),
|
onChanged: (selected) {
|
||||||
),
|
if (rxBool != null) {
|
||||||
value: rxBool?.value ?? false,
|
rxBool.value = selected ?? false;
|
||||||
onChanged: (bool? selected) {
|
controller.updateSelectedEmployees();
|
||||||
if (rxBool != null) {
|
}
|
||||||
rxBool.value = selected ?? false;
|
},
|
||||||
controller.updateSelectedEmployees();
|
fillColor: MaterialStateProperty.resolveWith((states) =>
|
||||||
}
|
states.contains(MaterialState.selected)
|
||||||
},
|
? const Color.fromARGB(255, 95, 132, 255)
|
||||||
fillColor:
|
: Colors.transparent),
|
||||||
WidgetStateProperty.resolveWith<Color>((states) {
|
checkColor: Colors.white,
|
||||||
if (states.contains(WidgetState.selected)) {
|
side: const BorderSide(color: Colors.black),
|
||||||
return const Color.fromARGB(255, 95, 132, 255);
|
|
||||||
}
|
|
||||||
return Colors.transparent;
|
|
||||||
}),
|
|
||||||
checkColor: Colors.white,
|
|
||||||
side: const BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(employee.name,
|
|
||||||
style: const TextStyle(fontSize: 14))),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
title: Text(employee.name, style: const TextStyle(fontSize: 14)),
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -249,30 +281,25 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
return Obx(() {
|
return Obx(() {
|
||||||
if (controller.selectedEmployees.isEmpty) return Container();
|
if (controller.selectedEmployees.isEmpty) return Container();
|
||||||
|
|
||||||
return Padding(
|
return Wrap(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
spacing: 4,
|
||||||
child: Wrap(
|
runSpacing: 4,
|
||||||
spacing: 4,
|
children: controller.selectedEmployees.map((e) {
|
||||||
runSpacing: 4,
|
return Obx(() {
|
||||||
children: controller.selectedEmployees.map((e) {
|
final isSelected = controller.uploadingStates[e.id]?.value ?? false;
|
||||||
return Obx(() {
|
if (!isSelected) return Container();
|
||||||
final isSelected =
|
|
||||||
controller.uploadingStates[e.id]?.value ?? false;
|
|
||||||
if (!isSelected) return Container();
|
|
||||||
|
|
||||||
return Chip(
|
return Chip(
|
||||||
label:
|
label: Text(e.name, style: const TextStyle(color: Colors.white)),
|
||||||
Text(e.name, style: const TextStyle(color: Colors.white)),
|
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
||||||
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
deleteIcon: const Icon(Icons.close, color: Colors.white),
|
||||||
deleteIcon: 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(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -289,25 +316,22 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(children: [
|
||||||
children: [
|
Icon(icon, size: 18, color: Colors.black54),
|
||||||
Icon(icon, size: 18, color: Colors.black54),
|
const SizedBox(width: 6),
|
||||||
const SizedBox(width: 6),
|
MyText.titleMedium(label, fontWeight: 600),
|
||||||
MyText.titleMedium(label, fontWeight: 600),
|
]),
|
||||||
],
|
|
||||||
),
|
|
||||||
MySpacing.height(6),
|
MySpacing.height(6),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
keyboardType: keyboardType,
|
keyboardType: keyboardType,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: '',
|
hintText: hintText,
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(6)),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
),
|
),
|
||||||
validator: (value) => this
|
validator: (value) => this.controller.formFieldValidator(value, fieldType: validatorType),
|
||||||
.controller
|
|
||||||
.formFieldValidator(value, fieldType: validatorType),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -326,13 +350,9 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
children: [
|
children: [
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
child: MyText.titleMedium("$title: ",
|
child: MyText.titleMedium("$title: ", fontWeight: 600, color: Colors.black),
|
||||||
fontWeight: 600, color: Colors.black),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: value,
|
|
||||||
style: const TextStyle(color: Colors.black),
|
|
||||||
),
|
),
|
||||||
|
TextSpan(text: value, style: const TextStyle(color: Colors.black)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -349,29 +369,20 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (selectedTeam.isEmpty) {
|
if (selectedTeam.isEmpty) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(title: "Team Required", message: "Please select at least one team member", type: SnackbarType.error);
|
||||||
title: "Team Required",
|
|
||||||
message: "Please select at least one team member",
|
|
||||||
type: SnackbarType.error,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final target = int.tryParse(targetController.text.trim());
|
final target = double.tryParse(targetController.text.trim());
|
||||||
if (target == null || target <= 0) {
|
if (target == null || target <= 0) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(title: "Invalid Input", message: "Please enter a valid target number", type: SnackbarType.error);
|
||||||
title: "Invalid Input",
|
|
||||||
message: "Please enter a valid target number",
|
|
||||||
type: SnackbarType.error,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target > widget.pendingTask) {
|
if (target > widget.pendingTask) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Target Too High",
|
title: "Target Too High",
|
||||||
message:
|
message: "Target cannot exceed pending task (${widget.pendingTask})",
|
||||||
"Target cannot be greater than pending task (${widget.pendingTask})",
|
|
||||||
type: SnackbarType.error,
|
type: SnackbarType.error,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -379,20 +390,18 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
|
|
||||||
final description = descriptionController.text.trim();
|
final description = descriptionController.text.trim();
|
||||||
if (description.isEmpty) {
|
if (description.isEmpty) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(title: "Description Required", message: "Please enter a description", type: SnackbarType.error);
|
||||||
title: "Description Required",
|
|
||||||
message: "Please enter a description",
|
|
||||||
type: SnackbarType.error,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.assignDailyTask(
|
controller.assignDailyTask(
|
||||||
workItemId: widget.workItemId,
|
workItemId: widget.workItemId,
|
||||||
plannedTask: target,
|
plannedTask: target.toInt(),
|
||||||
description: description,
|
description: description,
|
||||||
taskTeam: selectedTeam,
|
taskTeam: selectedTeam,
|
||||||
assignmentDate: widget.assignmentDate,
|
assignmentDate: widget.assignmentDate,
|
||||||
|
organizationId: selectedOrganization?.id,
|
||||||
|
serviceId: selectedService?.id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,20 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
|
|
||||||
ever(controller.isInitialized, (bool ready) {
|
ever(controller.isInitialized, (bool ready) {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
|
// Buckets - map all
|
||||||
|
if (c.bucketIds.isNotEmpty) {
|
||||||
|
final names = c.bucketIds
|
||||||
|
.map((id) {
|
||||||
|
return controller.bucketsMap.entries
|
||||||
|
.firstWhereOrNull((e) => e.value == id)
|
||||||
|
?.key;
|
||||||
|
})
|
||||||
|
.whereType<String>()
|
||||||
|
.toList();
|
||||||
|
controller.selectedBuckets.assignAll(names);
|
||||||
|
}
|
||||||
|
// Projects and Category mapping - as before
|
||||||
final projectIds = c.projectIds;
|
final projectIds = c.projectIds;
|
||||||
final bucketId = c.bucketIds.firstOrNull;
|
|
||||||
final category = c.contactCategory?.name;
|
|
||||||
|
|
||||||
if (category != null) controller.selectedCategory.value = category;
|
|
||||||
|
|
||||||
if (projectIds != null) {
|
if (projectIds != null) {
|
||||||
controller.selectedProjects.assignAll(
|
controller.selectedProjects.assignAll(
|
||||||
projectIds
|
projectIds
|
||||||
@ -90,16 +98,12 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
final category = c.contactCategory?.name;
|
||||||
if (bucketId != null) {
|
if (category != null) controller.selectedCategory.value = category;
|
||||||
final name = controller.bucketsMap.entries
|
|
||||||
.firstWhereOrNull((e) => e.value == bucketId)
|
|
||||||
?.key;
|
|
||||||
if (name != null) controller.selectedBucket.value = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
showAdvanced.value = false; // Optional
|
||||||
emailCtrls.add(TextEditingController());
|
emailCtrls.add(TextEditingController());
|
||||||
emailLabels.add('Office'.obs);
|
emailLabels.add('Office'.obs);
|
||||||
phoneCtrls.add(TextEditingController());
|
phoneCtrls.add(TextEditingController());
|
||||||
@ -363,10 +367,129 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _bucketMultiSelectField() {
|
||||||
|
return _multiSelectField(
|
||||||
|
items: controller.buckets
|
||||||
|
.map((name) => FilterItem(id: name, name: name))
|
||||||
|
.toList(),
|
||||||
|
fallback: "Choose Buckets",
|
||||||
|
selectedValues: controller.selectedBuckets,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _multiSelectField({
|
||||||
|
required List<FilterItem> items,
|
||||||
|
required String fallback,
|
||||||
|
required RxList<String> selectedValues,
|
||||||
|
}) {
|
||||||
|
if (items.isEmpty) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
return Obx(() {
|
||||||
|
final selectedNames = items
|
||||||
|
.where((f) => selectedValues.contains(f.id))
|
||||||
|
.map((f) => f.name)
|
||||||
|
.join(", ");
|
||||||
|
final displayText = selectedNames.isNotEmpty ? selectedNames : fallback;
|
||||||
|
|
||||||
|
return Builder(
|
||||||
|
builder: (context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
final RenderBox button = context.findRenderObject() as RenderBox;
|
||||||
|
final RenderBox overlay =
|
||||||
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
|
final position = button.localToGlobal(Offset.zero);
|
||||||
|
|
||||||
|
await showMenu(
|
||||||
|
context: context,
|
||||||
|
position: RelativeRect.fromLTRB(
|
||||||
|
position.dx,
|
||||||
|
position.dy + button.size.height,
|
||||||
|
overlay.size.width - position.dx - button.size.width,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
items: [
|
||||||
|
PopupMenuItem(
|
||||||
|
enabled: false,
|
||||||
|
child: StatefulBuilder(
|
||||||
|
builder: (context, setState) {
|
||||||
|
return SizedBox(
|
||||||
|
width: 250,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: items.map((f) {
|
||||||
|
final isChecked = selectedValues.contains(f.id);
|
||||||
|
return CheckboxListTile(
|
||||||
|
dense: true,
|
||||||
|
title: Text(f.name),
|
||||||
|
value: isChecked,
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
controlAffinity:
|
||||||
|
ListTileControlAffinity.leading,
|
||||||
|
side: const BorderSide(
|
||||||
|
color: Colors.black, width: 1.5),
|
||||||
|
fillColor:
|
||||||
|
MaterialStateProperty.resolveWith<Color>(
|
||||||
|
(states) {
|
||||||
|
if (states
|
||||||
|
.contains(MaterialState.selected)) {
|
||||||
|
return Colors.indigo; // selected color
|
||||||
|
}
|
||||||
|
return Colors
|
||||||
|
.white; // unselected background
|
||||||
|
}),
|
||||||
|
checkColor: Colors.white, // tick color
|
||||||
|
onChanged: (val) {
|
||||||
|
if (val == true) {
|
||||||
|
selectedValues.add(f.id);
|
||||||
|
} else {
|
||||||
|
selectedValues.remove(f.id);
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: MySpacing.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.shade100,
|
||||||
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyText(
|
||||||
|
displayText,
|
||||||
|
style: const TextStyle(color: Colors.black87),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(Icons.arrow_drop_down, color: Colors.grey),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _handleSubmit() {
|
void _handleSubmit() {
|
||||||
bool valid = formKey.currentState?.validate() ?? false;
|
bool valid = formKey.currentState?.validate() ?? false;
|
||||||
|
|
||||||
if (controller.selectedBucket.value.isEmpty) {
|
if (controller.selectedBuckets.isEmpty) {
|
||||||
bucketError.value = "Bucket is required";
|
bucketError.value = "Bucket is required";
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
@ -430,29 +553,14 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
_textField("Organization", orgCtrl, required: true),
|
_textField("Organization", orgCtrl, required: true),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
_labelWithStar("Bucket", required: true),
|
_labelWithStar("Buckets", required: true),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
_popupSelector(controller.selectedBucket, controller.buckets,
|
_bucketMultiSelectField(),
|
||||||
"Choose Bucket"),
|
|
||||||
Positioned(
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
top: 56,
|
|
||||||
child: Obx(() => bucketError.value.isEmpty
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
|
||||||
child: Text(bucketError.value,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.red, fontSize: 12)),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
MySpacing.height(24),
|
MySpacing.height(12),
|
||||||
Obx(() => GestureDetector(
|
Obx(() => GestureDetector(
|
||||||
onTap: () => showAdvanced.toggle(),
|
onTap: () => showAdvanced.toggle(),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -562,3 +670,9 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FilterItem {
|
||||||
|
final String id;
|
||||||
|
final String name;
|
||||||
|
FilterItem({required this.id, required this.name});
|
||||||
|
}
|
||||||
|
@ -5,7 +5,7 @@ import 'package:intl/intl.dart';
|
|||||||
|
|
||||||
import 'package:marco/controller/employee/add_employee_controller.dart';
|
import 'package:marco/controller/employee/add_employee_controller.dart';
|
||||||
import 'package:marco/controller/employee/employees_screen_controller.dart';
|
import 'package:marco/controller/employee/employees_screen_controller.dart';
|
||||||
import 'package:marco/controller/tenant/organization_selection_controller.dart';
|
import 'package:marco/controller/tenant/all_organization_controller.dart';
|
||||||
import 'package:marco/helpers/utils/base_bottom_sheet.dart';
|
import 'package:marco/helpers/utils/base_bottom_sheet.dart';
|
||||||
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
||||||
@ -24,8 +24,7 @@ class AddEmployeeBottomSheet extends StatefulWidget {
|
|||||||
class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
||||||
with UIMixin {
|
with UIMixin {
|
||||||
late final AddEmployeeController _controller;
|
late final AddEmployeeController _controller;
|
||||||
final OrganizationController _organizationController =
|
late final AllOrganizationController _organizationController;
|
||||||
Get.put(OrganizationController());
|
|
||||||
|
|
||||||
// Local UI state
|
// Local UI state
|
||||||
bool _hasApplicationAccess = false;
|
bool _hasApplicationAccess = false;
|
||||||
@ -39,52 +38,62 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
// Initialize text controllers
|
||||||
_orgFieldController = TextEditingController();
|
_orgFieldController = TextEditingController();
|
||||||
_joiningDateController = TextEditingController();
|
_joiningDateController = TextEditingController();
|
||||||
_genderController = TextEditingController();
|
_genderController = TextEditingController();
|
||||||
_roleController = TextEditingController();
|
_roleController = TextEditingController();
|
||||||
|
|
||||||
|
// Initialize AddEmployeeController
|
||||||
_controller = Get.put(AddEmployeeController(), tag: UniqueKey().toString());
|
_controller = Get.put(AddEmployeeController(), tag: UniqueKey().toString());
|
||||||
|
|
||||||
|
// Pass organization ID from employeeData if available
|
||||||
|
final orgIdFromEmployee =
|
||||||
|
widget.employeeData?['organization_id'] as String?;
|
||||||
|
_organizationController = Get.put(
|
||||||
|
AllOrganizationController(passedOrgId: orgIdFromEmployee),
|
||||||
|
tag: UniqueKey().toString(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Keep _orgFieldController in sync with selected organization safely
|
||||||
|
ever(_organizationController.selectedOrganization, (_) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_orgFieldController.text =
|
||||||
|
_organizationController.selectedOrganization.value?.name ??
|
||||||
|
'All Organizations';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prefill other fields if editing
|
||||||
if (widget.employeeData != null) {
|
if (widget.employeeData != null) {
|
||||||
_controller.editingEmployeeData = widget.employeeData;
|
_controller.editingEmployeeData = widget.employeeData;
|
||||||
_controller.prefillFields();
|
_controller.prefillFields();
|
||||||
|
|
||||||
|
// Application access
|
||||||
_hasApplicationAccess =
|
_hasApplicationAccess =
|
||||||
widget.employeeData?['hasApplicationAccess'] ?? false;
|
widget.employeeData?['hasApplicationAccess'] ?? false;
|
||||||
|
|
||||||
|
// Email
|
||||||
final email = widget.employeeData?['email'];
|
final email = widget.employeeData?['email'];
|
||||||
if (email != null && email.toString().isNotEmpty) {
|
if (email != null && email.toString().isNotEmpty) {
|
||||||
_controller.basicValidator.getController('email')?.text =
|
_controller.basicValidator.getController('email')?.text =
|
||||||
email.toString();
|
email.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
final orgId = widget.employeeData?['organization_id'];
|
// Joining date
|
||||||
if (orgId != null) {
|
|
||||||
final org = _organizationController.organizations
|
|
||||||
.firstWhereOrNull((o) => o.id == orgId);
|
|
||||||
if (org != null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_organizationController.selectOrganization(org);
|
|
||||||
_controller.selectedOrganizationId = org.id;
|
|
||||||
_orgFieldController.text = org.name;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Prefill Joining date
|
|
||||||
if (_controller.joiningDate != null) {
|
if (_controller.joiningDate != null) {
|
||||||
_joiningDateController.text =
|
_joiningDateController.text =
|
||||||
DateFormat('dd MMM yyyy').format(_controller.joiningDate!);
|
DateFormat('dd MMM yyyy').format(_controller.joiningDate!);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Prefill Gender
|
// Gender
|
||||||
if (_controller.selectedGender != null) {
|
if (_controller.selectedGender != null) {
|
||||||
_genderController.text =
|
_genderController.text =
|
||||||
_controller.selectedGender!.name.capitalizeFirst ?? '';
|
_controller.selectedGender!.name.capitalizeFirst ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Prefill Role
|
// Prefill Role
|
||||||
_controller.fetchRoles().then((_) {
|
_controller.fetchRoles().then((_) {
|
||||||
if (_controller.selectedRoleId != null) {
|
if (_controller.selectedRoleId != null) {
|
||||||
final roleName = _controller.roles.firstWhereOrNull(
|
final roleName = _controller.roles.firstWhereOrNull(
|
||||||
@ -97,6 +106,7 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// Not editing: fetch roles
|
||||||
_controller.fetchRoles();
|
_controller.fetchRoles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,27 +161,37 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
_sectionLabel('Organization'),
|
_sectionLabel('Organization'),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
GestureDetector(
|
Obx(() {
|
||||||
onTap: () => _showOrganizationPopup(context),
|
return GestureDetector(
|
||||||
child: AbsorbPointer(
|
onTap: () => _showOrganizationPopup(context),
|
||||||
child: TextFormField(
|
child: AbsorbPointer(
|
||||||
readOnly: true,
|
child: TextFormField(
|
||||||
controller: _orgFieldController,
|
readOnly: true,
|
||||||
validator: (val) {
|
controller: _orgFieldController,
|
||||||
if (val == null ||
|
validator: (val) {
|
||||||
val.trim().isEmpty ||
|
if (val == null ||
|
||||||
val == 'All Organizations') {
|
val.trim().isEmpty ||
|
||||||
return 'Organization is required';
|
val == 'All Organizations') {
|
||||||
}
|
return 'Organization is required';
|
||||||
return null;
|
}
|
||||||
},
|
return null;
|
||||||
decoration:
|
},
|
||||||
_inputDecoration('Select Organization').copyWith(
|
decoration:
|
||||||
suffixIcon: const Icon(Icons.expand_more),
|
_inputDecoration('Select Organization').copyWith(
|
||||||
|
suffixIcon: _organizationController
|
||||||
|
.isLoadingOrganizations.value
|
||||||
|
? const SizedBox(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
child:
|
||||||
|
CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.expand_more),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
_sectionLabel('Application Access'),
|
_sectionLabel('Application Access'),
|
||||||
Row(
|
Row(
|
||||||
@ -479,7 +499,7 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
context: context,
|
context: context,
|
||||||
initialDate: _controller.joiningDate ?? DateTime.now(),
|
initialDate: _controller.joiningDate ?? DateTime.now(),
|
||||||
firstDate: DateTime(2000),
|
firstDate: DateTime(2000),
|
||||||
lastDate: DateTime.now(),
|
lastDate: DateTime.now(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
@ -493,12 +513,13 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
final isValid =
|
final isValid =
|
||||||
_controller.basicValidator.formKey.currentState?.validate() ?? false;
|
_controller.basicValidator.formKey.currentState?.validate() ?? false;
|
||||||
|
|
||||||
|
final selectedOrg = _organizationController.selectedOrganization.value;
|
||||||
|
|
||||||
if (!isValid ||
|
if (!isValid ||
|
||||||
_controller.joiningDate == null ||
|
_controller.joiningDate == null ||
|
||||||
_controller.selectedGender == null ||
|
_controller.selectedGender == null ||
|
||||||
_controller.selectedRoleId == null ||
|
_controller.selectedRoleId == null ||
|
||||||
_organizationController.currentSelection.isEmpty ||
|
selectedOrg == null) {
|
||||||
_organizationController.currentSelection == 'All Organizations') {
|
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: 'Missing Fields',
|
title: 'Missing Fields',
|
||||||
message: 'Please complete all required fields.',
|
message: 'Please complete all required fields.',
|
||||||
@ -507,6 +528,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_controller.selectedOrganizationId = selectedOrg.id;
|
||||||
|
|
||||||
final result = await _controller.createOrUpdateEmployee(
|
final result = await _controller.createOrUpdateEmployee(
|
||||||
email: _controller.basicValidator.getController('email')?.text.trim(),
|
email: _controller.basicValidator.getController('email')?.text.trim(),
|
||||||
hasApplicationAccess: _hasApplicationAccess,
|
hasApplicationAccess: _hasApplicationAccess,
|
||||||
@ -539,7 +562,7 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final selected = await showMenu<String>(
|
final selectedOrgId = await showMenu<String>(
|
||||||
context: context,
|
context: context,
|
||||||
position: _popupMenuPosition(context),
|
position: _popupMenuPosition(context),
|
||||||
items: orgs
|
items: orgs
|
||||||
@ -552,12 +575,10 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (selected != null && selected.trim().isNotEmpty) {
|
if (selectedOrgId != null) {
|
||||||
final chosen = orgs.firstWhere((e) => e.id == selected);
|
final chosenOrg = orgs.firstWhere((org) => org.id == selectedOrgId,
|
||||||
_organizationController.selectOrganization(chosen);
|
orElse: () => orgs.first);
|
||||||
_controller.selectedOrganizationId = chosen.id;
|
_organizationController.selectOrganization(chosenOrg);
|
||||||
_orgFieldController.text = chosen.name;
|
|
||||||
_controller.update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import 'package:marco/view/directory/contact_detail_screen.dart';
|
|||||||
import 'package:marco/view/directory/manage_bucket_screen.dart';
|
import 'package:marco/view/directory/manage_bucket_screen.dart';
|
||||||
import 'package:marco/controller/permission_controller.dart';
|
import 'package:marco/controller/permission_controller.dart';
|
||||||
import 'package:marco/helpers/utils/permission_constants.dart';
|
import 'package:marco/helpers/utils/permission_constants.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_confirmation_dialog.dart';
|
||||||
|
|
||||||
class DirectoryView extends StatefulWidget {
|
class DirectoryView extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@ -89,7 +90,7 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(5),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -114,7 +115,7 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
backgroundColor: Colors.grey[300],
|
backgroundColor: Colors.grey[300],
|
||||||
foregroundColor: Colors.black,
|
foregroundColor: Colors.black,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(5),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
),
|
),
|
||||||
@ -129,7 +130,7 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
backgroundColor: Colors.indigo,
|
backgroundColor: Colors.indigo,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(5),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
),
|
),
|
||||||
@ -179,6 +180,7 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
// Search + Filter + More menu
|
||||||
Padding(
|
Padding(
|
||||||
padding: MySpacing.xy(8, 8),
|
padding: MySpacing.xy(8, 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -200,9 +202,8 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
suffixIcon: ValueListenableBuilder<TextEditingValue>(
|
suffixIcon: ValueListenableBuilder<TextEditingValue>(
|
||||||
valueListenable: searchController,
|
valueListenable: searchController,
|
||||||
builder: (context, value, _) {
|
builder: (context, value, _) {
|
||||||
if (value.text.isEmpty) {
|
if (value.text.isEmpty)
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: const Icon(Icons.clear,
|
icon: const Icon(Icons.clear,
|
||||||
size: 20, color: Colors.grey),
|
size: 20, color: Colors.grey),
|
||||||
@ -254,7 +255,7 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(
|
borderRadius: BorderRadius.vertical(
|
||||||
top: Radius.circular(20)),
|
top: Radius.circular(5)),
|
||||||
),
|
),
|
||||||
builder: (_) =>
|
builder: (_) =>
|
||||||
const DirectoryFilterBottomSheet(),
|
const DirectoryFilterBottomSheet(),
|
||||||
@ -292,8 +293,7 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
icon: const Icon(Icons.more_vert,
|
icon: const Icon(Icons.more_vert,
|
||||||
size: 20, color: Colors.black87),
|
size: 20, color: Colors.black87),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5)),
|
||||||
),
|
|
||||||
itemBuilder: (context) {
|
itemBuilder: (context) {
|
||||||
List<PopupMenuEntry<int>> menuItems = [];
|
List<PopupMenuEntry<int>> menuItems = [];
|
||||||
|
|
||||||
@ -302,17 +302,13 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
const PopupMenuItem<int>(
|
const PopupMenuItem<int>(
|
||||||
enabled: false,
|
enabled: false,
|
||||||
height: 30,
|
height: 30,
|
||||||
child: Text(
|
child: Text("Actions",
|
||||||
"Actions",
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontWeight: FontWeight.bold,
|
||||||
fontWeight: FontWeight.bold,
|
color: Colors.grey)),
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// ✅ Conditionally show Create Bucket option
|
|
||||||
if (permissionController
|
if (permissionController
|
||||||
.hasPermission(Permissions.directoryAdmin) ||
|
.hasPermission(Permissions.directoryAdmin) ||
|
||||||
permissionController
|
permissionController
|
||||||
@ -378,13 +374,10 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
const PopupMenuItem<int>(
|
const PopupMenuItem<int>(
|
||||||
enabled: false,
|
enabled: false,
|
||||||
height: 30,
|
height: 30,
|
||||||
child: Text(
|
child: Text("Preferences",
|
||||||
"Preferences",
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontWeight: FontWeight.bold,
|
||||||
fontWeight: FontWeight.bold,
|
color: Colors.grey)),
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -398,7 +391,8 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
const Icon(Icons.visibility_off_outlined,
|
const Icon(Icons.visibility_off_outlined,
|
||||||
size: 20, color: Colors.black87),
|
size: 20, color: Colors.black87),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
const Expanded(child: Text('Show Deleted Contacts')),
|
const Expanded(
|
||||||
|
child: Text('Show Deleted Contacts')),
|
||||||
Switch.adaptive(
|
Switch.adaptive(
|
||||||
value: !controller.isActive.value,
|
value: !controller.isActive.value,
|
||||||
activeColor: Colors.indigo,
|
activeColor: Colors.indigo,
|
||||||
@ -420,211 +414,347 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Contact List
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
return MyRefreshIndicator(
|
return MyRefreshIndicator(
|
||||||
onRefresh: _refreshDirectory,
|
onRefresh: _refreshDirectory,
|
||||||
backgroundColor: Colors.indigo,
|
backgroundColor: Colors.indigo,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: controller.isLoading.value
|
child: controller.isLoading.value
|
||||||
? ListView.separated(
|
? ListView.separated(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemCount: 10,
|
itemCount: 10,
|
||||||
separatorBuilder: (_, __) => MySpacing.height(12),
|
separatorBuilder: (_, __) => MySpacing.height(12),
|
||||||
itemBuilder: (_, __) =>
|
itemBuilder: (_, __) =>
|
||||||
SkeletonLoaders.contactSkeletonCard(),
|
SkeletonLoaders.contactSkeletonCard(),
|
||||||
)
|
)
|
||||||
: controller.filteredContacts.isEmpty
|
: controller.filteredContacts.isEmpty
|
||||||
? _buildEmptyState()
|
? _buildEmptyState()
|
||||||
: ListView.separated(
|
: ListView.separated(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
padding: MySpacing.only(
|
padding: MySpacing.only(
|
||||||
left: 8, right: 8, top: 4, bottom: 80),
|
left: 8, right: 8, top: 4, bottom: 80),
|
||||||
itemCount: controller.filteredContacts.length,
|
itemCount: controller.filteredContacts.length,
|
||||||
separatorBuilder: (_, __) => MySpacing.height(12),
|
separatorBuilder: (_, __) => MySpacing.height(12),
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
final contact =
|
final contact =
|
||||||
controller.filteredContacts[index];
|
controller.filteredContacts[index];
|
||||||
final nameParts = contact.name.trim().split(" ");
|
final isDeleted = !controller
|
||||||
final firstName = nameParts.first;
|
.isActive.value; // mark deleted contacts
|
||||||
final lastName =
|
final nameParts =
|
||||||
nameParts.length > 1 ? nameParts.last : "";
|
contact.name.trim().split(" ");
|
||||||
final tags =
|
final firstName = nameParts.first;
|
||||||
contact.tags.map((tag) => tag.name).toList();
|
final lastName =
|
||||||
|
nameParts.length > 1 ? nameParts.last : "";
|
||||||
|
final tags = contact.tags
|
||||||
|
.map((tag) => tag.name)
|
||||||
|
.toList();
|
||||||
|
|
||||||
return InkWell(
|
return Card(
|
||||||
onTap: () {
|
shape: RoundedRectangleBorder(
|
||||||
Get.to(() =>
|
borderRadius: BorderRadius.circular(5),
|
||||||
ContactDetailScreen(contact: contact));
|
),
|
||||||
},
|
elevation: 3,
|
||||||
child: Padding(
|
shadowColor: Colors.grey.withOpacity(0.3),
|
||||||
padding:
|
color: Colors.white,
|
||||||
const EdgeInsets.fromLTRB(12, 10, 12, 0),
|
child: InkWell(
|
||||||
child: Row(
|
borderRadius: BorderRadius.circular(5),
|
||||||
crossAxisAlignment:
|
onTap: isDeleted
|
||||||
CrossAxisAlignment.start,
|
? null
|
||||||
children: [
|
: () => Get.to(() =>
|
||||||
Avatar(
|
ContactDetailScreen(
|
||||||
firstName: firstName,
|
contact: contact)),
|
||||||
lastName: lastName,
|
child: Padding(
|
||||||
size: 35),
|
padding: const EdgeInsets.all(12),
|
||||||
MySpacing.width(12),
|
child: Row(
|
||||||
Expanded(
|
crossAxisAlignment:
|
||||||
child: Column(
|
CrossAxisAlignment.start,
|
||||||
crossAxisAlignment:
|
children: [
|
||||||
CrossAxisAlignment.start,
|
// Avatar
|
||||||
children: [
|
Avatar(
|
||||||
MyText.titleSmall(contact.name,
|
firstName: firstName,
|
||||||
fontWeight: 600,
|
lastName: lastName,
|
||||||
overflow:
|
size: 40,
|
||||||
TextOverflow.ellipsis),
|
backgroundColor: isDeleted
|
||||||
MyText.bodySmall(
|
? Colors.grey.shade400
|
||||||
contact.organization,
|
: null,
|
||||||
color: Colors.grey[700],
|
),
|
||||||
overflow:
|
MySpacing.width(12),
|
||||||
TextOverflow.ellipsis),
|
// Contact Info
|
||||||
MySpacing.height(8),
|
Expanded(
|
||||||
if (contact
|
child: Column(
|
||||||
.contactEmails.isNotEmpty)
|
crossAxisAlignment:
|
||||||
GestureDetector(
|
CrossAxisAlignment.start,
|
||||||
onTap: () =>
|
children: [
|
||||||
LauncherUtils.launchEmail(
|
MyText.titleSmall(
|
||||||
contact
|
contact.name,
|
||||||
.contactEmails
|
fontWeight: 600,
|
||||||
.first
|
overflow:
|
||||||
.emailAddress),
|
TextOverflow.ellipsis,
|
||||||
onLongPress: () => LauncherUtils
|
color: isDeleted
|
||||||
.copyToClipboard(
|
? Colors.grey
|
||||||
contact.contactEmails.first
|
: Colors.black87,
|
||||||
.emailAddress,
|
|
||||||
typeLabel: 'Email',
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
MyText.bodySmall(
|
||||||
padding:
|
contact.organization,
|
||||||
const EdgeInsets.only(
|
color: isDeleted
|
||||||
bottom: 4),
|
? Colors.grey
|
||||||
child: Row(
|
: Colors.grey[700],
|
||||||
children: [
|
overflow:
|
||||||
const Icon(
|
TextOverflow.ellipsis,
|
||||||
Icons.email_outlined,
|
|
||||||
size: 16,
|
|
||||||
color: Colors.indigo),
|
|
||||||
MySpacing.width(4),
|
|
||||||
Expanded(
|
|
||||||
child:
|
|
||||||
MyText.labelSmall(
|
|
||||||
contact
|
|
||||||
.contactEmails
|
|
||||||
.first
|
|
||||||
.emailAddress,
|
|
||||||
overflow: TextOverflow
|
|
||||||
.ellipsis,
|
|
||||||
color: Colors.indigo,
|
|
||||||
decoration:
|
|
||||||
TextDecoration
|
|
||||||
.underline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
MySpacing.height(6),
|
||||||
if (contact
|
if (contact
|
||||||
.contactPhones.isNotEmpty)
|
.contactEmails.isNotEmpty)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding:
|
||||||
bottom: 8, top: 4),
|
const EdgeInsets.only(
|
||||||
child: Row(
|
bottom: 4),
|
||||||
children: [
|
child: GestureDetector(
|
||||||
Expanded(
|
onTap: isDeleted
|
||||||
child: GestureDetector(
|
? null
|
||||||
onTap: () => LauncherUtils
|
: () => LauncherUtils
|
||||||
.launchPhone(contact
|
.launchEmail(contact
|
||||||
.contactPhones
|
.contactEmails
|
||||||
.first
|
.first
|
||||||
.phoneNumber),
|
.emailAddress),
|
||||||
onLongPress: () =>
|
onLongPress: isDeleted
|
||||||
LauncherUtils
|
? null
|
||||||
.copyToClipboard(
|
: () => LauncherUtils
|
||||||
contact
|
.copyToClipboard(
|
||||||
.contactPhones
|
|
||||||
.first
|
|
||||||
.phoneNumber,
|
|
||||||
typeLabel: 'Phone',
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(
|
|
||||||
Icons
|
|
||||||
.phone_outlined,
|
|
||||||
size: 16,
|
|
||||||
color: Colors
|
|
||||||
.indigo),
|
|
||||||
MySpacing.width(4),
|
|
||||||
Expanded(
|
|
||||||
child: MyText
|
|
||||||
.labelSmall(
|
|
||||||
contact
|
contact
|
||||||
.contactPhones
|
.contactEmails
|
||||||
.first
|
.first
|
||||||
.phoneNumber,
|
.emailAddress,
|
||||||
overflow:
|
typeLabel:
|
||||||
TextOverflow
|
'Email',
|
||||||
.ellipsis,
|
),
|
||||||
color: Colors
|
child: Row(
|
||||||
.indigo,
|
children: [
|
||||||
decoration:
|
Icon(
|
||||||
TextDecoration
|
Icons
|
||||||
.underline,
|
.email_outlined,
|
||||||
|
size: 16,
|
||||||
|
color: isDeleted
|
||||||
|
? Colors.grey
|
||||||
|
: Colors
|
||||||
|
.indigo),
|
||||||
|
MySpacing.width(4),
|
||||||
|
Expanded(
|
||||||
|
child: MyText
|
||||||
|
.labelSmall(
|
||||||
|
contact
|
||||||
|
.contactEmails
|
||||||
|
.first
|
||||||
|
.emailAddress,
|
||||||
|
overflow:
|
||||||
|
TextOverflow
|
||||||
|
.ellipsis,
|
||||||
|
color: isDeleted
|
||||||
|
? Colors.grey
|
||||||
|
: Colors
|
||||||
|
.indigo,
|
||||||
|
decoration:
|
||||||
|
TextDecoration
|
||||||
|
.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (contact
|
||||||
|
.contactPhones.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(
|
||||||
|
bottom: 8, top: 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child:
|
||||||
|
GestureDetector(
|
||||||
|
onTap: isDeleted
|
||||||
|
? null
|
||||||
|
: () => LauncherUtils
|
||||||
|
.launchPhone(contact
|
||||||
|
.contactPhones
|
||||||
|
.first
|
||||||
|
.phoneNumber),
|
||||||
|
onLongPress:
|
||||||
|
isDeleted
|
||||||
|
? null
|
||||||
|
: () =>
|
||||||
|
LauncherUtils
|
||||||
|
.copyToClipboard(
|
||||||
|
contact
|
||||||
|
.contactPhones
|
||||||
|
.first
|
||||||
|
.phoneNumber,
|
||||||
|
typeLabel:
|
||||||
|
'Phone',
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons
|
||||||
|
.phone_outlined,
|
||||||
|
size: 16,
|
||||||
|
color: isDeleted
|
||||||
|
? Colors
|
||||||
|
.grey
|
||||||
|
: Colors
|
||||||
|
.indigo),
|
||||||
|
MySpacing.width(
|
||||||
|
4),
|
||||||
|
Expanded(
|
||||||
|
child: MyText
|
||||||
|
.labelSmall(
|
||||||
|
contact
|
||||||
|
.contactPhones
|
||||||
|
.first
|
||||||
|
.phoneNumber,
|
||||||
|
overflow:
|
||||||
|
TextOverflow
|
||||||
|
.ellipsis,
|
||||||
|
color: isDeleted
|
||||||
|
? Colors
|
||||||
|
.grey
|
||||||
|
: Colors
|
||||||
|
.indigo,
|
||||||
|
decoration:
|
||||||
|
TextDecoration
|
||||||
|
.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.width(8),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: isDeleted
|
||||||
|
? null
|
||||||
|
: () => LauncherUtils
|
||||||
|
.launchWhatsApp(contact
|
||||||
|
.contactPhones
|
||||||
|
.first
|
||||||
|
.phoneNumber),
|
||||||
|
child: FaIcon(
|
||||||
|
FontAwesomeIcons
|
||||||
|
.whatsapp,
|
||||||
|
color: isDeleted
|
||||||
|
? Colors.grey
|
||||||
|
: Colors
|
||||||
|
.green,
|
||||||
|
size: 25),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (tags.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(
|
||||||
|
top: 0),
|
||||||
|
child: Wrap(
|
||||||
|
spacing: 6,
|
||||||
|
runSpacing: 2,
|
||||||
|
children: tags
|
||||||
|
.map(
|
||||||
|
(tag) => Chip(
|
||||||
|
label: Text(tag),
|
||||||
|
backgroundColor:
|
||||||
|
Colors.indigo
|
||||||
|
.shade50,
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: isDeleted
|
||||||
|
? Colors
|
||||||
|
.grey
|
||||||
|
: Colors
|
||||||
|
.indigo,
|
||||||
|
fontSize: 12),
|
||||||
|
visualDensity:
|
||||||
|
VisualDensity
|
||||||
|
.compact,
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius
|
||||||
|
.circular(
|
||||||
|
5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
)
|
||||||
),
|
.toList(),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
MySpacing.width(8),
|
),
|
||||||
GestureDetector(
|
],
|
||||||
onTap: () => LauncherUtils
|
),
|
||||||
.launchWhatsApp(
|
),
|
||||||
contact
|
// Actions Column (Arrow + Icons)
|
||||||
.contactPhones
|
Column(
|
||||||
.first
|
children: [
|
||||||
.phoneNumber),
|
IconButton(
|
||||||
child: const FaIcon(
|
icon: Icon(
|
||||||
FontAwesomeIcons
|
isDeleted
|
||||||
.whatsapp,
|
? Icons.restore
|
||||||
color: Colors.green,
|
: Icons.delete,
|
||||||
size: 25,
|
color: isDeleted
|
||||||
),
|
? Colors.green
|
||||||
),
|
: Colors.redAccent,
|
||||||
],
|
size: 20,
|
||||||
),
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
await Get.dialog(
|
||||||
|
ConfirmDialog(
|
||||||
|
title: isDeleted
|
||||||
|
? "Restore Contact"
|
||||||
|
: "Delete Contact",
|
||||||
|
message: isDeleted
|
||||||
|
? "Are you sure you want to restore this contact?"
|
||||||
|
: "Are you sure you want to delete this contact?",
|
||||||
|
confirmText: isDeleted
|
||||||
|
? "Restore"
|
||||||
|
: "Delete",
|
||||||
|
confirmColor: isDeleted
|
||||||
|
? Colors.green
|
||||||
|
: Colors.redAccent,
|
||||||
|
icon: isDeleted
|
||||||
|
? Icons.restore
|
||||||
|
: Icons
|
||||||
|
.delete_forever,
|
||||||
|
onConfirm: () async {
|
||||||
|
if (isDeleted) {
|
||||||
|
await controller
|
||||||
|
.restoreContact(
|
||||||
|
contact.id);
|
||||||
|
} else {
|
||||||
|
await controller
|
||||||
|
.deleteContact(
|
||||||
|
contact.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
if (tags.isNotEmpty) ...[
|
const SizedBox(height: 4),
|
||||||
MySpacing.height(2),
|
Icon(
|
||||||
MyText.labelSmall(tags.join(', '),
|
Icons.arrow_forward_ios,
|
||||||
color: Colors.grey[500],
|
color: Colors.grey,
|
||||||
maxLines: 1,
|
size: 20,
|
||||||
overflow:
|
)
|
||||||
TextOverflow.ellipsis),
|
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.arrow_forward_ios,
|
|
||||||
color: Colors.grey, size: 16),
|
|
||||||
MySpacing.height(8),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
}));
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -3,8 +3,8 @@ import 'package:get/get.dart';
|
|||||||
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
||||||
import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart';
|
import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart';
|
||||||
import 'package:flutter_html/flutter_html.dart' as html;
|
import 'package:flutter_html/flutter_html.dart' as html;
|
||||||
import 'package:marco/helpers/widgets/my_refresh_indicator.dart';
|
|
||||||
|
|
||||||
|
import 'package:marco/helpers/widgets/my_refresh_indicator.dart';
|
||||||
import 'package:marco/controller/directory/notes_controller.dart';
|
import 'package:marco/controller/directory/notes_controller.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
import 'package:marco/helpers/widgets/my_text.dart';
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
@ -68,7 +68,6 @@ class NotesView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inList) buffer.write('</ul>');
|
if (inList) buffer.write('</ul>');
|
||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +97,7 @@ class NotesView extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
/// 🔍 Search + Refresh (Top Row)
|
/// 🔍 Search Field
|
||||||
Padding(
|
Padding(
|
||||||
padding: MySpacing.xy(8, 8),
|
padding: MySpacing.xy(8, 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -132,7 +131,7 @@ class NotesView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
/// 📄 Notes List View
|
/// 📄 Notes List
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
if (controller.isLoading.value) {
|
if (controller.isLoading.value) {
|
||||||
@ -151,9 +150,7 @@ class NotesView extends StatelessWidget {
|
|||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints:
|
constraints:
|
||||||
BoxConstraints(minHeight: constraints.maxHeight),
|
BoxConstraints(minHeight: constraints.maxHeight),
|
||||||
child: Center(
|
child: Center(child: _buildEmptyState()),
|
||||||
child: _buildEmptyState(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -204,56 +201,166 @@ class NotesView extends StatelessWidget {
|
|||||||
duration: const Duration(milliseconds: 250),
|
duration: const Duration(milliseconds: 250),
|
||||||
padding: MySpacing.xy(12, 12),
|
padding: MySpacing.xy(12, 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isEditing ? Colors.indigo[50] : Colors.white,
|
color: isEditing
|
||||||
|
? Colors.indigo[50]
|
||||||
|
: note.isActive
|
||||||
|
? Colors.white
|
||||||
|
: Colors.grey.shade100,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color:
|
color: note.isActive
|
||||||
isEditing ? Colors.indigo : Colors.grey.shade300,
|
? (isEditing
|
||||||
|
? Colors.indigo
|
||||||
|
: Colors.grey.shade300)
|
||||||
|
: Colors.grey.shade400,
|
||||||
width: 1.1,
|
width: 1.1,
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
boxShadow: const [
|
boxShadow: const [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black12,
|
color: Colors.black12,
|
||||||
blurRadius: 4,
|
blurRadius: 4,
|
||||||
offset: Offset(0, 2)),
|
offset: Offset(0, 2),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
/// Header Row
|
// Header & Note content (fade them if inactive)
|
||||||
Row(
|
AnimatedOpacity(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
duration: const Duration(milliseconds: 200),
|
||||||
children: [
|
opacity: note.isActive ? 1.0 : 0.6,
|
||||||
Avatar(
|
child: IgnorePointer(
|
||||||
firstName: initials, lastName: '', size: 40),
|
ignoring: !note.isActive,
|
||||||
MySpacing.width(12),
|
child: Column(
|
||||||
Expanded(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Row(
|
||||||
children: [
|
crossAxisAlignment:
|
||||||
MyText.titleSmall(
|
CrossAxisAlignment.start,
|
||||||
"${note.contactName} (${note.organizationName})",
|
children: [
|
||||||
fontWeight: 600,
|
Avatar(
|
||||||
overflow: TextOverflow.ellipsis,
|
firstName: initials,
|
||||||
color: Colors.indigo[800],
|
lastName: '',
|
||||||
|
size: 40,
|
||||||
|
backgroundColor: note.isActive
|
||||||
|
? null
|
||||||
|
: Colors.grey.shade400,
|
||||||
|
),
|
||||||
|
MySpacing.width(12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
MyText.titleSmall(
|
||||||
|
"${note.contactName} (${note.organizationName})",
|
||||||
|
fontWeight: 600,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: note.isActive
|
||||||
|
? Colors.indigo[800]
|
||||||
|
: Colors.grey,
|
||||||
|
),
|
||||||
|
MyText.bodySmall(
|
||||||
|
"by ${note.createdBy.firstName} • $createdDate, $createdTime",
|
||||||
|
color: note.isActive
|
||||||
|
? Colors.grey[600]
|
||||||
|
: Colors.grey,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
MySpacing.height(12),
|
||||||
|
if (isEditing && quillController != null)
|
||||||
|
CommentEditorCard(
|
||||||
|
controller: quillController,
|
||||||
|
onCancel: () =>
|
||||||
|
controller.editingNoteId.value = null,
|
||||||
|
onSave: (quillCtrl) async {
|
||||||
|
final delta =
|
||||||
|
quillCtrl.document.toDelta();
|
||||||
|
final htmlOutput =
|
||||||
|
_convertDeltaToHtml(delta);
|
||||||
|
final updated =
|
||||||
|
note.copyWith(note: htmlOutput);
|
||||||
|
await controller.updateNote(updated);
|
||||||
|
controller.editingNoteId.value = null;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
html.Html(
|
||||||
|
data: note.note,
|
||||||
|
style: {
|
||||||
|
"body": html.Style(
|
||||||
|
margin: html.Margins.zero,
|
||||||
|
padding: html.HtmlPaddings.zero,
|
||||||
|
fontSize: html.FontSize.medium,
|
||||||
|
color: note.isActive
|
||||||
|
? Colors.black87
|
||||||
|
: Colors.grey,
|
||||||
|
),
|
||||||
|
},
|
||||||
),
|
),
|
||||||
MyText.bodySmall(
|
],
|
||||||
"by ${note.createdBy.firstName} • $createdDate, $createdTime",
|
|
||||||
color: Colors.grey[600],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// Edit / Delete / Restore Icons
|
// Action buttons (always fully visible)
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
if (note.isActive) ...[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
isEditing ? Icons.close : Icons.edit,
|
||||||
|
color: Colors.indigo,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.all(2),
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
controller.editingNoteId.value =
|
||||||
|
isEditing ? null : note.id;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () async {
|
||||||
|
await Get.dialog(
|
||||||
|
ConfirmDialog(
|
||||||
|
title: "Delete Note",
|
||||||
|
message:
|
||||||
|
"Are you sure you want to delete this note?",
|
||||||
|
confirmText: "Delete",
|
||||||
|
confirmColor: Colors.redAccent,
|
||||||
|
icon: Icons.delete_forever,
|
||||||
|
onConfirm: () async {
|
||||||
|
await controller.restoreOrDeleteNote(
|
||||||
|
note,
|
||||||
|
restore: false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
if (!note.isActive)
|
if (!note.isActive)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.restore,
|
icon: const Icon(
|
||||||
color: Colors.green, size: 20),
|
Icons.restore,
|
||||||
|
color: Colors.green,
|
||||||
|
size: 22,
|
||||||
|
),
|
||||||
tooltip: "Restore",
|
tooltip: "Restore",
|
||||||
padding: EdgeInsets
|
|
||||||
.zero,
|
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await Get.dialog(
|
await Get.dialog(
|
||||||
ConfirmDialog(
|
ConfirmDialog(
|
||||||
@ -272,87 +379,9 @@ class NotesView extends StatelessWidget {
|
|||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
|
||||||
else
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
/// Edit Icon
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
isEditing ? Icons.close : Icons.edit,
|
|
||||||
color: Colors.indigo,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets
|
|
||||||
.zero,
|
|
||||||
constraints:
|
|
||||||
const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
controller.editingNoteId.value =
|
|
||||||
isEditing ? null : note.id;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 6),
|
|
||||||
/// Delete Icon
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.delete_outline,
|
|
||||||
color: Colors.redAccent, size: 20),
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () async {
|
|
||||||
await Get.dialog(
|
|
||||||
ConfirmDialog(
|
|
||||||
title: "Delete Note",
|
|
||||||
message:
|
|
||||||
"Are you sure you want to delete this note?",
|
|
||||||
confirmText: "Delete",
|
|
||||||
confirmColor: Colors.redAccent,
|
|
||||||
icon: Icons.delete_forever,
|
|
||||||
onConfirm: () async {
|
|
||||||
await controller
|
|
||||||
.restoreOrDeleteNote(note,
|
|
||||||
restore: false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
barrierDismissible: false,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(12),
|
|
||||||
|
|
||||||
/// Content
|
|
||||||
if (isEditing && quillController != null)
|
|
||||||
CommentEditorCard(
|
|
||||||
controller: quillController,
|
|
||||||
onCancel: () =>
|
|
||||||
controller.editingNoteId.value = null,
|
|
||||||
onSave: (quillCtrl) async {
|
|
||||||
final delta = quillCtrl.document.toDelta();
|
|
||||||
final htmlOutput = _convertDeltaToHtml(delta);
|
|
||||||
final updated = note.copyWith(note: htmlOutput);
|
|
||||||
await controller.updateNote(updated);
|
|
||||||
controller.editingNoteId.value = null;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
else
|
|
||||||
html.Html(
|
|
||||||
data: note.note,
|
|
||||||
style: {
|
|
||||||
"body": html.Style(
|
|
||||||
margin: html.Margins.zero,
|
|
||||||
padding: html.HtmlPaddings.zero,
|
|
||||||
fontSize: html.FontSize.medium,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -40,9 +40,10 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
final projectId = projectController.selectedProjectId.value;
|
final projectId = projectController.selectedProjectId.value;
|
||||||
if (projectId.isNotEmpty) {
|
if (projectId.isNotEmpty) {
|
||||||
dailyTaskPlanningController.fetchTaskData(projectId);
|
dailyTaskPlanningController.fetchTaskData(projectId);
|
||||||
serviceController.fetchServices(projectId); // <-- Fetch services here
|
serviceController.fetchServices(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Whenever project changes, fetch tasks & services
|
||||||
ever<String>(
|
ever<String>(
|
||||||
projectController.selectedProjectId,
|
projectController.selectedProjectId,
|
||||||
(newProjectId) {
|
(newProjectId) {
|
||||||
@ -122,18 +123,19 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
final projectId = projectController.selectedProjectId.value;
|
final projectId = projectController.selectedProjectId.value;
|
||||||
if (projectId.isNotEmpty) {
|
if (projectId.isNotEmpty) {
|
||||||
try {
|
try {
|
||||||
await dailyTaskPlanningController.fetchTaskData(projectId);
|
await dailyTaskPlanningController.fetchTaskData(
|
||||||
|
projectId,
|
||||||
|
serviceId: serviceController.selectedService?.id,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Error refreshing task data: ${e.toString()}');
|
debugPrint('Error refreshing task data: ${e.toString()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
physics:
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
const AlwaysScrollableScrollPhysics(), // <-- always allow drag
|
|
||||||
padding: MySpacing.x(0),
|
padding: MySpacing.x(0),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
// <-- ensures full screen height
|
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
minHeight: MediaQuery.of(context).size.height -
|
minHeight: MediaQuery.of(context).size.height -
|
||||||
kToolbarHeight -
|
kToolbarHeight -
|
||||||
@ -158,8 +160,8 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
if (projectId.isNotEmpty) {
|
if (projectId.isNotEmpty) {
|
||||||
await dailyTaskPlanningController.fetchTaskData(
|
await dailyTaskPlanningController.fetchTaskData(
|
||||||
projectId,
|
projectId,
|
||||||
// serviceId: service
|
serviceId:
|
||||||
// ?.id,
|
service?.id, // <-- pass selected service
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -287,7 +289,6 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
final validWorkAreas = floor.workAreas
|
final validWorkAreas = floor.workAreas
|
||||||
.where((area) => area.workItems.isNotEmpty);
|
.where((area) => area.workItems.isNotEmpty);
|
||||||
|
|
||||||
// For each valid work area, return a Floor+WorkArea ExpansionTile
|
|
||||||
return validWorkAreas.map((area) {
|
return validWorkAreas.map((area) {
|
||||||
final floorWorkAreaKey =
|
final floorWorkAreaKey =
|
||||||
"${buildingKey}_${floor.floorName}_${area.areaName}";
|
"${buildingKey}_${floor.floorName}_${area.areaName}";
|
||||||
@ -301,6 +302,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
final totalProgress = totalPlanned == 0
|
final totalProgress = totalPlanned == 0
|
||||||
? 0.0
|
? 0.0
|
||||||
: (totalCompleted / totalPlanned).clamp(0.0, 1.0);
|
: (totalCompleted / totalPlanned).clamp(0.0, 1.0);
|
||||||
|
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
onExpansionChanged: (expanded) {
|
onExpansionChanged: (expanded) {
|
||||||
setMainState(() {
|
setMainState(() {
|
||||||
@ -352,7 +354,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
percent: totalProgress,
|
percent: totalProgress,
|
||||||
center: Text(
|
center: Text(
|
||||||
"${(totalProgress * 100).toStringAsFixed(0)}%",
|
"${(totalProgress * 100).toStringAsFixed(0)}%",
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 10.0,
|
fontSize: 10.0,
|
||||||
),
|
),
|
||||||
@ -438,7 +440,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
permissionController.hasPermission(
|
permissionController.hasPermission(
|
||||||
Permissions.assignReportTask))
|
Permissions.assignReportTask))
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: const Icon(
|
||||||
Icons.person_add_alt_1_rounded,
|
Icons.person_add_alt_1_rounded,
|
||||||
color:
|
color:
|
||||||
Color.fromARGB(255, 46, 161, 233),
|
Color.fromARGB(255, 46, 161, 233),
|
||||||
@ -502,7 +504,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
MyText.bodySmall(
|
MyText.bodySmall(
|
||||||
"${(progress * 100).toStringAsFixed(1)}%",
|
"${(progress * 100).toStringAsFixed(1)}%",
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user