Compare commits
	
		
			3 Commits
		
	
	
		
			540413173c
			...
			8c4b9d27f2
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 8c4b9d27f2 | |
|  | 5ea7a61915 | |
|  | 7c6f06e194 | 
|  | @ -13,6 +13,14 @@ export async function getStoriesWithGenres() { | |||
| 
 | ||||
| 	) | ||||
| } | ||||
| export async function getStoriesWithGenresAndSubs() { | ||||
| 	return prisma.story.findMany({ | ||||
| 		include: { | ||||
| 			genres: true, | ||||
| 			subs: true | ||||
| 		} | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| export async function getPubs() { | ||||
| 	return prisma.pub.findMany() | ||||
|  |  | |||
|  | @ -18,11 +18,13 @@ import { PubsWithGenres } from "./page" | |||
| import { DialogClose } from "@radix-ui/react-dialog" | ||||
| import { actions } from "app/ui/tables/actions" | ||||
| import { TextInputCell } from "app/ui/inputs/textInput" | ||||
| import { selectCol } from "app/ui/tables/selectColumn" | ||||
| 
 | ||||
| 
 | ||||
| const columnHelper = createColumnHelper<PubsWithGenres>() | ||||
| 
 | ||||
| export const columns: ColumnDef<PubsWithGenres>[] = [ | ||||
|   selectCol, | ||||
|   { | ||||
|     accessorKey: "title", | ||||
|     header: ({ column }) => { | ||||
|  |  | |||
|  | @ -26,6 +26,9 @@ export const TextInputCell = (props: CellContext<any, any>) => { | |||
|     initialValue = value | ||||
|     handleClose() | ||||
|   } | ||||
|   function handleOpen() { | ||||
|     setIsActive(true) | ||||
|   } | ||||
|   function handleClose() { | ||||
|     setValue(initialValue) | ||||
|     setIsActive(false) | ||||
|  | @ -40,6 +43,12 @@ export const TextInputCell = (props: CellContext<any, any>) => { | |||
|   return (<div | ||||
|     onDoubleClick={() => setIsActive(prev => !prev)} | ||||
|     className="w-full h-fit flex items-center justify-center" | ||||
|     tabIndex={0} | ||||
|     onKeyDown={e => { | ||||
|       if (e.code === "Enter" && !isActive) { | ||||
|         setIsActive(true) | ||||
|       } | ||||
|     }} | ||||
|   > | ||||
|     {isActive ? | ||||
|       <Input | ||||
|  |  | |||
|  | @ -22,21 +22,9 @@ export default function FormContextMenu({ table, row }: ComponentProps<"div"> & | |||
|           </> | ||||
|           : "" | ||||
|         } | ||||
| 
 | ||||
|         { | ||||
|           selectedRows.length <= 1 ? | ||||
|             <ContextMenuSub> | ||||
|               <ContextMenuSubTrigger>Edit</ContextMenuSubTrigger> | ||||
|               <ContextMenuSubContent> | ||||
|                 {Object.keys(row.original).map(e => { | ||||
|                   if (e !== "id") { | ||||
|                     return <ContextMenuItem>{letterCase(e)}</ContextMenuItem> | ||||
|                   } | ||||
|                 })} | ||||
|               </ContextMenuSubContent> | ||||
|             </ContextMenuSub> : "" | ||||
|         } | ||||
|         { | ||||
|           selectedRows ? | ||||
|           selectedRows.length > 0 ? | ||||
|             <ContextMenuItem onClick={() => { table.resetRowSelection() }}>Deselect</ContextMenuItem> | ||||
|             : "" | ||||
|         } | ||||
|  |  | |||
|  | @ -22,7 +22,9 @@ export const selectCol = { | |||
|         <Checkbox | ||||
|           checked={props.row.getIsSelected()} | ||||
|           onCheckedChange={props.row.toggleSelected} | ||||
|           aria-label="select/deselect row" /> | ||||
|           aria-label="select/deselect row" | ||||
|         /> | ||||
| 
 | ||||
|       </div> | ||||
|     ) | ||||
|   } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue