Skip to content
This repository has been archived by the owner on Oct 31, 2018. It is now read-only.

Commit

Permalink
Merge pull request #66 from stlhrt/display_false
Browse files Browse the repository at this point in the history
Display:false constraint should remove fields from scaffolded view
  • Loading branch information
joergrech committed Jan 25, 2014
2 parents d9eb2ed + 9a22477 commit d716358
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion KickstartWithBootstrapGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import kickstart.CustomDateEditorRegistrar
class KickstartWithBootstrapGrailsPlugin {

def title = "Kickstart with Bootstrap - Good looking websites!"
def version = "1.0.0"
def version = "1.0.3"
def license = "APACHE"
def description = """\
Kickstart is a plugin for Grails to start your project with a good looking frontend. \
Expand Down
9 changes: 3 additions & 6 deletions src/templates/scaffolding/_form.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
persistentPropNames << domainClass.identifier.name
}
}
props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
for (p in props) {
if (p.embedded) {
Expand All @@ -29,19 +29,16 @@
private renderFieldForProperty(p, owningClass, prefix = "") {
boolean hasHibernate = pluginManager?.hasGrailsPlugin('hibernate') || pluginManager?.hasGrailsPlugin('hibernate4')
boolean display = true
boolean required = false
if (hasHibernate) {
cp = owningClass.constrainedProperties[p.name]
display = (cp ? cp.display : true)
required = (cp ? !(cp.propertyType in [boolean, Boolean]) && !cp.nullable && (cp.propertyType != String || !cp.blank) : false)
}
if (display) { %>
} %>
<div class="\${hasErrors(bean: ${propertyName}, field: '${prefix}${p.name}', 'error')} ${required ? 'required' : ''}">
<label for="${prefix}${p.name}" class="control-label"><g:message code="${domainClass.propertyName}.${prefix}${p.name}.label" default="${p.naturalName}" /><% if (required) { %><span class="required-indicator">*</span><% } %></label>
<div>
${renderEditor(p)}
<span class="help-inline">\${hasErrors(bean: ${propertyName}, field: '${p.name}', 'error')}</span>
</div>
</div>
<% } } %>
<% } %>
2 changes: 1 addition & 1 deletion src/templates/scaffolding/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<tr>
<% excludedProps = Event.allEvents.toList() << 'id' << 'version'
allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) }
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.eachWithIndex { p, i ->
if (i < 6) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/scaffolding/list.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<tr>
<% excludedProps = Event.allEvents.toList() << 'id' << 'version'
allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) }
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.eachWithIndex { p, i ->
if (i < 6) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/scaffolding/show.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<tbody>
<% excludedProps = Event.allEvents.toList() << 'id' << 'version'
allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) }
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.each { p -> %>
<tr class="prop">
Expand Down

0 comments on commit d716358

Please sign in to comment.