diff --git a/apps/web/app/hooks/features/useKanban.ts b/apps/web/app/hooks/features/useKanban.ts index 4217299aa..cf6fed18b 100644 --- a/apps/web/app/hooks/features/useKanban.ts +++ b/apps/web/app/hooks/features/useKanban.ts @@ -62,6 +62,16 @@ export function useKanban() { return columnData[0].isCollapsed } + const reorderStatus = (itemStatus: string, index: number) => { + taskStatusHook.taskStatus.filter((status: ITaskStatusItemList)=> { + return status.name === itemStatus + }).map((status: ITaskStatusItemList)=> { + taskStatusHook.editTaskStatus(status.id, { + order: index + }); + }) + } + return { data: kanbanBoard, isLoading: loading, @@ -69,6 +79,7 @@ export function useKanban() { updateKanbanBoard: setKanbanBoard, updateTaskStatus: updateTask, toggleColumn, - isColumnCollapse + isColumnCollapse, + reorderStatus } } \ No newline at end of file diff --git a/apps/web/lib/components/Kanban.tsx b/apps/web/lib/components/Kanban.tsx index b5f7b2ac0..85cebb8de 100644 --- a/apps/web/lib/components/Kanban.tsx +++ b/apps/web/lib/components/Kanban.tsx @@ -62,7 +62,7 @@ function InnerItemList({items, title, dropSnapshot}: { minHeight: ((items.length < 0) && dropSnapshot.isDraggingOver) ? '120px' : '20px', marginTop: (items.length > 0) ? '20px' : '0px' }} - className="flex flex-col gap-2.5 max-h-[520px] overflow-y-scroll overflow-x-hidden"> + className="flex flex-col gap-2.5 max-h-[520px] overflow-y-auto overflow-x-hidden"> {items.map((item: ITeamTask, index: number) => ( {(dragProvided: DraggableProvided, dragSnapshot: DraggableStateSnapshot) => ( @@ -174,9 +174,10 @@ export const KanbanDroppable = ({ title, droppableId, type, content }: { * @param param0 * @returns */ -export const EmptyKanbanDroppable = ({index,title, items}: { +export const EmptyKanbanDroppable = ({index,title, items, backgroundColor}: { index: number; title: string; + backgroundColor: any; items: ITeamTask[]; })=> { const [enabled, setEnabled] = useState(false); @@ -219,7 +220,7 @@ export const EmptyKanbanDroppable = ({index,title, items}: { <>
-
+
{tags.map((tag: Tag, index: number)=> { return ( ) })} @@ -195,7 +195,7 @@ export default function Item(props: any) {
-
+
diff --git a/apps/web/lib/features/team-members-kanban-view.tsx b/apps/web/lib/features/team-members-kanban-view.tsx index 24e60723f..88d61c953 100644 --- a/apps/web/lib/features/team-members-kanban-view.tsx +++ b/apps/web/lib/features/team-members-kanban-view.tsx @@ -10,7 +10,7 @@ import { DragDropContext, DraggableLocation, DropResult, Droppable, DroppablePro export const KanbanView = ({ kanbanBoardTasks }: { kanbanBoardTasks: IKanban}) => { - const { columns:kanbanColumns, updateKanbanBoard, updateTaskStatus, isColumnCollapse } = useKanban(); + const { columns:kanbanColumns, updateKanbanBoard, updateTaskStatus, isColumnCollapse, reorderStatus } = useKanban(); const [items, setItems] = useState(kanbanBoardTasks); @@ -20,12 +20,11 @@ export const KanbanView = ({ kanbanBoardTasks }: { kanbanBoardTasks: IKanban}) = const tasks = Array.from(list); const [removedTask] = tasks.splice(startIndex, 1); tasks.splice(endIndex, 0, removedTask); - return tasks; }; const reorderColumn = (list: IKanban , startIndex:number , endIndex:number ) => { - const columns = Object.keys(list) + const columns = Object.keys(list); const [removedColumn] = columns.splice(startIndex, 1); columns.splice(endIndex, 0, removedColumn); return columns; @@ -138,6 +137,12 @@ export const KanbanView = ({ kanbanBoardTasks }: { kanbanBoardTasks: IKanban}) = if (result.type === 'COLUMN') { const reorderedItem = reorderColumn(items, source.index, destination.index); + + //update column order in server side + reorderedItem.map((item: string, index: number) => { + return reorderStatus(item, index); + }); + setColumn(reorderedItem); return; @@ -194,6 +199,7 @@ export const KanbanView = ({ kanbanBoardTasks }: { kanbanBoardTasks: IKanban}) = index={index} title={column} items={items[column]} + backgroundColor={getHeaderBackground(kanbanColumns, column)} />
: @@ -206,7 +212,6 @@ export const KanbanView = ({ kanbanBoardTasks }: { kanbanBoardTasks: IKanban}) = items={items[column]} backgroundColor={getHeaderBackground(kanbanColumns, column)} /> -
}