Page MenuHomePhabricator

Add JS hooks for changes to statements
Closed, ResolvedPublic

Description

It would be useful to have a client-side hook that fires whenever a statement is edited. In the WikibaseQualityConstraints extension, we would use this to re-check constraints on a statement after it has been edited, but it would probably also be useful to other user scripts and gadgets.

I propose the name wikibase.statement.edit (.add and .remove could be added later), and the arguments entityId, statementId, oldValue, newValue. The hook names are wikibase.statement.saved (add or edit) and wikibase.statement.removed, and the arguments are just entityId and statementId for now.

For the time being, the hook would be considered just as unstable as the rest of the Wikibase JavaScript code (one of the Unstable Interfaces not covered by the Stable Interface Policy).

(Implementation memo: mw.hook( 'wikibase.statement.edit' ).fire( … ) in ToolbarViewController.stopEditing, in the _model.save callback.)

Details

Related Gerrit Patches:
mediawiki/extensions/Wikibase : masterTest StatementsChanger hooks
mediawiki/extensions/Wikibase : masterInject mediaWiki.hook as actual dependency instead of a soft check
mediawiki/extensions/Wikibase : masterAdd hooks for saving and removing statements

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 14 2017, 12:18 PM

Change 359000 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Add hooks for saving and removing statements

https://gerrit.wikimedia.org/r/359000

Change 359937 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] Inject mediaWiki.hook as actual dependency instead of a soft check

https://gerrit.wikimedia.org/r/359937

Change 359000 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add hooks for saving and removing statements

https://gerrit.wikimedia.org/r/359000

Change 360355 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Test StatementsChanger hooks

https://gerrit.wikimedia.org/r/360355

Change 359937 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Inject mediaWiki.hook as actual dependency instead of a soft check

https://gerrit.wikimedia.org/r/359937

Lucas_Werkmeister_WMDE closed this task as Resolved.Jun 20 2017, 4:37 PM
Lucas_Werkmeister_WMDE moved this task from Review to Done on the Wikidata-Former-Sprint-Board board.

Closing. There’s another change that adds tests, but I think this task is done.

Change 360355 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Test StatementsChanger hooks

https://gerrit.wikimedia.org/r/360355