- Timestamp:
- Mar 7, 2010, 4:45:10 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/Config.groovy
r431 r433 148 148 [order:11, controller:'taskDetailed', title:'Calendar', action:'searchCalendar', isVisible: { true }], 149 149 [order:20, controller:'taskDetailed', title:'+Scheduled', action:'create', isVisible: { true }], 150 [order:30, controller:'taskDetailed', title:'+Callout', action:'createImmediateCallout', isVisible: { true }], 151 [order:90, controller:'taskDetailed', title:'Show', action:'show', isVisible: { params.action == 'show' }], 152 [order:91, controller:'taskDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }] 150 [order:30, controller:'taskDetailed', title:'+Unsheduled', action:'createUnscheduled', isVisible: { true }], 151 [order:40, controller:'taskDetailed', title:'+Callout', action:'createImmediateCallout', isVisible: { true }], 152 [order:90, controller:'taskDetailed', title:'Show', action:'show', id:'nav', isVisible: { params.action == 'show' }], 153 [order:91, controller:'taskDetailed', title:'Edit', action:'edit', id:'nav', isVisible: { params.action == 'edit' }] 153 154 ] 154 155 ], -
trunk/grails-app/controllers/TaskDetailedController.groovy
r418 r433 219 219 if(params._action_Show) 220 220 params.action='show' 221 222 // Used by navigation. 223 if(params.id == 'nav') { 224 params.id = session.currentTaskId ?: null 225 redirect(action: show, id: params.id) 226 return 227 } 221 228 222 229 def showTab = [:] … … 245 252 } 246 253 else { 254 // Remember the current task id for use with navigation. 255 session.currentTaskId = params.id 256 247 257 params.max = 10 248 258 params.order = "desc" … … 477 487 params.action='edit' 478 488 489 // Used by navigation. 490 if(params.id == 'nav') { 491 params.id = session.currentTaskId ?: null 492 redirect(action: edit, id: params.id) 493 return 494 } 495 479 496 def taskInstance = Task.get( params.id ) 480 497 … … 484 501 } 485 502 else { 503 // Remember the current task id for use with navigation. 504 session.currentTaskId = params.id 505 486 506 if(taskInstance.trash) { 487 507 flash.message = "You may not edit tasks that are in the trash." … … 524 544 taskInstance.leadPerson = authService.currentUser 525 545 taskInstance.properties = params 526 return ['taskInstance': taskInstance] 546 547 def scheduledTaskTypes = taskService.scheduledTaskTypes 548 def scheduledTaskPriorities = taskService.scheduledTaskPriorities 549 taskInstance.taskPriority = scheduledTaskPriorities.default 550 return ['taskInstance': taskInstance, 551 'scheduledTaskTypes': scheduledTaskTypes, 552 'scheduledTaskPriorities': scheduledTaskPriorities.list] 527 553 } 528 554 … … 540 566 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 541 567 542 render(view:'create', model:[taskInstance:result.taskInstance]) 568 569 def scheduledTaskTypes = taskService.scheduledTaskTypes 570 def scheduledTaskPriorities = taskService.scheduledTaskPriorities 571 render(view:'create', model:[taskInstance:result.taskInstance, 572 'scheduledTaskTypes': scheduledTaskTypes, 573 'scheduledTaskPriorities': scheduledTaskPriorities.list]) 543 574 } 544 575 … … 591 622 592 623 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 624 def createUnscheduled = { 625 def taskInstance = new Task() 626 627 // Default leadPerson to current user, unless supplied in params. 628 taskInstance.leadPerson = authService.currentUser 629 taskInstance.properties = params 630 631 // Always for Unscheduled task. 632 taskInstance.taskType = TaskType.get(2) // Unscheduled Breakin. 633 def unscheduledTaskPriorities = taskService.unscheduledTaskPriorities 634 taskInstance.taskPriority = unscheduledTaskPriorities.default 635 636 return ['taskInstance': taskInstance, 'unscheduledTaskPriorities': unscheduledTaskPriorities.list] 637 } 638 639 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 640 def saveUnscheduled = { 641 def result = taskService.saveUnscheduled(params) 642 643 if(!result.error) { 644 flash.message = "Task ${result.taskInstance.id} created." 645 redirect(action: 'show', id: result.taskInstance.id) 646 return 647 } 648 649 if(result.error.code == "task.modifications.failedToSave") 650 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 651 652 def unscheduledTaskPriorities = taskService.unscheduledTaskPriorities 653 654 render(view:'createUnscheduled', 655 model: ['taskInstance': result.taskInstance, 'unscheduledTaskPriorities': unscheduledTaskPriorities.list]) 656 } 657 658 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 593 659 def createImmediateCallout = { 594 660 def taskInstance = new Task() -
trunk/grails-app/services/CreateDataService.groovy
r431 r433 702 702 def taskPriorityInstance 703 703 704 taskPriorityInstance = new TaskPriority(name:" Normal") // #1704 taskPriorityInstance = new TaskPriority(name:"0 - Immediate") // #1 705 705 saveAndTest(taskPriorityInstance) 706 706 707 taskPriorityInstance = new TaskPriority(name:" Low") // #2707 taskPriorityInstance = new TaskPriority(name:"1 - Very High") // #2 708 708 saveAndTest(taskPriorityInstance) 709 709 710 taskPriorityInstance = new TaskPriority(name:" High") // #3710 taskPriorityInstance = new TaskPriority(name:"2 - High") // #3 711 711 saveAndTest(taskPriorityInstance) 712 712 713 taskPriorityInstance = new TaskPriority(name:"Immediate") // #4 713 taskPriorityInstance = new TaskPriority(name:"3 - Normal") // #4 714 saveAndTest(taskPriorityInstance) 715 716 taskPriorityInstance = new TaskPriority(name:"4 - Low") // #5 717 saveAndTest(taskPriorityInstance) 718 719 taskPriorityInstance = new TaskPriority(name:"5 - Minor") // #6 714 720 saveAndTest(taskPriorityInstance) 715 721 } -
trunk/grails-app/services/TaskService.groovy
r432 r433 29 29 30 30 /** 31 * Determines and returns a list of possible task types for scheduled tasks. 32 * @returns A list of the possible task types. 33 */ 34 def getScheduledTaskTypes() { 35 def criteria = TaskType.createCriteria() 36 def scheduledTaskTypes = criteria { 37 and { 38 eq('isActive', true) 39 gt('id', 2L) 40 } 41 } 42 } 43 44 /** 45 * Determines and returns a list of possible task priorites for Scheduled tasks. 46 * @returns A list of the possible task priorites. 47 */ 48 def getScheduledTaskPriorities() { 49 def criteria = TaskPriority.createCriteria() 50 def scheduledTaskPriorities = [:] 51 scheduledTaskPriorities.list = criteria { 52 and { 53 eq('isActive', true) 54 gt('id', 1L) 55 } 56 } 57 scheduledTaskPriorities.default = scheduledTaskPriorities.list.find { it.id == 4L } // 1-Normal. 58 return scheduledTaskPriorities 59 } 60 61 /** 62 * Determines and returns a list of possible task priorites for Unscheduled tasks. 63 * @returns A map containing a list of the possible task priorites and the default priority. 64 */ 65 def getUnscheduledTaskPriorities() { 66 def criteria = TaskPriority.createCriteria() 67 def unscheduledTaskPriorities = [:] 68 unscheduledTaskPriorities.list = criteria { 69 and { 70 eq('isActive', true) 71 lt('id', 5L) 72 ne('id', 1L) 73 } 74 } 75 unscheduledTaskPriorities.default = unscheduledTaskPriorities.list.find { it.id == 3L } // 2-High. 76 return unscheduledTaskPriorities 77 } 78 79 /** 31 80 * Creates a new task with the given params. 32 81 * @param params The params to use when creating the new task. … … 646 695 647 696 /** 697 * Creates a new unscheduled breakin task with the given params. 698 * @param params The params to use when creating the new task. 699 * @returns A map containing result.error (if any error) and result.taskInstance. 700 */ 701 def saveUnscheduled(params) { 702 Task.withTransaction { status -> 703 def result = [:] 704 705 def fail = { Map m -> 706 status.setRollbackOnly() 707 if(result.taskInstance && m.field) 708 result.taskInstance.errors.rejectValue(m.field, m.code) 709 result.error = [ code: m.code, args: ["Task", params.id] ] 710 return result 711 } 712 713 // If not supplied. 714 if(!params.taskStatus) 715 params.taskStatus = TaskStatus.get(1) // Not Started. 716 717 result.taskInstance = new Task(params) 718 719 // Always for an unscheduled breakin.. 720 result.taskInstance.taskType = TaskType.get(2) // Unscheduled Breakin. 721 result.taskInstance.taskBudgetStatus = TaskBudgetStatus.get(1) // Unplanned. 722 723 if(result.taskInstance.hasErrors() || !result.taskInstance.save()) 724 fail(code:"default.create.failure") 725 726 if(!result.error) { 727 def taskModification = new TaskModification(person: authService.currentUser, 728 taskModificationType: TaskModificationType.get(1), // Created. 729 task: result.taskInstance) 730 731 if(taskModification.hasErrors() || !taskModification.save()) 732 fail(field:"taskModifications", code:"task.modifications.failedToSave") 733 } 734 735 // Success. 736 return result 737 738 } //end withTransaction 739 } // end saveUnscheduled() 740 741 /** 648 742 * Creates a new immediate callout task with the given params. 649 743 * @param params The params to use when creating the new task. … … 671 765 result.taskInstance.taskType = TaskType.get(1) // Immediate Callout. 672 766 result.taskInstance.taskBudgetStatus = TaskBudgetStatus.get(1) // Unplanned. 673 result.taskInstance.taskPriority = TaskPriority.get( 4) // Immediate.767 result.taskInstance.taskPriority = TaskPriority.get(1) // Immediate. 674 768 result.taskInstance.taskGroup = TaskGroup.get(1) // Engineering Activites. 675 769 result.taskInstance.approved = true -
trunk/grails-app/views/taskDetailed/create.gsp
r313 r433 104 104 </td> 105 105 <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'taskPriority','errors')}"> 106 <g:select optionKey="id" from="${ TaskPriority.list()}" name="taskPriority.id" value="${taskInstance?.taskPriority?.id}" ></g:select>106 <g:select optionKey="id" from="${scheduledTaskPriorities}" name="taskPriority.id" value="${taskInstance?.taskPriority?.id}" ></g:select> 107 107 </td> 108 108 </tr> … … 140 140 </td> 141 141 <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'taskType','errors')}"> 142 <g:select optionKey="id" from="${ TaskType.list()}" name="taskType.id" value="${taskInstance?.taskType?.id}" ></g:select>142 <g:select optionKey="id" from="${scheduledTaskTypes}" name="taskType.id" value="${taskInstance?.taskType?.id}" ></g:select> 143 143 </td> 144 144 </tr>
Note: See TracChangeset
for help on using the changeset viewer.