Renamed Freemarker macro files. Implemented data input portion of main site admin page in Freemarker.
This commit is contained in:
parent
79da8d30ed
commit
fa247f1f79
11 changed files with 102 additions and 27 deletions
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -11,10 +13,12 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
|
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
|
||||||
|
import edu.cornell.mannlib.vedit.beans.Option;
|
||||||
import edu.cornell.mannlib.vedit.util.FormUtils;
|
import edu.cornell.mannlib.vedit.util.FormUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginTemplateHelper;
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginTemplateHelper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
@ -44,8 +48,30 @@ public class FreemarkerSiteAdminController extends FreemarkerHttpServlet {
|
||||||
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logged in: show editing options based on user role
|
||||||
int securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
int securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
||||||
|
|
||||||
|
WebappDaoFactory wadf = vreq.getFullWebappDaoFactory();
|
||||||
|
|
||||||
|
// Data input
|
||||||
|
if (securityLevel >= LoginFormBean.EDITOR) {
|
||||||
|
Map<String, Object> dataInputMap = new HashMap<String, Object>();
|
||||||
|
dataInputMap.put("formAction", UrlBuilder.getUrl("/edit/editRequestDispatch.jsp"));
|
||||||
|
|
||||||
|
// Create map for data input entry form options list
|
||||||
|
List classGroups = wadf.getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals
|
||||||
|
Iterator classGroupIt = classGroups.iterator();
|
||||||
|
LinkedHashMap<String, List> orderedClassGroups = new LinkedHashMap<String, List>(classGroups.size());
|
||||||
|
while (classGroupIt.hasNext()) {
|
||||||
|
VClassGroup group = (VClassGroup)classGroupIt.next();
|
||||||
|
List classes = group.getVitroClassList();
|
||||||
|
orderedClassGroups.put(group.getPublicName(),FormUtils.makeOptionListFromBeans(classes,"URI","PickListName",null,null,false));
|
||||||
|
}
|
||||||
|
dataInputMap.put("classGroupOptions", orderedClassGroups);
|
||||||
|
|
||||||
|
body.put("dataInput", dataInputMap);
|
||||||
|
}
|
||||||
|
|
||||||
if (securityLevel >= LoginFormBean.CURATOR) {
|
if (securityLevel >= LoginFormBean.CURATOR) {
|
||||||
String verbose = vreq.getParameter("verbose");
|
String verbose = vreq.getParameter("verbose");
|
||||||
if( "true".equals(verbose)) {
|
if( "true".equals(verbose)) {
|
||||||
|
@ -58,7 +84,7 @@ public class FreemarkerSiteAdminController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
body.put("singlePortal", new Boolean(vreq.getFullWebappDaoFactory().getPortalDao().isSinglePortal()));
|
body.put("singlePortal", new Boolean(vreq.getFullWebappDaoFactory().getPortalDao().isSinglePortal()));
|
||||||
|
|
||||||
WebappDaoFactory wadf = vreq.getFullWebappDaoFactory();
|
|
||||||
|
|
||||||
// Not used
|
// Not used
|
||||||
// int languageProfile = wadf.getLanguageProfile();
|
// int languageProfile = wadf.getLanguageProfile();
|
||||||
|
@ -71,17 +97,6 @@ public class FreemarkerSiteAdminController extends FreemarkerHttpServlet {
|
||||||
// body.put("languageModeStr", languageMode);
|
// body.put("languageModeStr", languageMode);
|
||||||
|
|
||||||
|
|
||||||
// Create map for data input entry form
|
|
||||||
List classGroups = wadf.getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals
|
|
||||||
Iterator classGroupIt = classGroups.iterator();
|
|
||||||
ListOrderedMap optGroupMap = new ListOrderedMap();
|
|
||||||
while (classGroupIt.hasNext()) {
|
|
||||||
VClassGroup group = (VClassGroup)classGroupIt.next();
|
|
||||||
List classes = group.getVitroClassList();
|
|
||||||
optGroupMap.put(group.getPublicName(),FormUtils.makeOptionListFromBeans(classes,"URI","PickListName",null,null,false));
|
|
||||||
}
|
|
||||||
body.put("VClassIdOptions", optGroupMap);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<#-- Template for autocomplete results. -->
|
<#-- Template for autocomplete results. -->
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
<#import "json.ftl" as json>
|
<#import "lib-json.ftl" as json>
|
||||||
<@json.array results />
|
<@json.array results />
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<#-- List individual members of a class. -->
|
<#-- List individual members of a class. -->
|
||||||
|
|
||||||
<#import "listMacros.ftl" as l>
|
<#import "lib-list.ftl" as l>
|
||||||
|
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
<div class="individualList">
|
<div class="individualList">
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
<#-- Main template for the login panel -->
|
<#-- Main template for the login panel -->
|
||||||
|
|
||||||
${loginPanel}
|
<#if loginPanel??>
|
||||||
|
${loginPanel}
|
||||||
|
|
||||||
${stylesheets.add("/css/login.css")}
|
${stylesheets.add("/css/login.css")}
|
||||||
${stylesheets.addFromTheme("/css/formedit.css")}
|
${stylesheets.addFromTheme("/css/formedit.css")}
|
||||||
${scripts.add("/js/jquery.js", "/js/login/loginUtils.js")}
|
${scripts.add("/js/jquery.js", "/js/login/loginUtils.js")}
|
||||||
|
</#if>
|
|
@ -1,3 +1,21 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#-- Template for Site Administration Data Input -->
|
<#-- Template for Site Administration data input panel -->
|
||||||
|
|
||||||
|
<#import "lib-form.ftl" as form>
|
||||||
|
|
||||||
|
<#if dataInput??>
|
||||||
|
<div class="pageBodyGroup">
|
||||||
|
|
||||||
|
<h3>Data Input</h3>
|
||||||
|
|
||||||
|
<form action="${dataInput.formAction}" method="get">
|
||||||
|
<select id="VClassURI" name="typeOfNew" class="form-item">
|
||||||
|
<@form.optionGroups groups=dataInput.classGroupOptions />
|
||||||
|
</select>
|
||||||
|
<input type="hidden" name="editform" value="newIndividualForm.jsp"/>
|
||||||
|
<input type="submit" class="add-action-button" value="Add individual of this class"/>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</#if>
|
|
@ -7,9 +7,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="adminDashboard">
|
<div id="adminDashboard">
|
||||||
|
<#include "login-main.ftl">
|
||||||
<#if loginPanel??>
|
<#include "siteAdmin-dataInput.ftl">
|
||||||
<#include "login-main.ftl">
|
<#include "siteAdmin-siteConfiguration.ftl">
|
||||||
</#if>
|
<#include "siteAdmin-ontologyEditor.ftl">
|
||||||
|
<#include "siteAdmin-advancedDataTools.ftl">
|
||||||
|
<#include "siteAdmin-customReports.ftl">
|
||||||
</div>
|
</div>
|
39
webapp/web/templates/freemarker/lib/lib-form.ftl
Normal file
39
webapp/web/templates/freemarker/lib/lib-form.ftl
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Macros for form controls -->
|
||||||
|
|
||||||
|
<#--
|
||||||
|
Macro: optionGroups
|
||||||
|
|
||||||
|
Output a sequence of option groups with options.
|
||||||
|
|
||||||
|
Input is a map of option groups to a list of Option objects.
|
||||||
|
|
||||||
|
Usage: <@optionGroups groups=myOptionGroups />
|
||||||
|
-->
|
||||||
|
<#macro optionGroups groups>
|
||||||
|
<#list groups?keys as group>
|
||||||
|
<optgroup label="${group}">
|
||||||
|
<@options opts=groups[group] />
|
||||||
|
</optgroup>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#---------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
<#--
|
||||||
|
Macro: options
|
||||||
|
|
||||||
|
Output a sequence of options.
|
||||||
|
|
||||||
|
Input is a list of Option objects.
|
||||||
|
|
||||||
|
Usage: <@options opts=myOptions />
|
||||||
|
-->
|
||||||
|
<#macro options opts>
|
||||||
|
<#list opts as opt>
|
||||||
|
<option value="${opt.value}"<#if opt.selected> selected="selected"</#if>>${opt.body}</option>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#---------------------------------------------------------------------------->
|
|
@ -1,6 +1,6 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#import "listMacros.ftl" as l>
|
<#import "lib-list.ftl" as l>
|
||||||
|
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#import "listMacros.ftl" as l>
|
<#import "lib-list.ftl" as l>
|
||||||
|
|
||||||
<div id="identity">
|
<div id="identity">
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue