Ignore:
Timestamp:
Mar 3, 2011, 11:17:40 PM (13 years ago)
Author:
gav
Message:

Update service, controller and view logic to hand Task and Entry highestSeverity.
Also remove associatedAssets from task search panes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/TaskService.groovy

    r832 r838  
    353353                return fail(code:"default.create.failure")
    354354
    355             // If task status is "Not Started" and entry type is "Work Done" and time has been booked.
     355            // If task status is "Not Started"
     356            // and entry type is "Work Done" or "PM Entry"
     357            // and time has been booked.
    356358            // Then we create the started modification and set task status.
    357             if(taskInstance.taskStatus.id == 1 && result.entryInstance.entryType.id == 3
     359            if(taskInstance.taskStatus.id == 1
     360                && (result.entryInstance.entryType.id == 3 || result.entryInstance.entryType.id == 6)
    358361                && (result.entryInstance.durationHour + result.entryInstance.durationMinute > 0)) {
    359362
     
    368371                // Set task status to "In Progress".
    369372                taskInstance.taskStatus = TaskStatus.read(2)
    370 
    371                 if(taskInstance.hasErrors() || !taskInstance.save())
    372                     return fail(field:"task", code:"task.failedToSave")
    373             }
     373            }
     374
     375            // If PM Entry update task.highestSeverity
     376            if(result.entryInstance.entryType.id == 6) {
     377                def clist = []
     378                taskInstance.entries.each { entry ->
     379                    if(entry.entryType.id == 6)
     380                        clist << entry.highestSeverity
     381                }
     382
     383                if(clist)
     384                    taskInstance.highestSeverity = clist.sort{p1,p2 -> p2.id <=> p1.id}[0]
     385            }
     386
     387            if(taskInstance.hasErrors() || !taskInstance.save())
     388                return fail(field:"task", code:"task.failedToSave")
    374389
    375390            // Success.
Note: See TracChangeset for help on using the changeset viewer.