Ignore:
Timestamp:
Feb 4, 2011, 2:11:45 AM (9 years ago)
Author:
gav
Message:

TaskProcedure? improvements, filter assemblies, pre populate a maintenanceAction for each assembly at creation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/features/taskProcedureRework/grails-app/controllers/TaskProcedureDetailedController.groovy

    r775 r776  
    55
    66    def filterService
     7    def assetService
    78    def taskProcedureService
    89
     
    9495        }
    9596        else {
    96             return [ taskProcedureInstance : taskProcedureInstance ]
     97            def assemblies = assetService.getAssemblies(taskProcedureInstance.linkedTask.primaryAsset)
     98            return [ taskProcedureInstance : taskProcedureInstance,
     99                            assemblies: assemblies ]
    97100        }
    98101    }
     
    125128        }
    126129
    127         render(view:'edit', model:[taskProcedureInstance: result.taskProcedureInstance])
     130        def assemblies = assetService.getAssemblies(result.taskProcedureInstance.linkedTask.primaryAsset)
     131        render(view:'edit', model:[taskProcedureInstance: result.taskProcedureInstance,
     132                                                assemblies: assemblies])
    128133    }
    129134
     
    157162        def taskProcedureInstance = new TaskProcedure()
    158163        taskProcedureInstance.properties = params
    159         return ['taskProcedureInstance':taskProcedureInstance]
     164
     165        // Populate a maintenanceAction for each assembly.
     166        def assemblies = assetService.getAssemblies(params.linkedTask.primaryAsset)
     167        assemblies.eachWithIndex { assembly, i ->
     168            def ma = taskProcedureInstance.maintenanceActionLazyList.get(i)
     169            ma.assetSubItem = assembly
     170            ma.procedureStepNumber = (i+1)*10
     171        }
     172
     173        return ['taskProcedureInstance':taskProcedureInstance, 'assemblies': assemblies]
    160174    }
    161175
     
    181195        }
    182196
    183         render(view:'create', model:[taskProcedureInstance: result.taskProcedureInstance])
     197        def assemblies = assetService.getAssemblies(result.taskProcedureInstance.linkedTask.primaryAsset)
     198        render(view:'create', model:[taskProcedureInstance: result.taskProcedureInstance,
     199                                                    assemblies: assemblies])
    184200    }
    185201
Note: See TracChangeset for help on using the changeset viewer.