schema: some schema editor fixes
This commit is contained in:
parent
e6880af3ee
commit
1664d3bc7f
20
actions/Schemas/find.ts
Normal file
20
actions/Schemas/find.ts
Normal 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;
|
||||
};
|
@ -9,7 +9,8 @@
|
||||
body {
|
||||
@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;
|
||||
}
|
||||
textarea {
|
||||
@ -46,8 +47,11 @@
|
||||
/* @apply bg-mixed-200 rounded-3xl p-6 shadow-2xl */;
|
||||
}
|
||||
|
||||
.btn {
|
||||
@apply rounded-full;
|
||||
}
|
||||
.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 {
|
||||
@apply dark:text-primary-500 text-primary-100 py-4 px-6 font-bold text-lg;
|
||||
|
@ -1,70 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||
sodipodi:docname="Help Icon.svg"
|
||||
id="svg6"
|
||||
version="1.1"
|
||||
viewBox="0 0 28 28"
|
||||
stroke="#ffffff"
|
||||
fill="#ffffff"
|
||||
height="28"
|
||||
width="28">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<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 xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||
sodipodi:docname="Help Icon.svg" id="svg6" version="1.1" viewBox="0 0 28 28" stroke="#ffffff" fill="#ffffff">
|
||||
<metadata id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<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>
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.9 KiB |
@ -9,7 +9,7 @@ export const HelpPopper: FC<PropsWithChildren> = ({ children }) => {
|
||||
preferredAlign="centered"
|
||||
preferredEdge="bottom"
|
||||
>
|
||||
<Icon icon="help" className="svg-white w-4 h-4" />
|
||||
<Icon icon="Help" className="svg-white w-4 h-4" />
|
||||
</Poppable>
|
||||
);
|
||||
};
|
||||
|
@ -101,14 +101,14 @@ export const FieldEditor: FC<IProps> = (
|
||||
<label className="w-min">
|
||||
Minimum:
|
||||
<input
|
||||
className="w-12"
|
||||
className="w-12 min-w-min"
|
||||
type="number"
|
||||
{...bindProperty("minimum")}
|
||||
/>
|
||||
</label>
|
||||
<label className="w-min">
|
||||
Limit:
|
||||
<input className="w-12" type="number" {...bindProperty("limit")} />
|
||||
<input className="w-12 min-w-min" type="number" {...bindProperty("limit")} />
|
||||
</label>
|
||||
<HelpPopper>
|
||||
<p className="text-sm">
|
||||
|
@ -55,8 +55,8 @@ export const SchemaBuilder: FC = () => {
|
||||
|
||||
const {
|
||||
value: schemaFieldName,
|
||||
bind: bindTemplateName,
|
||||
reset: resetTemplateName,
|
||||
bind: bindSchemaFieldName,
|
||||
reset: resetSchemaFieldName,
|
||||
} = useInput("", { disallowSpaces: true });
|
||||
const addSchemaField = useCallback(() => {
|
||||
updateSchema((s) => ({
|
||||
@ -68,8 +68,8 @@ export const SchemaBuilder: FC = () => {
|
||||
},
|
||||
},
|
||||
}));
|
||||
resetTemplateName();
|
||||
}, [resetTemplateName, schemaFieldName, updateSchema]);
|
||||
resetSchemaFieldName();
|
||||
}, [resetSchemaFieldName, schemaFieldName, updateSchema]);
|
||||
|
||||
const updateSchemaField = useCallback((key: string, template: Template) => {
|
||||
updateSchema((s) => ({
|
||||
@ -101,7 +101,7 @@ export const SchemaBuilder: FC = () => {
|
||||
<div>
|
||||
<p className="subheader mb-2">Add Schema Field</p>
|
||||
<div className="mb-2">
|
||||
<input type="text" {...bindTemplateName} />
|
||||
<input type="text" {...bindSchemaFieldName} />
|
||||
<button onClick={addSchemaField} disabled={!schemaFieldName}>
|
||||
Add
|
||||
</button>
|
||||
@ -178,13 +178,14 @@ export const SchemaBuilder: FC = () => {
|
||||
<div className="panel basis-1/3">
|
||||
<div className="flex gap-2 mb-2">
|
||||
<button
|
||||
className="btn btn-small bg-green-800"
|
||||
onClick={saveSchema}
|
||||
disabled={lastSaved === schema}
|
||||
>
|
||||
Save Schema
|
||||
</button>
|
||||
<button
|
||||
className="bg-red-800"
|
||||
className="bg-red-800 btn btn-small"
|
||||
onClick={() => setSchema(lastSaved)}
|
||||
disabled={lastSaved === schema}
|
||||
>
|
||||
|
@ -2,7 +2,7 @@ import { createElements } from "@/lib/tcmd";
|
||||
import React, { FC, Suspense, useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { MDSkeletonLoader } from "../loader";
|
||||
import { DevTool } from "../devtools/Toolbox";
|
||||
import { DevTool } from "../devtools/DevTool";
|
||||
|
||||
interface Props {
|
||||
body: string;
|
||||
|
@ -27,10 +27,11 @@ model Schema {
|
||||
gameSystemId String
|
||||
publications Publication[]
|
||||
|
||||
name String
|
||||
schema Json
|
||||
types Json
|
||||
version Int
|
||||
originalId String
|
||||
name String
|
||||
schema Json
|
||||
types Json
|
||||
version Int
|
||||
}
|
||||
|
||||
model Publication {
|
||||
|
Loading…
x
Reference in New Issue
Block a user