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:
parent
f5e1661f9a
commit
ad0ff55080
6 changed files with 35 additions and 37 deletions
|
@ -168,7 +168,11 @@ public class EditN3GeneratorVTwo {
|
||||||
//make the multivalue literal string
|
//make the multivalue literal string
|
||||||
List<String> n3Values = new ArrayList<String>(values.size());
|
List<String> n3Values = new ArrayList<String>(values.size());
|
||||||
for( Literal value : values){
|
for( Literal value : values){
|
||||||
n3Values.add( formatLiteral(value) );
|
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, ",");
|
String valueString = org.apache.commons.lang.StringUtils.join(n3Values, ",");
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,8 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
||||||
setTemplate(editConfiguration, vreq);
|
setTemplate(editConfiguration, vreq);
|
||||||
//Set edit key
|
//Set edit key
|
||||||
setEditKey(editConfiguration, vreq);
|
setEditKey(editConfiguration, vreq);
|
||||||
|
//Adding additional data, specifically edit mode
|
||||||
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
return editConfiguration;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,9 +96,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
private void populateDropdowns() {
|
private void populateDropdowns() {
|
||||||
String predicateUri = editConfig.getPredicateUri();
|
String predicateUri = editConfig.getPredicateUri();
|
||||||
if(predicateUri != null) {
|
if(predicateUri != null) {
|
||||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
|
||||||
setRangeOptions();
|
|
||||||
}
|
|
||||||
if(pageData.containsKey("objectSelect")) {
|
if(pageData.containsKey("objectSelect")) {
|
||||||
List<String> fieldNames = (List<String>)pageData.get("objectSelect");
|
List<String> fieldNames = (List<String>)pageData.get("objectSelect");
|
||||||
for(String field:fieldNames) {
|
for(String field:fieldNames) {
|
||||||
|
@ -123,11 +120,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
return selectedValue;
|
return selectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRangeOptionsExist() {
|
|
||||||
boolean rangeOptionsExist = (pageData.get("rangeOptionsExist") != null && (Boolean) pageData.get("rangeOptionsExist") == true);
|
|
||||||
return rangeOptionsExist;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFormTitle() {
|
private void setFormTitle() {
|
||||||
String predicateUri = editConfig.getPredicateUri();
|
String predicateUri = editConfig.getPredicateUri();
|
||||||
|
@ -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() {
|
public String getFormTitle() {
|
||||||
return (String) pageData.get("formTitle");
|
return (String) pageData.get("formTitle");
|
||||||
|
|
|
@ -28,5 +28,9 @@ public class MultiValueEditSubmissionTemplateModel {
|
||||||
public Map<String, List<String>> getUrisFromForm() {
|
public Map<String, List<String>> getUrisFromForm() {
|
||||||
return editSub.getUrisFromForm();
|
return editSub.getUrisFromForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSubmissionExists() {
|
||||||
|
return (this.editSub != null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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$ -->
|
||||||
|
|
||||||
<#if editConfiguration.rangeOptionsExist = true >
|
<#if rangeOptionsExist = true >
|
||||||
<p>If you don't find the appropriate entry on the selection list above:</p>
|
<p>If you don't find the appropriate entry on the selection list above:</p>
|
||||||
<#else>
|
<#else>
|
||||||
<p>Please create a new entry.</p>
|
<p>Please create a new entry.</p>
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
<#-- $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$ -->
|
||||||
|
|
||||||
|
<#--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>
|
<h2>${editConfiguration.formTitle}</h2>
|
||||||
|
|
||||||
<#if editConfiguration.propertySelectFromExisting = true>
|
<#if editConfiguration.propertySelectFromExisting = true>
|
||||||
<#if editConfiguration.rangeOptionsExist = true >
|
<#if rangeOptionsExist = true >
|
||||||
<#assign rangeOptionKeys = editConfiguration.rangeOptions?keys />
|
<#assign rangeOptionKeys = rangeOptions?keys />
|
||||||
<form class="editForm" action = "${submitUrl}">
|
<form class="editForm" action = "${submitUrl}">
|
||||||
<input type="hidden" name="editKey" id="editKey" value="${editKey}" role="input" />
|
<input type="hidden" name="editKey" id="editKey" value="${editKey}" role="input" />
|
||||||
<#if editConfiguration.propertyPublicDescription?has_content>
|
<#if editConfiguration.propertyPublicDescription?has_content>
|
||||||
|
@ -12,14 +19,14 @@
|
||||||
|
|
||||||
<select id="objectVar" name="objectVar" role="select">
|
<select id="objectVar" name="objectVar" role="select">
|
||||||
<#list rangeOptionKeys as key>
|
<#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>
|
</#list>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" id="submit" value="${editConfiguration.submitLabel}" role="button "/>
|
<input type="submit" id="submit" value="${editConfiguration.submitLabel}" role="button "/>
|
||||||
<span class="or"> or </span>
|
<span class="or"> or </span>
|
||||||
<a title="Cancel" href="${editConfiguration.cancelUrl}">Cancel</a>
|
<a title="Cancel" href="${cancelUrl}">Cancel</a>
|
||||||
</p>
|
</p>
|
||||||
</#if>
|
</#if>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue