Changeset 418 for trunk/grails-app/controllers
- Timestamp:
- Feb 28, 2010, 7:13:47 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r395 r418 14 14 15 15 // these actions only accept POST requests 16 static allowedMethods = [save:'POST', update:'POST', restore:'POST', trash:'POST', approve:'POST', renegeApproval:'POST', complete:'POST', reopen:'POST'] 16 static allowedMethods = [save:'POST',update:'POST',restore:'POST', trash:'POST', 17 approve:'POST', renegeApproval:'POST', complete:'POST', 18 reopen:'POST', setAttentionFlag:'POST', clearAttentionFlag:'POST'] 17 19 18 20 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 19 21 def index = { redirect(action: 'search', params: params) } 20 21 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser'])22 def list = {23 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100 )24 [ taskInstanceList: Task.list( params ), taskInstanceTotal: Task.count() ]25 }26 22 27 23 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) … … 115 111 filterParams.max = params.max 116 112 filterParams.offset = params.offset?.toInteger() ?: 0 117 filterParams.sort = params.sort ?: " id"113 filterParams.sort = params.sort ?: "attentionFlag" 118 114 filterParams.order = params.order ?: "desc" 119 115 … … 253 249 params.sort = "id" 254 250 255 def entryWorkDoneList = Entry.withCriteria {256 eq("entryType", EntryType.get(2))257 eq("task", taskInstance)258 }259 260 251 def entryFaultList = Entry.withCriteria { 261 252 eq("entryType", EntryType.get(1)) … … 263 254 } 264 255 256 def entryCauseList = Entry.withCriteria { 257 eq("entryType", EntryType.get(2)) 258 eq("task", taskInstance) 259 } 260 261 def entryWorkDoneList = Entry.withCriteria { 262 eq("entryType", EntryType.get(3)) 263 eq("task", taskInstance) 264 } 265 265 266 def subTaskInstanceList = Task.findAllByParentTaskAndTrash(taskInstance, false, params) 266 267 def subTaskInstanceTotal = Task.countByParentTaskAndTrash(taskInstance, false) … … 290 291 291 292 return [ taskInstance: taskInstance, 293 entryFaultList: entryFaultList, 294 entryCauseList: entryCauseList, 292 295 entryWorkDoneList: entryWorkDoneList, 293 entryFaultList: entryFaultList,294 296 taskProcedureInstance: taskProcedureInstance, 295 297 taskProcedureExits: taskProcedureExits, … … 308 310 } 309 311 312 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 310 313 def restore = { 311 314 312 if(!Task.exists(params.id)) {313 flash.message = "Task not found with id ${params.id}"314 redirect(action: 'search')315 }316 317 315 def result = taskService.restore(params) 318 316 319 317 if(!result.error) { 320 318 flash.message = "Task ${params.id} has been restored." 321 redirect(action: 'show', id: result.taskInstance.id)322 }323 else {324 if(result.taskInstance) { 325 render(view:'edit',model:[taskInstance:result.taskInstance])326 } 327 else {328 flash.message = "Task could not be updated."329 redirect(action: 'search')330 }331 } 332 333 } 334 319 redirect(action: show, id: params.id) 320 return 321 } 322 323 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 324 325 if(result.taskInstance) 326 redirect(action: show, id: params.id) 327 else 328 redirect(action: 'search') 329 330 } 331 332 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 335 333 def trash = { 336 337 if(!Task.exists(params.id)) {338 flash.message = "Task not found with id ${params.id}."339 redirect(action: 'search')340 }341 334 342 335 def result = taskService.trash(params) … … 345 338 flash.message = "Task ${params.id} has been moved to trash." 346 339 redirect(action: 'search') 347 }348 else {349 if(result.taskInstance) { 350 render(view:'edit',model:[taskInstance:result.taskInstance])351 } 352 else {353 flash.message = "Task could not be updated."354 redirect(action: 'search')355 }356 } 357 358 } 359 340 return 341 } 342 343 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 344 345 if(result.taskInstance) 346 redirect(action: show, id: params.id) 347 else 348 redirect(action: 'search') 349 350 } 351 352 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager']) 360 353 def approve = { 361 354 362 if(!Task.exists(params.id)) {363 flash.message = "Task not found with id ${params.id}."364 redirect(action: 'search')365 }366 367 355 def result = taskService.approve(params) 368 356 369 357 if(!result.error) { 370 358 flash.message = "Task ${params.id} has been approved." 371 redirect(action: 'show', id: result.taskInstance.id)372 }373 else {374 if(result.taskInstance) { 375 render(view:'edit',model:[taskInstance:result.taskInstance])376 } 377 else {378 flash.message = "Task could not be updated."379 redirect(action: 'search')380 }381 } 382 383 } 384 359 redirect(action: show, id: params.id) 360 return 361 } 362 363 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 364 365 if(result.taskInstance) 366 redirect(action: show, id: params.id) 367 else 368 redirect(action: 'search') 369 370 } 371 372 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 385 373 def renegeApproval = { 386 374 387 if(!Task.exists(params.id)) {388 flash.message = "Task not found with id ${params.id}."389 redirect(action: 'search')390 }391 392 375 def result = taskService.renegeApproval(params) 393 376 394 377 if(!result.error) { 395 378 flash.message = "Task ${params.id} has had approval removed." 396 redirect(action: 'show', id: result.taskInstance.id) 397 } 398 else { 399 if(result.taskInstance) { 400 render(view:'edit',model:[taskInstance:result.taskInstance]) 401 } 402 else { 403 flash.message = "Task could not be updated." 404 redirect(action: 'search') 405 } 406 } 379 redirect(action: show, id: params.id) 380 return 381 } 382 383 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 384 385 if(result.taskInstance) 386 redirect(action: show, id: params.id) 387 else 388 redirect(action: 'search') 407 389 408 390 } … … 411 393 def complete = { 412 394 413 if(!Task.exists(params.id)) {414 flash.message = "Task not found with id ${params.id}."415 redirect(action: 'search')416 }417 418 395 def result = taskService.complete(params) 419 396 420 397 if(!result.error) { 421 398 flash.message = "Task ${params.id} has been completed." 422 redirect(action: 'show', id: result.taskInstance.id) 423 } 424 else { 425 if(result.taskInstance) { 426 render(view:'edit',model:[taskInstance:result.taskInstance]) 427 } 428 else { 429 flash.message = "Task could not be updated." 430 redirect(action: 'search') 431 } 432 } 399 redirect(action: show, id: params.id) 400 return 401 } 402 403 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 404 405 if(result.taskInstance) 406 redirect(action: show, id: params.id) 407 else 408 redirect(action: 'search') 409 410 } 411 412 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 413 def setAttentionFlag = { 414 415 def result = taskService.setAttentionFlag(params) 416 417 if(!result.error) { 418 flash.message = "Task ${params.id} has been flagged for attention." 419 redirect(action: show, id: params.id) 420 return 421 } 422 423 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 424 425 if(result.taskInstance) 426 redirect(action: show, id: params.id) 427 else 428 redirect(action: 'search') 429 430 } 431 432 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 433 def clearAttentionFlag = { 434 435 def result = taskService.clearAttentionFlag(params) 436 437 if(!result.error) { 438 flash.message = "Task ${params.id} attention flag cleared." 439 redirect(action: show, id: params.id) 440 return 441 } 442 443 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 444 445 if(result.taskInstance) 446 redirect(action: show, id: params.id) 447 else 448 redirect(action: 'search') 433 449 434 450 } … … 437 453 def reopen = { 438 454 439 if(!Task.exists(params.id)) {440 flash.message = "Task not found with id ${params.id}."441 redirect(action: 'search')442 }443 444 455 def result = taskService.reopen(params) 445 456 446 457 if(!result.error) { 447 458 flash.message = "Task ${params.id} has been reopened." 448 redirect(action: 'show', id: result.taskInstance.id) 449 } 450 else { 451 if(result.taskInstance) { 452 render(view:'edit',model:[taskInstance:result.taskInstance]) 453 } 454 else { 455 flash.message = "Task could not be updated." 456 redirect(action: 'search') 457 } 458 } 459 redirect(action: show, id: params.id) 460 return 461 } 462 463 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 464 465 if(result.taskInstance) 466 redirect(action: show, id: params.id) 467 else 468 redirect(action: 'search') 459 469 460 470 } … … 488 498 def update = { 489 499 490 if(!Task.exists(params.id)) {491 flash.message = "Task not found with id ${params.id}"492 redirect(action: 'search')493 }494 495 500 def result = taskService.update(params) 496 501 497 502 if(!result.error) { 498 503 flash.message = "Task ${params.id} updated" 499 redirect(action: 'show', id: result.taskInstance.id) 500 } 501 else { 502 render(view:'edit',model:[taskInstance:result.taskInstance.attach()]) 503 } 504 redirect(action: show, id: params.id) 505 return 506 } 507 508 if(result.error.code == "task.modifications.failedToSave") 509 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 510 511 render(view:'edit',model:[taskInstance:result.taskInstance.attach()]) 504 512 505 513 } … … 526 534 flash.message = "Task ${result.taskInstance.id} created." 527 535 redirect(action: 'show', id: result.taskInstance.id) 528 } 529 else { 530 if(result.taskInstance) { 531 render(view:'create', model:[taskInstance:result.taskInstance]) 532 } 533 else { 534 flash.message = "Could not create task." 535 redirect(action: 'search') 536 } 537 538 } 536 return 537 } 538 539 if(result.error.code == "task.modifications.failedToSave") 540 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 541 542 render(view:'create', model:[taskInstance:result.taskInstance]) 539 543 } 540 544 … … 571 575 else { 572 576 if(result.taskInstance.errors.hasFieldErrors("parentTask")) { 573 flash. message = g.message(code:"task.operationNotPermittedOnTaskInTrash")577 flash.errorMessage = g.message(code:"task.operationNotPermittedOnTaskInTrash") 574 578 redirect(action: 'show', id: parentTaskInstance.id) 575 579 } … … 587 591 588 592 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 589 def create Breakin= {593 def createImmediateCallout = { 590 594 def taskInstance = new Task() 591 595 592 596 def entryFaultInstance = new Entry(entryType: EntryType.get(1)) // Fault. 593 def entryWorkDoneInstance = new Entry(entryType: EntryType.get(2)) // Work Done. 597 def entryCauseInstance = new Entry(entryType: EntryType.get(2)) // Cause. 598 def entryWorkDoneInstance = new Entry(entryType: EntryType.get(3)) // Work Done. 594 599 595 600 return ['taskInstance': taskInstance, 596 601 'entryFaultInstance': entryFaultInstance, 602 'entryCauseInstance': entryCauseInstance, 597 603 'entryWorkDoneInstance': entryWorkDoneInstance] 598 604 } 599 605 600 606 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 601 def save Breakin= {602 def result = taskService.save Breakin(params)607 def saveImmediateCallout = { 608 def result = taskService.saveImmediateCallout(params) 603 609 604 610 if(!result.error) { … … 611 617 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 612 618 613 render(view:'create Breakin',619 render(view:'createImmediateCallout', 614 620 model: ['taskInstance': result.taskInstance, 615 621 'entryFaultInstance': result.entryFaultInstance, 622 'entryCauseInstance': result.entryCauseInstance, 616 623 'entryWorkDoneInstance': result.entryWorkDoneInstance]) 617 624
Note: See TracChangeset
for help on using the changeset viewer.