Giter Club home page Giter Club logo

next-admin's People

Contributors

colin27091 avatar foyarash avatar github-actions[bot] avatar shinework avatar tlenclos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

next-admin's Issues

Html editor fields

Possibility of using some html editor library (Rich text editor) in fields configuration

Columns can be formatted

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

Include the possibility of overriding inputs

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() } />
              }
            }
          }
        }
      },
    }
  } ;

Data validation

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.

Proposed API

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.

Formatting relationships in columns

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

File upload

A user should be able to use a file input, handle upload and return a blob or file to save in the form.

Dynamic admin base path

Currently we use a constant to determine base path, this should be either automatic if possible or an option to pass to the library.

Hide models

Based on the template field system, add the ability to hide templates:

  • If no configuration is present, show all models
  • If there is a configuration about a template, show only configured templates

Note that if the user wants to display a template without making a configuration, he can enter the template as follows:
session: {}

ID field mandatory in fields list configuration

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,
            },
          },
        },
      },

Expected behavior

Clicking on a row in the users list should navigate to the user edition form

Current behavior

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

Translation

Is there a way to translate the terms used in the GUI?

One to many relations should be ignored in lists

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,
            },
          },
        },

Current behavior

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.

Expected behavior

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.

Edit page crash if no field in set for display

Given the following edit configuration:

edit: {
          fields: {
            id: {
              display: false,
            },
            email: {
              display: false,
            },
            name: {
              display: false,
            },
          },
        },

Current behavior

Accessing the ressource edit form makes the app crash with a Prisma error because the select statement is empty

Expected behavior

Accessing the ressource edit form should not crash and we should see at least one field, for example the id

Improve the release process

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:

  • when merging a non-release PR on main, we deploy the example and documentation in a beta environment
  • when merging a release PR on main, we deploy the example and documentation in the production environment

Custom pages

Add the possibility to add pages to the menu and assign components to them.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.