Commit 25c2d978 authored by µKöff's avatar µKöff

Always display disambiguation, even if there is only one result candidate;

Display notes below search term;
Simplified functions which access propertyDict
parent d3ad1fe9
Pipeline #102446683 passed with stages
in 2 minutes and 39 seconds
......@@ -88,8 +88,8 @@ export default class RequestManager {
data.tuple.uiRow.updateResult(items[0].id);
} else {
data.tuple.uiRow.updateStatus("disambiguation");
data.tuple.uiRow.generateDisambiguation(items);
}
data.tuple.uiRow.generateDisambiguation(items);
}
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ export default class RequestTuple implements Outputtable.default {
this._conditionList = conditionList || [];
this.propertyDict = propertyDict || {};
this._type = this.normalizeAndGetProperty("type", propertyDict, function(val: string) {
this._type = this.normalizeAndGetProperty("type", function(val: string) {
switch(val.toLowerCase()) {
case "f":
return "form";
......@@ -84,27 +84,27 @@ export default class RequestTuple implements Outputtable.default {
return this.result == null ? Outputtable.OutputMode.Failed : Outputtable.OutputMode.Success;
}
getProperty(key: string, propertyDict: PropertyDictionary, defaultTo: string = null) {
return this.hasProperty(key, propertyDict) ? propertyDict[key] : defaultTo;
getProperty(key: string, defaultTo: string = null) {
return this.hasProperty(key) ? this.propertyDict[key] : defaultTo;
}
hasProperty(key: string, propertyDict: PropertyDictionary) {
return propertyDict != null && typeof propertyDict[key] == "string";
hasProperty(key: string) {
return this.propertyDict != null && typeof this.propertyDict[key] == "string";
}
normalizeProperty(key: string, propertyDict: PropertyDictionary, normalizeFunction: ((value: string) => string)): string {
if(this.hasProperty(key, propertyDict)) {
var oldValue = propertyDict[key];
propertyDict[key] = normalizeFunction(propertyDict[key]);
normalizeProperty(key: string, normalizeFunction: ((value: string) => string)): string {
if(this.hasProperty(key)) {
var oldValue = this.propertyDict[key];
this.propertyDict[key] = normalizeFunction(this.propertyDict[key]);
return oldValue;
} else {
return null;
}
}
normalizeAndGetProperty(key: string, propertyDict: PropertyDictionary, normalizeFunction: ((value: string) => string), defaultTo: string = null): string {
this.normalizeProperty(key, propertyDict, normalizeFunction);
return this.getProperty(key, propertyDict, defaultTo);
normalizeAndGetProperty(key: string, normalizeFunction: ((value: string) => string), defaultTo: string = null): string {
this.normalizeProperty(key, normalizeFunction);
return this.getProperty(key, defaultTo);
}
request(requestManager: RequestManager, rowIndex: number, tupleIndex: number) {
......
......@@ -68,7 +68,7 @@ export default class UiRow {
var $row = $(`<tr class="status-${this.status.replace(/ /g, "-")}" data-rowindex="${this.rowIndex}" data-tupleindex="${this.tupleIndex}"></tr>`);
$row.append(`<th scope="row">${this.rowIndex + 1}</th>`);
$row.append(this.statusCell);
$row.append(`<td>${Util.sanitize(this.tuple.term)}</td>`);
$row.append(`<td>${Util.sanitize(this.tuple.term)}${this.tuple.hasProperty("note") ? `<br/><i>${Util.sanitize(this.tuple.getProperty("note"))}</i>` : ``}</td>`);
$row.append(this.resultCell);
$row.append(this.disambiguationCell);
......@@ -113,7 +113,7 @@ export default class UiRow {
}
private updateResultCell() {
if(this.resultCell != null) {
if(this.tuple.result != null) {
this.generateDisambiguation();
this.updateDisambiguationCell();
this.resultCell.html(`<a href="https://www.wikidata.org/wiki/${this.tuple.result}" target="_blank">${this.tuple.result}</a><small class="tool-candidateremoval">&nbsp;[<a href="#" data-action="remove-candidate">&times;</a>]</small>`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment