premieroctet / next-admin Goto Github PK
View Code? Open in Web Editor NEW▲ Full-featured admin for Next.js and Prisma
Home Page: https://next-admin.js.org
License: MIT License
▲ Full-featured admin for Next.js and Prisma
Home Page: https://next-admin.js.org
License: MIT License
A user should be able to use a JSON field
from Prisma : https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields
Possibility of using some html editor library (Rich text editor) in fields configuration
It seems the package is published without dist 😨
Add the possibility of adding a function to fields in the options for formatting columns:
model: {
user: {
list: {
fields: {
id: {
formatColumn: (id) => id
}
}
}
}
}
The function must be typed, using the field type
In the case of a Date
property, give the field option to choose between date
, date-time
or time
in the field options.
For the moment we are using the model name "as it" in the url :
model User {
id Int @id @default(autoincrement())
}
Returns: https://next-admin-po.vercel.app/admin/User
You'd have to use a slugified version in lowercase :
Include the possibility of overriding inputs, for example if you just want to display the date instead of a disabled input, or an image instead of a text field... etc.
const options : NextAdminOptions = {
modelOptions : {
user : {
toString : (user : User) => `${user.name} (${user.email})`,
list : {
fields : {
id : {
search : true,
},
name : {
search : true,
},
email : {
search : true,
},
role : {},
createdAt : {
formatter : (createdAt) => user.createdAt.toLocaleDateString(),
}
}
},
edit : {
fields : {
createdAt : {
input : (createdAt) => {
return <input type="date" value={ createdAt.toString() } />
}
}
}
}
},
}
} ;
Today there is no server side validation except for Prisma exception that can get thrown when saving the data (for example when saving an incorrect type or a mandatory column).
This is not enough and the library should provide a way to add validation for a specific fields, for example if we want to validate an email.
import { z } from "zod";
const options: NextAdminOptions = {
model: {
user: {
list: {
fields: {
email: {
search: true,
display: true,
validate: email => z.string().email().parse(email),
}
}
}
}
}
};
Errors should be displayed under each invalid fields.
But I'm not sure how.
Linked to ticket #14
Provide for relationships to be able to format the linked object, not just the id.
In One-to-Many relationships, the side carrying the relationship doesn't need to display the link (usually the id) but the object, so that it can be formatted.
The type of the formatColumn function must be overloaded to tolerate objects of type Collection
.
Delete the fields carrying the relationship to display only the relationship to the object
In the example :
model Post {
author User @relation("author", fields: [authorId], references: [id])
authorId Int
}
Remove from the json-schema
the authorId field for the formatted version of the author object, if there is no formatting function return only the id
Explore the possibility of Prisma extensions: https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions/model#example. This would avoid having to modify the schema manually
For the moment, the table identification field is fixed at id
Add the option of naming the identification field (@id
in the Prisma schema) by another name
We display the name of the model "as it" in the left-hand menu and in the section titles. The user should be able to override this title with a string (like "Utilisateurs") in the model config:
We can use a title
field
A user should be able to use a file input, handle upload and return a blob or file to save in the form.
Currently we use a constant to determine base path, this should be either automatic if possible or an option to pass to the library.
Based on the template field system, add the ability to hide templates:
Note that if the user wants to display a template without making a configuration, he can enter the template as follows:
session: {}
Given the following model config
User: {
toString: (user) => user.name!,
list: {
fields: {
name: {
search: true,
display: true,
},
team: {
search: true,
display: true,
},
accounts: {
display: true,
},
},
},
},
Clicking on a row in the users list should navigate to the user edition form
Navigation leads to an error as is navigates to an undefined
id. The URL we navigate to is http://localhost:3000/admin/User/undefined
.
Adding id
in the fields list fixes the issue
Is there a way to translate the terms used in the GUI?
React Json Schema for input for date-time
use datetime-locale
type input, so data stored from this input is locale
Sort relationship columns based on count
Given the following list fields config
list: {
fields: {
id: {
search: true,
display: true,
},
name: {
search: true,
display: true,
},
team: {
search: true,
display: true,
},
accounts: {
display: true,
},
},
},
The list page is correctly working, however it is giving a Prisma error because it tries to count team
, which is a One-to-Many relation, therefore not possible to apply a count on it.
The One-to-Many relation should simply be ignored, eventually a warning should pop in dev environment. But it should be removed from the select statement for the count.
Given the following edit configuration:
edit: {
fields: {
id: {
display: false,
},
email: {
display: false,
},
name: {
display: false,
},
},
},
Accessing the ressource edit form makes the app crash with a Prisma error because the select statement is empty
Accessing the ressource edit form should not crash and we should see at least one field, for example the id
Setting up compatibility for the App Router
Currently we don't have any feedback on page navigation.
Currently the release process is a bit messy, since merging a PR on main
triggers a deploy on the production documentation and example.
The idea would be the following:
main
, we deploy the example and documentation in a beta
environmentmain
, we deploy the example and documentation in the production environmentA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.