dwyl / abase

:house: A (solid) Base for your Web Application.
9 stars 0 forks source link

json config files #59

Open SimonLab opened 7 years ago

SimonLab commented 7 years ago

At the moment it seems that we need three config files:

["string", "integer", "email", "password",...]

These types are mapped to their html rendering tags This file is private and only used by the abase plugin itself so it should be defined inside the plugin

{
  "email": {"type": "email"},
  "password": {"type": "password"},
  "username": {"type": "string"},
  ...
}

This file is public and should be accessible by the user of the abase plugin like this she can add/remove fields of the user schema.

{
    "register": {
      "path": "/signup",
      "type": "signup",
      "method": [
        "GET",
        "POST"
      ],
      "fields": [
        {
          "field": "email",
          "type": "id",
          "attributes": {
            "name": "email",
            "label": "Email: "
          }
        },
        {
          "field": "password",
          "type": "password",
          "attributes": {
            "name": "password",
            "label": "Password: "
          }
        }
      ]
    },
    "login": {
      "path": "/login",
      "type": "login",
      "method": [
        "GET",
        "POST"
      ],
      "fields": [
        {
          "field": "email",
          "type": "id",
          "attributes": {
            "name": "email",
            "label": "Email: "
          }
        },
        {
          "field": "password",
          "type": "password",
          "attributes": {
            "name": "password",
            "label": "Password: "
          }
        }
      ]
    },
...
}

This file is also public and the user of the plugin can edit it.

So when the plugin is loaded for the first time it should:

@eliascodes @shouston3 @jrans @nelsonic does this sound good for you? If yes I'm going to add the load page config feature (see issue #60 ). This means also that the user will need to pass in the option of the plugin the path of this page config file.

eliasmalik commented 7 years ago

@SimonLab I think in an ideal world, we would like the user to have to do as little configuring as possible.

Do we need the user to define the mapping between field data-types and HTML form elements? I think we can just define that mapping in the plugin.

WRT the pages JSON file, again, if there are going to just be a few default routes to allow the consumer of the app to manage the users and have an authentication system, then it doesn't seem like we need to specify that in a public-facing JSON file that the user has to worry about; it would be simpler to keep it internal to the plugin. Take a look at #68 and #50 to see my thoughts on this.

If we want to support the case where the consumer of the plugin wants to define a custom view which displays user data, then a pages JSON file for those additional views does make sense.

SimonLab commented 7 years ago

We've started to abstract the features a bit too early and the goal of defining the pages into a json file was to let the users define new pages and define which fields to display on these pages, but agree keep it simple for now and let see if we will need to implement this feature later on.