Index: trunk/grails-app/controllers/TaskProcedureDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/TaskProcedureDetailedController.groovy	(revision 798)
+++ trunk/grails-app/controllers/TaskProcedureDetailedController.groovy	(revision 809)
@@ -43,41 +43,22 @@
         if(!taskProcedureInstance) {
             flash.errorMessage = "TaskProcedure not found with id ${params.id}"
-            redirect(controller:'taskDetailed', action:'search')
+            redirect(action:'list')
             return
         }
 
-        redirect(controller:'taskDetailed',
-                        action:'show',
-                        id:taskProcedureInstance.linkedTask?.id,
-                        params:[showTab:"showProcedureTab"])
-    }
+        def taskProcedureRevision
+        if(params.revision?.toInteger())
+             taskProcedureRevision = taskProcedureInstance.getRevision( params.revision )
+        else
+             taskProcedureRevision = taskProcedureInstance.latestRevision
 
-    def delete = {
-        def taskProcedureInstance = TaskProcedure.get( params.id )
-        if(taskProcedureInstance) {
-            def taskInstance = taskProcedureInstance.linkedTask
-            try {
-                taskProcedureInstance.tasks.each {
-                    it.taskProcedure = null
-                }
-                taskProcedureInstance.delete(flush:true)
-                flash.message = "TaskProcedure ${params.id} deleted"
-                redirect(controller:'taskDetailed',
-                                action:'show',
-                                id:taskInstance.id,
-                                params:[showTab:"showProcedureTab"])
-            }
-            catch(org.springframework.dao.DataIntegrityViolationException e) {
-                flash.errorMessage = "TaskProcedure ${params.id} could not be deleted"
-                redirect(controller:'taskDetailed',
-                                action:'show',
-                                id:taskInstance.id,
-                                params:[showTab:"showProcedureTab"])
-            }
+        if(!taskProcedureRevision) {
+            flash.errorMessage = "TaskProcedure ${params.id} revision ${params.revision} not found"
+            redirect(action:'list')
+            return
         }
-        else {
-            flash.errorMessage = "TaskProcedure not found with id ${params.id}"
-            redirect(action:list)
-        }
+
+        return [taskProcedureRevision: taskProcedureRevision]
+
     }
 
@@ -85,5 +66,5 @@
 
         // In the case of an actionSubmit button, rewrite action name from 'index'.
-        if(params._action_Edit)
+        //if(params._action_Edit)
             params.action='edit'
 
@@ -106,8 +87,5 @@
         if(!result.error) {
             flash.message = g.message(code: "default.update.success", args: ["TaskProcedure", params.id])
-            redirect(controller:'taskDetailed',
-                            action:'show',
-                            id:result.taskProcedureInstance.linkedTask.id,
-                            params:[showTab:"showProcedureTab"])
+            redirect(action:'show', id:result.taskProcedureInstance.id)
             return
         }
@@ -121,8 +99,5 @@
         if(result.error.code == "default.optimistic.locking.failure") {
             flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
-            redirect(controller:'taskDetailed',
-                            action:'show',
-                            id:result.taskProcedureInstance.linkedTask.id,
-                            params:[showTab:"showProcedureTab"])
+            redirect(action:'show', id:result.taskProcedureInstance.id)
             return
         }
@@ -144,5 +119,5 @@
 
         // Task already has a taskProcedure.
-        if(params.linkedTask.taskProcedure) {
+        if(params.linkedTask.taskProcedureRevision) {
             flash.errorMessage = g.message(code: 'default.optimistic.locking.failure')
             redirect(controller:'taskDetailed',
@@ -183,16 +158,14 @@
         if(!result.error) {
             flash.message = g.message(code: "default.create.success", args: ["TaskProcedure", result.taskProcedureInstance.id])
-            redirect(controller:'taskDetailed',
-                            action:'show',
-                            id:result.taskProcedureInstance.linkedTask.id,
-                            params:[showTab:"showProcedureTab"])
+            redirect(action:'show', id:result.taskProcedureInstance.id)
             return
         }
 
+        // Task already has a taskProcedure.
         if(result.error.code == "default.optimistic.locking.failure") {
             flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
             redirect(controller:'taskDetailed',
                             action:'show',
-                            id:result.taskProcedureInstance.linkedTask.id,
+                            id:params.linkedTask.id,
                             params:[showTab:"showProcedureTab"])
             return
