- Timestamp:
- Feb 16, 2011, 8:10:39 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.