Display the number of issues in the tab header

This commit is contained in:
Antonin Delpeuch 2018-01-10 18:04:39 +00:00
parent 1cf9378523
commit 7518d194f0
5 changed files with 28 additions and 5 deletions

View File

@ -5,7 +5,7 @@
<div id="schema-alignment-tabs" class="refine-tabs"> <div id="schema-alignment-tabs" class="refine-tabs">
<ul> <ul>
<li><a href="#schema-alignment-tabs-schema" bind="schemaTabHeader"></a></li> <li><a href="#schema-alignment-tabs-schema" bind="schemaTabHeader"></a></li>
<li><a href="#schema-alignment-tabs-warnings" bind="warningsTabHeader"></a></li> <li><a href="#schema-alignment-tabs-warnings"><span bind="warningsTabHeader"></span> <span class="schema-alignment-total-warning-count" bind="warningsTabCount"></span></a></li>
<li><a href="#schema-alignment-tabs-preview-qs" bind="qsPreviewTabHeader"></a></li> <li><a href="#schema-alignment-tabs-preview-qs" bind="qsPreviewTabHeader"></a></li>
</ul> </ul>
<div id="schema-alignment-tabs-schema"> <div id="schema-alignment-tabs-schema">

View File

@ -848,9 +848,9 @@ SchemaAlignmentDialog.preview = function(initial) {
} }
if (data.warnings) { if (data.warnings) {
self._updateWarnings(data.warnings); self._updateWarnings(data.warnings, data.nb_warnings);
} else { } else {
self._updateWarnings([]); self._updateWarnings([], 0);
} }
if ("code" in data && data.code === "error") { if ("code" in data && data.code === "error") {
@ -936,14 +936,25 @@ SchemaAlignmentDialog._renderWarning = function(warning) {
return tr; return tr;
} }
SchemaAlignmentDialog._updateWarnings = function(warnings) { SchemaAlignmentDialog._updateWarnings = function(warnings, totalCount) {
var mainDiv = this._elmts.warningsArea; var mainDiv = this._elmts.warningsArea;
var countsElem = this._elmts.warningsTabCount;
// clear everything
mainDiv.empty(); mainDiv.empty();
countsElem.hide();
var table = $('<table></table>').appendTo(mainDiv); var table = $('<table></table>').appendTo(mainDiv);
for (var i = 0; i != warnings.length; i++) { for (var i = 0; i != warnings.length; i++) {
var rendered = SchemaAlignmentDialog._renderWarning(warnings[i]); var rendered = SchemaAlignmentDialog._renderWarning(warnings[i]);
rendered.appendTo(table); rendered.appendTo(table);
} }
// update the counts
if (totalCount) {
countsElem.text(totalCount);
countsElem.show();
}
} }
/******************** /********************

View File

@ -230,7 +230,8 @@ tr.wb-warning:nth-of-type(odd) {
background-color: #f2f2f2; background-color: #f2f2f2;
} }
.wb-warning-count span { .wb-warning-count span,
.schema-alignment-total-warning-count {
color: white; color: white;
background-color: #777; background-color: #777;
padding: 0px 5px; padding: 0px 5px;

View File

@ -94,6 +94,11 @@ public class PreviewWikibaseSchemaCommand extends Command {
} }
writer.endArray(); writer.endArray();
// this is not the length of the warnings array written before,
// but the total number of issues raised (before deduplication)
writer.key("nb_warnings");
writer.value(inspector.getTotalNumberOfWarnings());
// Export to QuickStatements // Export to QuickStatements
QuickStatementsExporter exporter = new QuickStatementsExporter(); QuickStatementsExporter exporter = new QuickStatementsExporter();
exporter.translateItemList(editBatch, stringWriter); exporter.translateItemList(editBatch, stringWriter);

View File

@ -79,4 +79,10 @@ public class EditInspector {
return warningStore.getWarnings(); return warningStore.getWarnings();
} }
/**
* Retrieve the number of warnings before deduplication
*/
public int getTotalNumberOfWarnings() {
return warningStore.getNbWarnings();
}
} }