Ignore:
Timestamp:
May 8, 2009, 11:51:25 PM (15 years ago)
Author:
gav
Message:

Work on Detail views for Task, TaskProcedure? and MaintenanceAction?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r131 r133  
    2020    }
    2121
     22//     def show = {
     23//         def taskInstance = Task.get( params.id )
     24//
     25//         if(!taskInstance) {
     26//             flash.message = "Task not found with id ${params.id}"
     27//             redirect(action:list)
     28//         }
     29//         else {
     30//             def taskProcedureInstance = TaskProcedure.get(taskInstance?.taskProcedure?.id)
     31//             return [ taskInstance : taskInstance,  taskProcedureInstance: taskProcedureInstance]
     32//
     33//         }
     34//     }
     35
    2236    def show = {
    2337        def taskInstance = Task.get( params.id )
     
    2741            redirect(action:list)
    2842        }
    29         else {
    30             def taskProcedureInstance = TaskProcedure.get(taskInstance?.taskProcedure?.id)
    31             return [ taskInstance : taskInstance,  taskProcedureInstance: taskProcedureInstance]
     43        else {
     44            def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id)
     45            def taskProcedureExits = new Boolean("true")
     46            def showTaskTab = new String("true")
    3247
     48            if(!taskProcedureInstance) {
     49                taskProcedureExits = false
     50            }
     51            return [ taskInstance : taskInstance,
     52                            taskProcedureInstance: taskProcedureInstance,
     53                            taskProcedureExits: taskProcedureExits,
     54                            showTaskTab: showTaskTab]
    3355        }
    3456    }
     
    114136        }
    115137    }
     138
     139    //Generate a new TaskProcedure for a taskInstance.
     140    def generateProcedure = {
     141        def taskProcedureInstance = new TaskProcedure()
     142        taskProcedureInstance.properties = params
     143
     144        def taskInstance = Task.get(params.taskInstance.id)
     145        def taskProcedureExits = new Boolean("true")
     146        def showProcedureTab = new String("true")
     147
     148        if(!taskProcedureInstance.hasErrors() && taskProcedureInstance.save()) {
     149            taskProcedureInstance.addToTasks(taskInstance)
     150            flash.message = "Procedure created, you can now add steps to the procedure"
     151//             redirect(action:show, id:params.taskInstance.id)
     152        }
     153        else {
     154            taskProcedureExits = false
     155        }
     156
     157        render(view:'show',model:[ taskInstance : taskInstance, 
     158                                                        taskProcedureInstance: taskProcedureInstance,
     159                                                        taskProcedureExits: taskProcedureExits,
     160                                                        showProcedureTab: showProcedureTab])
     161    }
     162
     163    def findProcedure = {
     164        redirect(controller:"taskProcedureDetailed", action:"list", id:params.taskInstance.id)
     165    }
     166       
    116167}
Note: See TracChangeset for help on using the changeset viewer.