mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
refactor(task-modal): enhance employee timeblock management with custom filtering and improved rendering logic
This commit is contained in:
1 parent
7daf559f1c
commit
8e9e586276
5 files changed
+858
-269
No files matched your search
@@ -102,7 +102,7 @@
|
||||
:timeblocks="getEmployeeTimeblocks(subtask.employee_id)"
|
||||
:all-timeblocks="timeblocks"
|
||||
:deleted-timeblock-ids="deletedTimeblockIds"
|
||||
:custom-filter="customFilter"
|
||||
:custom-filter="getEmployeeCustomFilter(subtask.employee_id)"
|
||||
@update:timeblocks="
|
||||
updateEmployeeTimeblocks($event, subtask.employee_id)
|
||||
"
|
||||
@@ -122,7 +122,7 @@
|
||||
:timeblocks="getEmployeeTimeblocks(employee.id)"
|
||||
:all-timeblocks="timeblocks"
|
||||
:deleted-timeblock-ids="deletedTimeblockIds"
|
||||
:custom-filter="customFilter"
|
||||
:custom-filter="getEmployeeCustomFilter(employee.id)"
|
||||
:required="index === 0"
|
||||
@update:timeblocks="updateEmployeeTimeblocks($event, employee.id)"
|
||||
@clear-employee="() => removeEmployeeAtIndex(index)"
|
||||
@@ -564,6 +564,45 @@ export default {
|
||||
return this.timeblocks.filter((tb) => tb.employee_id == employeeId);
|
||||
},
|
||||
|
||||
// Custom filter for employee select to prevent selecting the same employee twice
|
||||
// currentEmployeeId: the ID of the employee currently selected in this dropdown (can be null)
|
||||
getEmployeeCustomFilter(currentEmployeeId) {
|
||||
return (itemText, queryText, item) => {
|
||||
// Get all selected employee IDs except the current one
|
||||
const selectedEmployeeIds = new Set();
|
||||
|
||||
if (this.isDraftWithMultipleEmployees && this.subtask?.employees) {
|
||||
// In multi-employee mode, collect all selected employee IDs except current
|
||||
this.subtask.employees.forEach((emp) => {
|
||||
if (emp.id && emp.id !== currentEmployeeId) {
|
||||
selectedEmployeeIds.add(emp.id);
|
||||
}
|
||||
});
|
||||
} else if (
|
||||
this.subtask?.employee_id &&
|
||||
this.subtask.employee_id !== currentEmployeeId
|
||||
) {
|
||||
// In single employee edit mode
|
||||
selectedEmployeeIds.add(this.subtask.employee_id);
|
||||
}
|
||||
|
||||
// Filter out already selected employees (but allow current selection)
|
||||
if (selectedEmployeeIds.has(item.id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apply default text filtering (from AutocompleteMixin)
|
||||
if (this.customFilter) {
|
||||
return this.customFilter(itemText, queryText, item);
|
||||
}
|
||||
|
||||
// Default case-insensitive text match
|
||||
const searchText = queryText.toString().toLowerCase();
|
||||
const text = itemText.toString().toLowerCase();
|
||||
return text.indexOf(searchText) > -1;
|
||||
};
|
||||
},
|
||||
|
||||
updateEmployeeTimeblocks(updatedTimeblocks, employeeId) {
|
||||
// Track deleted timeblocks (saved timeblocks that are no longer in the updated list)
|
||||
const updatedIds = new Set(
|
||||
|
||||
Reference in new issue
Block a user