Browse files

baseline with new scaffolding templates

  • Loading branch information...
1 parent a71fc36 commit 91895d6ff5e4caad82c659ace2ed6ef1717b36f9 Rob Fletcher committed Feb 5, 2011
View
74 src/templates/scaffolding/create.gsp
@@ -1,60 +1,56 @@
<% import grails.persistence.Event %>
<% import org.codehaus.groovy.grails.plugins.PluginManagerHolder %>
<%=packageName%>
+<!doctype html>
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="layout" content="main" />
+ <meta name="layout" content="main">
<g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
<title><g:message code="default.create.label" args="[entityName]" /></title>
</head>
<body>
- <div class="nav">
- <span class="menuButton"><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
- <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
+ <a href="#create-${domainClass.propertyName}" class="skip"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
+ <div class="nav" role="navigation">
+ <ul>
+ <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
+ <li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
+ </ul>
</div>
- <div class="body">
+ <div id="create-${domainClass.propertyName}" class="content scaffold-create" role="main">
<h1><g:message code="default.create.label" args="[entityName]" /></h1>
<g:if test="\${flash.message}">
- <div class="message">\${flash.message}</div>
+ <div class="message" role="alert">\${flash.message}</div>
</g:if>
<g:hasErrors bean="\${${propertyName}}">
- <div class="errors">
+ <div class="errors" role="alert">
<g:renderErrors bean="\${${propertyName}}" as="list" />
</div>
</g:hasErrors>
<g:form action="save" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
- <div class="dialog">
- <table>
- <tbody>
- <% excludedProps = Event.allEvents.toList() << 'version' << 'id' << 'dateCreated' << 'lastUpdated'
- persistentPropNames = domainClass.persistentProperties*.name
- props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
- Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
- display = true
- boolean hasHibernate = PluginManagerHolder.pluginManager.hasGrailsPlugin('hibernate')
- props.each { p ->
- if (!Collection.class.isAssignableFrom(p.type)) {
- if (hasHibernate) {
- cp = domainClass.constrainedProperties[p.name]
- display = (cp ? cp.display : true)
- }
- if (display) { %>
- <tr class="prop">
- <td valign="top" class="name">
- <label for="${p.name}"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></label>
- </td>
- <td valign="top" class="value \${hasErrors(bean: ${propertyName}, field: '${p.name}', 'errors')}">
- ${renderEditor(p)}
- </td>
- </tr>
- <% } } } %>
- </tbody>
- </table>
- </div>
- <div class="buttons">
- <span class="button"><g:submitButton name="create" class="save" value="\${message(code: 'default.button.create.label', default: 'Create')}" /></span>
- </div>
+ <fieldset class="form">
+ <% excludedProps = Event.allEvents.toList() << 'version' << 'id' << 'dateCreated' << 'lastUpdated'
+ persistentPropNames = domainClass.persistentProperties*.name
+ props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
+ Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
+ display = true
+ required = false
+ boolean hasHibernate = PluginManagerHolder.pluginManager.hasGrailsPlugin('hibernate')
+ props.each { p ->
+ if (hasHibernate) {
+ cp = domainClass.constrainedProperties[p.name]
+ display = (cp ? cp.display : true)
+ required = (cp ? !(cp.propertyType in [boolean, Boolean]) && !cp.nullable : false)
+ }
+ if (display) { %>
+ <div class="fieldcontain \${hasErrors(bean: ${propertyName}, field: '${p.name}', 'error')} ${required ? 'required' : ''}">
+ <label for="${p.name}"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /><% if (required) { %><span class="required-indicator">*</span><% } %></label>
+ ${renderEditor(p)}
+ </div>
+ <% } } %>
+ </fieldset>
+ <fieldset class="buttons">
+ <g:submitButton name="create" class="save" value="\${message(code: 'default.button.create.label', default: 'Create')}" />
+ </fieldset>
</g:form>
</div>
</body>
View
77 src/templates/scaffolding/edit.gsp
@@ -1,63 +1,60 @@
<% import grails.persistence.Event %>
<% import org.codehaus.groovy.grails.plugins.PluginManagerHolder %>
<%=packageName%>
+<!doctype html>
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="layout" content="main" />
+ <meta name="layout" content="main">
<g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
<title><g:message code="default.edit.label" args="[entityName]" /></title>
</head>
<body>
- <div class="nav">
- <span class="menuButton"><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
- <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
- <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
+ <a href="#edit-${domainClass.propertyName}" class="skip"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
+ <div class="nav" role="navigation">
+ <ul>
+ <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
+ <li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
+ <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
+ </ul>
</div>
- <div class="body">
+ <div id="edit-${domainClass.propertyName}" class="content scaffold-edit" role="main">
<h1><g:message code="default.edit.label" args="[entityName]" /></h1>
<g:if test="\${flash.message}">
- <div class="message">\${flash.message}</div>
+ <div class="message" role="alert">\${flash.message}</div>
</g:if>
<g:hasErrors bean="\${${propertyName}}">
- <div class="errors">
+ <div class="errors" role="alert">
<g:renderErrors bean="\${${propertyName}}" as="list" />
</div>
</g:hasErrors>
<g:form method="post" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
<g:hiddenField name="id" value="\${${propertyName}?.id}" />
<g:hiddenField name="version" value="\${${propertyName}?.version}" />
- <div class="dialog">
- <table>
- <tbody>
- <% excludedProps = Event.allEvents.toList() << 'version' << 'id' << 'dateCreated' << 'lastUpdated'
- persistentPropNames = domainClass.persistentProperties*.name
- props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
- Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
- display = true
- boolean hasHibernate = PluginManagerHolder.pluginManager.hasGrailsPlugin('hibernate')
- props.each { p ->
- if (hasHibernate) {
- cp = domainClass.constrainedProperties[p.name]
- display = (cp?.display ?: true)
- }
- if (display) { %>
- <tr class="prop">
- <td valign="top" class="name">
- <label for="${p.name}"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></label>
- </td>
- <td valign="top" class="value \${hasErrors(bean: ${propertyName}, field: '${p.name}', 'errors')}">
- ${renderEditor(p)}
- </td>
- </tr>
- <% } } %>
- </tbody>
- </table>
- </div>
- <div class="buttons">
- <span class="button"><g:actionSubmit class="save" action="update" value="\${message(code: 'default.button.update.label', default: 'Update')}" /></span>
- <span class="button"><g:actionSubmit class="delete" action="delete" value="\${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
- </div>
+ <fieldset class="form">
+ <% excludedProps = Event.allEvents.toList() << 'version' << 'id' << 'dateCreated' << 'lastUpdated'
+ persistentPropNames = domainClass.persistentProperties*.name
+ props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
+ Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
+ display = true
+ required = false
+ boolean hasHibernate = PluginManagerHolder.pluginManager.hasGrailsPlugin('hibernate')
+ props.each { p ->
+ if (hasHibernate) {
+ cp = domainClass.constrainedProperties[p.name]
+ display = (cp?.display ?: true)
+ required = (cp ? !(cp.propertyType in [boolean, Boolean]) && !cp.nullable : false)
+ }
+ if (display) { %>
+ <div class="fieldcontain \${hasErrors(bean: ${propertyName}, field: '${p.name}', 'error')} ${required ? 'required' : ''}">
+ <label for="${p.name}"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /><% if (required) { %><span class="required-indicator">*</span><% } %></label>
+ ${renderEditor(p)}
+ </div>
+ <% } } %>
+ </fieldset>
+ <fieldset class="buttons">
+ <g:actionSubmit class="save" action="update" value="\${message(code: 'default.button.update.label', default: 'Update')}" />
+ <g:actionSubmit class="delete" action="delete" value="\${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
+ </fieldset>
</g:form>
</div>
</body>
View
123 src/templates/scaffolding/list.gsp
@@ -1,61 +1,62 @@
-<% import grails.persistence.Event %>
-<%=packageName%>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="layout" content="main" />
- <g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
- <title><g:message code="default.list.label" args="[entityName]" /></title>
- </head>
- <body>
- <div class="nav">
- <span class="menuButton"><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
- <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
- </div>
- <div class="body">
- <h1><g:message code="default.list.label" args="[entityName]" /></h1>
- <g:if test="\${flash.message}">
- <div class="message">\${flash.message}</div>
- </g:if>
- <div class="list">
- <table>
- <thead>
- <tr>
- <% excludedProps = Event.allEvents.toList() << 'version'
- allowedNames = domainClass.persistentProperties*.name << 'id' << 'dateCreated' << 'lastUpdated'
- props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) }
- Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
- props.eachWithIndex { p, i ->
- if (i < 6) {
- if (p.isAssociation()) { %>
- <th><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></th>
- <% } else { %>
- <g:sortableColumn property="${p.name}" title="\${message(code: '${domainClass.propertyName}.${p.name}.label', default: '${p.naturalName}')}" />
- <% } } } %>
- </tr>
- </thead>
- <tbody>
- <g:each in="\${${propertyName}List}" status="i" var="${propertyName}">
- <tr class="\${(i % 2) == 0 ? 'odd' : 'even'}">
- <% props.eachWithIndex { p, i ->
- if (i == 0) { %>
- <td><g:link action="show" id="\${${propertyName}.id}">\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</g:link></td>
- <% } else if (i < 6) {
- if (p.type == Boolean.class || p.type == boolean.class) { %>
- <td><g:formatBoolean boolean="\${${propertyName}.${p.name}}" /></td>
- <% } else if (p.type == Date.class || p.type == java.sql.Date.class || p.type == java.sql.Time.class || p.type == Calendar.class) { %>
- <td><g:formatDate date="\${${propertyName}.${p.name}}" /></td>
- <% } else { %>
- <td>\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
- <% } } } %>
- </tr>
- </g:each>
- </tbody>
- </table>
- </div>
- <div class="paginateButtons">
- <g:paginate total="\${${propertyName}Total}" />
- </div>
- </div>
- </body>
-</html>
+<% import grails.persistence.Event %>
+<%=packageName%>
+<!doctype html>
+<html>
+ <head>
+ <g:if test="\${!request.xhr}"><meta name="layout" content="main"></g:if>
+ <g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
+ <title><g:message code="default.list.label" args="[entityName]" /></title>
+ </head>
+ <body>
+ <a href="#list-${domainClass.propertyName}" class="skip"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
+ <div class="nav" role="navigation">
+ <ul>
+ <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
+ <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
+ </ul>
+ </div>
+ <div id="list-${domainClass.propertyName}" class="content scaffold-list" role="main">
+ <h1><g:message code="default.list.label" args="[entityName]" /></h1>
+ <g:if test="\${flash.message}">
+ <div class="message">\${flash.message}</div>
+ </g:if>
+ <table>
+ <thead>
+ <tr>
+ <% excludedProps = Event.allEvents.toList() << 'version'
+ allowedNames = domainClass.persistentProperties*.name << 'id' << 'dateCreated' << 'lastUpdated'
+ props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) }
+ Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
+ props.eachWithIndex { p, i ->
+ if (i < 6) {
+ if (p.isAssociation()) { %>
+ <th><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></th>
+ <% } else { %>
+ <g:sortableColumn property="${p.name}" title="\${message(code: '${domainClass.propertyName}.${p.name}.label', default: '${p.naturalName}')}" />
+ <% } } } %>
+ </tr>
+ </thead>
+ <tbody>
+ <g:each in="\${${propertyName}List}" status="i" var="${propertyName}">
+ <tr class="\${(i % 2) == 0 ? 'odd' : 'even'}">
+ <% props.eachWithIndex { p, i ->
+ if (i == 0) { %>
+ <td><g:link action="show" id="\${${propertyName}.id}">\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</g:link></td>
+ <% } else if (i < 6) {
+ if (p.type == Boolean || p.type == boolean) { %>
+ <td><g:formatBoolean boolean="\${${propertyName}.${p.name}}" /></td>
+ <% } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
+ <td><g:formatDate date="\${${propertyName}.${p.name}}" /></td>
+ <% } else { %>
+ <td>\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
+ <% } } } %>
+ </tr>
+ </g:each>
+ </tbody>
+ </table>
+ <fieldset class="pagination">
+ <g:paginate total="\${${propertyName}Total}" />
+ </fieldset>
+ </div>
+ </body>
+</html>
View
98 src/templates/scaffolding/renderEditor.template
@@ -1,20 +1,20 @@
-<% if (property.type == Boolean.class || property.type == boolean.class)
+<% if (property.type == Boolean || property.type == boolean)
out << renderBooleanEditor(domainClass, property)
- else if (Number.class.isAssignableFrom(property.type) || (property.type.isPrimitive() && property.type != boolean.class))
+ else if (Number.isAssignableFrom(property.type) || (property.type.isPrimitive() && property.type != boolean))
out << renderNumberEditor(domainClass, property)
- else if (property.type == String.class)
+ else if (property.type == String)
out << renderStringEditor(domainClass, property)
- else if (property.type == Date.class || property.type == java.sql.Date.class || property.type == java.sql.Time.class || property.type == Calendar.class)
+ else if (property.type == Date || property.type == java.sql.Date || property.type == java.sql.Time || property.type == Calendar)
out << renderDateEditor(domainClass, property)
- else if (property.type == URL.class)
+ else if (property.type == URL)
out << renderStringEditor(domainClass, property)
else if (property.isEnum())
out << renderEnumEditor(domainClass, property)
- else if (property.type == TimeZone.class)
+ else if (property.type == TimeZone)
out << renderSelectTypeEditor("timeZone", domainClass, property)
- else if (property.type == Locale.class)
+ else if (property.type == Locale)
out << renderSelectTypeEditor("locale", domainClass, property)
- else if (property.type == Currency.class)
+ else if (property.type == Currency)
out << renderSelectTypeEditor("currency", domainClass, property)
else if (property.type==([] as Byte[]).class) //TODO: Bug in groovy means i have to do this :(
out << renderByteArrayEditor(domainClass, property)
@@ -34,25 +34,29 @@
private renderStringEditor(domainClass, property) {
if (!cp) {
return "<g:textField name=\"${property.name}\" value=\"\${${domainInstance}?.${property.name}}\" />"
- }
- else {
+ } else {
if ("textarea" == cp.widget || (cp.maxSize > 250 && !cp.password && !cp.inList)) {
return "<g:textArea name=\"${property.name}\" cols=\"40\" rows=\"5\" value=\"\${${domainInstance}?.${property.name}}\" />"
- }
- else {
- if (cp.inList) {
- return "<g:select name=\"${property.name}\" from=\"\${${domainInstance}.constraints.${property.name}.inList}\" value=\"\${${domainInstance}?.${property.name}}\" valueMessagePrefix=\"${domainClass.propertyName}.${property?.name}\" ${renderNoSelection(property)} />"
- }
- else {
- def sb = new StringBuffer("<g:")
- cp.password ? sb << "passwordField " : sb << "textField "
- sb << "name=\"${property.name}\" "
- if (cp.maxSize) sb << "maxlength=\"${cp.maxSize}\" "
- if (!cp.editable) sb << "readonly=\"readonly\" "
- sb << "value=\"\${${domainInstance}?.${property.name}}\" />"
- return sb.toString()
- }
- }
+ } else if (cp.inList) {
+ return "<g:select name=\"${property.name}\" from=\"\${${domainInstance}.constraints.${property.name}.inList}\" value=\"\${${domainInstance}?.${property.name}}\" valueMessagePrefix=\"${domainClass.propertyName}.${property?.name}\" ${renderNoSelection(property)} />"
+ } else {
+ def sb = new StringBuffer("")
+ if (cp.password) {
+ sb << "<g:field type=\"password\" "
+ } else if (cp.url) {
+ sb << "<g:field type=\"url\" "
+ } else if (cp.email) {
+ sb << "<g:field type=\"email\" "
+ } else {
+ sb << "<g:textField "
+ }
+ sb << "name=\"${property.name}\" "
+ if (cp.maxSize) sb << "maxlength=\"${cp.maxSize}\" "
+ if (!cp.editable) sb << "readonly=\"readonly\" "
+ if (!cp.nullable && !cp.blank) sb << "required=\"required\" "
+ sb << "value=\"\${${domainInstance}?.${property.name}}\" />"
+ return sb.toString()
+ }
}
}
@@ -67,7 +71,7 @@
}
private renderManyToMany(domainClass, property) {
- return "<g:select name=\"${property.name}\" from=\"\${${property.referencedDomainClass.fullName}.list()}\" multiple=\"yes\" optionKey=\"id\" size=\"5\" value=\"\${${domainInstance}?.${property.name}*.id}\" />"
+ return "<g:select name=\"${property.name}\" from=\"\${${property.referencedDomainClass.fullName}.list()}\" multiple=\"multiple\" optionKey=\"id\" size=\"5\" value=\"\${${domainInstance}?.${property.name}*.id}\" />"
}
private renderOneToMany(domainClass, property) {
@@ -85,31 +89,26 @@
private renderNumberEditor(domainClass, property) {
if (!cp) {
- if (property.type == Byte.class) {
- return "<g:select name=\"${property.name}\" from=\"\${-128..127}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" />"
- }
- else {
- return "<g:textField name=\"${property.name}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" />"
+ if (property.type == Byte) {
+ return "<g:select name=\"${property.name}\" from=\"\${-128..127}\" class=\"range\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" />"
+ } else {
+ return "<g:field type=\"number\" name=\"${property.name}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" />"
}
- }
- else {
+ } else {
if (cp.range) {
- return "<g:select name=\"${property.name}\" from=\"\${${cp.range.from}..${cp.range.to}}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" ${renderNoSelection(property)} />"
- }
- else if (cp.inList) {
+ return "<g:select name=\"${property.name}\" from=\"\${${cp.range.from}..${cp.range.to}}\" class=\"range\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" ${renderNoSelection(property)} />"
+ } else if (cp.inList) {
return "<g:select name=\"${property.name}\" from=\"\${${domainInstance}.constraints.${property.name}.inList}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" valueMessagePrefix=\"${domainClass.propertyName}.${property?.name}\" ${renderNoSelection(property)} />"
- }
- else {
- return "<g:textField name=\"${property.name}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" />"
+ } else {
+ return "<g:field type=\"number\" name=\"${property.name}\" value=\"\${fieldValue(bean: ${domainInstance}, field: '${property.name}')}\" />"
}
}
}
private renderBooleanEditor(domainClass, property) {
if (!cp) {
return "<g:checkBox name=\"${property.name}\" value=\"\${${domainInstance}?.${property.name}}\" />"
- }
- else {
+ } else {
def sb = new StringBuffer("<g:checkBox name=\"${property.name}\" ")
if (cp.widget) sb << "widget=\"${cp.widget}\" ";
cp.attributes.each { k, v ->
@@ -121,15 +120,13 @@
}
private renderDateEditor(domainClass, property) {
- def precision = (property.type == Date.class || property.type == java.sql.Date.class || property.type == Calendar.class) ? "day" : "minute";
+ def precision = (property.type == Date || property.type == java.sql.Date || property.type == Calendar) ? "day" : "minute";
if (!cp) {
return "<g:datePicker name=\"${property.name}\" precision=\"${precision}\" value=\"\${${domainInstance}?.${property.name}}\" />"
- }
- else {
+ } else {
if (!cp.editable) {
return "\${${domainInstance}?.${property.name}?.toString()}"
- }
- else {
+ } else {
def sb = new StringBuffer("<g:datePicker name=\"${property.name}\" ")
if (cp.format) sb << "format=\"${cp.format}\" "
if (cp.widget) sb << "widget=\"${cp.widget}\" "
@@ -145,8 +142,7 @@
private renderSelectTypeEditor(type, domainClass,property) {
if (!cp) {
return "<g:${type}Select name=\"${property.name}\" value=\"\${${domainInstance}?.${property.name}}\" />"
- }
- else {
+ } else {
def sb = new StringBuffer("<g:${type}Select name=\"${property.name}\" ")
if (cp.widget) sb << "widget=\"${cp.widget}\" ";
cp.attributes.each { k, v ->
@@ -161,11 +157,9 @@
if (property.optional) {
if (property.manyToOne || property.oneToOne) {
return "noSelection=\"['null': '']\""
- }
- else if (property.type == Date.class || property.type == java.sql.Date.class || property.type == java.sql.Time.class || property.type == Calendar.class) {
+ } else if (property.type == Date || property.type == java.sql.Date || property.type == java.sql.Time || property.type == Calendar) {
return "default=\"none\" noSelection=\"['': '']\""
- }
- else {
+ } else {
return "noSelection=\"['': '']\""
}
}
View
89 src/templates/scaffolding/show.gsp
@@ -1,64 +1,57 @@
<% import grails.persistence.Event %>
<%=packageName%>
+<!doctype html>
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="layout" content="main" />
+ <meta name="layout" content="main">
<g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
<title><g:message code="default.show.label" args="[entityName]" /></title>
</head>
<body>
- <div class="nav">
- <span class="menuButton"><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
- <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
- <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
+ <a href="#show-${domainClass.propertyName}" class="skip"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
+ <div class="nav" role="navigation">
+ <ul>
+ <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
+ <li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
+ <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
+ </ul>
</div>
- <div class="body">
+ <div id="show-${domainClass.propertyName}" class="content scaffold-show" role="main">
<h1><g:message code="default.show.label" args="[entityName]" /></h1>
<g:if test="\${flash.message}">
<div class="message">\${flash.message}</div>
</g:if>
- <div class="dialog">
- <table>
- <tbody>
- <% excludedProps = Event.allEvents.toList() << 'version'
- allowedNames = domainClass.persistentProperties*.name << 'id' << 'dateCreated' << 'lastUpdated'
- props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) }
- Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
- props.each { p -> %>
- <tr class="prop">
- <td valign="top" class="name"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></td>
- <% if (p.isEnum()) { %>
- <td valign="top" class="value">\${${propertyName}?.${p.name}?.encodeAsHTML()}</td>
- <% } else if (p.oneToMany || p.manyToMany) { %>
- <td valign="top" style="text-align: left;" class="value">
- <ul>
- <g:each in="\${${propertyName}.${p.name}}" var="${p.name[0]}">
- <li><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${p.name[0]}.id}">\${${p.name[0]}?.encodeAsHTML()}</g:link></li>
- </g:each>
- </ul>
- </td>
- <% } else if (p.manyToOne || p.oneToOne) { %>
- <td valign="top" class="value"><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${propertyName}?.${p.name}?.id}">\${${propertyName}?.${p.name}?.encodeAsHTML()}</g:link></td>
- <% } else if (p.type == Boolean.class || p.type == boolean.class) { %>
- <td valign="top" class="value"><g:formatBoolean boolean="\${${propertyName}?.${p.name}}" /></td>
- <% } else if (p.type == Date.class || p.type == java.sql.Date.class || p.type == java.sql.Time.class || p.type == Calendar.class) { %>
- <td valign="top" class="value"><g:formatDate date="\${${propertyName}?.${p.name}}" /></td>
- <% } else if(!p.type.isArray()) { %>
- <td valign="top" class="value">\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
- <% } %>
- </tr>
- <% } %>
- </tbody>
- </table>
- </div>
- <div class="buttons">
- <g:form>
- <g:hiddenField name="id" value="\${${propertyName}?.id}" />
- <span class="button"><g:actionSubmit class="edit" action="edit" value="\${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
- <span class="button"><g:actionSubmit class="delete" action="delete" value="\${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
- </g:form>
- </div>
+ <dl>
+ <% excludedProps = Event.allEvents.toList() << 'version'
+ allowedNames = domainClass.persistentProperties*.name << 'id' << 'dateCreated' << 'lastUpdated'
+ props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) }
+ Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
+ props.each { p -> %>
+ <dt><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></dt>
+ <% if (p.isEnum()) { %>
+ <dd><g:fieldValue bean="\${${propertyName}}" field="${p.name}"/></dd>
+ <% } else if (p.oneToMany || p.manyToMany) { %>
+ <g:each in="\${${propertyName}.${p.name}}" var="${p.name[0]}">
+ <dd><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${p.name[0]}.id}">\${${p.name[0]}?.encodeAsHTML()}</g:link></dd>
+ </g:each>
+ <% } else if (p.manyToOne || p.oneToOne) { %>
+ <dd><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${propertyName}?.${p.name}?.id}">\${${propertyName}?.${p.name}?.encodeAsHTML()}</g:link></dd>
+ <% } else if (p.type == Boolean || p.type == boolean) { %>
+ <dd><g:formatBoolean boolean="\${${propertyName}?.${p.name}}" /></dd>
+ <% } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
+ <dd><g:formatDate date="\${${propertyName}?.${p.name}}" /></dd>
+ <% } else if(!p.type.isArray()) { %>
+ <dd><g:fieldValue bean="\${${propertyName}}" field="${p.name}"/></dd>
+ <% } %>
+ <% } %>
+ </dl>
+ <g:form>
+ <fieldset class="buttons">
+ <g:hiddenField name="id" value="\${${propertyName}?.id}" />
+ <g:actionSubmit class="edit" action="edit" value="\${message(code: 'default.button.edit.label', default: 'Edit')}" />
+ <g:actionSubmit class="delete" action="delete" value="\${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
+ </fieldset>
+ </g:form>
</div>
</body>
</html>

0 comments on commit 91895d6

Please sign in to comment.