Simplification of default object property form (in the edit configuration template - i.e. leaving out the range options generation for all but the default forms) -

This commit is contained in:
hjkhjk54 2011-11-04 22:01:38 +00:00
parent f5e1661f9a
commit ad0ff55080
6 changed files with 35 additions and 37 deletions

View file

@ -168,7 +168,11 @@ public class EditN3GeneratorVTwo {
//make the multivalue literal string
List<String> n3Values = new ArrayList<String>(values.size());
for( Literal value : values){
if(value != null) {
n3Values.add( formatLiteral(value) );
} else {
log.debug("value of literal for " + var + " was null");
}
}
String valueString = org.apache.commons.lang.StringUtils.join(n3Values, ",");

View file

@ -123,6 +123,8 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
setTemplate(editConfiguration, vreq);
//Set edit key
setEditKey(editConfiguration, vreq);
//Adding additional data, specifically edit mode
addFormSpecificData(editConfiguration, vreq);
return editConfiguration;
}
@ -523,6 +525,18 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
}
}
//Form specific data
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
//range options need to be stored for object property
//Store field names
List<String> objectSelect = new ArrayList<String>();
objectSelect.add(editConfiguration.getVarNameForObject());
//TODO: Check if this is the proper way to do this?
formSpecificData.put("objectSelect", objectSelect);
editConfiguration.setFormSpecificData(formSpecificData);
}
}

View file

@ -96,9 +96,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
private void populateDropdowns() {
String predicateUri = editConfig.getPredicateUri();
if(predicateUri != null) {
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
setRangeOptions();
}
if(pageData.containsKey("objectSelect")) {
List<String> fieldNames = (List<String>)pageData.get("objectSelect");
for(String field:fieldNames) {
@ -124,11 +121,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
return selectedValue;
}
private boolean isRangeOptionsExist() {
boolean rangeOptionsExist = (pageData.get("rangeOptionsExist") != null && (Boolean) pageData.get("rangeOptionsExist") == true);
return rangeOptionsExist;
}
private void setFormTitle() {
String predicateUri = editConfig.getPredicateUri();
if(predicateUri != null) {
@ -228,29 +220,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
}
private void setRangeOptions() {
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
if( prop != null && prop.getSelectFromExisting() ){
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
//TODO: Change this to varname for object from object property?
String fieldName = editConfig.getVarNameForObject();
//TODO: Check if this still works?
Map<String,String> rangeOptions = SelectListGeneratorVTwo.getOptions(editConfig, fieldName , wdf);
if( rangeOptions != null && rangeOptions.size() > 0 ) {
pageData.put("rangeOptionsExist", true);
pageData.put("rangeOptions", rangeOptions);
} else {
pageData.put("rangeOptionsExist",false);
}
}
}
//Get page data
public boolean getRangeOptionsExist() {
return isRangeOptionsExist();
}
public String getFormTitle() {
return (String) pageData.get("formTitle");

View file

@ -29,4 +29,8 @@ public class MultiValueEditSubmissionTemplateModel {
return editSub.getUrisFromForm();
}
public boolean getSubmissionExists() {
return (this.editSub != null);
}
}

View file

@ -1,6 +1,6 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#if editConfiguration.rangeOptionsExist = true >
<#if rangeOptionsExist = true >
<p>If you don't find the appropriate entry on the selection list above:</p>
<#else>
<p>Please create a new entry.</p>

View file

@ -1,10 +1,17 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#--Assign variables from editConfig-->
<#assign rangeOptions = editConfiguration.pageData.objectVar />
<#assign rangeOptionsExist = false />
<#if (rangeOptions?keys?size > 0)>
<#assign rangeOptionsExist = true/>
</#if>
<h2>${editConfiguration.formTitle}</h2>
<#if editConfiguration.propertySelectFromExisting = true>
<#if editConfiguration.rangeOptionsExist = true >
<#assign rangeOptionKeys = editConfiguration.rangeOptions?keys />
<#if rangeOptionsExist = true >
<#assign rangeOptionKeys = rangeOptions?keys />
<form class="editForm" action = "${submitUrl}">
<input type="hidden" name="editKey" id="editKey" value="${editKey}" role="input" />
<#if editConfiguration.propertyPublicDescription?has_content>
@ -12,14 +19,14 @@
<select id="objectVar" name="objectVar" role="select">
<#list rangeOptionKeys as key>
<option value="${key}" <#if editConfiguration.objectUri?has_content && editConfiguration.objectUri = key>selected</#if> role="option">${editConfiguration.rangeOptions[key]}</option>
<option value="${key}" <#if editConfiguration.objectUri?has_content && editConfiguration.objectUri = key>selected</#if> role="option">${rangeOptions[key]}</option>
</#list>
</select>
<p>
<input type="submit" id="submit" value="${editConfiguration.submitLabel}" role="button "/>
<span class="or"> or </span>
<a title="Cancel" href="${editConfiguration.cancelUrl}">Cancel</a>
<a title="Cancel" href="${cancelUrl}">Cancel</a>
</p>
</#if>
</form>