diff --git a/src/Board.tsx b/src/Board.tsx index 950860f..3063182 100644 --- a/src/Board.tsx +++ b/src/Board.tsx @@ -1,34 +1,6 @@ +import { DragDropContext, Droppable } from "react-beautiful-dnd"; import React, { useState } from "react"; -import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd"; - -export type task = { - id: string, - name: string, - description: string, - column: string, - workload?: number, - remainingWorkload?: number, - progress?: number, - metadata: { - created: Date, - updated?: Date, - completed?: Date, - assigned?: string - }, - relations: Array<{ - type: string, - task: string - }>, - subTasks: Array<{ - text: string, - completed: boolean - }>, - comments: Array<{ - author: string, - date: Date, - text: string - }> -}; +import Task from './Task'; declare var acquireVsCodeApi: any; const vscode = acquireVsCodeApi(); @@ -44,7 +16,7 @@ const onDragEnd = (result, columns, setColumns) => { const { source, destination } = result; // The item that was moved - let removed: task; + let removed: KanbnTask; // The task was dragged from one column to another if (source.droppableId !== destination.droppableId) { @@ -84,72 +56,53 @@ const onDragEnd = (result, columns, setColumns) => { }); }; -const Board = ({ columns }) => { +const Board = ({ columns, startedColumns, completedColumns }: { + columns: Record, + startedColumns: string[], + completedColumns: string[] +}) => { const [, setColumns] = useState(columns); return ( -
+
onDragEnd(result, columns, setColumns)} > - {Object.entries(columns).map(([columnId, column]) => { + {Object.entries(columns).map(([columnName, column]) => { return (
-

{columnId}

-
- +

+ {columnName} + {column.length || ''} +

+ {/* + // TODO codicons https://github.com/microsoft/vscode-extension-samples/tree/main/webview-codicons-sample + // TODO 'Add task' button next to each column header + // TODO show count next to header + */} +
+ {(provided, snapshot) => { return (
i).join(' ')} > - {(column as task[]).map((item, index) => { - return ( - - {(provided, snapshot) => { - return ( -
- {item.name} -
- ); - }} -
- ); - })} + {column.map((task, index) => )} {provided.placeholder}
); diff --git a/src/KanbnTask.d.ts b/src/KanbnTask.d.ts new file mode 100644 index 0000000..293c0f2 --- /dev/null +++ b/src/KanbnTask.d.ts @@ -0,0 +1,28 @@ +declare type KanbnTask = { + id: string, + name: string, + description: string, + column: string, + workload?: number, + remainingWorkload?: number, + progress?: number, + metadata: { + created: Date, + updated?: Date, + completed?: Date, + assigned?: string + }, + relations: Array<{ + type: string, + task: string + }>, + subTasks: Array<{ + text: string, + completed: boolean + }>, + comments: Array<{ + author: string, + date: Date, + text: string + }> +}; diff --git a/src/Task.tsx b/src/Task.tsx new file mode 100644 index 0000000..ef1764f --- /dev/null +++ b/src/Task.tsx @@ -0,0 +1,49 @@ +import React from "react"; +import { Draggable } from "react-beautiful-dnd"; + +const Task = ({ task, index }: { task: KanbnTask, index: number }) => { + return ( + + {(provided, snapshot) => { + return ( +
i).join(' ')} + style={{ + userSelect: "none", + ...provided.draggableProps.style + }} + > + + {/* + // TODO add task info + truncated description (?), + progress as %-filled bottom border, + created/updated (updated date, fallback to created), + tags (provide default colours in css, put tagname in className), + count sub-tasks (if >0), + count comments (if >0) + */} +
+ ); + }} +
+ ); +} + +export default Task;