diff --git a/prisma/dev.db b/prisma/dev.db index 8d5fc0a..8dfbea3 100644 Binary files a/prisma/dev.db and b/prisma/dev.db differ diff --git a/src/app/submission/columns.tsx b/src/app/submission/columns.tsx index 63ad16f..8ea0949 100644 --- a/src/app/submission/columns.tsx +++ b/src/app/submission/columns.tsx @@ -9,19 +9,19 @@ import EditSubmissionDialog from "./edit" const EditSubCell = (props: CellContext) => { - return { - props.getValue() instanceof Date ? -

- {props.getValue().toLocaleDateString()} -

- :

{props.getValue()}

- - }
+ // return { + // props.getValue() instanceof Date ? + //

+ // {props.getValue().toLocaleDateString()} + //

+ // :

{props.getValue()}

+ // + // }
} export const columns: ColumnDef[] = [ @@ -35,7 +35,7 @@ export const columns: ColumnDef[] = [ }, id: "story", header: "Story", - cell: EditSubCell + cell: (props: CellContext) => (

{props.getValue()}

) }, { accessorFn: row => { @@ -46,7 +46,7 @@ export const columns: ColumnDef[] = [ }, id: "pub", header: "Publication", - cell: EditSubCell + cell: (props: CellContext) => (

{props.getValue()}

) }, { accessorFn: row => new Date(row.submitted), @@ -64,7 +64,7 @@ export const columns: ColumnDef[] = [ }, enableColumnFilter: false, sortingFn: "datetime", - cell: EditSubCell + cell: (props: CellContext) => (

{props.getValue().toLocaleDateString()}

) }, { accessorFn: row => row.responded ? new Date(row.responded) : null, @@ -82,7 +82,7 @@ export const columns: ColumnDef[] = [ }, enableColumnFilter: false, sortingFn: "datetime", - cell: EditSubCell + cell: (props: CellContext) => (

{props.getValue()?.toLocaleDateString()}

) }, { accessorFn: row => { @@ -93,7 +93,7 @@ export const columns: ColumnDef[] = [ }, id: "response", header: "Response", - cell: EditSubCell + cell: (props: CellContext) => (

{props.getValue()}

) }, ] diff --git a/src/app/submission/edit.tsx b/src/app/submission/edit.tsx index b4c15ac..c1b5750 100644 --- a/src/app/submission/edit.tsx +++ b/src/app/submission/edit.tsx @@ -11,22 +11,17 @@ import SubmissionForm, { SubForm } from "app/ui/forms/sub"; export default function EditSubmissionDialog({ stories, pubs, responses, defaults, children }: ComponentProps<"div"> & { stories: Story[], pubs: Pub[], responses: Response[], defaults: SubForm }) { return ( - - - {children} - - - - Edit Submission - Change response status, edit dates etc - - - - - - - - - + <> + + Edit Submission + Change response status, edit dates etc + + + + + + + + ) } diff --git a/src/app/tailwind.css b/src/app/tailwind.css index 2c62f45..a735070 100644 --- a/src/app/tailwind.css +++ b/src/app/tailwind.css @@ -862,6 +862,10 @@ body { height: fit-content; } +.h-full { + height: 100%; +} + .h-px { height: 1px; } @@ -870,10 +874,6 @@ body { height: 100vh; } -.h-full { - height: 100%; -} - .max-h-96 { max-height: 24rem; } diff --git a/src/app/ui/tables/contextMenu.tsx b/src/app/ui/tables/contextMenu.tsx index 5faf8fc..0975cd7 100644 --- a/src/app/ui/tables/contextMenu.tsx +++ b/src/app/ui/tables/contextMenu.tsx @@ -2,16 +2,18 @@ import { Dialog, DialogTrigger, DialogClose, DialogDescription, DialogContent, D import { Button } from "@/components/ui/button" import { ContextMenuContent, ContextMenuItem, ContextMenuSubTrigger, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent } from "@/components/ui/context-menu" import { deleteRecord } from "app/lib/del" -import { Trash2 } from "lucide-react" import Link from "next/link" -import { ComponentProps } from "react" +import { ComponentProps, useState } from "react" import { Row, Table, TableState } from "@tanstack/react-table" -import { letterCase } from "app/lib/functions" import { tableNameToItemName } from "app/lib/nameMaps" +import EditSubmissionDialog from "app/submission/edit" export default function FormContextMenu({ table, row }: ComponentProps<"div"> & { table: Table, row: Row }) { const pathname = table.options.meta.pathname const selectedRows = table.getSelectedRowModel().flatRows + + const [dialog, setDialog] = useState<"edit" | "delete" | null>("delete") + return ( @@ -24,6 +26,18 @@ export default function FormContextMenu({ table, row }: ComponentProps<"div"> & : "" } + { + pathname === "/submission" ? + <> + + setDialog("edit")}> + Edit + + + + : "" + } + { selectedRows.length > 0 ? { table.resetRowSelection() }}>Deselect @@ -31,25 +45,41 @@ export default function FormContextMenu({ table, row }: ComponentProps<"div"> & } - Delete + setDialog("delete")}>Delete - - Are you sure? - - Deleting a {tableNameToItemName(table.options.meta.tableName)} cannot be undone! - - - - - - - + { + dialog === "delete" ? + <> + + Are you sure? + + Deleting a {tableNameToItemName(table.options.meta.tableName)} cannot be undone! + + + + + + + + + : dialog === "edit" ? + + : + <> + Edit/delete dialog + + }