Extension talk:VisualData

Add topic
From mediawiki.org
Latest comment: 12 days ago by Osnard in topic MediaWiki version compatibility

Uncaught TypeError: mw.widgets.TitleInputWidget is not a constructor[edit]

Hi,

I really like the approach of the extension - thanks for that!

When trying to add a new field to schema definition, I get the following error: Uncaught TypeError: mw.widgets.TitleInputWidget is not a constructor.

The widget popup does not appear. Other widgets like Add content block, add subtiem and Add geolocation work.

Tested with a fresh installation of MW1.39 and MW1.41 and latest master branch of the extension.

Thanks for support! Filburt (talk) 09:34, 22 February 2024 (UTC)Reply

Ok, I may have found the error: In the file /resources/VisualDataFormField.js in line 204 it must be instead of:
var wikilistInput = new mw.widgets.TitleInputWidget( { 
as follows:
var wikilistInput = new OO.ui.TextInputWidget( { 
Hope, it helps... Filburt (talk) 11:12, 22 February 2024 (UTC)Reply
hello @Filburt I'm not sure I can reproduce, here https://wikisphere.org/wiki/Main_Page there is a similar installation and the mw.widgets.TitleInputWidget works as well Thomas-topway-it (talk) 18:54, 22 February 2024 (UTC)Reply
can you try to add "mediawiki.widgets" to the dependencies of ext.VisualData.Common or ext.VisualData.ManageSchemas ? (extension.json) -- It's possible on my install is loaded in some other way but should indeed be required Thomas-topway-it (talk) 20:25, 22 February 2024 (UTC)Reply
Thanks for the quick reply! Adding the mediawiki.widgets as a dependency of ext.VisualData.Common works.
I had also thought in the direction that it is somehow loaded differently. Filburt (talk) 08:25, 23 February 2024 (UTC)Reply

API Error when trying to delete a schema[edit]

Hi,

I have another question: When clicking - Manage Schema > XYZ > Delete - I get the following API call error:

visualdata-save-schema internal_api_error_Error VisualDataSchemas.js:699:17

   callApi VisualDataSchemas.js:699

   jQuery 31

   xhr index.js:292

   jQuery 6

   ajax index.js:270

   post index.js:154

   postWithToken index.js:352

Any idea? Thanks for support! Filburt (talk) 15:45, 23 February 2024 (UTC)Reply

can you please post the server side debug ? (using $wgDebugLogFile and then retrieving the related error ) thank you Thomas-topway-it (talk) 20:43, 23 February 2024 (UTC)Reply
no need to post it, I can reproduce, I will back shortly Thomas-topway-it (talk) 20:47, 23 February 2024 (UTC)Reply
just updated to the last version Extension:VisualData/Release notes Thomas-topway-it (talk) 11:29, 24 February 2024 (UTC)Reply
Thanks a lot for the great support - it works correctly! Filburt (talk) 15:20, 24 February 2024 (UTC)Reply

Features[edit]

Hi again,

I'm diving deeper into VisualData and have two questions:

1. is it possible to generate the page title from another field and

2. can individual fields be prefilled via the form call?

Thanks a lot! Filburt (talk) 17:50, 12 March 2024 (UTC)Reply

hello Filburt:
1) you can use a pagename formula Extension:VisualData/Forms
2) you can use preload-data Extension:VisualData/Forms or the default value for specific fields Thomas-topway-it (talk) 09:44, 13 March 2024 (UTC)Reply
Thanks for the quick reply!
1. This works this way: pagename-formula = <fieldname> - great!
2. What would be the syntax to fill a single field with preload-data? (I was only able to load a complete JSON-dataset)
Thank you! Filburt (talk) 10:43, 13 March 2024 (UTC)Reply
@Filburt with preload data I think you cannot fill a single field, unless you don't leave the other fields as null values but I should test. I was also thinking to add an option to update the article title if it depends by a field on subsequent edits of the form, since for now it only works on creation. In case let me know if you have a use-case for that Thomas-topway-it (talk) 08:42, 16 March 2024 (UTC)Reply
for the single field the default value does not work ? Thomas-topway-it (talk) 08:44, 16 March 2024 (UTC)Reply
Hello Thomas,
My use case is a tree structure where I need the option to add a new child element in each level. To do this, I need to tell the child elements what their parent element is. The tree structure is displayed using nested templates, something like this:
Level x
|- Level x.x
|  |  |- Level x.x.x
|  |  + Add item x.x.x
|- Level x.x
|  |  |- Level x.x.x
|  |  |- Level x.x.x
|  |  + Add item x.x.x
|  + Add item x.x
|- Level x.x
|  |  + Add item x.x.x
|  + Add item x.x
+ Add item x
Ideally, I could add something like 'belongs_to' and then a template parameter like {{{parent-level-field}}}, i.e. the value of a field from VisualData that is queried in the higher-level template.
I have already considered how it could be best implemented syntactically, perhaps by extending the preload parameter - similar to the template parameter in the queries:
|preload?visualdatafieldname = xyz or |preload <visualdatafieldname> = xyz
in my case:
|preload?belongs to = {{{parent-level-field}}} or |preload <belongs to> = {{{parent-level-field}}}
Many thanks & best regards Filburt (talk) 11:02, 16 March 2024 (UTC)Reply
interesting. Do you have an online demo or can you try to reproduce a partially working version on https://wikisphere.org/wiki/Main_Page to evaluate it better ? Thomas-topway-it (talk) 09:37, 17 March 2024 (UTC)Reply
Hi Thomas,
I have added a more general example here:
https://wikisphere.org/wiki/User:Filburt/Nested_Schemas_and_Templates_Example
In this example there are the three different levels School district, School and School class. In the output there is a button below each level to add new items.
In order for these elements to be automatically assigned to the right place in the tree, I would have to give them the parent item, which would have to be preselected in the 'Belongs to' field. Therefore, it would be useful if the template paramter {{{name}}} could be added as parameter to the form button.
Unfortunately, it does not work if I set {{{name}}} as the default value directly in the form, as the context of the template is missing.
(Probably the cache has to be cleared to see new items)
I hope the example is understandable.
Many thanks! Filburt (talk) 13:17, 18 March 2024 (UTC)Reply
interesting. Thank you for the demo. I think it is unrelated to this, however for your information yesterday I've added another feature Extension:VisualData/QueryLink parser function -- I will document it better.
Regarding your demo, yes, if the data has to be retrieved from the template the preload-data with a syntax as suggested by you seems the only way. I will send an update about this as soon as possible Thomas-topway-it (talk) 17:02, 18 March 2024 (UTC)Reply
also, this is interesting because it combines different schemas, however, this can be also managed by a unique schema with subitems, (subitems can be also arrays, so the tree can be implemented) have you also tried this path ? Thomas-topway-it (talk) 17:22, 18 March 2024 (UTC)Reply
Yes, I was thinking in that direction, but it would make the form very long and complex, maybe the partial editing of schemas mentioned in your roadmap will be a solution in the future... Filburt (talk) 17:37, 18 March 2024 (UTC)Reply
done https://wikisphere.org/wiki/User:Filburt/Nested_Schemas_and_Templates_Example
already published as last version Thomas-topway-it (talk) 09:11, 19 March 2024 (UTC)Reply
it requires to run composer install in the extension folder Thomas-topway-it (talk) 09:13, 19 March 2024 (UTC)Reply
Hi Thomas,
Thanks a lot - it works!
At the moment I try to figure out the following:
I prefill preload-data?belongs_to = {{{articleid}}}. In the related form I don't want to show the articleid but the related title. I tried to use the DropdownInputWidget and to build a query for the Options label formula as follows (but it doesn't work):
{{#visualdataquery: [[belongs_to::<value>]] |?title |schema=Test |format=raw }}
Any idea?
Thank you! Filburt (talk) 17:40, 20 March 2024 (UTC)Reply
first can you check if "belongs_to" with underscore is correct ? (in your example there is just space). <value> in any case should be filled with the value from the input, so if the value from the input is retrieved from the template, it should work. Could I also post somewhere else your use-case (i.e. the page you have created on wikisphere) to which other users may be interested ? thank you Thomas-topway-it (talk) 07:01, 21 March 2024 (UTC)Reply
and also "belongs to" currently takes the title, not the article id Thomas-topway-it (talk) 07:08, 21 March 2024 (UTC)Reply
Hi Thomas,
I have updated my example on Wikisphere (https://wikisphere.org/wiki/User:Filburt/Nested_Schemas_and_Templates_Example). The 'belongs to' field now works with IDs. Now I'm trying to display the name of the parent element as a label in a DropdownInputWidget in the form instead of the ID - see schemas for School and School class.
Another problem I encountered: I also use URL parameters, which I read out with {{#urlget:...}}. However, return-page does not work with URL parameters at the moment.
Thanks a lot! Filburt (talk) 16:00, 21 March 2024 (UTC)Reply
hello, I have added the support for the query in return-page. https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/VisualData/+archive/14f6d9bda6e3cdc9ed14ed560d58bf36f7623502.tar.gz -- I'm not sure why you want to have the dropdown pageid => page title, shouldn't remain hidden ? However the following query does not work:
{{#visualdataquery:[[articleid::<value>]]|?name|schema=School district|format=raw}}
but the following should work
{{#visualdataprint:<value>|?name|schema=School district|format=raw}} Thomas-topway-it (talk) 06:41, 22 March 2024 (UTC)Reply
Hi, the idea behind is to have the possibility to clone items and attach them to other parents.
Unfortunately, the query is still not working for me. The articleid does not seem to appear as <value> in the DropdownInputWidget. Thank you! Filburt (talk) 14:18, 22 March 2024 (UTC)Reply
can you try now ? https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/VisualData/+archive/5391fc64fe4376b2f1d68ef288d224395d49f6e7.tar.gz
added <articleid> in all query results and updated dialog messages at this regards, now are more clear. There was also a typo that prevented options-label-formula to work Thomas-topway-it (talk) 22:45, 22 March 2024 (UTC)Reply
Hi, thanks for the changes! I think we almost have it. However, at the moment I get the error message 'must be equal to one of the allowed values' when I try to save a new item (i.e. add a new school). I already tried to add the <articleid> as default value, but that didn't work. Thanks! Filburt (talk) 14:14, 25 March 2024 (UTC)Reply
@Filburt I've done https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=VisualData&extdistversion=master -- however can you check that it works correctly ? thank you Thomas-topway-it (talk) 09:16, 30 March 2024 (UTC)Reply
regarding <articleid> it does not work as default value, only in input options Thomas-topway-it (talk) 09:21, 30 March 2024 (UTC)Reply
Super - now it works correctly - Thanks a lot! Filburt (talk) 19:50, 3 April 2024 (UTC)Reply

General thoughts on the preload parameter[edit]

Hi Thomas, I have been thinking about the following: Currently, when using the preload parameter in the form definition, the complete wikitext of the specified page is rendered into the page that is generated by VisualData. Wouldn't it make more sense to specify a template at this point? In other words, the free text of the generated page would only contain {{My template}} and this template could then contain a visualprint statement, for example. In this way, all pages generated with a specific form could be modified at once (e.g. for layout reasons).

To do this, the raw string specified in the preload parameter, e.g. |preload = {{My template}}, would simply have to be inserted into the new page (without searching for a corresponding page title or being rendered).

What do you think? Thank you!

Filburt (talk) 16:13, 4 April 2024 (UTC)Reply

hi @Filburt first -- are you able to setup a working version of your workflow here https://wikisphere.org/wiki/User:Filburt/Nested_Schemas_and_Templates_Example as you did at the beginning ? This could be used for reference also for others in case they want to manage multiple dependent schemas.
Regarding the last comment, I'm not sure to understand the benefit of your proposal, if you preload a standard wikitext article, aren't you already able to include queries and templates as well ? (that page could contain only the string {{My template}} in your case) Thomas-topway-it (talk) 18:51, 8 April 2024 (UTC)Reply
Hi @Thomas-topway-it I just wanted to update my example - unfortunatelly my query
{{#visualdataquery:[[belongs to::{{{articleid}}}]]|...}}
no longer seems to work, see: https://wikisphere.org/w/index.php?title=Template:School_district&veaction=editsource
The correct ID is stored on the corresponding pages under 'belongs to', see e.g. https://wikisphere.org/wiki/School/46
Is {{{articleid}}} (received from parent page/template) rendered in der query? Has it changed in the latest VisualData version?
Thanks a lot! Filburt (talk) 12:22, 10 April 2024 (UTC)Reply
hello Fliburt, I've setup this https://wikisphere.org/wiki/User:Filburt/Nested_Schemas_and_Templates_Example
for me it works, but let me know if some data is missing Thomas-topway-it (talk) 20:05, 10 April 2024 (UTC)Reply
Hi @Thomas-topway-it, Yes, the example works now, no idea what the problem was. Btw. I find VisualData really great (I worked with PageForms for a long time - that was also the reason why I suggested the direct input of a template for the preload parameter). At the moment I'm still experimenting a lot with VisualData... Filburt (talk) 20:10, 11 April 2024 (UTC)Reply

Small bug in VisualDataForms.js[edit]

Hi, I found a small bug in VisualDataForms.js line 1740 - it should be:

ThisPageLayout.super.call( this, name, thisConfig );

Otherwise the booklet layout will not work.

Greetings Filburt (talk) 21:03, 11 April 2024 (UTC)Reply

MediaWiki version compatibility[edit]

Hi!

First of all: this is a very interesting extension! Thanks for creating it.

I tried to install it, but unfortunately ran into some issues:

1. When installed on MediaWiki 1.39, in many cases the JavaScript is not properly loaded: E.g. when accessing action=editdata the JavaScript console shows an error Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules

2. When installed on MediaWiki 1.42, I get a database error when trying to "browse" the data (accessing SpecialVisualDataBrowse)

[3015f5a54dcf1202071f4f64] /w/index.php?title=Spezial:VisualDataBrowse/Data Wikimedia\Rdbms\DBLanguageError: Table name component contains unexpected quote or dot character

Backtrace:

from /var/www/htdocs/w/includes/libs/rdbms/platform/SQLPlatform.php(1051)
#0 /var/www/htdocs/w/includes/libs/rdbms/platform/SQLPlatform.php(991): Wikimedia\Rdbms\Platform\SQLPlatform->extractTableNameComponents(string)
#1 /var/www/htdocs/w/includes/libs/rdbms/platform/SQLPlatform.php(957): Wikimedia\Rdbms\Platform\SQLPlatform->qualifiedTableComponents(string)
#2 /var/www/htdocs/w/includes/libs/rdbms/platform/SQLPlatform.php(936): Wikimedia\Rdbms\Platform\SQLPlatform->tableName(string)
#3 /var/www/htdocs/w/includes/libs/rdbms/platform/SQLPlatform.php(837): Wikimedia\Rdbms\Platform\SQLPlatform->tableNameWithAlias(string, string)
#4 /var/www/htdocs/w/includes/libs/rdbms/platform/SQLPlatform.php(666): Wikimedia\Rdbms\Platform\SQLPlatform->tableNamesWithIndexClauseOrJOIN(array, array, array, array)
#5 /var/www/htdocs/w/includes/libs/rdbms/database/Database.php(3334): Wikimedia\Rdbms\Platform\SQLPlatform->selectSQLText(array, array, array, string, array, array)
#6 /var/www/htdocs/w/includes/libs/rdbms/database/DatabaseMySQL.php(730): Wikimedia\Rdbms\Database->selectSQLText(array, array, array, string, array, array)
#7 /var/www/htdocs/w/includes/libs/rdbms/database/Database.php(1342): Wikimedia\Rdbms\DatabaseMySQL->selectSQLText(array, array, array, string, array, array)
#8 /var/www/htdocs/w/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#9 /var/www/htdocs/w/includes/libs/rdbms/database/DBConnRef.php(351): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#10 /var/www/htdocs/w/includes/pager/IndexPager.php(467): Wikimedia\Rdbms\DBConnRef->select(array, array, array, string, array, array)
#11 /var/www/htdocs/w/includes/pager/IndexPager.php(289): MediaWiki\Pager\IndexPager->reallyDoQuery(string, integer, boolean)
#12 /var/www/htdocs/w/includes/pager/IndexPager.php(739): MediaWiki\Pager\IndexPager->doQuery()
#13 /var/www/htdocs/w/extensions/VisualData/includes/specials/SpecialVisualDataBrowse.php(149): MediaWiki\Pager\IndexPager->getNumRows()
#14 /var/www/htdocs/w/includes/specialpage/SpecialPage.php(718): SpecialVisualDataBrowse->execute(string)
#15 /var/www/htdocs/w/includes/specialpage/SpecialPageFactory.php(1669): MediaWiki\SpecialPage\SpecialPage->run(string)
#16 /var/www/htdocs/w/includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#17 /var/www/htdocs/w/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#18 /var/www/htdocs/w/includes/MediaWikiEntryPoint.php(199): MediaWiki\Actions\ActionEntryPoint->execute()
#19 /var/www/htdocs/w/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#20 {main}

I tested different versions of the extension (REL1_42 and current master) and of MediaWiki (1.39 and 1.42). Besides some standard extensions like VisualEditor and WikiEditor, I do not have any other extension enabled. The browser was Google Chrome 124. Osnard (talk) 05:56, 26 April 2024 (UTC)Reply

I can confirm it works with MW1.41 (1.42 is not yet fully supported). Don't forget to run
composer install --no-dev
in the VisualData extension folder.
Hope it helps. Filburt (talk) 07:50, 26 April 2024 (UTC)Reply
hello Robert @Osnard, they are known issues. Regarding the first please use $wgResourceLoaderDebug = true; in LocalSettings.php -- this is caused in certain cases by the ResourceLoader and I'm not sure if there is a fix for that. Regarding 1.42 as mentioned by Filburt, it's not yet fully supported (or tested). Thomas-topway-it (talk) 08:21, 26 April 2024 (UTC)Reply
I can confirm, $wgResourceLoaderDebug = true; solved the await issue on MediaWiki 1.39. Osnard (talk) 13:48, 26 April 2024 (UTC)Reply