Skip to content

Commit

Permalink
feat: form docs
Browse files Browse the repository at this point in the history
  • Loading branch information
awesthouse committed May 15, 2024
1 parent 5c7370d commit ac4d5f2
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 0 deletions.
74 changes: 74 additions & 0 deletions packages/dm-core-plugins/blueprints/form/docs/Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Form allows user to input and save data.

## Table of contents
- [Selecting form fields](#fields)
- [Using widgets](#using-widgets)
- [Configuring recipe for nested objects](#object-recipes)
- [Available Widgets](#available-widgets)


### Selecting form fields \{#fields}
Pass field names defined in blueprint to fields array.
```json {3}
"config": {
"type": "PLUGINS:dm-core-plugins/form/FormInput",
"fields": ["name", "date_of_birth", "address"]
}
```

### Using widgets \{#using-widgets}
```json {7}
"config": {
"type": "PLUGINS:dm-core-plugins/form/FormInput",
"attributes": [
{
"name": "date_of_birth",
"type": "PLUGINS:dm-core-plugins/form/fields/StringField",
"widget": "DateTimeWidget"
}
],
"fields": ["name", "date_of_birth", "address"]
}
```

### Configuring recipe for nested objects \{#object-recipes}
```json {8}
"config": {
"type": "PLUGINS:dm-core-plugins/form/FormInput",
"attributes": [
{
"name": "address",
"type": "PLUGINS:dm-core-plugins/form/fields/ObjectField",
"showInline": true,
"uiRecipe": "Edit"
}
],
"fields": ["name", "date_of_birth", "address"]
}
```


### Available Widgets \{#available-widgets}
`CheckboxWidget`: [Blueprint](./Blueprints.md#CheckboxWidget)

`TextWidget`: [Blueprint](./Blueprints.md#TextWidget)

`TextareaWidget`: [Blueprint](./Blueprints.md#TextareaWidget)

`BlueprintPickerWidget`: [Blueprint](./Blueprints.md#BlueprintPickerWidget)

`TypeWidget`: [Blueprint](./Blueprints.md#TypeWidget)

`SwitchWidget`: [Blueprint](./Blueprints.md#SwitchWidget)

`SelectWidget`: [Blueprint](./Blueprints.md#SelectWidget)

`NumberWidget`: [Blueprint](./Blueprints.md#NumberWidget)

`DateTimeWidget`: [Blueprint](./Blueprints.md#DateTimeWidget)

`DimensionalScalarWidget`: [Blueprint](./Blueprints.md#DimensionalScalarWidget)

`EntityPickerWidget`: [Blueprint](./Blueprints.md#EntityPickerWidget)

`HyperlinkWidget`: [Blueprint](./Blueprints.md#HyperlinkWidget)
56 changes: 56 additions & 0 deletions packages/dm-core-plugins/blueprints/form/docs/Examples/Basic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"title": "Basic Form",
"description": "Minimal example for use of form plugin",
"note": "",
"showDemo": true,
"entityFilePrefix": "car",
"blueprint": {
"name": "Car",
"type": "CORE:Blueprint",
"description": "",
"attributes": [
{
"name": "type",
"type": "dmss://system/SIMOS/BlueprintAttribute",
"attributeType": "string",
"optional": false
},
{
"name": "name",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Manufacturer"
},
{
"name": "model",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Model"
},
{
"name": "color",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Color",
"optional": true
}
]
},
"entity": {
"type": "./Car",
"_id": "volvo-in-car-list",
"name": "Volvo",
"color": "White",
"model": "XC40"
},
"recipe": {
"name": "car",
"type": "CORE:UiRecipe",
"description": "Car form",
"plugin": "@development-framework/dm-core-plugins/form",
"config": {
"type": "PLUGINS:dm-core-plugins/form/FormInput",
"fields": ["name", "color", "model"]
}
}
}
105 changes: 105 additions & 0 deletions packages/dm-core-plugins/blueprints/form/docs/Examples/Nested.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"title": "Nested Form",
"description": "Nested example for use of form plugin",
"note": "",
"showDemo": false,
"entityFilePrefix": "person",
"blueprint": {
"name": "Person",
"type": "CORE:Blueprint",
"description": "",
"attributes": [
{
"name": "type",
"type": "dmss://system/SIMOS/BlueprintAttribute",
"attributeType": "string",
"optional": false
},
{
"name": "name",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Name"
},
{
"name": "data_of_birth",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Date of birth"
},
{
"name": "address",
"type": "CORE:BlueprintAttribute",
"attributeType": "./Address",
"label": "Address"
}
]
},
"entity": {
"type": "./Person",
"_id": "1179c897-df62-445f-87e4-f393b4253936",
"name": "Joe Biden",
"date_of_birth": "1942-11-20T00:00:00.000+01:00",
"address": {
"street": "1600 Pennsylvania Avenue NW",
"postal_code": "20500",
"city": "Washington DC"
}
},
"recipe": {
"name": "person",
"type": "CORE:UiRecipe",
"description": "Person form",
"plugin": "@development-framework/dm-core-plugins/form",
"config": {
"type": "PLUGINS:dm-core-plugins/form/FormInput",
"attributes": [
{
"name": "date_of_birth",
"type": "PLUGINS:dm-core-plugins/form/fields/StringField",
"widget": "DateTimeWidget"
},
{
"name": "address",
"type": "PLUGINS:dm-core-plugins/form/fields/ObjectField",
"showInline": true,
"uiRecipe": "Edit"
}
],
"fields": ["name", "date_of_birth", "address"]
}
},
"childBlueprints": [
{
"name": "Address",
"type": "CORE:Blueprint",
"description": "",
"attributes": [
{
"name": "type",
"type": "dmss://system/SIMOS/BlueprintAttribute",
"attributeType": "string",
"optional": false
},
{
"name": "street",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Street"
},
{
"name": "postal_code",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Postal code"
},
{
"name": "city",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "City"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"title": "Widget Example",
"description": "Example on how to configure use widget in form recipe",
"note": "",
"showDemo": true,
"entityFilePrefix": "person",
"blueprint": {
"name": "Person",
"type": "CORE:Blueprint",
"description": "",
"attributes": [
{
"name": "type",
"type": "dmss://system/SIMOS/BlueprintAttribute",
"attributeType": "string",
"optional": false
},
{
"name": "name",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Name"
},
{
"name": "date_of_birth",
"type": "CORE:BlueprintAttribute",
"attributeType": "string",
"label": "Date of birth"
}
]
},
"entity": {
"type": "./Person",
"_id": "1179c897-df62-445f-87e4-f393b4253936",
"name": "Joe Biden",
"date_of_birth": "1942-11-20T00:00:00.000+01:00",
"address": {
"street": "1600 Pennsylvania Avenue NW",
"postal_code": "20500",
"city": "Washington DC"
}
},
"recipe": {
"name": "person",
"type": "CORE:UiRecipe",
"description": "Person form",
"plugin": "@development-framework/dm-core-plugins/form",
"config": {
"type": "PLUGINS:dm-core-plugins/form/FormInput",
"attributes": [
{
"name": "date_of_birth",
"type": "PLUGINS:dm-core-plugins/form/fields/StringField",
"widget": "DateTimeWidget"
}
],
"fields": ["name", "date_of_birth"]
}
}
}

0 comments on commit ac4d5f2

Please sign in to comment.