jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/359001 )
Change subject: Check constraints on saved statements
......................................................................
Check constraints on saved statements
When a statement is saved, we check it again, using the
wikibase.statement.saved hook added in I5efdb67c57 and the claimid API
parameter.
A small change to addReportsToStatement is necessary, since in edited
statements, the value is wrapped in a .valueview-instaticmode div; if we
append the button to the surrounding .wikibase-snakview-value instead of
the .valueview-instaticmode div, they appear on separate lines.
Bug: T168627
Change-Id: I2bab15b792fbc1201cbea56b0250b7fad906968f
Depends-On: I5efdb67c57106c64dd2bee0e888ba1bb230886ea
---
M modules/gadget.js
1 file changed, 23 insertions(+), 4 deletions(-)
Approvals:
Jonas Kress (WMDE): Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/gadget.js b/modules/gadget.js
index 3e07d7e..adbc77e 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -66,7 +66,8 @@
results,
reports,
i,
- report;
+ report,
+ $target;
if ( !( propertyId in entityData && statementId in entityData[
propertyId ] ) ) {
return;
@@ -83,7 +84,11 @@
}
if ( reports.length > 0 ) {
- $statement.append( buildWidget( reports ).$element );
+ $target = $statement.find( '.valueview-instaticmode' );
+ if ( $target.length === 0 ) {
+ $target = $statement;
+ }
+ $target.append( buildWidget( reports ).$element );
}
}
@@ -102,15 +107,29 @@
'oojs-ui.styles.icons-interactions',
'wikibase.quality.constraints.ui'
] ).done( function () {
- var api = new mw.Api();
+ var api = new mw.Api(),
+ lang = mw.config.get( 'wgUserLanguage' );
api.get( {
action: 'wbcheckconstraints',
format: 'json',
- uselang: mw.config.get( 'wgUserLanguage' ),
+ uselang: lang,
id: entityId
} ).then( function( data ) {
$( '.wikibase-statementgroupview
.wikibase-statementview-mainsnak .wikibase-snakview-value' )
.each( function () { addReportsToStatement(
data.wbcheckconstraints[ entityId ], $( this ) ); } );
} );
+
+ mw.hook( 'wikibase.statement.saved' ).add( function( entityId,
statementId ) {
+ api.get( {
+ action: 'wbcheckconstraints',
+ format: 'json',
+ uselang: lang,
+ claimid: statementId
+ } ).then( function( data ) {
+ var statementClass = 'wikibase-statement-' +
statementId.replace( /\$/, '\\$$' );
+ $( '.wikibase-statementgroupview .' +
statementClass + ' .wikibase-statementview-mainsnak .wikibase-snakview-value' )
+ .each( function () {
addReportsToStatement( data.wbcheckconstraints[ entityId ], $( this ) ); } );
+ } );
+ } );
} );
} )( mediaWiki, jQuery, OO );
--
To view, visit https://gerrit.wikimedia.org/r/359001
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2bab15b792fbc1201cbea56b0250b7fad906968f
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>
Gerrit-Reviewer: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits