Changeset 809 for trunk/grails-app/controllers
- Timestamp:
- Feb 16, 2011, 8:10:39 PM (14 years ago)
- Location:
- trunk/grails-app/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r747 r809 434 434 def assignedPersonList = taskInstance.assignedPersons.sort { p1, p2 -> p1.person.firstName.compareToIgnoreCase(p2.person.firstName) } 435 435 436 def taskProcedure Instance = TaskProcedure.get(taskInstance.taskProcedure?.id)436 def taskProcedureRevision = TaskProcedureRevision.get(taskInstance.taskProcedureRevision?.id) 437 437 def taskProcedureExits = new Boolean("true") 438 if(!taskProcedure Instance) {438 if(!taskProcedureRevision) { 439 439 taskProcedureExits = false 440 440 } 441 442 def maParams = [:]443 maParams.max = 100444 maParams.order = "asc"445 maParams.sort = "procedureStepNumber"446 def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, maParams)447 441 448 442 def taskRecurringScheduleInstance = TaskRecurringSchedule.get(taskInstance.taskRecurringSchedule?.id) … … 456 450 entryCauseList: entryCauseList, 457 451 entryWorkDoneList: entryWorkDoneList, 458 taskProcedure Instance: taskProcedureInstance,452 taskProcedureRevision: taskProcedureRevision, 459 453 taskProcedureExits: taskProcedureExits, 460 454 showTab: showTab, … … 462 456 subTaskInstanceTotal: subTaskInstanceTotal, 463 457 subTaskInstanceMax: params.max, 464 maintenanceActionList: maintenanceActionList,465 458 taskRecurringScheduleInstance: taskRecurringScheduleInstance, 466 459 taskRecurringScheduleExits: taskRecurringScheduleExits, -
trunk/grails-app/controllers/TaskProcedureDetailedController.groovy
r798 r809 43 43 if(!taskProcedureInstance) { 44 44 flash.errorMessage = "TaskProcedure not found with id ${params.id}" 45 redirect( controller:'taskDetailed', action:'search')45 redirect(action:'list') 46 46 return 47 47 } 48 48 49 redirect(controller:'taskDetailed',50 action:'show',51 id:taskProcedureInstance.linkedTask?.id,52 params:[showTab:"showProcedureTab"])53 }49 def taskProcedureRevision 50 if(params.revision?.toInteger()) 51 taskProcedureRevision = taskProcedureInstance.getRevision( params.revision ) 52 else 53 taskProcedureRevision = taskProcedureInstance.latestRevision 54 54 55 def delete = { 56 def taskProcedureInstance = TaskProcedure.get( params.id ) 57 if(taskProcedureInstance) { 58 def taskInstance = taskProcedureInstance.linkedTask 59 try { 60 taskProcedureInstance.tasks.each { 61 it.taskProcedure = null 62 } 63 taskProcedureInstance.delete(flush:true) 64 flash.message = "TaskProcedure ${params.id} deleted" 65 redirect(controller:'taskDetailed', 66 action:'show', 67 id:taskInstance.id, 68 params:[showTab:"showProcedureTab"]) 69 } 70 catch(org.springframework.dao.DataIntegrityViolationException e) { 71 flash.errorMessage = "TaskProcedure ${params.id} could not be deleted" 72 redirect(controller:'taskDetailed', 73 action:'show', 74 id:taskInstance.id, 75 params:[showTab:"showProcedureTab"]) 76 } 55 if(!taskProcedureRevision) { 56 flash.errorMessage = "TaskProcedure ${params.id} revision ${params.revision} not found" 57 redirect(action:'list') 58 return 77 59 } 78 else { 79 flash.errorMessage = "TaskProcedure not found with id ${params.id}" 80 redirect(action:list) 81 } 60 61 return [taskProcedureRevision: taskProcedureRevision] 62 82 63 } 83 64 … … 85 66 86 67 // In the case of an actionSubmit button, rewrite action name from 'index'. 87 if(params._action_Edit)68 //if(params._action_Edit) 88 69 params.action='edit' 89 70 … … 106 87 if(!result.error) { 107 88 flash.message = g.message(code: "default.update.success", args: ["TaskProcedure", params.id]) 108 redirect(controller:'taskDetailed', 109 action:'show', 110 id:result.taskProcedureInstance.linkedTask.id, 111 params:[showTab:"showProcedureTab"]) 89 redirect(action:'show', id:result.taskProcedureInstance.id) 112 90 return 113 91 } … … 121 99 if(result.error.code == "default.optimistic.locking.failure") { 122 100 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 123 redirect(controller:'taskDetailed', 124 action:'show', 125 id:result.taskProcedureInstance.linkedTask.id, 126 params:[showTab:"showProcedureTab"]) 101 redirect(action:'show', id:result.taskProcedureInstance.id) 127 102 return 128 103 } … … 144 119 145 120 // Task already has a taskProcedure. 146 if(params.linkedTask.taskProcedure ) {121 if(params.linkedTask.taskProcedureRevision) { 147 122 flash.errorMessage = g.message(code: 'default.optimistic.locking.failure') 148 123 redirect(controller:'taskDetailed', … … 183 158 if(!result.error) { 184 159 flash.message = g.message(code: "default.create.success", args: ["TaskProcedure", result.taskProcedureInstance.id]) 185 redirect(controller:'taskDetailed', 186 action:'show', 187 id:result.taskProcedureInstance.linkedTask.id, 188 params:[showTab:"showProcedureTab"]) 160 redirect(action:'show', id:result.taskProcedureInstance.id) 189 161 return 190 162 } 191 163 164 // Task already has a taskProcedure. 192 165 if(result.error.code == "default.optimistic.locking.failure") { 193 166 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 194 167 redirect(controller:'taskDetailed', 195 168 action:'show', 196 id: result.taskProcedureInstance.linkedTask.id,169 id:params.linkedTask.id, 197 170 params:[showTab:"showProcedureTab"]) 198 171 return
Note: See TracChangeset
for help on using the changeset viewer.