NIHVIVO-1392 Move verbose property display form from site admin page to admin panel on individual page
This commit is contained in:
parent
bc8d979ba5
commit
af8ce43e16
4 changed files with 47 additions and 29 deletions
|
@ -30,6 +30,7 @@ import com.hp.hpl.jena.shared.Lock;
|
|||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
|
||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
|
@ -40,6 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RdfResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||
|
@ -123,6 +125,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
body.put("relatedSubject", getRelatedSubject(vreq));
|
||||
body.put("namespaces", namespaces);
|
||||
body.put("temporalVisualizationEnabled", getTemporalVisualizationFlag());
|
||||
body.put("verbosePropertyForm", getVerbosePropertyValues(vreq));
|
||||
|
||||
IndividualTemplateModel itm = getIndividualTemplateModel(vreq, individual);
|
||||
/* We need to expose non-getters in displaying the individual's property list,
|
||||
|
@ -151,6 +154,39 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
EditSubmission.clearAllEditSubmissionsInSession(session);
|
||||
}
|
||||
|
||||
private Map<String, Object> getVerbosePropertyValues(VitroRequest vreq) {
|
||||
|
||||
Map<String, Object> map = null;
|
||||
|
||||
LoginStatusBean loginBean = LoginStatusBean.getBean(vreq);
|
||||
|
||||
if (loginBean.isLoggedInAtLeast(LoginStatusBean.CURATOR)) {
|
||||
// Get current verbose property display value
|
||||
String verbose = vreq.getParameter("verbose");
|
||||
Boolean verbosePropertyDisplayValue;
|
||||
// If the form was submitted, get that value
|
||||
if (verbose != null) {
|
||||
verbosePropertyDisplayValue = "true".equals(verbose);
|
||||
// If form not submitted, get the session value
|
||||
} else {
|
||||
Boolean verbosePropertyDisplayValueInSession = (Boolean) vreq.getSession().getAttribute("verbosePropertyDisplay");
|
||||
// True if session value is true, otherwise (session value is false or null) false
|
||||
verbosePropertyDisplayValue = Boolean.TRUE.equals(verbosePropertyDisplayValueInSession);
|
||||
}
|
||||
vreq.getSession().setAttribute("verbosePropertyDisplay", verbosePropertyDisplayValue);
|
||||
|
||||
map = new HashMap<String, Object>();
|
||||
map.put("verboseFieldValue", String.valueOf(!verbosePropertyDisplayValue)); // the form toggles the current value
|
||||
map.put("action", ""); // FIX THIS -
|
||||
map.put("currentValue", verbosePropertyDisplayValue ? "on" : "off");
|
||||
map.put("newValue", verbosePropertyDisplayValue ? "off" : "on");
|
||||
} else {
|
||||
vreq.getSession().setAttribute("verbosePropertyDisplay", false);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<String, Object> getRelatedSubject(VitroRequest vreq) {
|
||||
Map<String, Object> map = null;
|
||||
|
||||
|
|
|
@ -179,27 +179,6 @@ public class SiteAdminController extends FreemarkerHttpServlet {
|
|||
urls.put("objectPropertyHierarchy", urlBuilder.getPortalUrl("/showObjectPropertyHierarchy", new ParamMap("iffRoot", "true")));
|
||||
map.put("urls", urls);
|
||||
|
||||
// Get current verbose property display value
|
||||
String verbose = vreq.getParameter("verbose");
|
||||
Boolean verbosePropertyDisplayValue;
|
||||
// If the form was submitted, get that value
|
||||
if (verbose != null) {
|
||||
verbosePropertyDisplayValue = "true".equals(verbose);
|
||||
// If form not submitted, get the session value
|
||||
} else {
|
||||
Boolean verbosePropertyDisplayValueInSession = (Boolean) vreq.getSession().getAttribute("verbosePropertyDisplay");
|
||||
// True if session value is true, otherwise (session value is false or null) false
|
||||
verbosePropertyDisplayValue = Boolean.TRUE.equals(verbosePropertyDisplayValueInSession);
|
||||
}
|
||||
vreq.getSession().setAttribute("verbosePropertyDisplay", verbosePropertyDisplayValue);
|
||||
|
||||
Map<String, Object> verbosePropertyForm = new HashMap<String, Object>();
|
||||
verbosePropertyForm.put("verboseFieldValue", String.valueOf(!verbosePropertyDisplayValue)); // the form toggles the current value
|
||||
verbosePropertyForm.put("action", urlBuilder.getPortalUrl(Route.SITE_ADMIN));
|
||||
verbosePropertyForm.put("currentValue", verbosePropertyDisplayValue ? "on" : "off");
|
||||
verbosePropertyForm.put("newValue", verbosePropertyDisplayValue ? "off" : "on");
|
||||
map.put("verbosePropertyForm", verbosePropertyForm);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,5 +4,15 @@
|
|||
|
||||
<section id="admin">
|
||||
<h3>Admin Panel</h3><a class="edit-individual" href="${individual.editUrl}">Edit this individual</a>
|
||||
|
||||
<#if verbosePropertyForm??>
|
||||
<#assign formId = "verbosePropertyForm">
|
||||
<form id="${formId}" action="${verbosePropertyForm.action}#${formId}" method="get">
|
||||
<input type="hidden" name="verbose" value="${verbosePropertyForm.verboseFieldValue}" />
|
||||
<span>Verbose property display for this session is <b>${verbosePropertyForm.currentValue}</b></span>
|
||||
<input type="submit" id="submit" value="Turn ${verbosePropertyForm.newValue}" />
|
||||
</form>
|
||||
</#if>
|
||||
|
||||
<p class="uri-link">Resource URI: <a href="${individual.uri}" target="_blank">${individual.uri}</a></p>
|
||||
</section>
|
|
@ -32,13 +32,6 @@
|
|||
<li><a href="${ontologyEditor.urls.dataPropertyHierarchy}">Data property hierarchy</a></li>
|
||||
<li><a href="${ontologyEditor.urls.propertyGroups}">Property groups</a></li>
|
||||
</ul>
|
||||
|
||||
<#assign formId = "verbosePropertyForm">
|
||||
<form id="${formId}" action="${ontologyEditor.verbosePropertyForm.action}#${formId}" method="get">
|
||||
<input type="hidden" name="verbose" value="${ontologyEditor.verbosePropertyForm.verboseFieldValue}" />
|
||||
<span>Verbose property display for this session is <b>${ontologyEditor.verbosePropertyForm.currentValue}</b>.</span>
|
||||
<input type="submit" id="submit" value="Turn ${ontologyEditor.verbosePropertyForm.newValue}" />
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</#if>
|
Loading…
Add table
Reference in a new issue