Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start of example of form enhancement
- Loading branch information
1 parent
46aa31c
commit f34485e
Showing
31 changed files
with
421 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
grails-app/controllers/gr8/examples/forms/RatingController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package gr8.examples.forms | ||
|
||
class RatingController { | ||
|
||
def index = { | ||
def album = Album.findByTitle("Up From Below") | ||
def related = Album.list() - album | ||
[album: album, related: related] | ||
} | ||
|
||
def rate = { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package gr8.examples.forms | ||
|
||
class Album { | ||
|
||
String title | ||
String artist | ||
URI cover | ||
List<String> tracks | ||
|
||
static hasMany = [tracks: String] | ||
|
||
static constraints = { | ||
title blank: false | ||
artist blank: false | ||
} | ||
|
||
@Override | ||
String toString() { | ||
"$title by $artist" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package gr8.examples.forms | ||
|
||
class Rating { | ||
|
||
String userToken | ||
int rating | ||
|
||
static constraints = { | ||
userToken blank: false, unique: true | ||
rating range: 1..5 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta name="layout" content="main"> | ||
<title>${album}</title> | ||
<r:use module="forms"/> | ||
</head> | ||
<body> | ||
|
||
<article id="album"> | ||
<r:img uri="${album.cover.toString()}" alt="${album}" class="large-cover"/> | ||
<hgroup> | ||
<h1 class="title">${album.title}</h1> | ||
<h2 class="artist">${album.artist}</h2> | ||
</hgroup> | ||
<ol class="tracks"> | ||
<g:each in="${album.tracks}"> | ||
<li>${it}</li> | ||
</g:each> | ||
</ol> | ||
|
||
<g:form action="rate" class="rating"> | ||
<fieldset> | ||
<legend>Rating:</legend> | ||
<input type="hidden" name="id" value="${album.id}"> | ||
<g:radioGroup name="rating" values="${1..5}" labels="${1..5}"> | ||
<label><span class="num">${it.label}</span>${it.radio}</label> | ||
</g:radioGroup> | ||
</fieldset> | ||
</g:form> | ||
</article> | ||
|
||
<aside id="related"> | ||
<header><h1>People who bought <em>${album}</em> also bought…</h1></header> | ||
<ul> | ||
<g:each in="${related}"> | ||
<li> | ||
<article class="album"> | ||
<r:img uri="${it.cover.toString()}" alt="${it.title} by ${it.artist}" class="small-cover"/> | ||
<hgroup> | ||
<h1 class="title">${it.title}</h1> | ||
<h2 class="artist">${it.artist}</h2> | ||
</hgroup> | ||
</article> | ||
</li> | ||
</g:each> | ||
</ul> | ||
</aside> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package gr8.examples.forms | ||
|
||
import grails.test.* | ||
|
||
class AlbumTests extends GrailsUnitTestCase { | ||
protected void setUp() { | ||
super.setUp() | ||
} | ||
|
||
protected void tearDown() { | ||
super.tearDown() | ||
} | ||
|
||
void testSomething() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package gr8.examples.forms | ||
|
||
import grails.test.* | ||
|
||
class RatingControllerTests extends ControllerUnitTestCase { | ||
protected void setUp() { | ||
super.setUp() | ||
} | ||
|
||
protected void tearDown() { | ||
super.tearDown() | ||
} | ||
|
||
void testSomething() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package gr8.examples.forms | ||
|
||
import grails.test.* | ||
|
||
class RatingTests extends GrailsUnitTestCase { | ||
protected void setUp() { | ||
super.setUp() | ||
} | ||
|
||
protected void tearDown() { | ||
super.tearDown() | ||
} | ||
|
||
void testSomething() { | ||
|
||
} | ||
} |
Oops, something went wrong.