VIVO-904: the display limit annotation on data and faux properties now determines when the more... link is employed for one of these properties. Regular object properties will have a default limit of 5. Also, the add statement link is no longer suppressed when the display limit is reached.

This commit is contained in:
Tim Worrall 2015-02-09 15:54:11 -05:00
parent ed9b82258d
commit b21cd24489
4 changed files with 35 additions and 6 deletions

View file

@ -65,6 +65,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
private String objectKey;
private String queryString;
private Set<String> constructQueries;
private int displayLimit;
DataPropertyTemplateModel(DataProperty dp, Individual subject, VitroRequest vreq,
boolean editing, List<DataProperty> populatedDataPropertyList) {
@ -82,7 +83,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
constructQueries = getConstructQueries();
statements = new ArrayList<DataPropertyStatementTemplateModel>();
displayLimit = dp.getDisplayLimit();
// If the property is populated, get the data property statements via a sparql query
if (populatedDataPropertyList.contains(dp)) {
log.debug("Getting data for populated data property " + getUri());
@ -108,14 +109,22 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
return;
}
// If the display limit has already been reached, we can't add a new statement.
// NB This appears to be a misuse of a value called "display limit". Note that it's
// not used to limit display, either, so should be renamed.
/* If the display limit has already been reached, we can't add a new statement.
NB This appears to be a misuse of a value called "display limit". Note that it's
not used to limit display, either, so should be renamed.
int displayLimit = dp.getDisplayLimit();
// Display limit of -1 (default value for new property) means no display limit
Display limit of -1 (default value for new property) means no display limit
if ( displayLimit >= 0 && statements.size() >= displayLimit ) {
return;
}
*/
// Rewriting the above per jc55. If the data property is functional, there should only
// be 1 statement. The Display Limit is for determining how many statements to display
// before a "more..." link is used to hide statements exceeding the display limit. tlw72
boolean functional = dp.getFunctional();
if ( functional && statements.size() >= 1 ) {
return;
}
// Determine whether a new statement can be added
RequestedAction action = new AddDataPropertyStatement(
@ -146,6 +155,11 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
protected Route getPropertyEditRoute() {
return Route.DATA_PROPERTY_EDIT;
}
@Override
public int getDisplayLimit() {
return displayLimit;
}
public ConfigError checkQuery(String queryString) {
if (StringUtils.isBlank(queryString)) {
@ -191,6 +205,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
public String getTemplate() {
return getTemplateName();
}
/* Template methods */

View file

@ -41,6 +41,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
private String name;
private FauxProperty fauxProperty;
private int displayLimit;
PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq, String name) {
this.vreq = vreq;
@ -49,11 +50,13 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
propertyUri = property.getURI();
localName = property.getLocalName();
this.name = name;
this.displayLimit = displayLimit;
addUrl = "";
fauxProperty = isFauxProperty(property);
if (fauxProperty != null) {
this.name = fauxProperty.getDisplayName();
this.displayLimit = fauxProperty.getDisplayLimit();
}
setVerboseDisplayValues(property);
@ -142,6 +145,10 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
return name;
}
public int getDisplayLimit() {
return displayLimit;
}
public String getLocalName() {
return localName;
}

View file

@ -67,4 +67,7 @@ li.selectedGroupTab {
}
li.groupTabSpacer {
float:left;border-bottom: 1px solid #DFE6E5;background-color:#fff;width:3px;height:37px
}
div.additionalItems {
margin-top: 0 !important;
}

View file

@ -42,7 +42,11 @@
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> </h3>
</#if>
<#-- List the statements for each property -->
<ul class="property-list" role="list" id="${property.localName}-${rangeClass}-List">
<#assign limit = property.getDisplayLimit()!5 />
<#if limit == -1 || limit == 0 >
<#assign limit = 5 />
</#if>
<ul class="property-list" role="list" id="${property.localName}-${rangeClass}-List" displayLimit="${limit}">
<#-- data property -->
<#if property.type == "data">
<@p.dataPropertyList property editable />