- How-to configure the widget
Configuring the widget needs 4 steps:
- configure the table model
- configure the display/edition of fields in the table view
- configure the cards view
- configure the widget (html)
Edit the ictst/model/tools.frictionless-table-schema.json file.
This files defines the name and type of the columns of the CSV. It uses the table schema syntax of Table Schema | Data Package (v1).
We need to define one entry for each column of the CSV.
Mandatory fields are:
- name
- title
- type
Optional fields (not sure that they are used by the widget) are:
- "constraints": "A constraint descriptor (for example to list allowed values)
- "description": "A description for the field"
- "example": "An example value for the field"
- "format": "A string specifying a format"
⚠ Optional fields may not be used by the widget but may be used as documentation.
{
"fields": [
{
"name": "tool_name",
"title": "the name of the tool",
"type": "string",
"constraints": {"minLength":3},
"description": "A long description about the field that is named tool_name",
"example": "Boavizta API",
"format": "A string specifying a format, but not used by the widget"
},
{
"name": "organization",
"title": "the organization behind the tool",
"type": "string"
}
]
}
Use the constraint field.
It does not distinguish between mono or multiple values. This is done later at step 2 when configuring the widget.
{
"fields": [
{
"name": "status",
"type": "string",
"constraints": {
"enum": [
"started",
"ready",
"unknown"
]
}
},
{
"name": "languages",
"type": "string",
"constraints": {
"enum": [
"rust",
"python",
"docker",
"other tek"
]
}
}
]
}
We need to configure how the widget displays and let the user edit the fields in a separate file.
Edit ictst/widget/tools.fields-custom-properties.json
[!NOTE] The configuration of cards view (how content is displayed as cards insted of table is done separately.
{
"fields": [
{
"name": "name",
"sticky": true,
"primaryKey": true,
"maxLength": 50
},
{
"name": "organization"
}
]
}
Use link
as the subtype.
"subtype": "link"
{
"name": "website",
"subtype": "link"
}
Use the tag
vs tags
(plural) to let the widget know if the field accepts multiple values.
In addition to being displayed as a data table, Datami offers a card view of each row.
A card view is displayed as:
- a mini card (just a summary of the fields) that will will shown on a grid
- a detail card (contains more fields and allows to edit the card content)
- Activate the functionality: add a
cardsettings
entry to the widget configuration - Specify which field to display in the mini and detail view.
Example card view settings.
"cardsview": {
"activate": true,
"default": false
},
"cardssettings": {
"mini": {
"tool_name": {
"position": "title"
},
"organization": {
"position": "resume"
},
"website": {
"position": "links"
}
},
"detail": {
"tool_name": {
"position": "title"
},
"organization": {
"position": "resume"
},
"quick_description": {
"position": "resume"
},
"website": {
"position": "links"
},
"environmental_indicator": {
"position": "tags"
}
}
}
During development phase it is tedious to use a separate configuration file or the widget. Because this configuration is declared as a github url in the html, it would involve constantly committing / pushing a change to test it.
💡 An alternative is to write the json configuration inline in the HTML file (see the example in tools-widget-inline-dev.html).
Things that remain to be explained
- Tag vs tags mention how to manage the separator for multiple values
- Configuration of the card view
- Explicit that multiline strings are not easily supported.
- Development flow (how to edit / test step by step)
- Example projet
- Hosting / deployment
- Github PAT configuration
- How to validate in data CI