Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
926dc69
remove unused import
doomlab Dec 27, 2024
e0e093b
update schema to have the new columns for project forms
doomlab Dec 27, 2024
6ef8497
remove old declarations
doomlab Dec 27, 2024
0506e1a
add the ability to see forms for the user to assign
doomlab Dec 27, 2024
867d0ae
update the schema to only keep the formversion id
doomlab Dec 27, 2024
9f1151e
updates to the form so you can add the form
doomlab Dec 27, 2024
218c1c2
update to show default form button
doomlab Dec 27, 2024
19ebed2
add project schema
doomlab Dec 27, 2024
4792ab8
make this match other visuals
doomlab Dec 27, 2024
ac8fc04
add project to default forms
doomlab Dec 27, 2024
05907c4
needed form version id not forms connection
doomlab Dec 27, 2024
5ca77db
editing the schema again to be one to many
doomlab Dec 27, 2024
c9f43b7
updating create projects to take the form version correctly
doomlab Dec 27, 2024
a850c1a
adding task when you add project
doomlab Dec 27, 2024
231dbe2
change to save due to feedback
doomlab Dec 30, 2024
59500a4
output was misaligned
doomlab Dec 30, 2024
cffa0c6
adding button props so it doesn't submit forms
doomlab Dec 30, 2024
20fb6c4
restructuring page so you can edit and view what you have
doomlab Dec 30, 2024
02cae5f
you can now add, update, and work on forms
doomlab Dec 30, 2024
8b6490d
you can edit and reset the form!
doomlab Dec 31, 2024
f2ad05f
fix initial values not showing
doomlab Dec 31, 2024
7aed0d8
only add task to complete if you add metadata
doomlab Dec 31, 2024
899f34a
update views for project summary
doomlab Dec 31, 2024
aaa8573
keywords in the wrong place
doomlab Dec 31, 2024
9005302
updating page headers and fixing form updates
doomlab Dec 31, 2024
d861bd0
updating warning
doomlab Dec 31, 2024
511b6d9
adding migration files
doomlab Dec 31, 2024
1beefdc
update to queries to be able to run
doomlab Dec 31, 2024
59d543d
remove my specific migrations
doomlab Dec 31, 2024
d918b0c
missed adding formid which otherwise causes a typescript error
doomlab Dec 31, 2024
d839c44
make sure the data updates in the background
doomlab Dec 31, 2024
4adb3a9
Merge pull request #387 from STAPLE-verse/project-meta-data
doomlab Jan 3, 2025
6dae07f
Merge branch 'super-user' into dev
doomlab Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions db/migrations/migration_lock.toml

This file was deleted.

10 changes: 7 additions & 3 deletions db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ model Project {
notifications Notification[]
ProjectPrivilege ProjectPrivilege[]
invitations Invitation[]
metadata Json? // Add metadata field
formVersion FormVersion? @relation(fields: [formVersionId], references: [id])
formVersionId Int?
}

enum Status {
Expand Down Expand Up @@ -243,15 +246,16 @@ model Form {
}

model FormVersion {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
name String
formId Int
version Int
schema Json
uiSchema Json?
createdAt DateTime @default(now())
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
tasks Task[]
projects Project[]

@@index([formId, version], name: "formVersionIndex")
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/components/DateFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function DateFormat({ date }: DateFormatProps) {
const locale = currentUser ? currentUser.language : "en-US"

return (
<span data-testid="dateformat-id">
<>
{" "}
{date
? date.toLocaleDateString(locale, {
Expand All @@ -22,6 +22,6 @@ export default function DateFormat({ date }: DateFormatProps) {
hour12: false, // Use 24-hour format
})
: ""}
</span>
</>
)
}
2 changes: 1 addition & 1 deletion src/core/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const Table = <TData,>({
onChange={(e) => {
table.setPageSize(Number(e.target.value))
}}
className={`text-secondary input-secondary input-bordered border-2 bg-base-300 rounded input-sm ${
className={`text-secondary input-secondary input-bordered border-2 bg-base-300 rounded input-sm mt-2 ${
classNames?.pageSizeSelect || ""
}`}
>
Expand Down
16 changes: 15 additions & 1 deletion src/core/components/fields/RadioFieldTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,38 @@ interface RadioFieldTableProps<T> {
options: { id: number; label: string }[]
extraData?: T[]
extraColumns?: any[]
value?: number | null // New prop for pre-selected value
onChange?: (selectedId: number) => void // Callback for when a radio button is selected
}

const RadioFieldTable = <T,>({
name,
options,
extraData = [],
extraColumns = [],
value, // Receive the pre-selected value
onChange, // Receive the onChange callback
}: RadioFieldTableProps<T>) => {
const {
input: { value: selectedId, onChange: setSelectedId },
meta,
} = useField(name, { subscription: { value: true, touched: true, error: true } })

// Ensure the selected ID is initialized with the provided value
React.useEffect(() => {
if (value && value !== selectedId) {
setSelectedId(value)
}
}, [value, selectedId, setSelectedId])

const handleSelection = useCallback(
(id) => {
setSelectedId(id)
if (onChange) {
onChange(id) // Trigger the parent callback when a selection is made
}
},
[setSelectedId]
[setSelectedId, onChange]
)

const columns = React.useMemo(
Expand Down
2 changes: 1 addition & 1 deletion src/forms/components/AddFormTemplates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const AddFormTemplates: React.FC<AddFormTemplatesProps> = ({

return (
<Modal open={open} size="large">
<h2>Select Form Templates</h2>
<h2 className="flex justify-center mb-2 text-3xl">Select Form Templates</h2>
{open && (
<Form
schema={AddFormTemplatesSchema}
Expand Down
11 changes: 9 additions & 2 deletions src/forms/components/DownloadJSON.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import React from "react"

const DownloadJSON = ({ data, fileName, className }) => {
interface DownloadJSONProps {
data: any
fileName: string
type?: "button" | "submit" | "reset" // Match the allowed types
className?: string
}

const DownloadJSON = ({ data, fileName, type = "button", className }: DownloadJSONProps) => {
const downloadJSON = () => {
const jsonData = new Blob([JSON.stringify(data)], { type: "application/json" })
const jsonURL = URL.createObjectURL(jsonData)
Expand All @@ -13,7 +20,7 @@ const DownloadJSON = ({ data, fileName, className }) => {
}

return (
<button className={className} onClick={downloadJSON}>
<button type={type} className={className} onClick={downloadJSON}>
Download JSON
</button>
)
Expand Down
11 changes: 9 additions & 2 deletions src/forms/components/DownloadXLSX.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import React from "react"
import * as XLSX from "xlsx"
import { saveAs } from "file-saver"

function DownloadXLSX({ data, fileName, className }) {
interface DownloadXLSXProps {
data: any
fileName: string
type?: "button" | "submit" | "reset" // Match the allowed types
className?: string
}

function DownloadXLSX({ data, fileName, type = "button", className }: DownloadXLSXProps) {
const exportToExcel = () => {
const worksheet = XLSX.utils.json_to_sheet(data)
const workbook = XLSX.utils.book_new()
Expand All @@ -18,7 +25,7 @@ function DownloadXLSX({ data, fileName, className }) {
}

return (
<button className={className} onClick={exportToExcel}>
<button type={type} className={className} onClick={exportToExcel}>
Download XLSX
</button>
)
Expand Down
3 changes: 3 additions & 0 deletions src/forms/mutations/createForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export default resolver.pipe(
},
},
},
include: {
versions: true, // Include related formVersion in the return
},
})

return form
Expand Down
52 changes: 52 additions & 0 deletions src/forms/schema/projectSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export const JsonProject = `
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "Project Information",
"required": [],
"properties": {
"abstract": {
"type": "string",
"title": "Abstract:"
},
"citation": {
"type": "string",
"title": "Citation:"
},
"keywords": {
"type": "string",
"title": "Keywords:",
"description": "Keywords separated by commas."
},
"publisher": {
"type": "string",
"title": "Publisher:"
},
"identifier": {
"type": "string",
"title": "Identifier:",
"description": "DOI, ISSN, etc."
}
},
"description": "Default Project Metadata",
"dependencies": {}
}
`

export const JsonProjectUI = `
{
"abstract": {
"ui:widget": "textarea"
},
"citation": {
"ui:widget": "textarea"
},
"ui:order": [
"abstract",
"keywords",
"citation",
"publisher",
"identifier"
]
}
`
5 changes: 3 additions & 2 deletions src/forms/utils/getDefaultSchemaList.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { JsonProjectMember, JsonProjectMemberUI } from "src/forms/schema/projectMemberSchema"
import { JsonFunder, JsonFunderUI } from "src/forms/schema/funderSchema"
import { JsonProject, JsonProjectUI } from "src/forms/schema/projectSchema"

export function getDefaultSchemaLists() {
const schemas = [JsonProjectMember, JsonFunder]
const uis = [JsonProjectMemberUI, JsonFunderUI]
const schemas = [JsonProjectMember, JsonFunder, JsonProject]
const uis = [JsonProjectMemberUI, JsonFunderUI, JsonProjectUI]

const restructured = schemas.map((schema, index) => {
const parsed = JSON.parse(schema)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Suspense } from "react"
import { Routes } from "@blitzjs/next"
import Head from "next/head"
import { useRouter } from "next/router"
import { useQuery, useMutation } from "@blitzjs/rpc"
import { useParam } from "@blitzjs/next"
Expand Down
Loading
Loading