Changeset 180 for trunk/grails-app/controllers
- Timestamp:
- Nov 4, 2009, 2:47:47 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r179 r180 6 6 def authenticateService 7 7 def dateUtilService 8 def taskService 8 9 def taskSearchService 9 10 def filterService … … 186 187 187 188 def inventoryMovementList = InventoryMovement.findAllByTask(taskInstance, [max:100, sort:"id", order:"desc", offset:0]) 189 190 def taskModificationList = TaskModification.findAllByTask(taskInstance, [max:100, sort:"id", order:"asc", offset:0]) 188 191 189 192 def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id) … … 215 218 taskRecurringScheduleInstance: taskRecurringScheduleInstance, 216 219 taskRecurringScheduleExits: taskRecurringScheduleExits, 217 inventoryMovementList: inventoryMovementList] 220 inventoryMovementList: inventoryMovementList, 221 taskModificationList: taskModificationList] 218 222 } 219 223 } … … 263 267 264 268 def update = { 265 def taskInstance = Task.get( params.id ) 266 if(taskInstance) { 267 if(params.version) { 268 def version = params.version.toLong() 269 if(taskInstance.version > version) { 270 271 taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 272 render(view:'edit',model:[taskInstance:taskInstance]) 273 return 274 } 275 } 276 taskInstance.properties = params 277 if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) { 269 270 if(!Task.exists(params.id)) { 271 flash.message = "Task not found with id ${params.id}" 272 redirect(action:'search') 273 } 274 275 def result = taskService.update(params) 276 277 if(!result.error) { 278 278 flash.message = "Task ${params.id} updated" 279 redirect(action:show,id:taskInstance.id) 280 } 281 else { 282 render(view:'edit',model:[taskInstance:taskInstance]) 283 } 284 } 285 else { 286 flash.message = "Task not found with id ${params.id}" 287 redirect(action:edit,id:params.id) 288 } 289 } 279 redirect(action:show,id:result.taskInstance.id) 280 } 281 else { 282 if(result.taskInstance) { 283 render(view:'edit',model:[taskInstance:result.taskInstance]) 284 } 285 else { 286 flash.message = "Task could not be updated." 287 redirect(action:'search') 288 } 289 } 290 291 } 292 293 // def update = { 294 // def taskInstance = Task.get( params.id ) 295 // if(taskInstance) { 296 // if(params.version) { 297 // def version = params.version.toLong() 298 // if(taskInstance.version > version) { 299 // 300 // taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 301 // render(view:'edit',model:[taskInstance:taskInstance]) 302 // return 303 // } 304 // } 305 // taskInstance.properties = params 306 // if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) { 307 // flash.message = "Task ${params.id} updated" 308 // redirect(action:show,id:taskInstance.id) 309 // } 310 // else { 311 // render(view:'edit',model:[taskInstance:taskInstance]) 312 // } 313 // } 314 // else { 315 // flash.message = "Task not found with id ${params.id}" 316 // redirect(action:edit,id:params.id) 317 // } 318 // } 290 319 291 320 def create = { … … 296 325 297 326 def save = { 298 def taskInstance = new Task(params) 299 if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) { 300 flash.message = "Task ${taskInstance.id} created" 301 redirect(action:show,id:taskInstance.id) 302 } 303 else { 304 render(view:'create',model:[taskInstance:taskInstance]) 327 def result = taskService.create(params) 328 329 if(!result.error) { 330 flash.message = "Task ${result.taskInstance.id} created." 331 redirect(action: show,id: result.taskInstance.id) 332 } 333 else { 334 if(result.taskInstance) { 335 render(view:'create',model:[taskInstance:result.taskInstance]) 336 } 337 else { 338 flash.message = "Could not create task." 339 redirect(action:"search") 340 } 341 305 342 } 306 343 }
Note: See TracChangeset
for help on using the changeset viewer.