- Timestamp:
- Mar 24, 2009, 3:30:12 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TaskRewrite/src/grails-app/controllers/TaskController.groovy
r74 r84 6 6 7 7 // the delete, save and update actions only accept POST requests 8 static allowedMethods = [delete:'POST', save:'POST', update:'POST']8 static allowedMethods = [delete:'POST', deleteDetailed:'POST', save:'POST', saveDetailed:'POST', updateDetailed:'POST'] 9 9 10 @Secured(['ROLE_AppAdmin']) 10 11 def list = { 11 12 if(!params.max) params.max = 10 … … 13 14 } 14 15 16 def listDetailed = { 17 if(!params.max) params.max = 10 18 [ taskInstanceList: Task.list( params ) ] 19 } 20 21 @Secured(['ROLE_AppAdmin']) 15 22 def show = { 16 23 def taskInstance = Task.get( params.id ) … … 23 30 } 24 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']) 25 43 def delete = { 26 44 def taskInstance = Task.get( params.id ) … … 36 54 } 37 55 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']) 38 70 def edit = { 39 71 def taskInstance = Task.get( params.id ) … … 48 80 } 49 81 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']) 50 101 def update = { 51 102 def taskInstance = Task.get( params.id ) … … 66 117 } 67 118 119 def updateDetailed = { 120 def taskInstance = Task.get( params.id ) 121 if(taskInstance) { 122 taskInstance.properties = params 123 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']) 68 138 def create = { 69 139 def taskInstance = new Task() … … 72 142 } 73 143 144 def createDetailed = { 145 def taskInstance = new Task() 146 taskInstance.properties = params 147 return ['taskInstance':taskInstance] 148 } 149 150 @Secured(['ROLE_AppAdmin']) 74 151 def save = { 75 152 def taskInstance = new Task(params) … … 82 159 } 83 160 } 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 } 84 172 }
Note: See TracChangeset
for help on using the changeset viewer.