Skip to content
Browse files

Merge pull request #34 from kuceram/develop

Load class names from database to enable the suggestion for class attribute filtering
  • Loading branch information...
2 parents 9ccc0a5 + 6a9d9b7 commit 8b5298aba586dda9865a992f6d1d86b3d8b9c815 @ctoestreich ctoestreich committed Jan 6, 2014
Showing with 15 additions and 3 deletions.
  1. +15 −3 grails-app/taglib/org/grails/plugin/filterpane/FilterPaneTagLib.groovy
View
18 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 8b5298a

Please sign in to comment.
Something went wrong with that request. Please try again.