Preload data with nested and multiple values: Difference between revisions
Jump to navigation
Jump to search
(Created page with "This example shows an concept, how to handle the VisualData form parameter 'preload-data' with nested and multiple values. <syntaxhighlight lang="wikitext"> {{#visualdataform: Dataset |title = {{int:webmo-add-dataset}} |action = create |return-page = {{FULLPAGENAME}} |view = popup |popup-size = larger |css-class = form-dataset |pagename-formula = <unique title> |edit-freetext = false |edit-categories = false |edit-content-model = false |edit-target-slot = false |target-...") Tag: 2017 source edit |
(VisualData update) |
||
(25 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This example shows | == Syntax == | ||
This example shows a concept, how to handle the VisualData form parameter 'preload-data' with nested and multiple values. This makes it possible to generate dynamical forms, e.g. to collect data differentiated by district, gender and age categories: | |||
<syntaxhighlight lang="wikitext"> | <syntaxhighlight lang="wikitext"> | ||
... | |||
|preload-data?classes/$/class name = District 1@@@@District 2@@@@District 3 | |||
|preload-data?classes/$/sub-classes/$/sub-class name = female@@@@male@@@@diverse | |||
|preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = 0 - 14@@@@15 - 29@@@@30 - 44@@@@45 - 59@@@@60 + | |||
... | |||
</syntaxhighlight> | |||
Notice the placeholder <code>$</code> and the value separator <code>@@@@</code>. The value separator can be set in VisualData queries, see below. | |||
{{#visualdataform: Dataset | {{#visualdataform: Dataset | ||
|title = {{int:webmo-add-dataset}} | |title = {{int:webmo-add-dataset}} | ||
Line 17: | Line 27: | ||
|default-content-model = json | |default-content-model = json | ||
|preload-data?belongs to = {{PAGEID}} | |preload-data?belongs to = {{PAGEID}} | ||
|preload-data?classes/$/class name = | |preload-data?classes/$/class name = District 1@@@@District 2@@@@District 3 | ||
|preload-data?classes/$/sub-classes/$/sub-class name = | |preload-data?classes/$/sub-classes/$/sub-class name = female@@@@male@@@@diverse | ||
|preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = | |preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = 0 - 14@@@@15 - 29@@@@30 - 44@@@@45 - 59@@@@60 + | ||
}} | }} | ||
See corresponding form [[VisualDataSchema:Data_classes|Data Classes]] | |||
(For styling see [[MediaWiki:Common.css]]) | |||
== Workflow example == | |||
=== Step 1: Define one or more statistical class sets === | |||
{{#visualdataform: Data classes | {{#visualdataform: Data classes | ||
|title = | |title = Create class set | ||
|action = create | |action = create | ||
|return-page = {{FULLPAGENAME}} | |return-page = {{FULLPAGENAME}} | ||
|view = popup | |view = popup | ||
Line 89: | Line 54: | ||
|default-categories = classes | |default-categories = classes | ||
|default-content-model = json | |default-content-model = json | ||
| | |preload-data?belongs to = {{PAGEID}} | ||
}} | }} | ||
[{{canonicalurl:Help:Available_data_classes}} See | [{{canonicalurl:Help:Available_data_classes}} See available class sets] | ||
=== Step 2: Attach class sets to this page === | |||
{{#visualdataform: Page classes | |||
{{#visualdataform: | |title = Add class sets to page | ||
|title = | |action = edit | ||
|action = | |edit-page = {{FULLPAGENAME}} | ||
|edit-page = | |||
|return-page = {{FULLPAGENAME}} | |return-page = {{FULLPAGENAME}} | ||
|view = popup | |view = popup | ||
|popup-size = | |popup-size = larger | ||
|css-class = | |css-class = | ||
|edit-freetext = false | |edit-freetext = false | ||
|edit-categories = false | |edit-categories = false | ||
|edit-content-model = false | |edit-content-model = false | ||
|edit-target-slot = false | |edit-target-slot = false | ||
|layout-align = top | |layout-align = top | ||
}} | }} | ||
< | === Step 3: Add datasets to this page === | ||
<syntaxhighlight lang="wikitext"> | |||
... | |||
|preload-data?classes/$/class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}} | |||
|preload-data?classes/$/sub-classes/$/sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}} | |||
|preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-sub-classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}} | |||
... | |||
</syntaxhighlight> | |||
{{#visualdataform: Dataset | {{#visualdataform: Dataset | ||
|title = {{int:webmo-add-dataset}} | |title = {{int:webmo-add-dataset}} | ||
|action = create | |action = create | ||
|return-page = {{FULLPAGENAME}} | |return-page = {{FULLPAGENAME}} | ||
|view = popup | |view = popup | ||
|popup-size = | |popup-size = larger | ||
|css-class = form-dataset | |css-class = form-dataset | ||
|pagename-formula = <unique title> | |pagename-formula = <unique title> | ||
Line 202: | Line 100: | ||
|edit-target-slot = false | |edit-target-slot = false | ||
|target-slot = main | |target-slot = main | ||
|default-content-model = json | |||
|preload-data?belongs to = {{PAGEID}} | |preload-data?belongs to = {{PAGEID}} | ||
|preload-data?classes/$/class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?classes|schema = | |preload-data?classes/$/class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}} | ||
|preload-data?classes/$/sub-classes/$/sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-classes|schema = | |preload-data?classes/$/sub-classes/$/sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}} | ||
|preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-sub-classes|schema = | |preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-sub-classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}} | ||
}} | }} | ||
jsondata | |||
---|---|---|---|
Line 1: | Line 1: | ||
{} | { | ||
"schemas": { | |||
"Page classes": { | |||
"classes": "594", | |||
"add sub-classes": "true", | |||
"sub-classes": "596", | |||
"add sub-sub-classes": "true", | |||
"sub-sub-classes": "535" | |||
} | |||
} | |||
} |
Latest revision as of 06:30, 16 May 2024
Syntax[edit | edit source]
This example shows a concept, how to handle the VisualData form parameter 'preload-data' with nested and multiple values. This makes it possible to generate dynamical forms, e.g. to collect data differentiated by district, gender and age categories:
...
|preload-data?classes/$/class name = District 1@@@@District 2@@@@District 3
|preload-data?classes/$/sub-classes/$/sub-class name = female@@@@male@@@@diverse
|preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = 0 - 14@@@@15 - 29@@@@30 - 44@@@@45 - 59@@@@60 +
...
Notice the placeholder $
and the value separator @@@@
. The value separator can be set in VisualData queries, see below.
Required json-diff library is not installed. Run composer in the extension folder to enable preload-data
form is loading...
See corresponding form Data Classes
(For styling see MediaWiki:Common.css)
Workflow example[edit | edit source]
Step 1: Define one or more statistical class sets[edit | edit source]
Required json-diff library is not installed. Run composer in the extension folder to enable preload-data
form is loading...
Step 2: Attach class sets to this page[edit | edit source]
form is loading...
Step 3: Add datasets to this page[edit | edit source]
...
|preload-data?classes/$/class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}}
|preload-data?classes/$/sub-classes/$/sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}}
|preload-data?classes/$/sub-classes/$/sub-sub-classes/$/sub-sub-class name = {{#visualdataprint:{{#visualdataprint:{{PAGEID}}|?sub-sub-classes|schema = Page classes|format = raw}}|?class names|schema = Data classes|format = raw|values-separator = @@@@}}
...
Required json-diff library is not installed. Run composer in the extension folder to enable preload-data
form is loading...