fix with reflection of tags and assignees in details screen after creating job
This commit is contained in:
parent
d453ec40fc
commit
c6fbee7083
@ -62,27 +62,39 @@ class AddServiceProjectJobController extends GetxController {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final assigneeIds = selectedAssignees.map((e) => e.id).toList();
|
|
||||||
|
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
|
||||||
final success = await ApiService.createServiceProjectJobApi(
|
final jobId = await ApiService.createServiceProjectJobApi(
|
||||||
title: titleCtrl.text.trim(),
|
title: titleCtrl.text.trim(),
|
||||||
description: descCtrl.text.trim(),
|
description: descCtrl.text.trim(),
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
branchId: selectedBranch.value?.id,
|
branchId: selectedBranch.value?.id,
|
||||||
assignees: assigneeIds.map((id) => {"id": id}).toList(),
|
assignees: selectedAssignees // payload mapping
|
||||||
|
.map((e) => {"employeeId": e.id, "isActive": true})
|
||||||
|
.toList(),
|
||||||
startDate: startDate.value!,
|
startDate: startDate.value!,
|
||||||
dueDate: dueDate.value!,
|
dueDate: dueDate.value!,
|
||||||
tags: enteredTags.map((tag) => {"name": tag}).toList(),
|
tags: enteredTags
|
||||||
|
.map((tag) => {
|
||||||
|
"id": null,
|
||||||
|
"name": tag,
|
||||||
|
"isActive": true
|
||||||
|
})
|
||||||
|
.toList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
|
||||||
if (success) {
|
if (jobId != null) {
|
||||||
if (Get.isRegistered<ServiceProjectDetailsController>()) {
|
if (Get.isRegistered<ServiceProjectDetailsController>()) {
|
||||||
Get.find<ServiceProjectDetailsController>().refreshJobsAfterAdd();
|
final detailsCtrl = Get.find<ServiceProjectDetailsController>();
|
||||||
|
|
||||||
|
// 🔥 1. Refresh job LIST
|
||||||
|
detailsCtrl.refreshJobsAfterAdd();
|
||||||
|
|
||||||
|
// 🔥 2. Refresh job DETAILS (FULL DATA - including tags and assignees)
|
||||||
|
await detailsCtrl.fetchJobDetail(jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Get.back();
|
Get.back();
|
||||||
|
|||||||
@ -595,8 +595,7 @@ class ApiService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Service Project Job
|
static Future<String?> createServiceProjectJobApi({
|
||||||
static Future<bool> createServiceProjectJobApi({
|
|
||||||
required String title,
|
required String title,
|
||||||
required String description,
|
required String description,
|
||||||
required String projectId,
|
required String projectId,
|
||||||
@ -623,32 +622,22 @@ class ApiService {
|
|||||||
try {
|
try {
|
||||||
final response = await _postRequest(endpoint, body);
|
final response = await _postRequest(endpoint, body);
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) return null;
|
||||||
logSafe("Create Service Project Job failed: null response",
|
|
||||||
level: LogLevel.error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
logSafe(
|
|
||||||
"Create Service Project Job response status: ${response.statusCode}");
|
|
||||||
logSafe("Create Service Project Job response body: ${response.body}");
|
|
||||||
|
|
||||||
final json = jsonDecode(response.body);
|
final json = jsonDecode(response.body);
|
||||||
|
|
||||||
if (json['success'] == true) {
|
if (json['success'] == true) {
|
||||||
logSafe("Service Project Job created successfully: ${json['data']}");
|
final jobId = json['data']?['id'];
|
||||||
return true;
|
logSafe("Service Project Job created successfully: $jobId");
|
||||||
} else {
|
return jobId;
|
||||||
logSafe(
|
|
||||||
"Failed to create Service Project Job: ${json['message'] ?? 'Unknown error'}",
|
|
||||||
level: LogLevel.warning,
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
logSafe("Exception during createServiceProjectJobApi: $e",
|
logSafe("Exception during createServiceProjectJobApi: $e",
|
||||||
level: LogLevel.error);
|
level: LogLevel.error);
|
||||||
logSafe("StackTrace: $stack", level: LogLevel.debug);
|
logSafe("StackTrace: $stack", level: LogLevel.debug);
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,8 +660,7 @@ class ApiService {
|
|||||||
'pageNumber': pageNumber.toString(),
|
'pageNumber': pageNumber.toString(),
|
||||||
'pageSize': pageSize.toString(),
|
'pageSize': pageSize.toString(),
|
||||||
'isActive': isActive.toString(),
|
'isActive': isActive.toString(),
|
||||||
if (isArchive)
|
if (isArchive) 'isArchive': 'true',
|
||||||
'isArchive': 'true',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
final response = await _getRequest(endpoint, queryParams: queryParams);
|
final response = await _getRequest(endpoint, queryParams: queryParams);
|
||||||
|
|||||||
@ -248,6 +248,44 @@ class _UserProfileBarState extends State<UserProfileBar>
|
|||||||
final tenants = tenantSwitchController.tenants;
|
final tenants = tenantSwitchController.tenants;
|
||||||
if (tenants.isEmpty) return _noTenantContainer();
|
if (tenants.isEmpty) return _noTenantContainer();
|
||||||
|
|
||||||
|
// If only one organization, don't show switch option
|
||||||
|
if (tenants.length == 1) {
|
||||||
|
final selectedTenant = tenants.first;
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.shade100,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: Colors.grey.shade300, width: 1),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Container(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
color: Colors.grey.shade200,
|
||||||
|
child: TenantLogo(logoImage: selectedTenant.logoImage),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
selectedTenant.name,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: contentTheme.primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(Icons.check_circle, color: Colors.green, size: 18),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final selectedTenant = TenantService.currentTenant;
|
final selectedTenant = TenantService.currentTenant;
|
||||||
|
|
||||||
final sortedTenants = List.of(tenants);
|
final sortedTenants = List.of(tenants);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user