Skip to content

Instantly share code, notes, and snippets.

@ahonor
Created August 9, 2012 18:17
Show Gist options
  • Save ahonor/3306761 to your computer and use it in GitHub Desktop.
Save ahonor/3306761 to your computer and use it in GitHub Desktop.
getNodeAttributes.groovy
/**
* AJAX call used in the views, "/nodeType/{create,edit}.gsp"
*/
def getNodeAttributes = {
def response = []
def attrs = []
if(params.templateid){
def attributes = []
Attribute.list().each() {
attributes += [id:it.id, name:it.name]
}
def atts = NodeAttribute.withCriteria {
eq("nodetype", params.templateid)
//order("name")
}
atts.each() { NodeAttribute na ->
attrs += [tid:na.nodetype.id,id:na.id,
val:na.attribute.name, datatype:na.attribute.filter.dataType];
}
response += [attList:attributes, atts:attrs]
}
render response as JSON
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment