NIHVIVO-799 Added select list type UNSORTED_LITERALS to specify a list of literals with no alpha sorting. Allows putting "Select one" as first option without getting sorted into the middle of the list.
This commit is contained in:
parent
1b93c6f85a
commit
33d5023f3d
3 changed files with 10 additions and 2 deletions
|
@ -18,6 +18,7 @@ public class Field {
|
|||
|
||||
public enum OptionsType {
|
||||
LITERALS,
|
||||
UNSORTED_LITERALS,
|
||||
STRINGS_VIA_DATATYPE_PROPERTY,
|
||||
INDIVIDUALS_VIA_OBJECT_PROPERTY,
|
||||
INDIVIDUALS_VIA_VCLASS,
|
||||
|
@ -204,6 +205,8 @@ public class Field {
|
|||
public void setOptionsType(String s) {
|
||||
if ("LITERALS".equals(s)) {
|
||||
setOptionsType(Field.OptionsType.LITERALS);
|
||||
} else if ("UNSORTED_LITERALS".equals(s)) {
|
||||
setOptionsType(Field.OptionsType.UNSORTED_LITERALS);
|
||||
} else if ("STRINGS_VIA_DATATYPE_PROPERTY".equalsIgnoreCase(s)) {
|
||||
setOptionsType(Field.OptionsType.STRINGS_VIA_DATATYPE_PROPERTY);
|
||||
} else if ("INDIVIDUALS_VIA_OBJECT_PROPERTY".equalsIgnoreCase(s)) {
|
||||
|
|
|
@ -59,10 +59,11 @@ public class SelectListGenerator {
|
|||
Field.OptionsType optionsType = field.getOptionsType();
|
||||
String vclassUri = null;
|
||||
switch (optionsType){
|
||||
case UNSORTED_LITERALS: // deliberate fall-through case! Like LITERALS, but should not be sorted - order as specified
|
||||
case LITERALS:
|
||||
List<List<String>> literalOptions = field.getLiteralOptions();
|
||||
if (literalOptions==null) {
|
||||
log.error("no literalOptions List found for field \""+fieldName+"\" in SelectListGenerator.getOptions() when OptionsType LITERAL specified");
|
||||
log.error("no literalOptions List found for field \""+fieldName+"\" in SelectListGenerator.getOptions() when OptionsType LITERALS or UNSORTED_LITERALS specified");
|
||||
return new HashMap <String,String>();
|
||||
}
|
||||
for(Object obj: ((Iterable)literalOptions)){
|
||||
|
|
|
@ -454,7 +454,11 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
} else {
|
||||
out.print("<select "+classStr+" id=\""+getId()+"\" name=\""+getName()+"\">");
|
||||
}
|
||||
|
||||
Field thisField = editConfig.getField(getName());
|
||||
if (! thisField.getOptionsType().equals(Field.OptionsType.UNSORTED_LITERALS)) {
|
||||
optionsMap = getSortedMap(optionsMap);
|
||||
}
|
||||
Iterator iter = optionsMap.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String key = (String) iter.next();
|
||||
|
|
Loading…
Add table
Reference in a new issue