Kanban: Fix live updates for card assignee changes - reload board on assignee update to ensure proper data sync

This commit is contained in:
DGSoft 2025-12-14 21:48:42 +01:00
parent 7d8e839dbe
commit 37a351163b
2 changed files with 28 additions and 15 deletions

View File

@ -193,21 +193,33 @@ const KanbanBoard: React.FC = () => {
try {
await kanbanAPI.updateCard(cardId, updates);
// For assignee changes, reload the board to get fresh data
if (updates.assignee_id !== undefined) {
loadBoard();
return;
}
// Update the card in the local state for other changes
setBoard(prev => prev ? {
...prev,
columns: prev.columns.map(col => ({
...col,
cards: col.cards.map(card =>
card.id === cardId ? { ...card, ...updates } : card
)
}))
} : null);
// Update selectedCard if it's the one being updated
if (selectedCard && selectedCard.id === cardId) {
setSelectedCard(prev => prev ? { ...prev, ...updates } : null);
}
// If card is being restored from archive, reload the board to show it
if (updates.is_archived === false) {
setShowCardModal(false);
setSelectedCard(null);
loadBoard();
} else {
setBoard(prev => prev ? {
...prev,
columns: prev.columns.map(col => ({
...col,
cards: col.cards.map(card =>
card.id === cardId ? { ...card, ...updates } : card
)
}))
} : null);
}
} catch (error: any) {
addToast('Fehler beim Aktualisieren der Karte: ' + (error.response?.data?.detail || error.message), 'error');
@ -385,6 +397,8 @@ const KanbanBoard: React.FC = () => {
onClose={() => {
setShowCardModal(false);
setSelectedCard(null);
// Reload board to ensure all changes are reflected
loadBoard();
}}
onUpdate={handleUpdateCard}
/>

View File

@ -547,13 +547,12 @@ const KanbanCardModal: React.FC<KanbanCardModalProps> = ({
</label>
<select
value={assigneeId || ''}
onChange={(e) => {
onChange={async (e) => {
const newAssigneeId = e.target.value ? parseInt(e.target.value) : undefined;
setAssigneeId(newAssigneeId);
// Check and save immediately with new value
if (newAssigneeId !== card.assignee_id) {
onUpdate(card.id, { assignee_id: newAssigneeId });
}
// Always update since we changed the local state
const assignee = availableUsers.find(u => u.id === newAssigneeId);
await onUpdate(card.id, { assignee_id: newAssigneeId, assignee });
}}
className="w-full p-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
>