Change verbose property switch from a form element to an anchor element.
This commit is contained in:
parent
28d9155283
commit
1bc5db2cd8
2 changed files with 23 additions and 22 deletions
|
@ -125,7 +125,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
body.put("relatedSubject", getRelatedSubject(vreq));
|
||||
body.put("namespaces", namespaces);
|
||||
body.put("temporalVisualizationEnabled", getTemporalVisualizationFlag());
|
||||
body.put("verbosePropertyForm", getVerbosePropertyFormValues(vreq));
|
||||
body.put("verbosePropertySwitch", getVerbosePropertyValues(vreq));
|
||||
|
||||
IndividualTemplateModel itm = getIndividualTemplateModel(vreq, individual);
|
||||
/* We need to expose non-getters in displaying the individual's property list,
|
||||
|
@ -154,7 +154,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
EditSubmission.clearAllEditSubmissionsInSession(session);
|
||||
}
|
||||
|
||||
private Map<String, Object> getVerbosePropertyFormValues(VitroRequest vreq) {
|
||||
private Map<String, Object> getVerbosePropertyValues(VitroRequest vreq) {
|
||||
|
||||
Map<String, Object> map = null;
|
||||
|
||||
|
@ -176,18 +176,20 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
vreq.getSession().setAttribute("verbosePropertyDisplay", verboseValue);
|
||||
|
||||
map = new HashMap<String, Object>();
|
||||
String formAction = vreq.getRequestURI();
|
||||
// Append query string for current page, including uri param for individuals in non-default namespace.
|
||||
String queryString = vreq.getQueryString();
|
||||
if (! StringUtils.isBlank(queryString)) {
|
||||
formAction += "?" + queryString;
|
||||
}
|
||||
map.put("action", formAction);
|
||||
// NB Query params on form action url not recognized for get (also makes processing easier, else
|
||||
// we'd need to strip the verbose param out of the query string).
|
||||
map.put("method", "post");
|
||||
map.put("currentValue", verboseValue);
|
||||
map.put("newValue", String.valueOf(!verboseValue));
|
||||
|
||||
String url = vreq.getRequestURI() + "?verbose=" + !verboseValue;
|
||||
// Append request query string, except for current verbose value, to url
|
||||
String queryString = vreq.getQueryString();
|
||||
if (queryString != null) {
|
||||
String[] params = queryString.split("&");
|
||||
for (String param : params) {
|
||||
if (! param.startsWith("verbose=")) {
|
||||
url += "&" + param;
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("url", url);
|
||||
} else {
|
||||
vreq.getSession().setAttribute("verbosePropertyDisplay", false);
|
||||
}
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
|
||||
<#-- Template for admin panel on individual profile page -->
|
||||
|
||||
<#import "lib-form.ftl" as form>
|
||||
|
||||
<#if individual.showAdminPanel>
|
||||
<section id="admin">
|
||||
<h3>Admin Panel</h3><a class="edit-individual" href="${individual.editUrl}">Edit this individual</a>
|
||||
|
||||
<#if verbosePropertyForm??>
|
||||
<#assign formId = "verbosePropertyForm">
|
||||
<#assign currentValue = verbosePropertyForm.currentValue?string("on", "off")>
|
||||
<#assign newValue = verbosePropertyForm.currentValue?string("off", "on")>
|
||||
<form id="${formId}" action="${verbosePropertyForm.action}#${formId}" method="${verbosePropertyForm.method}">
|
||||
<input type="hidden" name="verbose" value="${verbosePropertyForm.newValue}" />
|
||||
<span>Verbose property display is <b>${currentValue}</b> | </span>
|
||||
<input type="submit" id="submit" class="small" value="Turn ${newValue}" />
|
||||
</form>
|
||||
<#if verbosePropertySwitch??>
|
||||
<#assign anchorId = "verbosePropertySwitch">
|
||||
<#assign currentValue = verbosePropertySwitch.currentValue?string("on", "off")>
|
||||
<#assign newValue = verbosePropertySwitch.currentValue?string("off", "on")>
|
||||
<span>Verbose property display is <b>${currentValue}</b> | </span>
|
||||
<a id="${anchorId}" href="${verbosePropertySwitch.url}#${anchorId}">Turn ${newValue}</a>
|
||||
</#if>
|
||||
|
||||
<p class="uri-link">Resource URI: <a href="${individual.uri}" target="_blank">${individual.uri}</a></p>
|
||||
|
|
Loading…
Add table
Reference in a new issue