Demo VisualData 1.0 / Dependent values

Dependent values: Difference between revisions

From Wikisphere
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
The following form uses the schema [[PagePropertiesSchema:Dependent_values]].
The following form uses the schema [[PagePropertiesSchema:Dependent_values]].
{{#pagepropertiesform: Dependent values
|title = Dependent values
|action = create
|edit-page =
|return-page =
|view = inline
|popup-size = medium
|css-class =
|pagename-formula =
|edit-freetext = false
|edit-categories = false
|edit-content-model = false
|default-categories = tasks
|default-content-model = json
|layout-align = top
|popup-help = true
|submit-button-text =
|layout = tabs
|submit-button-text =
|validate-button-text =
}}


The first field (country) is a OOUI DropdownInputWidget with items taken from the template [[Template:Countries]].
The first field (country) is a OOUI DropdownInputWidget with items taken from the template [[Template:Countries]].
Line 18: Line 42:
'''The query searches within a database of 250 wiki pages with content model json as the following [[Data:Countries/Afghanistan]], containing more than 620,000 entries.'''
'''The query searches within a database of 250 wiki pages with content model json as the following [[Data:Countries/Afghanistan]], containing more than 620,000 entries.'''


The database can been created downloading this data [https://github.com/dr5hn/countries-states-cities-database/blob/master/countries%2Bstates%2Bcities.json] from [https://github.com/dr5hn/countries-states-cities-database] and then importing them on your wiki using the following maintenance script:
The database can been created downloading this data [https://github.com/dr5hn/countries-states-cities-database/blob/master/countries%2Bstates%2Bcities.json countries%2Bstates%2Bcities.json] from [https://github.com/dr5hn/countries-states-cities-database github.com/dr5hn/countries-states-cities-database] and then importing them on your wiki using the following maintenance command:


<pre>
<pre>
php extensions/PageProperties/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot
php extensions/PageProperties/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot
</pre>
The script takes only a few minutes to create all the required entries and the data can be rebuild any time through the following command:
<pre>
php extensions/PageProperties/maintenance/RebuildData.php
</pre>
</pre>




This is the wikitext used to create the form itself:
<pre>


{{#pagepropertiesform: Dependent values
{{#pagepropertiesform: Dependent values
Line 47: Line 79:
|validate-button-text =
|validate-button-text =
}}
}}
</pre>

Revision as of 10:44, 5 December 2023

The following form uses the schema PagePropertiesSchema:Dependent_values.


{{#pagepropertiesform: Dependent values |title = Dependent values |action = create |edit-page = |return-page = |view = inline |popup-size = medium |css-class = |pagename-formula = |edit-freetext = false |edit-categories = false |edit-content-model = false |default-categories = tasks |default-content-model = json |layout-align = top |popup-help = true |submit-button-text = |layout = tabs |submit-button-text = |validate-button-text = }}


The first field (country) is a OOUI DropdownInputWidget with items taken from the template Template:Countries.

The second field (state) is a LookupElement with query

[[name::<country>]][[states/name::<value>~]]

where <country> is the name of the first field and <value> is the value being inserted in the input.. The requested printout is states/name that matches the path properties/states/items/properties/name in the schema PagePropertiesSchema:Country. (where only relevant property names are concatenated, leaving aside properties and items that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property name equal to the value of the first field, and value of the property states/name equal to the state input value.

The third field (city) uses this query

[[name::<country>]][[states/name::<state>]][[states/cities/name::<value>~]]

The query as above will search json data related to the schema "Country" with value of the property name equal to the value of the first field, value of the property states/name equal to the second field, and value of the property states/cities/name equal to the city input value. The requested printout in this case is states/cities/name.

The query searches within a database of 250 wiki pages with content model json as the following Data:Countries/Afghanistan, containing more than 620,000 entries.

The database can been created downloading this data countries%2Bstates%2Bcities.json from github.com/dr5hn/countries-states-cities-database and then importing them on your wiki using the following maintenance command:

php extensions/PageProperties/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot

The script takes only a few minutes to create all the required entries and the data can be rebuild any time through the following command:

php extensions/PageProperties/maintenance/RebuildData.php


This is the wikitext used to create the form itself:

{{#pagepropertiesform: Dependent values
|title = Dependent values
|action = create
|edit-page = 
|return-page = 
|view = inline
|popup-size = medium
|css-class =
|pagename-formula = 
|edit-freetext = false
|edit-categories = false
|edit-content-model = false
|default-categories = tasks
|default-content-model = json
|layout-align = top
|popup-help = true 
|submit-button-text =
|layout = tabs
|submit-button-text =
|validate-button-text =
}}