Lucas Werkmeister (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/365988 )
Change subject: Make “bad parameters” results less promiment
......................................................................
Make “bad parameters” results less promiment
This orders the “bad parameters” constraint reports below the
“violation” ones and also makes them semi-transparent.
The opacity change is done via CSS; the reordering is done in a new
OO.ui class, ConstraintReportStack, which is extracted from gadget.js
just like ConstraintReportPanel was extracted in Ic7143092eb. It also
takes over the job of filtering out reports that aren’t violations or
bad parameters (compliance, exception, todo).
This is only for the “regular” gadget, which exposes wbcheckconstraints
results on entity pages; the part of the gadget that checks constraint
parameters on the constraint statements themselves is unaffected for now
(some code that was previously in buildWidget is copy+pasted into it).
Bug: T169971
Change-Id: I6e31e84d40d4b3e8edfc7bd4359ae615a595453d
---
M extension.json
M modules/gadget.css
M modules/gadget.js
A modules/ui/ConstraintReportStack.js
4 files changed, 107 insertions(+), 20 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
refs/changes/88/365988/1
diff --git a/extension.json b/extension.json
index 3029c4f..4f6cbf6 100644
--- a/extension.json
+++ b/extension.json
@@ -63,7 +63,8 @@
],
"scripts": [
"modules/ui/module.js",
- "modules/ui/ConstraintReportPanel.js"
+ "modules/ui/ConstraintReportPanel.js",
+ "modules/ui/ConstraintReportStack.js"
]
},
"wikibase.quality.constraints.gadget": {
diff --git a/modules/gadget.css b/modules/gadget.css
index 8e26c50..ac1c815 100644
--- a/modules/gadget.css
+++ b/modules/gadget.css
@@ -10,3 +10,7 @@
.wbqc-constraint-type-help {
transform: scale( 0.75 );
}
+
+.wbqc-report-status-bad-parameters {
+ opacity: 0.5;
+}
diff --git a/modules/gadget.js b/modules/gadget.js
index 69c6c0e..9c5c18b 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -3,7 +3,7 @@
var entityId;
- function buildWidget( reports, messageKey, flags /* = '' */ ) {
+ function buildPopup( $content, messageKey, flags /* = '' */ ) {
var widget = new OO.ui.PopupButtonWidget( {
icon: 'alert',
iconTitle: mw.message( 'wbqc-' + messageKey + '-long'
).text(),
@@ -11,12 +11,7 @@
framed: false,
classes: [ 'wbqc-reports-button' ],
popup: {
- $content: new OO.ui.StackLayout( {
- items: reports,
- continuous: true,
- expanded: false, // expanded: true does
not work within a popup
- classes: [ 'wbqc-reports' ]
- } ).$element,
+ $content: $content,
width: 400,
padded: true,
head: true,
@@ -29,15 +24,11 @@
}
function buildReport( result ) {
- if ( result.status === 'violation' || result.status ===
'bad-parameters' ) {
- return new
wb.quality.constraints.ui.ConstraintReportPanel( {
- status: result.status,
- constraint: result.constraint,
- message: result[ 'message-html' ]
- } );
- } else {
- return null;
- }
+ return new wb.quality.constraints.ui.ConstraintReportPanel( {
+ status: result.status,
+ constraint: result.constraint,
+ message: result[ 'message-html' ]
+ } );
}
function buildParameterReport( problem ) {
@@ -67,6 +58,7 @@
reports,
i,
report,
+ stack,
$target;
if ( !( propertyId in entityData && statementId in entityData[
propertyId ] ) ) {
@@ -83,12 +75,17 @@
}
}
- if ( reports.length > 0 ) {
+ stack = new
wikibase.quality.constraints.ui.ConstraintReportStack( {
+ items: reports,
+ statuses: [ 'violation', 'bad-parameters' ],
+ expanded: false // expanded: true does not work within
a popup
+ } );
+ if ( stack.items.length > 0 ) {
$target = $statement.find( '.valueview-instaticmode' );
if ( $target.length === 0 ) {
$target = $statement;
}
- $target.append( buildWidget( reports, 'potentialissues'
).$element );
+ $target.append( buildPopup( stack.$element,
'potentialissues' ).$element );
}
}
@@ -99,6 +96,7 @@
reports,
i,
report,
+ stack,
$statement,
$target;
@@ -117,13 +115,20 @@
}
}
+ stack = new OO.ui.StackLayout( {
+ items: reports,
+ continuous: true,
+ expanded: false,
+ classes: [ 'wbqc-reports' ]
+ } );
+
$statement = $( '.wikibase-statement-' +
constraintId.replace( /\$/g, '\\$' ) +
'
.wikibase-statementview-mainsnak .wikibase-snakview-value' );
$target = $statement.find( '.valueview-instaticmode' );
if ( $target.length === 0 ) {
$target = $statement;
}
- $target.append( buildWidget( reports, 'badparameters',
'warning' ).$element );
+ $target.append( buildPopup( stack.$element,
'badparameters', 'warning' ).$element );
}
}
diff --git a/modules/ui/ConstraintReportStack.js
b/modules/ui/ConstraintReportStack.js
new file mode 100644
index 0000000..8adcaea
--- /dev/null
+++ b/modules/ui/ConstraintReportStack.js
@@ -0,0 +1,77 @@
+( function( wb ) {
+ 'use strict';
+
+ /**
+ * A panel for a list of constraint report results.
+ *
+ * @example
+ * var report = new
wikibase.quality.constraints.ui.ConstraintReportStack( {
+ * items: [
+ * new
wikibase.quality.constraints.ui.ConstraintReportPanel( {
+ * status: 'compliance',
+ * constraint: {
+ * type: 'Q1',
+ * typeLabel: 'my constraint',
+ * link: 'http://example.com/my-constraint'
+ * },
+ * message: 'everything okay'
+ * } ),
+ * new
wikibase.quality.constraints.ui.ConstraintReportPanel( {
+ * status: 'violation',
+ * constraint: {
+ * type: 'Q2',
+ * typeLabel: 'my other constraint',
+ * link: 'http://example.com/my-other-constraint'
+ * },
+ * message: 'doing it wrong'
+ * } )
+ * ],
+ * statuses = [ 'violation' ]
+ * } );
+ * $( 'body' ).append( report.$element );
+ *
+ * @class
+ * @extends OO.ui.StackLayout
+ *
+ * @constructor
+ * @param {Object} config Configuration options
+ * @cfg {wikibase.quality.constraints.ui.ConstraintReportPanel[]} items
The individual constraint report results.
+ * @cfg {string[]} statuses The constraint statuses to include in the
list.
+ * Constraints will be sorted by status in the order given in this
array;
+ * constraints with a status not in this array will be excluded.
+ */
+ wb.quality.constraints.ui.ConstraintReportStack = function
WBQCConstraintReportStack( config ) {
+ var itemsByStatus = {};
+
+ // Configuration initialization
+ config.continuous = true;
+ config.classes = ( config.classes || [] ).concat( [
'wbqc-reports' ] );
+
+ config.items.forEach( function( panel ) {
+ itemsByStatus[ panel.status ] = itemsByStatus[
panel.status ] || [];
+ itemsByStatus[ panel.status ].push( panel );
+ } );
+ config.items = [];
+ config.statuses.forEach( function( status ) {
+ config.items = config.items.concat( itemsByStatus[
status ] || [] );
+ } );
+
+ // Parent constructor
+ wb.quality.constraints.ui.ConstraintReportStack.parent.call(
this, config );
+
+ // Mixin constructors
+ // (none)
+
+ // Properties
+ this.statuses = config.statuses;
+ };
+
+ /* Setup */
+
+ OO.inheritClass( wb.quality.constraints.ui.ConstraintReportStack,
OO.ui.StackLayout );
+
+ /* Methods */
+
+ // (none)
+
+}( wikibase ) );
--
To view, visit https://gerrit.wikimedia.org/r/365988
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e31e84d40d4b3e8edfc7bd4359ae615a595453d
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