diff --git a/packages/dm-core-plugins/blueprints/form/docs/Documentation.md b/packages/dm-core-plugins/blueprints/form/docs/Documentation.md new file mode 100644 index 000000000..590e66ad8 --- /dev/null +++ b/packages/dm-core-plugins/blueprints/form/docs/Documentation.md @@ -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) \ No newline at end of file diff --git a/packages/dm-core-plugins/blueprints/form/docs/Examples/Basic.json b/packages/dm-core-plugins/blueprints/form/docs/Examples/Basic.json new file mode 100644 index 000000000..49bc3623b --- /dev/null +++ b/packages/dm-core-plugins/blueprints/form/docs/Examples/Basic.json @@ -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"] + } + } +} diff --git a/packages/dm-core-plugins/blueprints/form/docs/Examples/Nested.json b/packages/dm-core-plugins/blueprints/form/docs/Examples/Nested.json new file mode 100644 index 000000000..c664e200e --- /dev/null +++ b/packages/dm-core-plugins/blueprints/form/docs/Examples/Nested.json @@ -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" + } + ] + } + ] +} diff --git a/packages/dm-core-plugins/blueprints/form/docs/Examples/WidgetExample.json b/packages/dm-core-plugins/blueprints/form/docs/Examples/WidgetExample.json new file mode 100644 index 000000000..33c7c68a3 --- /dev/null +++ b/packages/dm-core-plugins/blueprints/form/docs/Examples/WidgetExample.json @@ -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"] + } + } +}