design-first / system-designer

A low-code development platform for creating systems πŸ‡ΊπŸ‡¦#standwithUkraine
https://designfirst.io/systemdesigner/
Apache License 2.0
930 stars 136 forks source link

Where can I see the description of types and schema key:value? #146

Open ryuliantoro opened 2 years ago

ryuliantoro commented 2 years ago

Hi @ecarriou,

I learn how to use System Designer to design the database and relationship between forms. And I got confused by the various options for types and schema key:value. Where can I get a description of each options? From there I hope to be able to understand more about how to use System Designer. Or if there are more example of how the things work.

Example of things I want to do:

Thank you

ecarriou commented 2 years ago

Hello,

Did you check first the documentation for creating schemas, models and types ?

If you want a description of the properties you can have a look in the MSON core definition files of System Runtime. For example, here is the description of a type schema:

{
  "_id": {
    "type": "string",
    "mandatory": true
  },
  "name": {
    "type": "string",
    "mandatory": true
  },
  "type": {
    "type": "string",
    "mandatory": true
  },
  "schema": {
    "type": "object",
    "mandatory": false
  },
  "value": {
    "type": ["any"],
    "mandatory": false
  },
  "core": {
    "type": "boolean",
    "mandatory": false
  },
  "description": {
    "type": "string",
    "mandatory": false
  }
}

For information there are also many checks done on save to help you to write valid schemas.

About your questions, there is not only one way to do what you want but here some tips.

If you have for example this definition for this new type:

{
  "_id": "d82472ce-3034-4bd2-ad55-ad25eb04c09c",
  "name": "eyeColor",
  "description": "eye colors",
  "type": "string",
  "value": ["blue", "green", "maroon", "other"]
}

and this model:

{
  "_id": "bdce6d04-d68f-4c2a-b36a-565ff06d3cb9",
  "_name": "Person",
  "_description": "",
  "eyeColor": {
    "description": "",
    "type": "eyeColor",
    "readOnly": false,
    "mandatory": false,
    "default": "maroon"
  }
}

To get the list of values to fill a dropdown where you can select an eye color:

// in a behavior you can require the Datastore to get the type definition
const db = this.require('db')
const eyeColorDefinition = db.collections()._Type.find({name: 'eyeColor'})[0]
const values = eyeColorDefinition.value

When a value is selected in the dropdown you can update the component:

this.require('id_of_the_component').eyeColor('blue')

Also remember that you can export your system and use it in any JS Framework. For example you can define your UI with React, import your system and then use create/edit/delete components.

Is that answer to your questions ?

ryuliantoro commented 2 years ago

Hello,

Thank you for your long and quick response. πŸ‘

I will try your suggestions and see if I can find my way using your guidance.

If there is any more issues I will come back to you.

Cheers,

β€”β€”β€”β€”β€” This electronic message contains information which maybe privileged or confidential. The information is for the use of the intended individuals or entities only. Any unauthorized disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify the sender by telephone or email immediately and destroy all copies of the message. β€”β€”β€”β€”β€”

On 27 May 2022, at 20.57, Erwan Carriou @.***> wrote:

ο»Ώ Hello,

Did you check first the documentation for creating schemas, models and types ?

If you want a description of the properties you can have a look in the MSON core definition files of System Runtime. For example, here is the description of a type schema:

{ "_id": { "type": "string", "mandatory": true }, "name": { "type": "string", "mandatory": true }, "type": { "type": "string", "mandatory": true }, "schema": { "type": "object", "mandatory": false }, "value": { "type": ["any"], "mandatory": false }, "core": { "type": "boolean", "mandatory": false }, "description": { "type": "string", "mandatory": false } } For information there are also many checks done on save to help you to write valid schemas.

About your questions, there is not only one way to do what you want but here some tips:

if you have for example this definition for this new type: { "_id": "d82472ce-3034-4bd2-ad55-ad25eb04c09c", "name": "eyeColor", "description": "eye Color", "type": "string", "value": ["blue", "green", "maroon", "other"] } and this model for a component:

{ "_id": "bdce6d04-d68f-4c2a-b36a-565ff06d3cb9", "_name": "Person", "_description": "", "eyeColor": { "description": "", "type": "eyeColor", "readOnly": false, "mandatory": false, "default": "maroon" } } To get the list of values to fill a dropdown where you can select an eye color:

// in a behavior you can require the Datastore to get the type definition const db = this.require('db') const eyeColor = db.collections()._Type.find({name: 'eyeColor'})[0] const values = eyeColor.value You can set a type to a component:

this.require('id_of_the_component').eyeColor('blue') Also remember that you can export your system and use it in any JS Framework. For example you can define your UI with React, import your system and then use create/edit/delete components.

Is that answer to your questions ?

β€” Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

ecarriou commented 2 years ago

You are welcome.

Do not hesitate, if something is not clear I will update the documentation.

ecarriou commented 2 years ago

For information I have just updated documentation for creating schemas, models and types.

ryuliantoro commented 2 years ago

Where can I find the PWA version?

ecarriou commented 2 years ago

You have just to click on Try it online button on https://designfirst.io/systemdesigner/ .

Direct links: