Comments
(Redirected from Demo JsonForms/Comments)
This page demonstrates the following features:
- compounded schemas: the JsonSchema:Comment is a reference within JsonSchema:Comments
- use of nested template using
children(e.g. Template:Comments ) edit_schemaandedit_pathparameters to add/edit items at the current level of the tree (see Template:Comments.comments)- use of parameter
depthto add margin to the content (see Template:Comments.comments.Item.replies) - use of property
x-render-templateto specify a fixed template name for the related subschema. This is necessary for nested items otherwise the processor would require a template for each level (see JsonSchema:Comment) - use of
allOfto override thex-hiddenproperty in the replies subschema from the parent schema. This allows the base schema to edit all data, while the popup forms to keep the replies array hidden. (see JsonSchema:Comments and the notice for more information)
In the JsonSchema:Comment the replies subschema is set to hidden, in order to hide it from the "New comment" and "Add reply" forms, but at the same time to create an empty array with replies in order to allow the template processor to render the related container. |
Schemas:
Templates:
- Template:Comments
- Template:Comments.comments
- Template:Comments.comments.Item
- Template:Comments.comments.Item.replies
Parser function:
{{#jsonformsrender:{{FULLPAGENAME}}
|slot=jsonforms-data
}}
Comments
Template:Comments.comments.Item
Name: a name
Message: a content
Template:Comments.comments.Item.replies
Replies
Template:Comments.comments.Item
Name: a1 name
Message: a1 content
Template:Comments.comments.Item.replies
Replies
loading form
Params
{
"key": "replies",
"properties": "",
"count": 0,
"childrenCount": 0,
"path": "comments.0.replies.0.replies",
"jsonpath": "properties.comments.items.properties.replies.items.properties.replies",
"depth": 5,
"templateName": "Comments.comments.Item.replies",
"data": []
}Params
{
"key": 0,
"properties": "name, content, createdAt, replies",
"count": 4,
"childrenCount": 4,
"path": "comments.0.replies.0",
"jsonpath": "properties.comments.items.properties.replies.items",
"depth": 4,
"templateName": "Template:Comments.comments.Item",
"data": {
"name": "a1 name",
"content": "a1 content",
"createdAt": "",
"replies": []
},
"name": "a1 name",
"content": "a1 content",
"createdAt": "",
"replies": "<subitem>"
}loading form
Params
{
"key": "replies",
"properties": "0",
"count": 1,
"childrenCount": 1,
"path": "comments.0.replies",
"jsonpath": "properties.comments.items.properties.replies",
"depth": 3,
"templateName": "Comments.comments.Item.replies",
"data": [
{
"name": "a1 name",
"content": "a1 content",
"createdAt": "",
"replies": []
}
],
"0": "<subitem>"
}Params
{
"key": 0,
"properties": "name, content, createdAt, replies",
"count": 4,
"childrenCount": 4,
"path": "comments.0",
"jsonpath": "properties.comments.items",
"depth": 2,
"templateName": "Template:Comments.comments.Item",
"data": {
"name": "a name",
"content": "a content",
"createdAt": "",
"replies": [
{
"name": "a1 name",
"content": "a1 content",
"createdAt": "",
"replies": []
}
]
},
"name": "a name",
"content": "a content",
"createdAt": "",
"replies": "<subitem>"
}
loading form
Params
{
"key": "comments",
"properties": "0",
"count": 1,
"childrenCount": 1,
"path": "comments",
"jsonpath": "properties.comments",
"depth": 1,
"templateName": "Template:Comments.comments",
"data": [
{
"name": "a name",
"content": "a content",
"createdAt": "",
"replies": [
{
"name": "a1 name",
"content": "a1 content",
"createdAt": "",
"replies": []
}
]
}
],
"0": "<subitem>"
}Params
{
"key": "",
"properties": "comments",
"count": 1,
"childrenCount": 1,
"path": "",
"jsonpath": null,
"depth": 0,
"templateName": "Template:Comments",
"data": {
"comments": [
{
"name": "a name",
"content": "a content",
"createdAt": "",
"replies": [
{
"name": "a1 name",
"content": "a1 content",
"createdAt": "",
"replies": []
}
]
}
]
},
"comments": "<subitem>"
}
The following form is rendered with this parser function:
{{#jsonforms:Default
|schema=Comments
|editor_options.debug=true
|view=inline
|title=comments
|edit={{FULLPAGENAME}}
|width=800px
}}
(it's not necessary for the purpose of this demo, and the article's data can usually be edited using the action "Edit schema")
loading form
See also
- Demo JsonForms
- Comments
- ConditionFlow
- Captcha
- Contact Form
- Survey
- Text editors
- SMW Ask query builder
- Wikispeech
- Interactive demos
- Interactive JSON-Schema-Test-Suite
- Form Builder (requires permissions)
- Schema Builder (requires permissions)