Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added front-end for story managment

  • Loading branch information...
commit 598fe039a068807652e3f620fee3036f32adec7d 1 parent ba7e10b
@henyojess authored
View
106 grails-app/controllers/timelog/StoryController.groovy
@@ -0,0 +1,106 @@
+package timelog
+
+import org.springframework.dao.DataIntegrityViolationException
+
+class StoryController {
+
+ static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
+ def springSecurityService
+
+ def index() {
+ redirect(action: "list", params: params)
+ }
+
+ def list() {
+ params.max = Math.min(params.max ? params.int('max') : 10, 100)
+ [storyInstanceList: Story.list(params), storyInstanceTotal: Story.count()]
+ }
+
+ def create() {
+ [storyInstance: new Story(params)]
+ }
+
+ def save() {
+ def storyInstance = new Story(params)
+ storyInstance.createdBy = springSecurityService.getPrincipal().username
+ if (!storyInstance.save(flush: true)) {
+ render(view: "create", model: [storyInstance: storyInstance])
+ return
+ }
+
+ flash.message = message(code: 'default.created.message', args: [message(code: 'story.label', default: 'Story'), storyInstance.id])
+ redirect(action: "show", id: storyInstance.id)
+ }
+
+ def show() {
+ def storyInstance = Story.get(params.id)
+ if (!storyInstance) {
+ flash.message = message(code: 'default.not.found.message', args: [message(code: 'story.label', default: 'Story'), params.id])
+ redirect(action: "list")
+ return
+ }
+
+ [storyInstance: storyInstance]
+ }
+
+ def edit() {
+ def storyInstance = Story.get(params.id)
+ if (!storyInstance) {
+ flash.message = message(code: 'default.not.found.message', args: [message(code: 'story.label', default: 'Story'), params.id])
+ redirect(action: "list")
+ return
+ }
+
+ [storyInstance: storyInstance]
+ }
+
+ def update() {
+ def storyInstance = Story.get(params.id)
+ if (!storyInstance) {
+ flash.message = message(code: 'default.not.found.message', args: [message(code: 'story.label', default: 'Story'), params.id])
+ redirect(action: "list")
+ return
+ }
+
+ if (params.version) {
+ def version = params.version.toLong()
+ if (storyInstance.version > version) {
+ storyInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
+ [message(code: 'story.label', default: 'Story')] as Object[],
+ "Another user has updated this Story while you were editing")
+ render(view: "edit", model: [storyInstance: storyInstance])
+ return
+ }
+ }
+
+ storyInstance.properties = params
+ storyInstance.updatedBy = springSecurityService.getPrincipal().username
+
+ if (!storyInstance.save(flush: true)) {
+ render(view: "edit", model: [storyInstance: storyInstance])
+ return
+ }
+
+ flash.message = message(code: 'default.updated.message', args: [message(code: 'story.label', default: 'Story'), storyInstance.id])
+ redirect(action: "show", id: storyInstance.id)
+ }
+
+ def delete() {
+ def storyInstance = Story.get(params.id)
+ if (!storyInstance) {
+ flash.message = message(code: 'default.not.found.message', args: [message(code: 'story.label', default: 'Story'), params.id])
+ redirect(action: "list")
+ return
+ }
+
+ try {
+ storyInstance.delete(flush: true)
+ flash.message = message(code: 'default.deleted.message', args: [message(code: 'story.label', default: 'Story'), params.id])
+ redirect(action: "list")
+ }
+ catch (DataIntegrityViolationException e) {
+ flash.message = message(code: 'default.not.deleted.message', args: [message(code: 'story.label', default: 'Story'), params.id])
+ redirect(action: "show", id: params.id)
+ }
+ }
+}
View
44 grails-app/views/story/_form.gsp
@@ -0,0 +1,44 @@
+<%@ page import="timelog.Story" %>
+
+<div class="fieldcontain ${hasErrors(bean: storyInstance, field: 'project', 'error')} required">
+ <label for="project">
+ <g:message code="story.project.label" default="Project" />
+ <span class="required-indicator">*</span>
+ </label>
+ <g:select id="project" name="project.id" from="${timelog.Project.list()}" optionKey="id" optionValue="name" required="" value="${storyInstance?.project?.id}" class="many-to-one"/>
+</div>
+
+
+<div class="fieldcontain ${hasErrors(bean: storyInstance, field: 'description', 'error')} required">
+ <label for="description">
+ <g:message code="story.description.label" default="Description" />
+ <span class="required-indicator">*</span>
+ </label>
+ <g:textField name="description" required="" value="${storyInstance?.description}"/>
+</div>
+
+<div class="fieldcontain ${hasErrors(bean: storyInstance, field: 'releaseTarget', 'error')} required">
+ <label for="releaseTarget">
+ <g:message code="story.releaseTarget.label" default="Release Target" />
+ <span class="required-indicator">*</span>
+ </label>
+ <g:textField name="releaseTarget" required="" value="${storyInstance?.releaseTarget}"/>
+</div>
+
+<div class="fieldcontain ${hasErrors(bean: storyInstance, field: 'status', 'error')} required">
+ <label for="status">
+ <g:message code="story.status.label" default="Status" />
+ <span class="required-indicator">*</span>
+ </label>
+ <g:textField name="status" required="" value="${storyInstance?.status}"/>
+</div>
+
+<div class="fieldcontain ${hasErrors(bean: storyInstance, field: 'active', 'error')} ">
+ <label for="active">
+ <g:message code="story.active.label" default="Active" />
+
+ </label>
+ <g:checkBox name="active" value="${storyInstance?.active}" />
+</div>
+
+
View
39 grails-app/views/story/create.gsp
@@ -0,0 +1,39 @@
+<%@ page import="timelog.Story" %>
+<!doctype html>
+<html>
+ <head>
+ <meta name="layout" content="main">
+ <g:set var="entityName" value="${message(code: 'story.label', default: 'Story')}" />
+ <title><g:message code="default.create.label" args="[entityName]" /></title>
+ </head>
+ <body>
+ <a href="#create-story" class="skip" tabindex="-1"><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 id="create-story" class="content scaffold-create" role="main">
+ <h1><g:message code="default.create.label" args="[entityName]" /></h1>
+ <g:if test="${flash.message}">
+ <div class="message" role="status">${flash.message}</div>
+ </g:if>
+ <g:hasErrors bean="${storyInstance}">
+ <ul class="errors" role="alert">
+ <g:eachError bean="${storyInstance}" var="error">
+ <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
+ </g:eachError>
+ </ul>
+ </g:hasErrors>
+ <g:form action="save" >
+ <fieldset class="form">
+ <g:render template="form"/>
+ </fieldset>
+ <fieldset class="buttons">
+ <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
+ </fieldset>
+ </g:form>
+ </div>
+ </body>
+</html>
View
43 grails-app/views/story/edit.gsp
@@ -0,0 +1,43 @@
+<%@ page import="timelog.Story" %>
+<!doctype html>
+<html>
+ <head>
+ <meta name="layout" content="main">
+ <g:set var="entityName" value="${message(code: 'story.label', default: 'Story')}" />
+ <title><g:message code="default.edit.label" args="[entityName]" /></title>
+ </head>
+ <body>
+ <a href="#edit-story" class="skip" tabindex="-1"><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 id="edit-story" class="content scaffold-edit" role="main">
+ <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
+ <g:if test="${flash.message}">
+ <div class="message" role="status">${flash.message}</div>
+ </g:if>
+ <g:hasErrors bean="${storyInstance}">
+ <ul class="errors" role="alert">
+ <g:eachError bean="${storyInstance}" var="error">
+ <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
+ </g:eachError>
+ </ul>
+ </g:hasErrors>
+ <g:form method="post" >
+ <g:hiddenField name="id" value="${storyInstance?.id}" />
+ <g:hiddenField name="version" value="${storyInstance?.version}" />
+ <fieldset class="form">
+ <g:render template="form"/>
+ </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')}" formnovalidate="" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
+ </fieldset>
+ </g:form>
+ </div>
+ </body>
+</html>
View
62 grails-app/views/story/list.gsp
@@ -0,0 +1,62 @@
+
+<%@ page import="timelog.Story" %>
+<!doctype html>
+<html>
+ <head>
+ <meta name="layout" content="main">
+ <g:set var="entityName" value="${message(code: 'story.label', default: 'Story')}" />
+ <title><g:message code="default.list.label" args="[entityName]" /></title>
+ </head>
+ <body>
+ <a href="#list-story" class="skip" tabindex="-1"><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-story" class="content scaffold-list" role="main">
+ <h1><g:message code="default.list.label" args="[entityName]" /></h1>
+ <g:if test="${flash.message}">
+ <div class="message" role="status">${flash.message}</div>
+ </g:if>
+ <table>
+ <thead>
+ <tr>
+
+ <g:sortableColumn property="project" title="${message(code: 'story.project.label', default: 'Project')}" />
+
+ <g:sortableColumn property="description" title="${message(code: 'story.description.label', default: 'Description')}" />
+
+ <g:sortableColumn property="releaseTarget" title="${message(code: 'story.releaseTarget.label', default: 'Release Target')}" />
+
+ <g:sortableColumn property="status" title="${message(code: 'story.status.label', default: 'Status')}" />
+
+ <g:sortableColumn property="active" title="${message(code: 'story.active.label', default: 'Active')}" />
+
+ </tr>
+ </thead>
+ <tbody>
+ <g:each in="${storyInstanceList}" status="i" var="storyInstance">
+ <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
+
+ <td>${fieldValue(bean: storyInstance.project, field: "name")}</td>
+
+ <td><g:link action="show" id="${storyInstance.id}">${fieldValue(bean: storyInstance, field: "description")}</g:link></td>
+
+ <td>${fieldValue(bean: storyInstance, field: "releaseTarget")}</td>
+
+ <td>${fieldValue(bean: storyInstance, field: "status")}</td>
+
+ <td><g:formatBoolean boolean="${storyInstance.active}" /></td>
+
+ </tr>
+ </g:each>
+ </tbody>
+ </table>
+ <div class="pagination">
+ <g:paginate total="${storyInstanceTotal}" />
+ </div>
+ </div>
+ </body>
+</html>
View
117 grails-app/views/story/show.gsp
@@ -0,0 +1,117 @@
+
+<%@ page import="timelog.Story" %>
+<!doctype html>
+<html>
+ <head>
+ <meta name="layout" content="main">
+ <g:set var="entityName" value="${message(code: 'story.label', default: 'Story')}" />
+ <title><g:message code="default.show.label" args="[entityName]" /></title>
+ </head>
+ <body>
+ <a href="#show-story" class="skip" tabindex="-1"><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 id="show-story" class="content scaffold-show" role="main">
+ <h1><g:message code="default.show.label" args="[entityName]" /></h1>
+ <g:if test="${flash.message}">
+ <div class="message" role="status">${flash.message}</div>
+ </g:if>
+ <ol class="property-list story">
+
+ <g:if test="${storyInstance?.project}">
+ <li class="fieldcontain">
+ <span id="project-label" class="property-label"><g:message code="story.project.label" default="Project" /></span>
+
+ <span class="property-value" aria-labelledby="project-label"><g:link controller="project" action="show" id="${storyInstance?.project?.id}">${storyInstance?.project?.name?.encodeAsHTML()}</g:link></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.description}">
+ <li class="fieldcontain">
+ <span id="description-label" class="property-label"><g:message code="story.description.label" default="Description" /></span>
+
+ <span class="property-value" aria-labelledby="description-label"><g:fieldValue bean="${storyInstance}" field="description"/></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.releaseTarget}">
+ <li class="fieldcontain">
+ <span id="releaseTarget-label" class="property-label"><g:message code="story.releaseTarget.label" default="Release Target" /></span>
+
+ <span class="property-value" aria-labelledby="releaseTarget-label"><g:fieldValue bean="${storyInstance}" field="releaseTarget"/></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.status}">
+ <li class="fieldcontain">
+ <span id="status-label" class="property-label"><g:message code="story.status.label" default="Status" /></span>
+
+ <span class="property-value" aria-labelledby="status-label"><g:fieldValue bean="${storyInstance}" field="status"/></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.createdBy}">
+ <li class="fieldcontain">
+ <span id="createdBy-label" class="property-label"><g:message code="story.createdBy.label" default="Created By" /></span>
+
+ <span class="property-value" aria-labelledby="createdBy-label"><g:fieldValue bean="${storyInstance}" field="createdBy"/></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.updatedBy}">
+ <li class="fieldcontain">
+ <span id="updatedBy-label" class="property-label"><g:message code="story.updatedBy.label" default="Updated By" /></span>
+
+ <span class="property-value" aria-labelledby="updatedBy-label"><g:fieldValue bean="${storyInstance}" field="updatedBy"/></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.active}">
+ <li class="fieldcontain">
+ <span id="active-label" class="property-label"><g:message code="story.active.label" default="Active" /></span>
+
+ <span class="property-value" aria-labelledby="active-label"><g:formatBoolean boolean="${storyInstance?.active}" /></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.dateCreated}">
+ <li class="fieldcontain">
+ <span id="dateCreated-label" class="property-label"><g:message code="story.dateCreated.label" default="Date Created" /></span>
+
+ <span class="property-value" aria-labelledby="dateCreated-label"><g:formatDate date="${storyInstance?.dateCreated}" /></span>
+
+ </li>
+ </g:if>
+
+ <g:if test="${storyInstance?.lastUpdated}">
+ <li class="fieldcontain">
+ <span id="lastUpdated-label" class="property-label"><g:message code="story.lastUpdated.label" default="Last Updated" /></span>
+
+ <span class="property-value" aria-labelledby="lastUpdated-label"><g:formatDate date="${storyInstance?.lastUpdated}" /></span>
+
+ </li>
+ </g:if>
+
+ </ol>
+ <g:form>
+ <fieldset class="buttons">
+ <g:hiddenField name="id" value="${storyInstance?.id}" />
+ <g:link class="edit" action="edit" id="${storyInstance?.id}"><g:message code="default.button.edit.label" default="Edit" /></g:link>
+ <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 598fe03

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