Cap number of terms and statements displayed in the preview
This commit is contained in:
parent
cb81da0923
commit
3bf3f84ca6
@ -1110,13 +1110,13 @@ SchemaAlignmentDialog.getJSON = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SchemaAlignmentDialog._hasChanged = function() {
|
SchemaAlignmentDialog._hasChanged = function() {
|
||||||
this._hasUnsavedChanges = true;
|
SchemaAlignmentDialog._hasUnsavedChanges = true;
|
||||||
SchemaAlignmentDialog.preview(false);
|
SchemaAlignmentDialog.preview(false);
|
||||||
this._unsavedIndicator.show();
|
SchemaAlignmentDialog._unsavedIndicator.show();
|
||||||
this._schemaElmts.saveButton
|
SchemaAlignmentDialog._schemaElmts.saveButton
|
||||||
.prop('disabled', false)
|
.prop('disabled', false)
|
||||||
.removeClass('disabled');
|
.removeClass('disabled');
|
||||||
this._schemaElmts.discardButton
|
SchemaAlignmentDialog._schemaElmts.discardButton
|
||||||
.prop('disabled', false)
|
.prop('disabled', false)
|
||||||
.removeClass('disabled');
|
.removeClass('disabled');
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
var EditRenderer = {};
|
var EditRenderer = {};
|
||||||
|
|
||||||
|
// settings
|
||||||
|
EditRenderer.maxTerms = 15; // max number of terms displayed
|
||||||
|
EditRenderer.maxStatements = 25; // max number of statements per statement group
|
||||||
|
|
||||||
// main method: takes a DOM element and a list
|
// main method: takes a DOM element and a list
|
||||||
// of edits to render there.
|
// of edits to render there.
|
||||||
EditRenderer.renderEdits = function(edits, container) {
|
EditRenderer.renderEdits = function(edits, container) {
|
||||||
@ -35,20 +39,12 @@ EditRenderer._renderItem = function(json, container) {
|
|||||||
if ((json.labels && json.labels.length) ||
|
if ((json.labels && json.labels.length) ||
|
||||||
(json.descriptions && json.descriptions.length) ||
|
(json.descriptions && json.descriptions.length) ||
|
||||||
(json.addedAliases && json.addedAliases.length)) {
|
(json.addedAliases && json.addedAliases.length)) {
|
||||||
//$('<span></span>').addClass('wbs-namedesc-header')
|
|
||||||
// .text($.i18n._('wikidata-schema')["terms-header"]).appendTo(right);
|
|
||||||
var termsContainer = $('<div></div>').addClass('wbs-namedesc-container')
|
var termsContainer = $('<div></div>').addClass('wbs-namedesc-container')
|
||||||
.appendTo(right);
|
.appendTo(right);
|
||||||
|
|
||||||
for(var i = 0; i != json.labels.length; i++) {
|
this._renderTermsList(json.labels, "label", termsContainer);
|
||||||
EditRenderer._renderTerm("label", json.labels[i], termsContainer);
|
this._renderTermsList(json.descriptions, "description", termsContainer);
|
||||||
}
|
this._renderTermsList(json.aliases, "alias", termsContainer);
|
||||||
for(var i = 0; i != json.descriptions.length; i++) {
|
|
||||||
EditRenderer._renderTerm("description", json.descriptions[i], termsContainer);
|
|
||||||
}
|
|
||||||
for(var i = 0; i != json.addedAliases.length; i++) {
|
|
||||||
EditRenderer._renderTerm("alias", json.addedAliases[i], termsContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the float
|
// Clear the float
|
||||||
$('<div></div>').attr('style', 'clear: right').appendTo(right);
|
$('<div></div>').attr('style', 'clear: right').appendTo(right);
|
||||||
@ -70,6 +66,18 @@ EditRenderer._renderItem = function(json, container) {
|
|||||||
* NAMES AND DESCRIPTIONS *
|
* NAMES AND DESCRIPTIONS *
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
|
EditRenderer._renderTermsList = function(termList, termType, termsContainer) {
|
||||||
|
if(!termList) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(var i = 0; i != Math.min(termList.length, this.maxTerms); i++) {
|
||||||
|
EditRenderer._renderTerm(termType, termList[i], termsContainer);
|
||||||
|
}
|
||||||
|
if(termList.length > this.maxTerms) {
|
||||||
|
$('<div></div>').addClass('wbs-namedesc').text('...').appendTo(termsContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EditRenderer._renderTerm = function(termType, json, container) {
|
EditRenderer._renderTerm = function(termType, json, container) {
|
||||||
var namedesc = $('<div></div>').addClass('wbs-namedesc').appendTo(container);
|
var namedesc = $('<div></div>').addClass('wbs-namedesc').appendTo(container);
|
||||||
var type_container = $('<div></div>').addClass('wbs-namedesc-type').appendTo(namedesc);
|
var type_container = $('<div></div>').addClass('wbs-namedesc-type').appendTo(namedesc);
|
||||||
@ -96,6 +104,12 @@ EditRenderer._renderStatementGroup = function(json, container) {
|
|||||||
for (var i = 0; i != json.statements.length; i++) {
|
for (var i = 0; i != json.statements.length; i++) {
|
||||||
EditRenderer._renderStatement(json.statements[i], statementContainer);
|
EditRenderer._renderStatement(json.statements[i], statementContainer);
|
||||||
}
|
}
|
||||||
|
if(json.statements.length > EditRenderer.maxStatements) {
|
||||||
|
$('<div></div>')
|
||||||
|
.text('...')
|
||||||
|
.addClass('wbs-statement')
|
||||||
|
.appendTo(statementContainer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
|
Loading…
Reference in New Issue
Block a user