Permalink
Browse files

Load class names from database to enable the suggestion for class att…

…ribute filtering
  • Loading branch information...
1 parent 6250763 commit 6a9d9b7842563b2dc1ba7c92c97544a4b430a8ec @kuceram kuceram committed Jan 2, 2014
Showing with 15 additions and 3 deletions.
  1. +15 −3 grails-app/taglib/org/grails/plugin/filterpane/FilterPaneTagLib.groovy
@@ -16,6 +16,8 @@ class FilterPaneTagLib {
static namespace = 'filterpane'
+ def grailsApplication
+
GrailsPluginManager pluginManager
GrailsConventionGroovyPageLocator groovyPageLocator
@@ -643,9 +645,19 @@ class FilterPaneTagLib {
if(inList) {
map.ctrlAttrs.values = inList
} else if(type == 'class') { // property is class type
- def domainClasses = sp.domainClass.subClasses.findAll { !Modifier.isAbstract( it.clazz.modifiers ) } // do not add abstract classes
- map.ctrlAttrs.values = domainClasses.collect { it.name } // set values
- map.ctrlAttrs.keys = domainClasses.collect { it.fullName } // set keys
+ if (sp.name == 'class') { // class attribute for inheritance
+ def domainClasses = sp.domainClass.subClasses.findAll { !Modifier.isAbstract( it.clazz.modifiers ) } // do not add abstract classes
+ map.ctrlAttrs.values = domainClasses.collect { it.name } // set values
+ map.ctrlAttrs.keys = domainClasses.collect { it.fullName } // set keys
+ } else { // custom class attribute
+ def classes = sp.domainClass.clazz.createCriteria().listDistinct {
+ projections {
+ distinct(sp.name)
+ }
+ }
+ map.ctrlAttrs.values = classes.collect { it.simpleName } // set values
+ map.ctrlAttrs.keys = classes.collect { it.name } // set keys
+ }
} else if(sp.type.isEnum()) {
//map.ctrlAttrs.values = sp.type.enumConstants as List
def valueList = []

0 comments on commit 6a9d9b7

Please sign in to comment.