schema: some schema editor fixes

This commit is contained in:
Emmaline Autumn 2024-06-11 05:09:14 -06:00
parent e6880af3ee
commit 1664d3bc7f
8 changed files with 68 additions and 85 deletions

20
actions/Schemas/find.ts Normal file
View File

@ -0,0 +1,20 @@
"use server";
import { prisma } from "@/prisma/prismaClient";
export const findSchema = async (id: string) => {
const schema = await prisma.schema.findFirst({
where: {
id,
},
include: {
gameSystem: {
select: {
id: true,
name: true,
},
},
},
});
return schema;
};

View File

@ -9,7 +9,8 @@
body { body {
@apply dark:bg-mixed-100 bg-primary-600; @apply dark:bg-mixed-100 bg-primary-600;
} }
input { input,
select {
@apply py-2 px-4 rounded-full dark:bg-mixed-200 bg-mixed-600 placeholder:text-dark-500; @apply py-2 px-4 rounded-full dark:bg-mixed-200 bg-mixed-600 placeholder:text-dark-500;
} }
textarea { textarea {
@ -46,8 +47,11 @@
/* @apply bg-mixed-200 rounded-3xl p-6 shadow-2xl */; /* @apply bg-mixed-200 rounded-3xl p-6 shadow-2xl */;
} }
.btn {
@apply rounded-full;
}
.btn-primary { .btn-primary {
@apply dark:bg-primary-500 bg-primary-100 py-4 px-6 dark:text-mixed-100 text-white rounded-full font-bold text-lg; @apply dark:bg-primary-500 bg-primary-100 py-4 px-6 dark:text-mixed-100 text-white font-bold text-lg btn;
} }
.btn-secondary { .btn-secondary {
@apply dark:text-primary-500 text-primary-100 py-4 px-6 font-bold text-lg; @apply dark:text-primary-500 text-primary-100 py-4 px-6 font-bold text-lg;

View File

@ -1,70 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg"
xmlns:cc="http://creativecommons.org/ns#" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
xmlns:svg="http://www.w3.org/2000/svg" sodipodi:docname="Help Icon.svg" id="svg6" version="1.1" viewBox="0 0 28 28" stroke="#ffffff" fill="#ffffff">
xmlns="http://www.w3.org/2000/svg" <metadata id="metadata12">
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" <rdf:RDF>
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" <cc:Work rdf:about="">
inkscape:version="1.0 (4035a4fb49, 2020-05-01)" <dc:format>image/svg+xml</dc:format>
sodipodi:docname="Help Icon.svg" <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
id="svg6" <dc:title></dc:title>
version="1.1" </cc:Work>
viewBox="0 0 28 28" </rdf:RDF>
stroke="#ffffff" </metadata>
fill="#ffffff" <defs id="defs10" />
height="28" <sodipodi:namedview inkscape:current-layer="svg6" inkscape:window-maximized="1" inkscape:window-y="1432"
width="28"> inkscape:window-x="-8" inkscape:cy="14" inkscape:cx="14" inkscape:zoom="27.222222" fit-margin-bottom="0"
<metadata fit-margin-right="0" fit-margin-left="0" fit-margin-top="0" showgrid="false" id="namedview8"
id="metadata12"> inkscape:window-height="1369" inkscape:window-width="3440" inkscape:pageshadow="2" inkscape:pageopacity="0"
<rdf:RDF> guidetolerance="10" gridtolerance="10" objecttolerance="10" borderopacity="1" bordercolor="#666666"
<cc:Work pagecolor="#ffffff" />
rdf:about=""> <circle id="circle2" stroke-width="3" fill="none" stroke="inherit" r="12.5" cy="14" cx="14" />
<dc:format>image/svg+xml</dc:format> <!-- <path d="M0.5,13.5a12.5,12.5 0 1,0 25,0a12.5,12.5 0 1,0 -25,0" fill="none" stroke="inherit" /> -->
<dc:type <path id="path4" fill="inherit"
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> d="m 12.0039,17.8164 v -0.8672 c 0,-0.5312 0.0742,-1 0.2227,-1.4062 0.1484,-0.4141 0.3867,-0.8047 0.7148,-1.1719 0.3281,-0.375 0.7617,-0.7578 1.3008,-1.1484 0.4844,-0.3438 0.8711,-0.6524 1.1601,-0.9258 0.2969,-0.2735 0.5118,-0.543 0.6446,-0.8086 0.1406,-0.2735 0.2109,-0.5821 0.2109,-0.9258 0,-0.50781 -0.1875,-0.89453 -0.5625,-1.16016 -0.375,-0.26562 -0.8984,-0.39843 -1.5703,-0.39843 -0.6719,0 -1.3398,0.10547 -2.0039,0.3164 -0.6563,0.21094 -1.3242,0.48828 -2.00391,0.83203 L 8.83984,7.58594 c 0.78125,-0.4375 1.62891,-0.78906 2.54296,-1.05469 0.9141,-0.27344 1.9141,-0.41016 3,-0.41016 1.6719,0 2.9649,0.40235 3.8789,1.20703 0.9219,0.79688 1.3828,1.8125 1.3828,3.04688 0,0.6562 -0.1054,1.2266 -0.3164,1.7109 -0.2031,0.4766 -0.5156,0.9219 -0.9375,1.336 -0.414,0.4062 -0.9336,0.8359 -1.5586,1.289 -0.4687,0.3438 -0.8281,0.6329 -1.0781,0.8672 -0.25,0.2344 -0.4219,0.4688 -0.5156,0.7031 -0.086,0.2266 -0.1289,0.504 -0.1289,0.8321 v 0.7031 z m -0.375,4.0078 c 0,-0.7344 0.1992,-1.25 0.5977,-1.5469 0.4062,-0.2968 0.8945,-0.4453 1.4648,-0.4453 0.5547,0 1.0313,0.1485 1.4297,0.4453 0.4062,0.2969 0.6094,0.8125 0.6094,1.5469 0,0.7031 -0.2032,1.211 -0.6094,1.5235 -0.3984,0.3125 -0.875,0.4687 -1.4297,0.4687 -0.5703,0 -1.0586,-0.1562 -1.4648,-0.4687 -0.3985,-0.3125 -0.5977,-0.8204 -0.5977,-1.5235 z" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
inkscape:current-layer="svg6"
inkscape:window-maximized="1"
inkscape:window-y="1432"
inkscape:window-x="-8"
inkscape:cy="14"
inkscape:cx="14"
inkscape:zoom="27.222222"
fit-margin-bottom="0"
fit-margin-right="0"
fit-margin-left="0"
fit-margin-top="0"
showgrid="false"
id="namedview8"
inkscape:window-height="1369"
inkscape:window-width="3440"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff" />
<circle
id="circle2"
stroke-width="3"
fill="none"
stroke="inherit"
r="12.5"
cy="14"
cx="14" />
<!-- <path d="M0.5,13.5a12.5,12.5 0 1,0 25,0a12.5,12.5 0 1,0 -25,0" fill="none" stroke="inherit" /> -->
<path
id="path4"
fill="inherit"
d="m 12.0039,17.8164 v -0.8672 c 0,-0.5312 0.0742,-1 0.2227,-1.4062 0.1484,-0.4141 0.3867,-0.8047 0.7148,-1.1719 0.3281,-0.375 0.7617,-0.7578 1.3008,-1.1484 0.4844,-0.3438 0.8711,-0.6524 1.1601,-0.9258 0.2969,-0.2735 0.5118,-0.543 0.6446,-0.8086 0.1406,-0.2735 0.2109,-0.5821 0.2109,-0.9258 0,-0.50781 -0.1875,-0.89453 -0.5625,-1.16016 -0.375,-0.26562 -0.8984,-0.39843 -1.5703,-0.39843 -0.6719,0 -1.3398,0.10547 -2.0039,0.3164 -0.6563,0.21094 -1.3242,0.48828 -2.00391,0.83203 L 8.83984,7.58594 c 0.78125,-0.4375 1.62891,-0.78906 2.54296,-1.05469 0.9141,-0.27344 1.9141,-0.41016 3,-0.41016 1.6719,0 2.9649,0.40235 3.8789,1.20703 0.9219,0.79688 1.3828,1.8125 1.3828,3.04688 0,0.6562 -0.1054,1.2266 -0.3164,1.7109 -0.2031,0.4766 -0.5156,0.9219 -0.9375,1.336 -0.414,0.4062 -0.9336,0.8359 -1.5586,1.289 -0.4687,0.3438 -0.8281,0.6329 -1.0781,0.8672 -0.25,0.2344 -0.4219,0.4688 -0.5156,0.7031 -0.086,0.2266 -0.1289,0.504 -0.1289,0.8321 v 0.7031 z m -0.375,4.0078 c 0,-0.7344 0.1992,-1.25 0.5977,-1.5469 0.4062,-0.2968 0.8945,-0.4453 1.4648,-0.4453 0.5547,0 1.0313,0.1485 1.4297,0.4453 0.4062,0.2969 0.6094,0.8125 0.6094,1.5469 0,0.7031 -0.2032,1.211 -0.6094,1.5235 -0.3984,0.3125 -0.875,0.4687 -1.4297,0.4687 -0.5703,0 -1.0586,-0.1562 -1.4648,-0.4687 -0.3985,-0.3125 -0.5977,-0.8204 -0.5977,-1.5235 z" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -9,7 +9,7 @@ export const HelpPopper: FC<PropsWithChildren> = ({ children }) => {
preferredAlign="centered" preferredAlign="centered"
preferredEdge="bottom" preferredEdge="bottom"
> >
<Icon icon="help" className="svg-white w-4 h-4" /> <Icon icon="Help" className="svg-white w-4 h-4" />
</Poppable> </Poppable>
); );
}; };

View File

@ -101,14 +101,14 @@ export const FieldEditor: FC<IProps> = (
<label className="w-min"> <label className="w-min">
Minimum: Minimum:
<input <input
className="w-12" className="w-12 min-w-min"
type="number" type="number"
{...bindProperty("minimum")} {...bindProperty("minimum")}
/> />
</label> </label>
<label className="w-min"> <label className="w-min">
Limit: Limit:
<input className="w-12" type="number" {...bindProperty("limit")} /> <input className="w-12 min-w-min" type="number" {...bindProperty("limit")} />
</label> </label>
<HelpPopper> <HelpPopper>
<p className="text-sm"> <p className="text-sm">

View File

@ -55,8 +55,8 @@ export const SchemaBuilder: FC = () => {
const { const {
value: schemaFieldName, value: schemaFieldName,
bind: bindTemplateName, bind: bindSchemaFieldName,
reset: resetTemplateName, reset: resetSchemaFieldName,
} = useInput("", { disallowSpaces: true }); } = useInput("", { disallowSpaces: true });
const addSchemaField = useCallback(() => { const addSchemaField = useCallback(() => {
updateSchema((s) => ({ updateSchema((s) => ({
@ -68,8 +68,8 @@ export const SchemaBuilder: FC = () => {
}, },
}, },
})); }));
resetTemplateName(); resetSchemaFieldName();
}, [resetTemplateName, schemaFieldName, updateSchema]); }, [resetSchemaFieldName, schemaFieldName, updateSchema]);
const updateSchemaField = useCallback((key: string, template: Template) => { const updateSchemaField = useCallback((key: string, template: Template) => {
updateSchema((s) => ({ updateSchema((s) => ({
@ -101,7 +101,7 @@ export const SchemaBuilder: FC = () => {
<div> <div>
<p className="subheader mb-2">Add Schema Field</p> <p className="subheader mb-2">Add Schema Field</p>
<div className="mb-2"> <div className="mb-2">
<input type="text" {...bindTemplateName} /> <input type="text" {...bindSchemaFieldName} />
<button onClick={addSchemaField} disabled={!schemaFieldName}> <button onClick={addSchemaField} disabled={!schemaFieldName}>
Add Add
</button> </button>
@ -178,13 +178,14 @@ export const SchemaBuilder: FC = () => {
<div className="panel basis-1/3"> <div className="panel basis-1/3">
<div className="flex gap-2 mb-2"> <div className="flex gap-2 mb-2">
<button <button
className="btn btn-small bg-green-800"
onClick={saveSchema} onClick={saveSchema}
disabled={lastSaved === schema} disabled={lastSaved === schema}
> >
Save Schema Save Schema
</button> </button>
<button <button
className="bg-red-800" className="bg-red-800 btn btn-small"
onClick={() => setSchema(lastSaved)} onClick={() => setSchema(lastSaved)}
disabled={lastSaved === schema} disabled={lastSaved === schema}
> >

View File

@ -2,7 +2,7 @@ import { createElements } from "@/lib/tcmd";
import React, { FC, Suspense, useEffect, useMemo, useState } from "react"; import React, { FC, Suspense, useEffect, useMemo, useState } from "react";
import { MDSkeletonLoader } from "../loader"; import { MDSkeletonLoader } from "../loader";
import { DevTool } from "../devtools/Toolbox"; import { DevTool } from "../devtools/DevTool";
interface Props { interface Props {
body: string; body: string;

View File

@ -27,10 +27,11 @@ model Schema {
gameSystemId String gameSystemId String
publications Publication[] publications Publication[]
name String originalId String
schema Json name String
types Json schema Json
version Int types Json
version Int
} }
model Publication { model Publication {