Changeset 196 for trunk/grails-app/controllers
- Timestamp:
- Nov 24, 2009, 7:57:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r190 r196 14 14 static allowedMethods = [save:'POST', update:'POST', restore:'POST', trash:'POST', approve:'POST', renegeApproval:'POST', complete:'POST', reopen:'POST'] 15 15 16 def index = { redirect(action: search,params:params) }16 def index = { redirect(action: 'search', params: params) } 17 17 18 18 def list = { … … 163 163 if(!taskInstance) { 164 164 flash.message = "Task not found with id ${params.id}" 165 redirect(action: search)165 redirect(action: 'search') 166 166 } 167 167 else { … … 180 180 } 181 181 182 def subTaskInstanceList = Task.findAllByParentTask (taskInstance, params)183 def subTaskInstanceTotal = Task.countByParentTask (taskInstance)182 def subTaskInstanceList = Task.findAllByParentTaskAndTrash(taskInstance, false, params) 183 def subTaskInstanceTotal = Task.countByParentTaskAndTrash(taskInstance, false) 184 184 def showTaskTab = new String("true") 185 185 … … 225 225 if(!Task.exists(params.id)) { 226 226 flash.message = "Task not found with id ${params.id}" 227 redirect(action: 'search')227 redirect(action: 'search') 228 228 } 229 229 … … 232 232 if(!result.error) { 233 233 flash.message = "Task ${params.id} has been restored." 234 redirect(action: show,id:result.taskInstance.id)235 } 236 else { 237 if(result.taskInstance) { 238 render(view:'edit',model:[taskInstance:result.taskInstance]) 239 } 240 else { 241 flash.message = "Task could not be updated." 242 redirect(action: 'search')234 redirect(action: 'show', id: result.taskInstance.id) 235 } 236 else { 237 if(result.taskInstance) { 238 render(view:'edit',model:[taskInstance:result.taskInstance]) 239 } 240 else { 241 flash.message = "Task could not be updated." 242 redirect(action: 'search') 243 243 } 244 244 } … … 250 250 if(!Task.exists(params.id)) { 251 251 flash.message = "Task not found with id ${params.id}." 252 redirect(action: 'search')252 redirect(action: 'search') 253 253 } 254 254 … … 257 257 if(!result.error) { 258 258 flash.message = "Task ${params.id} has been moved to trash." 259 redirect(action: 'search')260 } 261 else { 262 if(result.taskInstance) { 263 render(view:'edit',model:[taskInstance:result.taskInstance]) 264 } 265 else { 266 flash.message = "Task could not be updated." 267 redirect(action: 'search')259 redirect(action: 'search') 260 } 261 else { 262 if(result.taskInstance) { 263 render(view:'edit',model:[taskInstance:result.taskInstance]) 264 } 265 else { 266 flash.message = "Task could not be updated." 267 redirect(action: 'search') 268 268 } 269 269 } … … 275 275 if(!Task.exists(params.id)) { 276 276 flash.message = "Task not found with id ${params.id}." 277 redirect(action: 'search')277 redirect(action: 'search') 278 278 } 279 279 … … 282 282 if(!result.error) { 283 283 flash.message = "Task ${params.id} has been approved." 284 redirect(action: show,id:result.taskInstance.id)285 } 286 else { 287 if(result.taskInstance) { 288 render(view:'edit',model:[taskInstance:result.taskInstance]) 289 } 290 else { 291 flash.message = "Task could not be updated." 292 redirect(action: 'search')284 redirect(action: 'show', id: result.taskInstance.id) 285 } 286 else { 287 if(result.taskInstance) { 288 render(view:'edit',model:[taskInstance:result.taskInstance]) 289 } 290 else { 291 flash.message = "Task could not be updated." 292 redirect(action: 'search') 293 293 } 294 294 } … … 300 300 if(!Task.exists(params.id)) { 301 301 flash.message = "Task not found with id ${params.id}." 302 redirect(action: 'search')302 redirect(action: 'search') 303 303 } 304 304 … … 307 307 if(!result.error) { 308 308 flash.message = "Task ${params.id} has had approval removed." 309 redirect(action: show,id:result.taskInstance.id)310 } 311 else { 312 if(result.taskInstance) { 313 render(view:'edit',model:[taskInstance:result.taskInstance]) 314 } 315 else { 316 flash.message = "Task could not be updated." 317 redirect(action: 'search')309 redirect(action: 'show', id: result.taskInstance.id) 310 } 311 else { 312 if(result.taskInstance) { 313 render(view:'edit',model:[taskInstance:result.taskInstance]) 314 } 315 else { 316 flash.message = "Task could not be updated." 317 redirect(action: 'search') 318 318 } 319 319 } … … 325 325 if(!Task.exists(params.id)) { 326 326 flash.message = "Task not found with id ${params.id}." 327 redirect(action: 'search')327 redirect(action: 'search') 328 328 } 329 329 … … 332 332 if(!result.error) { 333 333 flash.message = "Task ${params.id} has been completed." 334 redirect(action: show,id:result.taskInstance.id)335 } 336 else { 337 if(result.taskInstance) { 338 render(view:'edit',model:[taskInstance:result.taskInstance]) 339 } 340 else { 341 flash.message = "Task could not be updated." 342 redirect(action: 'search')334 redirect(action: 'show', id: result.taskInstance.id) 335 } 336 else { 337 if(result.taskInstance) { 338 render(view:'edit',model:[taskInstance:result.taskInstance]) 339 } 340 else { 341 flash.message = "Task could not be updated." 342 redirect(action: 'search') 343 343 } 344 344 } … … 350 350 if(!Task.exists(params.id)) { 351 351 flash.message = "Task not found with id ${params.id}." 352 redirect(action: 'search')352 redirect(action: 'search') 353 353 } 354 354 … … 357 357 if(!result.error) { 358 358 flash.message = "Task ${params.id} has been reopened." 359 redirect(action: show,id:result.taskInstance.id)360 } 361 else { 362 if(result.taskInstance) { 363 render(view:'edit',model:[taskInstance:result.taskInstance]) 364 } 365 else { 366 flash.message = "Task could not be updated." 367 redirect(action: 'search')359 redirect(action: 'show', id: result.taskInstance.id) 360 } 361 else { 362 if(result.taskInstance) { 363 render(view:'edit',model:[taskInstance:result.taskInstance]) 364 } 365 else { 366 flash.message = "Task could not be updated." 367 redirect(action: 'search') 368 368 } 369 369 } … … 381 381 if(!taskInstance) { 382 382 flash.message = "Task not found with id ${params.id}" 383 redirect(action: search)383 redirect(action: 'search') 384 384 } 385 385 else { 386 386 if(taskInstance.trash) { 387 flash.message = "You may not edit items in the trash." 388 redirect(action:show,id:taskInstance.id) 389 } 390 def criteria = taskInstance.createCriteria() 391 def possibleParentList = criteria { 392 and { 393 notEqual('id', taskInstance.id) 394 taskInstance.subTasks.each() { notEqual('id', it.id) } 395 } 396 } 387 flash.message = "You may not edit tasks that are in the trash." 388 redirect(action: 'show', id: taskInstance.id) 389 return 390 } 391 def possibleParentList = taskService.possibleParentList(taskInstance) 397 392 return [ taskInstance : taskInstance, possibleParentList: possibleParentList ] 398 393 } … … 403 398 if(!Task.exists(params.id)) { 404 399 flash.message = "Task not found with id ${params.id}" 405 redirect(action: 'search')400 redirect(action: 'search') 406 401 } 407 402 … … 410 405 if(!result.error) { 411 406 flash.message = "Task ${params.id} updated" 412 redirect(action: show,id:result.taskInstance.id)413 } 414 else { 415 if(result.taskInstance) { 416 render(view:'edit',model:[taskInstance:result.taskInstance]) 417 } 418 else { 419 flash.message = "Task could not be updated." 420 redirect(action: 'search')407 redirect(action: 'show', id: result.taskInstance.id) 408 } 409 else { 410 if(result.taskInstance) { 411 render(view:'edit',model:[taskInstance:result.taskInstance]) 412 } 413 else { 414 flash.message = "Task could not be updated." 415 redirect(action: 'search') 421 416 } 422 417 } … … 453 448 def create = { 454 449 def taskInstance = new Task() 455 // Default leadPerson to current user .450 // Default leadPerson to current user, unless supplied in params. 456 451 taskInstance.leadPerson = personService.currentUser() 457 452 taskInstance.properties = params 458 return ['taskInstance': taskInstance]453 return ['taskInstance': taskInstance] 459 454 } 460 455 … … 464 459 if(!result.error) { 465 460 flash.message = "Task ${result.taskInstance.id} created." 466 redirect(action: show,id: result.taskInstance.id)467 } 468 else { 469 if(result.taskInstance) { 470 render(view:'create', model:[taskInstance:result.taskInstance])461 redirect(action: 'show', id: result.taskInstance.id) 462 } 463 else { 464 if(result.taskInstance) { 465 render(view:'create', model:[taskInstance:result.taskInstance]) 471 466 } 472 467 else { 473 468 flash.message = "Could not create task." 474 redirect(action: "search")469 redirect(action: 'search') 475 470 } 476 471 … … 483 478 if(!parentTaskInstance) { 484 479 flash.message = "Task not found with id ${params.id}" 485 redirect(action: search)480 redirect(action: 'search') 486 481 } 487 482 else { 488 483 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 489 def subTaskInstanceList = Task.findAllByParentTask (parentTaskInstance, params)490 def subTaskInstanceTotal = Task.countByParentTask (parentTaskInstance)484 def subTaskInstanceList = Task.findAllByParentTaskAndTrash(parentTaskInstance, false, params) 485 def subTaskInstanceTotal = Task.countByParentTaskAndTrash(parentTaskInstance, false) 491 486 492 487 [ taskInstanceList: subTaskInstanceList, … … 496 491 } 497 492 498 } 493 def createSubTask = { 494 def parentTaskInstance = Task.get(params.id) 495 496 if(parentTaskInstance) { 497 498 def result = taskService.createSubTask(parentTaskInstance) 499 if(!result.error) { 500 flash.message = "Sub Task ${result.taskInstance.id} created, please edit and update to your requirements." 501 redirect(action: 'edit', id: result.taskInstance.id) 502 } 503 else { 504 if(result.taskInstance.errors.hasFieldErrors("parentTask")) { 505 flash.message = g.message(code:"task.operationNotPermittedOnTaskInTrash") 506 redirect(action: 'show', id: parentTaskInstance.id) 507 } 508 else { 509 render(view: 'create', model:[taskInstance: result.taskInstance]) 510 } 511 } 512 } 513 514 else { 515 flash.message = "Task not found with id ${params.id}" 516 redirect(action: 'search') 517 } 518 } 519 520 } // end of class.
Note: See TracChangeset
for help on using the changeset viewer.