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:
parent
346d7ba4ce
commit
ce76206f7c
7 changed files with 49 additions and 46 deletions
|
@ -46,7 +46,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
if (policyHelper != null) {
|
if (policyHelper != null) {
|
||||||
// If the display limit has already been reached, we can't add a new statement
|
// If the display limit has already been reached, we can't add a new statement
|
||||||
int displayLimit = dp.getDisplayLimit();
|
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()) ) {
|
if ( (displayLimit < 0) || (displayLimit > statements.size()) ) {
|
||||||
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
|
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
|
||||||
if (policyHelper.isAuthorizedAction(action)) {
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
return propertyList;
|
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,
|
// 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.
|
// but whether he has editing privileges on this profile.
|
||||||
return VitroRequestPrep.isSelfEditing(vreq) ||
|
return VitroRequestPrep.isSelfEditing(vreq) ||
|
||||||
|
|
|
@ -17,6 +17,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
private static final Log log = LogFactory.getLog(PropertyTemplateModel.class);
|
private static final Log log = LogFactory.getLog(PropertyTemplateModel.class);
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
private String localName;
|
||||||
protected String propertyUri;
|
protected String propertyUri;
|
||||||
|
|
||||||
// For editing
|
// For editing
|
||||||
|
@ -24,10 +25,12 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
protected boolean addAccess = false;
|
protected boolean addAccess = false;
|
||||||
|
|
||||||
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper) {
|
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
|
// 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.
|
// means of getting the label differs between object and data properties.
|
||||||
// this.name = property.getLabel();
|
// this.name = property.getLabel();
|
||||||
propertyUri = property.getURI();
|
|
||||||
|
|
||||||
if (policyHelper != null) {
|
if (policyHelper != null) {
|
||||||
subjectUri = subject.getURI();
|
subjectUri = subject.getURI();
|
||||||
|
@ -38,10 +41,6 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getUri() {
|
|
||||||
return propertyUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Access methods for templates */
|
/* Access methods for templates */
|
||||||
|
|
||||||
|
@ -51,7 +50,14 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocalName() {
|
||||||
|
return localName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUri() {
|
||||||
|
return propertyUri;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract String getAddUrl();
|
public abstract String getAddUrl();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<section id="individual-intro" class="vcard" role="region">
|
<section id="individual-intro" class="vcard" role="region">
|
||||||
<section id="share-contact" role="region">
|
<section id="share-contact" role="region">
|
||||||
<#-- Image -->
|
<#-- Image -->
|
||||||
<@p.imageLinks individual propertyGroups editing />
|
<@p.imageLinks individual propertyGroups editable />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="individual-info" role="region">
|
<section id="individual-info" role="region">
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
<#-- Label -->
|
<#-- Label -->
|
||||||
<#assign label = individual.nameStatement>
|
<#assign label = individual.nameStatement>
|
||||||
${label.value}
|
${label.value}
|
||||||
<@p.editingLinks label editing />
|
<@p.editingLinks label label editable />
|
||||||
|
|
||||||
<#-- Moniker -->
|
<#-- Moniker -->
|
||||||
<#if individual.moniker?has_content>
|
<#if individual.moniker?has_content>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<#-- Links -->
|
<#-- Links -->
|
||||||
<@p.vitroLinks propertyGroups editing />
|
<@p.vitroLinks propertyGroups editable />
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -21,20 +21,22 @@
|
||||||
|
|
||||||
<#-- List the properties in the group -->
|
<#-- List the properties in the group -->
|
||||||
<#list group.properties as property>
|
<#list group.properties as property>
|
||||||
<#assign propertyNameCamel = property.name?capitalize?replace(" ", "")?uncap_first />
|
|
||||||
<article class="property" role="article">
|
<article class="property" role="article">
|
||||||
<#-- Property display name -->
|
<#-- 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 -->
|
<#-- List the statements for each property -->
|
||||||
<ul class="property-list" role="list">
|
<ul class="property-list" role="list">
|
||||||
<#-- data property -->
|
<#-- data property -->
|
||||||
<#if property.type == "data">
|
<#if property.type == "data">
|
||||||
<@p.dataPropertyList property.statements editing />
|
<@p.dataPropertyList property editable />
|
||||||
<#-- object property -->
|
<#-- object property -->
|
||||||
<#elseif property.collatedBySubclass> <#-- collated -->
|
<#elseif property.collatedBySubclass> <#-- collated -->
|
||||||
<@p.collatedObjectPropertyList property editing />
|
<@p.collatedObjectPropertyList property editable />
|
||||||
<#else> <#-- uncollated -->
|
<#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>
|
</#if>
|
||||||
</ul>
|
</ul>
|
||||||
</article> <!-- end property -->
|
</article> <!-- end property -->
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
<#import "lib-list.ftl" as l>
|
<#import "lib-list.ftl" as l>
|
||||||
<#import "lib-properties.ftl" as p>
|
<#import "lib-properties.ftl" as p>
|
||||||
|
|
||||||
<#assign editing = individual.showEditingLinks>
|
<#assign editable = individual.editable>
|
||||||
|
|
||||||
<#assign editingClass>
|
|
||||||
<#if editing>editing</#if>
|
|
||||||
</#assign>
|
|
||||||
|
|
||||||
<#assign propertyGroups = individual.propertyList>
|
<#assign propertyGroups = individual.propertyList>
|
|
@ -4,46 +4,46 @@
|
||||||
Macros for generating property lists
|
Macros for generating property lists
|
||||||
------------------------------------------------------------------------------>
|
------------------------------------------------------------------------------>
|
||||||
|
|
||||||
<#macro dataPropertyList statements showEditingLinks>
|
<#macro dataPropertyList property editable>
|
||||||
<#list statements as statement>
|
<#list property.statements as statement>
|
||||||
<@propertyListItem statement showEditingLinks>${statement.value}</@propertyListItem>
|
<@propertyListItem property statement editable>${statement.value}</@propertyListItem>
|
||||||
</#list>
|
</#list>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro collatedObjectPropertyList property showEditingLinks>
|
<#macro collatedObjectPropertyList property editable>
|
||||||
<#assign subclasses = property.subclasses>
|
<#assign subclasses = property.subclasses>
|
||||||
<#list subclasses?keys as subclass>
|
<#list subclasses?keys as subclass>
|
||||||
<li class="subclass">
|
<li class="subclass">
|
||||||
<h3>${subclass?lower_case}</h3>
|
<h3>${subclass?lower_case}</h3>
|
||||||
<ul class="subclass-property-list">
|
<ul class="subclass-property-list">
|
||||||
<@objectPropertyList subclasses[subclass] property.template showEditingLinks />
|
<@objectPropertyList property subclasses[subclass] property.template editable />
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</#list>
|
</#list>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro simpleObjectPropertyList property showEditingLinks>
|
<#macro simpleObjectPropertyList property editable>
|
||||||
<@objectPropertyList property.statements "propStatement-simple.ftl" showEditingLinks />
|
<@objectPropertyList property property.statements "propStatement-simple.ftl" editable />
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro objectPropertyList statements template showEditingLinks>
|
<#macro objectPropertyList property statements template editable>
|
||||||
<#list statements as statement>
|
<#list statements as statement>
|
||||||
<@propertyListItem statement showEditingLinks><#include "${template}"></@propertyListItem>
|
<@propertyListItem property statement editable><#include "${template}"></@propertyListItem>
|
||||||
</#list>
|
</#list>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#-- Some properties usually display without a label. But if there's an add link,
|
<#-- 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
|
we need to also show the property label. If no label is specified, the property
|
||||||
name will be used as the label. -->
|
name will be used as the label. -->
|
||||||
<#macro addLinkWithLabel property showEditingLinks label="${property.name?capitalize}">
|
<#macro addLinkWithLabel property editable label="${property.name?capitalize}">
|
||||||
<#local addLink><@addLink property showEditingLinks /></#local>
|
<#local addLink><@addLink property editable /></#local>
|
||||||
<#if addLink?has_content>
|
<#if addLink?has_content>
|
||||||
<h3>${label} ${addLink}</h3>
|
<h3>${label} ${addLink}</h3>
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro addLink property showEditingLinks>
|
<#macro addLink property editable>
|
||||||
<#if showEditingLinks>
|
<#if editable>
|
||||||
<#local url = property.addUrl>
|
<#local url = property.addUrl>
|
||||||
<#if url?has_content>
|
<#if url?has_content>
|
||||||
<a href="${url}" title="add entry"><img class="add-individual" src="${urls.images}/individual/addIcon.gif" alt="add" /></a>
|
<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>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro propertyListItem statement showEditingLinks>
|
<#macro propertyListItem property statement editable>
|
||||||
<li role="listitem">
|
<li role="listitem">
|
||||||
<#nested>
|
<#nested>
|
||||||
<@editingLinks statement showEditingLinks />
|
<@editingLinks property statement editable />
|
||||||
</li>
|
</li>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro editingLinks statement showEditingLinks>
|
<#macro editingLinks property statement editable>
|
||||||
<#if showEditingLinks>
|
<#if editable>
|
||||||
<@editLink statement />
|
<@editLink property statement />
|
||||||
<@deleteLink statement />
|
<@deleteLink property statement />
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro editLink statement>
|
<#macro editLink property statement>
|
||||||
<#local url = statement.editUrl>
|
<#local url = statement.editUrl>
|
||||||
<#if url?has_content>
|
<#if url?has_content>
|
||||||
<a href="${url}" title="edit this entry"><img class="edit-individual" src="${urls.images}/individual/editIcon.gif" alt="edit" /></a>
|
<a href="${url}" title="edit this entry"><img class="edit-individual" src="${urls.images}/individual/editIcon.gif" alt="edit" /></a>
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro deleteLink statement>
|
<#macro deleteLink property statement>
|
||||||
<#local url = statement.deleteUrl>
|
<#local url = statement.deleteUrl>
|
||||||
<#if url?has_content>
|
<#if url?has_content>
|
||||||
<a href="${url}" title="delete this entry"><img class="delete-individual" src="${urls.images}/individual/deleteIcon.gif" alt="delete" /></a>
|
<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" />
|
<@addLinkWithLabel primaryLink showEditLinks "Primary Web Page" />
|
||||||
<#if primaryLink.statements?has_content> <#-- if there are any statements -->
|
<#if primaryLink.statements?has_content> <#-- if there are any statements -->
|
||||||
<ul class="${linkListClass}" id="links-primary" role="list">
|
<ul class="${linkListClass}" id="links-primary" role="list">
|
||||||
<@objectPropertyList primaryLink.statements primaryLink.template showEditLinks />
|
<@objectPropertyList primaryLink primaryLink.statements primaryLink.template showEditLinks />
|
||||||
</ul>
|
</ul>
|
||||||
</#if>
|
</#if>
|
||||||
<@addLinkWithLabel additionalLinks showEditLinks "Additional Web Pages" />
|
<@addLinkWithLabel additionalLinks showEditLinks "Additional Web Pages" />
|
||||||
<#if additionalLinks.statements?has_content> <#-- if there are any statements -->
|
<#if additionalLinks.statements?has_content> <#-- if there are any statements -->
|
||||||
<ul class="${linkListClass}" id="links-additional" role="list">
|
<ul class="${linkListClass}" id="links-additional" role="list">
|
||||||
<@objectPropertyList additionalLinks.statements additionalLinks.template showEditLinks />
|
<@objectPropertyList additionalLinks additionalLinks.statements additionalLinks.template showEditLinks />
|
||||||
</ul>
|
</ul>
|
||||||
</#if>
|
</#if>
|
||||||
</nav>
|
</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 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>
|
<#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>
|
<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>
|
<#else>
|
||||||
<@p.addLinkWithLabel mainImage showEditLinks "Photo" />
|
<@p.addLinkWithLabel mainImage showEditLinks "Photo" />
|
||||||
<#if placeholderImage?has_content>
|
<#if placeholderImage?has_content>
|
||||||
<img class="individual-photo" src="${placeholderImage}" title = "no image" alt="placeholder image" width="160" />
|
<img class="individual-photo" src="${placeholderImage}" title = "no image" alt="placeholder image" width="160" />
|
||||||
</#if>
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
</#macro>
|
</#macro>
|
Loading…
Add table
Reference in a new issue