Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357355 )

Change subject: Add formatted constraint item ID to API output
......................................................................

Add formatted constraint item ID to API output

For constraints imported from statements,
CheckResult::getConstraintName() contains the item ID of the constraint
item (this is not clearly documented on the function, but CheckResult is
always instantiated with argument Constraint::getConstraintTypeQid(),
never Constraint::getConstraintTypeName()). The API now formats that
item ID and includes the result in the response, and the user script can
use that response part (if it is present) for the constraint name; the
effect of this is that constraints from statements are displayed as
hyperlinks with localized labels instead of blank Q-IDs.

For constraints not imported from statements, parsing the name into an
ItemId will fail and ConstraintParameterRenderer falls back to
HTML-escaping the string, so those constraint types continue to work as
before.

Change-Id: Ia43423bc276d8de9b8df5e67ddc4f48dd1f21a96
---
M api/CheckConstraints.php
M docs/user.js
2 files changed, 7 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/55/357355/1

diff --git a/api/CheckConstraints.php b/api/CheckConstraints.php
index 323a94c..13d94bf 100644
--- a/api/CheckConstraints.php
+++ b/api/CheckConstraints.php
@@ -309,6 +309,7 @@
                                'constraint' => [
                                        'id' => $checkResult->getConstraintId(),
                                        'type' => 
$checkResult->getConstraintName(),
+                                       'typeHTML' => 
$this->constraintParameterRenderer->formatItemId( 
$checkResult->getConstraintName() ),
                                        'detail' => 
$checkResult->getParameters(),
                                        'detailHTML' => 
$this->constraintParameterRenderer->formatParameters( 
$checkResult->getParameters() )
                                ]
diff --git a/docs/user.js b/docs/user.js
index 355e6f0..166ecb3 100644
--- a/docs/user.js
+++ b/docs/user.js
@@ -39,7 +39,12 @@
                if ( result.status === 'violation' ) {
                        $report = $( '<div>' ).addClass( 'wbqc-report' );
                        $report.css( 'border-top', '1px solid #eaecf0' ); // 
TODO move to CSS on .wbqc-report class
-                       $heading = $( '<h4>' ).text( result.constraint.type );
+                       $heading = $( '<h4>' );
+                       if ( result.constraint.typeHTML ) {
+                               $heading.html( result.constraint.typeHTML );
+                       } else {
+                               $heading.text( result.constraint.type );
+                       }
                        $helpButton = new OO.ui.ButtonWidget( {
                                icon: 'help',
                                framed: false,

-- 
To view, visit https://gerrit.wikimedia.org/r/357355
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia43423bc276d8de9b8df5e67ddc4f48dd1f21a96
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to