Index: trunk/grails-app/controllers/EntryDetailedController.groovy =================================================================== --- trunk/grails-app/controllers/EntryDetailedController.groovy (revision 837) +++ trunk/grails-app/controllers/EntryDetailedController.groovy (revision 838) @@ -67,4 +67,5 @@ } + /// @todo: Refactor to taskService and include moving task to "In Progress" when Entry.duration is updated. def update = { def entryInstance = Entry.get( params.id ) @@ -74,4 +75,15 @@ entryInstance.properties = params if(!entryInstance.hasErrors() && entryInstance.save(flush: true)) { + // If PM Entry update task.highestSeverity + if(entryInstance.entryType.id == 6) { + def clist = [] + entryInstance.task.entries.each { entry -> + if(entry.entryType.id == 6) + clist << entry.highestSeverity + } + + if(clist) + entryInstance.task.highestSeverity = clist.sort{p1,p2 -> p2.id <=> p1.id}[0] + } flash.message = "Entry ${params.id} updated" redirect(action:show,id:entryInstance.id) Index: trunk/grails-app/controllers/TaskDetailedController.groovy =================================================================== --- trunk/grails-app/controllers/TaskDetailedController.groovy (revision 837) +++ trunk/grails-app/controllers/TaskDetailedController.groovy (revision 838) @@ -185,4 +185,6 @@ associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) + def highestSeverityCodeQuery = 'select distinct cs.code from ConditionSeverity cs where cs.isActive = ? order by cs.code' + associatedPropertyValues.highestSeverityList = ConditionSeverity.executeQuery(highestSeverityCodeQuery, [true], [max:associatedPropertyMax]) associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) @@ -342,4 +344,6 @@ associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) + def highestSeverityCodeQuery = 'select distinct cs.code from ConditionSeverity cs where cs.isActive = ? order by cs.code' + associatedPropertyValues.highestSeverityList = ConditionSeverity.executeQuery(highestSeverityCodeQuery, [true], [max:associatedPropertyMax]) associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) Index: trunk/grails-app/services/TaskService.groovy =================================================================== --- trunk/grails-app/services/TaskService.groovy (revision 837) +++ trunk/grails-app/services/TaskService.groovy (revision 838) @@ -353,7 +353,10 @@ return fail(code:"default.create.failure") - // If task status is "Not Started" and entry type is "Work Done" and time has been booked. + // If task status is "Not Started" + // and entry type is "Work Done" or "PM Entry" + // and time has been booked. // Then we create the started modification and set task status. - if(taskInstance.taskStatus.id == 1 && result.entryInstance.entryType.id == 3 + if(taskInstance.taskStatus.id == 1 + && (result.entryInstance.entryType.id == 3 || result.entryInstance.entryType.id == 6) && (result.entryInstance.durationHour + result.entryInstance.durationMinute > 0)) { @@ -368,8 +371,20 @@ // Set task status to "In Progress". taskInstance.taskStatus = TaskStatus.read(2) - - if(taskInstance.hasErrors() || !taskInstance.save()) - return fail(field:"task", code:"task.failedToSave") - } + } + + // If PM Entry update task.highestSeverity + if(result.entryInstance.entryType.id == 6) { + def clist = [] + taskInstance.entries.each { entry -> + if(entry.entryType.id == 6) + clist << entry.highestSeverity + } + + if(clist) + taskInstance.highestSeverity = clist.sort{p1,p2 -> p2.id <=> p1.id}[0] + } + + if(taskInstance.hasErrors() || !taskInstance.save()) + return fail(field:"task", code:"task.failedToSave") // Success. Index: trunk/grails-app/views/entryDetailed/_create.gsp =================================================================== --- trunk/grails-app/views/entryDetailed/_create.gsp (revision 837) +++ trunk/grails-app/views/entryDetailed/_create.gsp (revision 838) @@ -16,4 +16,38 @@
+ + | +
+ |
+ ||||||||||||||||
+ + | +
+ |
+ ||||||||||||||||
- - | -
- |
- ||||||||||||||||
+ + | +Comment | Date Done | @@ -28,4 +35,10 @@|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ ${entry.highestSeverity.code.encodeAsHTML()} + | +Index: trunk/grails-app/views/entryDetailed/edit.gsp =================================================================== --- trunk/grails-app/views/entryDetailed/edit.gsp (revision 837) +++ trunk/grails-app/views/entryDetailed/edit.gsp (revision 838) @@ -37,4 +37,38 @@ | ||||||||||||||||
+ + | +
+ |
+ ||||||||||||||||
+ + | +
+ |
+ ||||||||||||||||
- - | -
- |
- ||||||||||||||||
Production: | + ++ ${fieldValue(bean:entryInstance, field:'productionReference')} + | + +||||||||||||||||
Condition Severity: | + ++ ${fieldValue(bean:entryInstance, field:'highestSeverity')} + | + +||||||||||||||||
Production: | - -- ${fieldValue(bean:entryInstance, field:'productionReference')} - | - -||||||||||||||||
+ |
@@ -237,5 +249,5 @@
leadPerson.firstName,
taskGroup.name,
- associatedAssets.name,
+ highestSeverity.code,
primaryAsset.name,
taskStatus.name,
@@ -245,5 +257,5 @@
'leadPerson.firstName':[values: associatedPropertyValues.firstNameList],
'taskGroup.name':[values: associatedPropertyValues.taskGroupList],
- 'associatedAssets.name':[values: associatedPropertyValues.assetList],
+ 'highestSeverity.code':[values: associatedPropertyValues.highestSeverityList],
'primaryAsset.name':[values: associatedPropertyValues.assetList],
'taskStatus.name':[values: associatedPropertyValues.taskStatusList],
Index: trunk/grails-app/views/taskDetailed/searchCalendar.gsp
===================================================================
--- trunk/grails-app/views/taskDetailed/searchCalendar.gsp (revision 837)
+++ trunk/grails-app/views/taskDetailed/searchCalendar.gsp (revision 838)
@@ -122,5 +122,5 @@
leadPerson.firstName,
taskGroup.name,
- associatedAssets.name,
+ highestSeverity.code,
primaryAsset.name,
taskStatus.name,
@@ -130,6 +130,6 @@
'leadPerson.firstName':[values: associatedPropertyValues.firstNameList],
'taskGroup.name':[values: associatedPropertyValues.taskGroupList],
- 'associatedAssets.name':[values: associatedPropertyValues.assetList],
'primaryAsset.name':[values: associatedPropertyValues.assetList],
+ 'highestSeverity.code':[values: associatedPropertyValues.highestSeverityList],
'taskStatus.name':[values: associatedPropertyValues.taskStatusList],
'taskType.name':[values: associatedPropertyValues.taskTypeList],