NIHVIVO-1704 Enable jump links after returning to individual profile after submitting an editing form. Pass property all the way down the property display macro chain, so any macro has access to property attributes like name, localname, and uri. Provide PropertyTemplateModel.getLocalName() and PropertyTemplateModel.getUri() for this purpose.

This commit is contained in:
rjy7 2011-01-18 21:21:14 +00:00
parent 346d7ba4ce
commit ce76206f7c
7 changed files with 49 additions and 46 deletions

View file

@ -46,7 +46,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
if (policyHelper != null) {
// If the display limit has already been reached, we can't add a new statement
int displayLimit = dp.getDisplayLimit();
// Display limit of -1 (default value for new property) doesn't count
// Display limit of -1 (default value for new property) means no display limit
if ( (displayLimit < 0) || (displayLimit > statements.size()) ) {
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
if (policyHelper.isAuthorizedAction(action)) {

View file

@ -140,7 +140,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
return propertyList;
}
public boolean getShowEditingLinks() {
public boolean isEditable() {
// RY This will be improved later. What is important is not whether the user is a self-editor,
// but whether he has editing privileges on this profile.
return VitroRequestPrep.isSelfEditing(vreq) ||

View file

@ -17,6 +17,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
private static final Log log = LogFactory.getLog(PropertyTemplateModel.class);
private String name;
private String localName;
protected String propertyUri;
// For editing
@ -24,10 +25,12 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
protected boolean addAccess = false;
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper) {
propertyUri = property.getURI();
localName = property.getLocalName();
// Do in subclass constructor. The label has not been set on the property, and the
// means of getting the label differs between object and data properties.
// this.name = property.getLabel();
propertyUri = property.getURI();
if (policyHelper != null) {
subjectUri = subject.getURI();
@ -38,10 +41,6 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
this.name = name;
}
protected String getUri() {
return propertyUri;
}
/* Access methods for templates */
@ -51,7 +50,14 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
return name;
}
public String getLocalName() {
return localName;
}
public String getUri() {
return propertyUri;
}
public abstract String getAddUrl();
}

View file

@ -11,7 +11,7 @@
<section id="individual-intro" class="vcard" role="region">
<section id="share-contact" role="region">
<#-- Image -->
<@p.imageLinks individual propertyGroups editing />
<@p.imageLinks individual propertyGroups editable />
</section>
<section id="individual-info" role="region">
@ -24,7 +24,7 @@
<#-- Label -->
<#assign label = individual.nameStatement>
${label.value}
<@p.editingLinks label editing />
<@p.editingLinks label label editable />
<#-- Moniker -->
<#if individual.moniker?has_content>
@ -47,7 +47,7 @@
</nav>
<#-- Links -->
<@p.vitroLinks propertyGroups editing />
<@p.vitroLinks propertyGroups editable />
</section>
</section>

View file

@ -21,20 +21,22 @@
<#-- List the properties in the group -->
<#list group.properties as property>
<#assign propertyNameCamel = property.name?capitalize?replace(" ", "")?uncap_first />
<article class="property" role="article">
<#-- Property display name -->
<h3 id="${propertyNameCamel}">${property.name} <@p.addLink property editing /></h3>
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /></h3>
<#-- List the statements for each property -->
<ul class="property-list" role="list">
<#-- data property -->
<#if property.type == "data">
<@p.dataPropertyList property.statements editing />
<@p.dataPropertyList property editable />
<#-- object property -->
<#elseif property.collatedBySubclass> <#-- collated -->
<@p.collatedObjectPropertyList property editing />
<@p.collatedObjectPropertyList property editable />
<#else> <#-- uncollated -->
<@p.objectPropertyList property.statements property.template editing />
<#-- We pass property.statements and property.template even though we are also
passing property, because objecctPropertyList can get other values, and
doesn't necessarily use property.statements and property.template -->
<@p.objectPropertyList property property.statements property.template editable />
</#if>
</ul>
</article> <!-- end property -->

View file

@ -5,10 +5,6 @@
<#import "lib-list.ftl" as l>
<#import "lib-properties.ftl" as p>
<#assign editing = individual.showEditingLinks>
<#assign editingClass>
<#if editing>editing</#if>
</#assign>
<#assign editable = individual.editable>
<#assign propertyGroups = individual.propertyList>

View file

@ -4,46 +4,46 @@
Macros for generating property lists
------------------------------------------------------------------------------>
<#macro dataPropertyList statements showEditingLinks>
<#list statements as statement>
<@propertyListItem statement showEditingLinks>${statement.value}</@propertyListItem>
<#macro dataPropertyList property editable>
<#list property.statements as statement>
<@propertyListItem property statement editable>${statement.value}</@propertyListItem>
</#list>
</#macro>
<#macro collatedObjectPropertyList property showEditingLinks>
<#macro collatedObjectPropertyList property editable>
<#assign subclasses = property.subclasses>
<#list subclasses?keys as subclass>
<li class="subclass">
<h3>${subclass?lower_case}</h3>
<ul class="subclass-property-list">
<@objectPropertyList subclasses[subclass] property.template showEditingLinks />
<@objectPropertyList property subclasses[subclass] property.template editable />
</ul>
</li>
</#list>
</#macro>
<#macro simpleObjectPropertyList property showEditingLinks>
<@objectPropertyList property.statements "propStatement-simple.ftl" showEditingLinks />
<#macro simpleObjectPropertyList property editable>
<@objectPropertyList property property.statements "propStatement-simple.ftl" editable />
</#macro>
<#macro objectPropertyList statements template showEditingLinks>
<#macro objectPropertyList property statements template editable>
<#list statements as statement>
<@propertyListItem statement showEditingLinks><#include "${template}"></@propertyListItem>
<@propertyListItem property statement editable><#include "${template}"></@propertyListItem>
</#list>
</#macro>
<#-- Some properties usually display without a label. But if there's an add link,
we need to also show the property label. If no label is specified, the property
name will be used as the label. -->
<#macro addLinkWithLabel property showEditingLinks label="${property.name?capitalize}">
<#local addLink><@addLink property showEditingLinks /></#local>
<#macro addLinkWithLabel property editable label="${property.name?capitalize}">
<#local addLink><@addLink property editable /></#local>
<#if addLink?has_content>
<h3>${label} ${addLink}</h3>
</#if>
</#macro>
<#macro addLink property showEditingLinks>
<#if showEditingLinks>
<#macro addLink property editable>
<#if editable>
<#local url = property.addUrl>
<#if url?has_content>
<a href="${url}" title="add entry"><img class="add-individual" src="${urls.images}/individual/addIcon.gif" alt="add" /></a>
@ -51,28 +51,28 @@ name will be used as the label. -->
</#if>
</#macro>
<#macro propertyListItem statement showEditingLinks>
<#macro propertyListItem property statement editable>
<li role="listitem">
<#nested>
<@editingLinks statement showEditingLinks />
<@editingLinks property statement editable />
</li>
</#macro>
<#macro editingLinks statement showEditingLinks>
<#if showEditingLinks>
<@editLink statement />
<@deleteLink statement />
<#macro editingLinks property statement editable>
<#if editable>
<@editLink property statement />
<@deleteLink property statement />
</#if>
</#macro>
<#macro editLink statement>
<#macro editLink property statement>
<#local url = statement.editUrl>
<#if url?has_content>
<a href="${url}" title="edit this entry"><img class="edit-individual" src="${urls.images}/individual/editIcon.gif" alt="edit" /></a>
</#if>
</#macro>
<#macro deleteLink statement>
<#macro deleteLink property statement>
<#local url = statement.deleteUrl>
<#if url?has_content>
<a href="${url}" title="delete this entry"><img class="delete-individual" src="${urls.images}/individual/deleteIcon.gif" alt="delete" /></a>
@ -98,13 +98,13 @@ name will be used as the label. -->
<@addLinkWithLabel primaryLink showEditLinks "Primary Web Page" />
<#if primaryLink.statements?has_content> <#-- if there are any statements -->
<ul class="${linkListClass}" id="links-primary" role="list">
<@objectPropertyList primaryLink.statements primaryLink.template showEditLinks />
<@objectPropertyList primaryLink primaryLink.statements primaryLink.template showEditLinks />
</ul>
</#if>
<@addLinkWithLabel additionalLinks showEditLinks "Additional Web Pages" />
<#if additionalLinks.statements?has_content> <#-- if there are any statements -->
<ul class="${linkListClass}" id="links-additional" role="list">
<@objectPropertyList additionalLinks.statements additionalLinks.template showEditLinks />
<@objectPropertyList additionalLinks additionalLinks.statements additionalLinks.template showEditLinks />
</ul>
</#if>
</nav>
@ -119,12 +119,11 @@ name will be used as the label. -->
If there's a mainImage statement but no thumbnail image, treat it as if there is no image. -->
<#if (mainImage.statements)?has_content && thumbUrl?has_content>
<a href="${individual.imageUrl}"><img class="individual-photo" src="${thumbUrl}" title="click to view larger image" alt="${individual.name}" width="160" /></a>
<@p.editingLinks mainImage.statements[0] showEditLinks />
<@p.editingLinks mainImage mainImage.statements[0] showEditLinks />
<#else>
<@p.addLinkWithLabel mainImage showEditLinks "Photo" />
<#if placeholderImage?has_content>
<img class="individual-photo" src="${placeholderImage}" title = "no image" alt="placeholder image" width="160" />
</#if>
</#if>
</#macro>