Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ryuliantoro opened this issue May 27, 2022 · 6 comments
Open

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

ryuliantoro opened this issue May 27, 2022 · 6 comments
Labels

Comments

@ryuliantoro
Copy link

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:

  • in the forms there will be dropdown list of related items. How to create this dynamic list?
  • also a dropdown but for a fixed selection like gender, how to make this?
  • for a selection of location, I want user to select a city, then the system will auto-fill the state. How to relate state with city?
  • etc.

Thank you

  • System Designer version number: v5.2.0
  • System Designer platform: macOS
  • Your OS version: macOS 12.3.1
@ecarriou
Copy link
Member

ecarriou commented May 27, 2022

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
Copy link
Author

ryuliantoro commented May 27, 2022 via email

@ecarriou
Copy link
Member

You are welcome.

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

@ecarriou
Copy link
Member

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

@ryuliantoro
Copy link
Author

Where can I find the PWA version?

@ecarriou
Copy link
Member

ecarriou commented Jun 2, 2022

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

Direct links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants