Weiteres Feintuning des CategoryFilter

git-svn-id: https://svn.libreccm.org/ccm/trunk@2341 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-10-08 14:09:26 +00:00
parent e36ecd9b7a
commit 722892e912
1 changed files with 13 additions and 6 deletions

View File

@ -74,7 +74,7 @@ public class CategoryFilter {
} else { } else {
//Otherwise, we assume that we get the ID of a single category //Otherwise, we assume that we get the ID of a single category
final com.arsdigita.persistence.Filter filter = filterFactory.in( final com.arsdigita.persistence.Filter filter = filterFactory.in(
"parent.id", "com.arsdigita.categorization.objectIDsInSubtree"); "parent.id", "com.arsdigita.categorization.objectIDsInSubtree");
filter.set("categoryID", value); filter.set("categoryID", value);
compoundFilter.addFilter(filter); compoundFilter.addFilter(filter);
} }
@ -118,10 +118,12 @@ public class CategoryFilter {
multipleElem.setText("false"); multipleElem.setText("false");
} }
for (String value : values) { if (!multiple) {
if (!catNameToCatId.containsKey(value)) { for (String value : values) {
invalid.newChildElement("value").setText(value); if (!catNameToCatId.containsKey(value)) {
invalidFound = true; invalid.newChildElement("value").setText(value);
invalidFound = true;
}
} }
} }
@ -138,7 +140,7 @@ public class CategoryFilter {
final StringBuffer searchString) { final StringBuffer searchString) {
final Element elem = new Element("category"); final Element elem = new Element("category");
elem.addAttribute("id", category.getID().toString()); elem.addAttribute("id", category.getID().toString());
//if ((values != null) && !values.isEmpty() && values.contains(category.getID().toString())) { if (multiple) {
if ((values != null) && !values.isEmpty() && values.contains(category.getName())) { if ((values != null) && !values.isEmpty() && values.contains(category.getName())) {
elem.addAttribute("selected", "selected"); elem.addAttribute("selected", "selected");
if (searchString.length() > 0) { if (searchString.length() > 0) {
@ -146,6 +148,11 @@ public class CategoryFilter {
} }
searchString.append(category.getName()); searchString.append(category.getName());
} }
} else {
if ((values != null) && !values.isEmpty() && values.contains(category.getID().toString())) {
elem.addAttribute("selected", "selected");
}
}
elem.setText(category.getName()); elem.setText(category.getName());
parent.addContent(elem); parent.addContent(elem);
} }