Edit task in table view
This commit is contained in:
@@ -70,7 +70,7 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|||||||
<th
|
<th
|
||||||
data-slot="table-head"
|
data-slot="table-head"
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
"text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-0.5",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -83,7 +83,7 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|||||||
<td
|
<td
|
||||||
data-slot="table-cell"
|
data-slot="table-cell"
|
||||||
className={cn(
|
className={cn(
|
||||||
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-0.5",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { MultiSelect } from "@/components/ui/multi-select";
|
||||||
|
import {
|
||||||
|
Sheet,
|
||||||
|
SheetContent,
|
||||||
|
SheetDescription,
|
||||||
|
SheetHeader,
|
||||||
|
SheetTitle,
|
||||||
|
} from "@/components/ui/sheet";
|
||||||
|
import { Task } from "@/lib/types";
|
||||||
|
import { Color, getColor } from "@/lib/ui/color";
|
||||||
|
import { DraggableProvided } from "@hello-pangea/dnd";
|
||||||
|
|
||||||
|
export default function TaskEdit({
|
||||||
|
task,
|
||||||
|
setTask,
|
||||||
|
tags,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
task: Task;
|
||||||
|
setTask: (t: Task) => void;
|
||||||
|
tags: Record<string, { color: Color; name: string }>;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Sheet>
|
||||||
|
{children}
|
||||||
|
<SheetContent>
|
||||||
|
<SheetHeader>
|
||||||
|
<SheetTitle>Edit task</SheetTitle>
|
||||||
|
<SheetDescription>
|
||||||
|
Make changes to the task here. Click save when you're done.
|
||||||
|
</SheetDescription>
|
||||||
|
</SheetHeader>
|
||||||
|
<div className="grid flex-1 auto-rows-min gap-6 px-4">
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<Label>Title</Label>
|
||||||
|
<Input
|
||||||
|
defaultValue={task.title}
|
||||||
|
onChange={(e) => setTask({ ...task, title: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<Label>Description</Label>
|
||||||
|
<Input
|
||||||
|
defaultValue={task.description}
|
||||||
|
onChange={(e) =>
|
||||||
|
setTask({ ...task, description: e.target.value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<Label>Status</Label>
|
||||||
|
<MultiSelect
|
||||||
|
options={Object.entries(tags).map(([id, tag]) => ({
|
||||||
|
label: tag.name,
|
||||||
|
value: id,
|
||||||
|
style: {
|
||||||
|
iconColor: getColor(tag.color).color,
|
||||||
|
badgeColor: getColor(tag.color).backgroundColor,
|
||||||
|
},
|
||||||
|
}))}
|
||||||
|
onValueChange={(tags) => setTask({ ...task, tags })}
|
||||||
|
defaultValue={task.tags}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</SheetContent>
|
||||||
|
</Sheet>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,20 +6,11 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
import { Input } from "@/components/ui/input";
|
import { SheetTrigger } from "@/components/ui/sheet";
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { MultiSelect } from "@/components/ui/multi-select";
|
|
||||||
import {
|
|
||||||
Sheet,
|
|
||||||
SheetContent,
|
|
||||||
SheetDescription,
|
|
||||||
SheetHeader,
|
|
||||||
SheetTitle,
|
|
||||||
SheetTrigger,
|
|
||||||
} from "@/components/ui/sheet";
|
|
||||||
import { Task } from "@/lib/types";
|
import { Task } from "@/lib/types";
|
||||||
import { Color, getColor } from "@/lib/ui/color";
|
import { Color, getColor } from "@/lib/ui/color";
|
||||||
import { DraggableProvided } from "@hello-pangea/dnd";
|
import { DraggableProvided } from "@hello-pangea/dnd";
|
||||||
|
import TaskEdit from "../TaskEdit";
|
||||||
|
|
||||||
export default function BoardTask({
|
export default function BoardTask({
|
||||||
task,
|
task,
|
||||||
@@ -33,7 +24,7 @@ export default function BoardTask({
|
|||||||
tags: Record<string, { color: Color; name: string }>;
|
tags: Record<string, { color: Color; name: string }>;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Sheet>
|
<TaskEdit task={task} tags={tags} setTask={setTask}>
|
||||||
<SheetTrigger asChild>
|
<SheetTrigger asChild>
|
||||||
<Card
|
<Card
|
||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
@@ -58,53 +49,6 @@ export default function BoardTask({
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</SheetTrigger>
|
</SheetTrigger>
|
||||||
<SheetContent>
|
</TaskEdit>
|
||||||
<SheetHeader>
|
|
||||||
<SheetTitle>Edit task</SheetTitle>
|
|
||||||
<SheetDescription>
|
|
||||||
Make changes to the task here. Click save when you're done.
|
|
||||||
</SheetDescription>
|
|
||||||
</SheetHeader>
|
|
||||||
<div className="grid flex-1 auto-rows-min gap-6 px-4">
|
|
||||||
<div className="grid gap-3">
|
|
||||||
<Label>Title</Label>
|
|
||||||
<Input
|
|
||||||
defaultValue={task.title}
|
|
||||||
onChange={(e) => setTask({ ...task, title: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="grid gap-3">
|
|
||||||
<Label>Description</Label>
|
|
||||||
<Input
|
|
||||||
defaultValue={task.description}
|
|
||||||
onChange={(e) =>
|
|
||||||
setTask({ ...task, description: e.target.value })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="grid gap-3">
|
|
||||||
<Label>Status</Label>
|
|
||||||
<MultiSelect
|
|
||||||
options={Object.entries(tags).map(([id, tag]) => ({
|
|
||||||
label: tag.name,
|
|
||||||
value: id,
|
|
||||||
style: {
|
|
||||||
iconColor: getColor(tag.color).color,
|
|
||||||
badgeColor: getColor(tag.color).backgroundColor,
|
|
||||||
},
|
|
||||||
}))}
|
|
||||||
onValueChange={(tags) => setTask({ ...task, tags })}
|
|
||||||
defaultValue={task.tags}
|
|
||||||
/>
|
|
||||||
{/* <Input
|
|
||||||
defaultValue={task.description}
|
|
||||||
onChange={(e) =>
|
|
||||||
setTask({ ...task, description: e.target.value })
|
|
||||||
}
|
|
||||||
/> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</SheetContent>
|
|
||||||
</Sheet>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { SheetTrigger } from "@/components/ui/sheet";
|
||||||
import { TableCell, TableRow } from "@/components/ui/table";
|
import { TableCell, TableRow } from "@/components/ui/table";
|
||||||
import { Task } from "@/lib/types";
|
import { Task } from "@/lib/types";
|
||||||
import { Color, getColor } from "@/lib/ui/color";
|
import { Color, getColor } from "@/lib/ui/color";
|
||||||
|
import TaskEdit from "../TaskEdit";
|
||||||
|
|
||||||
export default function TableTask({
|
export default function TableTask({
|
||||||
task,
|
task,
|
||||||
@@ -13,31 +15,39 @@ export default function TableTask({
|
|||||||
tags: Record<string, { color: Color; name: string }>;
|
tags: Record<string, { color: Color; name: string }>;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<TableRow>
|
<TaskEdit task={task} tags={tags} setTask={setTask}>
|
||||||
<TableCell className="font-medium">{task.title}</TableCell>
|
<SheetTrigger asChild>
|
||||||
<TableCell className="max-w-[250px] truncate">
|
<TableRow>
|
||||||
{task.description || "-"}
|
<TableCell className="font-medium">{task.title}</TableCell>
|
||||||
</TableCell>
|
<TableCell className="max-w-[250px] truncate">
|
||||||
<TableCell>
|
{task.description || "-"}
|
||||||
<Badge
|
</TableCell>
|
||||||
variant={
|
<TableCell>
|
||||||
task.status === "done"
|
<Badge
|
||||||
? "default"
|
variant={
|
||||||
: task.status === "in-progress"
|
task.status === "done"
|
||||||
? "secondary"
|
? "default"
|
||||||
: "outline"
|
: task.status === "in-progress"
|
||||||
}
|
? "secondary"
|
||||||
>
|
: "outline"
|
||||||
{task.status}
|
}
|
||||||
</Badge>
|
>
|
||||||
</TableCell>
|
{task.status}
|
||||||
<TableCell className="flex gap-1 items-center">
|
</Badge>
|
||||||
{task.tags?.map((tag, i) => (
|
</TableCell>
|
||||||
<Badge key={tag} variant="outline" style={getColor(tags[tag].color)}>
|
<TableCell className="flex gap-1 items-center">
|
||||||
{tag}
|
{task.tags?.map((tag, i) => (
|
||||||
</Badge>
|
<Badge
|
||||||
))}
|
key={tag}
|
||||||
</TableCell>
|
variant="outline"
|
||||||
</TableRow>
|
style={getColor(tags[tag].color)}
|
||||||
|
>
|
||||||
|
{tag}
|
||||||
|
</Badge>
|
||||||
|
))}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</SheetTrigger>
|
||||||
|
</TaskEdit>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user