Changeset 85 for branches/TaskRewrite/src/grails-app
- Timestamp:
- Mar 24, 2009, 2:49:44 PM (16 years ago)
- Location:
- branches/TaskRewrite/src/grails-app
- Files:
-
- 1 added
- 2 edited
- 1 copied
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/TaskRewrite/src/grails-app/controllers/TaskController.groovy
r84 r85 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 @Secured(['ROLE_AppAdmin']) 3 4 class TaskController extends BaseController { 4 5 … … 6 7 7 8 // the delete, save and update actions only accept POST requests 8 static allowedMethods = [delete:'POST', deleteDetailed:'POST', save:'POST', saveDetailed:'POST', updateDetailed:'POST']9 static allowedMethods = [delete:'POST', save:'POST', update:'POST'] 9 10 10 @Secured(['ROLE_AppAdmin'])11 11 def list = { 12 12 if(!params.max) params.max = 10 13 13 [ taskInstanceList: Task.list( params ) ] 14 14 } 15 16 def listDetailed = {17 if(!params.max) params.max = 1018 [ taskInstanceList: Task.list( params ) ]19 }20 21 @Secured(['ROLE_AppAdmin'])22 15 def show = { 23 16 def taskInstance = Task.get( params.id ) … … 29 22 else { return [ taskInstance : taskInstance ] } 30 23 } 31 32 def showDetailed = { 33 def taskInstance = Task.get( params.id ) 34 35 if(!taskInstance) { 36 flash.message = "Task not found with id ${params.id}" 37 redirect(action:list) 38 } 39 else { return [ taskInstance : taskInstance ] } 40 } 41 42 @Secured(['ROLE_AppAdmin']) 24 43 25 def delete = { 44 26 def taskInstance = Task.get( params.id ) … … 54 36 } 55 37 56 def deleteDetailed = {57 def taskInstance = Task.get( params.id )58 if(taskInstance) {59 taskInstance.delete()60 flash.message = "Task ${params.id} deleted"61 redirect(action:list)62 }63 else {64 flash.message = "Task not found with id ${params.id}"65 redirect(action:list)66 }67 }68 69 @Secured(['ROLE_AppAdmin'])70 38 def edit = { 71 39 def taskInstance = Task.get( params.id ) … … 80 48 } 81 49 82 def editDetailed = {83 def taskInstance = Task.get( params.id )84 85 if(!taskInstance) {86 flash.message = "Task not found with id ${params.id}"87 redirect(action:list)88 }89 else {90 def criteria = taskInstance.createCriteria()91 def results = criteria {92 and {93 notEqual('id', taskInstance.id)94 }95 }96 return [ taskInstance : taskInstance, possibleParentList: results ]97 }98 }99 100 @Secured(['ROLE_AppAdmin'])101 50 def update = { 102 51 def taskInstance = Task.get( params.id ) … … 117 66 } 118 67 119 def updateDetailed = {120 def taskInstance = Task.get( params.id )121 if(taskInstance) {122 taskInstance.properties = params123 if(!taskInstance.hasErrors() && taskInstance.save()) {124 flash.message = "Task ${params.id} updated"125 redirect(action:show,id:taskInstance.id)126 }127 else {128 render(view:'edit',model:[taskInstance:taskInstance])129 }130 }131 else {132 flash.message = "Task not found with id ${params.id}"133 redirect(action:edit,id:params.id)134 }135 }136 137 @Secured(['ROLE_AppAdmin'])138 68 def create = { 139 69 def taskInstance = new Task() … … 142 72 } 143 73 144 def createDetailed = {145 def taskInstance = new Task()146 taskInstance.properties = params147 return ['taskInstance':taskInstance]148 }149 150 @Secured(['ROLE_AppAdmin'])151 74 def save = { 152 75 def taskInstance = new Task(params) … … 160 83 } 161 84 162 def saveDetailed = {163 def taskInstance = new Task(params)164 if(!taskInstance.hasErrors() && taskInstance.save()) {165 flash.message = "Task ${taskInstance.id} created"166 redirect(action:showDetailed,id:taskInstance.id)167 }168 else {169 render(view:'createDetailed',model:[taskInstance:taskInstance])170 }171 }172 85 } -
branches/TaskRewrite/src/grails-app/controllers/TaskDetailedController.groovy
r84 r85 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 class Task Controller extends BaseController {3 class TaskDetailedController extends BaseController { 4 4 5 5 def index = { redirect(action:list,params:params) } 6 6 7 7 // the delete, save and update actions only accept POST requests 8 static allowedMethods = [delete:'POST', deleteDetailed:'POST', save:'POST', saveDetailed:'POST', updateDetailed:'POST']8 static allowedMethods = [delete:'POST', save:'POST', update:'POST'] 9 9 10 @Secured(['ROLE_AppAdmin'])11 10 def list = { 12 11 if(!params.max) params.max = 10 … … 14 13 } 15 14 16 def listDetailed = {17 if(!params.max) params.max = 1018 [ taskInstanceList: Task.list( params ) ]19 }20 21 @Secured(['ROLE_AppAdmin'])22 15 def show = { 23 16 def taskInstance = Task.get( params.id ) … … 30 23 } 31 24 32 def showDetailed = {33 def taskInstance = Task.get( params.id )34 35 if(!taskInstance) {36 flash.message = "Task not found with id ${params.id}"37 redirect(action:list)38 }39 else { return [ taskInstance : taskInstance ] }40 }41 42 @Secured(['ROLE_AppAdmin'])43 25 def delete = { 44 26 def taskInstance = Task.get( params.id ) … … 54 36 } 55 37 56 def deleteDetailed = {57 def taskInstance = Task.get( params.id )58 if(taskInstance) {59 taskInstance.delete()60 flash.message = "Task ${params.id} deleted"61 redirect(action:list)62 }63 else {64 flash.message = "Task not found with id ${params.id}"65 redirect(action:list)66 }67 }68 69 @Secured(['ROLE_AppAdmin'])70 38 def edit = { 71 def taskInstance = Task.get( params.id )72 73 if(!taskInstance) {74 flash.message = "Task not found with id ${params.id}"75 redirect(action:list)76 }77 else {78 return [ taskInstance : taskInstance ]79 }80 }81 82 def editDetailed = {83 39 def taskInstance = Task.get( params.id ) 84 40 … … 98 54 } 99 55 100 @Secured(['ROLE_AppAdmin'])101 56 def update = { 102 57 def taskInstance = Task.get( params.id ) … … 117 72 } 118 73 119 def updateDetailed = {120 def taskInstance = Task.get( params.id )121 if(taskInstance) {122 taskInstance.properties = params123 if(!taskInstance.hasErrors() && taskInstance.save()) {124 flash.message = "Task ${params.id} updated"125 redirect(action:show,id:taskInstance.id)126 }127 else {128 render(view:'edit',model:[taskInstance:taskInstance])129 }130 }131 else {132 flash.message = "Task not found with id ${params.id}"133 redirect(action:edit,id:params.id)134 }135 }136 137 @Secured(['ROLE_AppAdmin'])138 74 def create = { 139 75 def taskInstance = new Task() … … 142 78 } 143 79 144 def createDetailed = {145 def taskInstance = new Task()146 taskInstance.properties = params147 return ['taskInstance':taskInstance]148 }149 150 @Secured(['ROLE_AppAdmin'])151 80 def save = { 152 81 def taskInstance = new Task(params) … … 159 88 } 160 89 } 161 162 def saveDetailed = {163 def taskInstance = new Task(params)164 if(!taskInstance.hasErrors() && taskInstance.save()) {165 flash.message = "Task ${taskInstance.id} created"166 redirect(action:showDetailed,id:taskInstance.id)167 }168 else {169 render(view:'createDetailed',model:[taskInstance:taskInstance])170 }171 }172 90 } -
branches/TaskRewrite/src/grails-app/views/appCore/home.gsp
r84 r85 8 8 <body> 9 9 <div class="nav"> 10 <span class="menuButton"><g:link class="list" controller="task " action="listDetailed">Tasks</g:link></span>10 <span class="menuButton"><g:link class="list" controller="taskDetailed" action="list">Tasks</g:link></span> 11 11 12 12 </div> -
branches/TaskRewrite/src/grails-app/views/taskDetailed/create.gsp
r84 r85 10 10 <div class="nav"> 11 11 <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span> 12 <span class="menuButton"><g:link class="list" action="list Detailed">Task List</g:link></span>12 <span class="menuButton"><g:link class="list" action="list">Task List</g:link></span> 13 13 </div> 14 14 <div class="body"> … … 148 148 </div> 149 149 <div class="buttons"> 150 <span class="button"><input class="save" type="submit" value="Create Detailed" /></span>150 <span class="button"><input class="save" type="submit" value="Create" /></span> 151 151 </div> 152 152 </g:form> -
branches/TaskRewrite/src/grails-app/views/taskDetailed/edit.gsp
r84 r85 10 10 <div class="nav"> 11 11 <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span> 12 <span class="menuButton"><g:link class="list" action="list Detailed">Task List</g:link></span>13 <span class="menuButton"><g:link class="create" action="create Detailed">New Task</g:link></span>12 <span class="menuButton"><g:link class="list" action="list">Task List</g:link></span> 13 <span class="menuButton"><g:link class="create" action="create">New Task</g:link></span> 14 14 </div> 15 15 <div class="body"> -
branches/TaskRewrite/src/grails-app/views/taskDetailed/list.gsp
r84 r85 56 56 <td>${fieldValue(bean:taskInstance, field:'taskStatus')}</td> 57 57 58 <td><g:link action="edit Detailed" id="${taskInstance.id}">Edit</g:link></td>58 <td><g:link action="edit" id="${taskInstance.id}">Edit</g:link></td> 59 59 60 <td><g:link action="show Detailed" id="${taskInstance.id}">Show</g:link></td>60 <td><g:link action="show" id="${taskInstance.id}">Show</g:link></td> 61 61 62 62 </tr> -
branches/TaskRewrite/src/grails-app/views/taskDetailed/show.gsp
r84 r85 8 8 <div class="nav"> 9 9 <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span> 10 <span class="menuButton"><g:link class="list Detailed" action="listDetailed">Task List</g:link></span>11 <span class="menuButton"><g:link class="create Detailed" action="createDetailed">New Task</g:link></span>10 <span class="menuButton"><g:link class="list" action="list">Task List</g:link></span> 11 <span class="menuButton"><g:link class="create" action="create">New Task</g:link></span> 12 12 </div> 13 13 <div class="body">
Note: See TracChangeset
for help on using the changeset viewer.