Changeset 838


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.

Location:
trunk
Files:
1 added
9 edited

Legend:

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

    r833 r838  
    6767    }
    6868
     69    /// @todo: Refactor to taskService and include moving task to "In Progress" when Entry.duration is updated.
    6970    def update = {
    7071        def entryInstance = Entry.get( params.id )
     
    7475                entryInstance.properties = params
    7576                if(!entryInstance.hasErrors() && entryInstance.save(flush: true)) {
     77                    // If PM Entry update task.highestSeverity
     78                    if(entryInstance.entryType.id == 6) {
     79                        def clist = []
     80                        entryInstance.task.entries.each { entry ->
     81                            if(entry.entryType.id == 6)
     82                                clist << entry.highestSeverity
     83                        }
     84
     85                        if(clist)
     86                            entryInstance.task.highestSeverity = clist.sort{p1,p2 -> p2.id <=> p1.id}[0]
     87                    }
    7688                    flash.message = "Entry ${params.id} updated"
    7789                    redirect(action:show,id:entryInstance.id)
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r833 r838  
    185185        associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
    186186        associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     187        def highestSeverityCodeQuery = 'select distinct cs.code from ConditionSeverity cs where cs.isActive = ? order by cs.code'
     188        associatedPropertyValues.highestSeverityList = ConditionSeverity.executeQuery(highestSeverityCodeQuery, [true], [max:associatedPropertyMax])
    187189        associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
    188190        associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     
    342344        associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
    343345        associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     346        def highestSeverityCodeQuery = 'select distinct cs.code from ConditionSeverity cs where cs.isActive = ? order by cs.code'
     347        associatedPropertyValues.highestSeverityList = ConditionSeverity.executeQuery(highestSeverityCodeQuery, [true], [max:associatedPropertyMax])
    344348        associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
    345349        associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
  • 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.
  • trunk/grails-app/views/entryDetailed/_create.gsp

    r833 r838  
    1616            <table>
    1717                <tbody>
     18
     19                    <g:if test="${entryInstance?.entryType?.id == 1}">
     20                        <tr class="prop">
     21                            <td valign="top" class="name">
     22                                <label for="productionReference">Production:</label>
     23                            </td>
     24                            <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'productionReference','errors')}">
     25                                <g:select optionKey="id"
     26                                                    from="${ProductionReference.findAllByIsActive(true)}"
     27                                                    name="productionReference.id"
     28                                                    value="${entryInstance.productionReference?.id}"
     29                                                    noSelection="['null':'--None--']">
     30                                </g:select>
     31                                <custom:helpBalloon code="entry.productionReference.fault" iconSrc="${resource(plugin:'help-balloons', dir:'images', file:'balloon-icon.gif')}" />
     32                            </td>
     33                        </tr>
     34                    </g:if>
     35
     36                    <g:if test="${entryInstance?.entryType?.id == 6}">
     37                        <tr class="prop">
     38                            <td valign="top" class="name">
     39                                <label for="highestSeverity">Condition Severity:</label>
     40                            </td>
     41                            <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'highestSeverity','errors')}">
     42                                <g:select optionKey="id"
     43                                                    from="${ConditionSeverity.findAllByIsActive(true)}"
     44                                                    name="highestSeverity.id"
     45                                                    value="${entryInstance.highestSeverity?.id}"
     46                                                    noSelection="['null':/${g.message(code:'default.please.select.text')}/]" >
     47                                </g:select>
     48                                <custom:helpBalloon code="entry.comment.pm.entry" iconSrc="${resource(plugin:'help-balloons', dir:'images', file:'balloon-icon.gif')}" />
     49                            </td>
     50                        </tr>
     51                    </g:if>
    1852
    1953                    <tr class="prop">
     
    4882                    </tr>
    4983
    50                     <g:if test="${entryInstance?.entryType?.id == 1}">
    51                         <tr class="prop">
    52                             <td valign="top" class="name">
    53                                 <label for="productionReference">Production:</label>
    54                             </td>
    55                             <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'productionReference','errors')}">
    56                                 <g:select optionKey="id"
    57                                                     from="${ProductionReference.findAllByIsActive(true)}"
    58                                                     name="productionReference.id"
    59                                                     value="${entryInstance.productionReference?.id}"
    60                                                     noSelection="['null':'--None--']">
    61                                 </g:select>
    62                                 <custom:helpBalloon code="entry.productionReference.fault" iconSrc="${resource(plugin:'help-balloons', dir:'images', file:'balloon-icon.gif')}" />
    63                             </td>
    64                         </tr>
    65                     </g:if>
    66 
    6784                    <g:if test="${entryInstance?.entryType?.id != 2}">
    6885                        <tr class="prop">
  • trunk/grails-app/views/entryDetailed/_list.gsp

    r834 r838  
    1818                <thead>
    1919                    <tr>
     20                        <g:if test="${entryList[0]?.entryType?.id == 6}">
     21                            <th>
     22                                <img src="${resource(dir:'images/skin',file:'award_star_silver_3.png')}"
     23                                        alt="Severity"
     24                                        title="Highest Severity"  />
     25                            </th>
     26                        </g:if>
    2027                        <th>Comment</th>
    2128                        <th>Date Done</th>
     
    2835                    <g:each in="${entryList}" status="i" var="entry">
    2936                            <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}">
     37
     38                                <g:if test="${entryList[0]?.entryType?.id == 6}">
     39                                    <td onclick='window.location = "${request.getContextPath()}/entryDetailed/edit/${entry.id}"'>
     40                                        ${entry.highestSeverity.code.encodeAsHTML()}
     41                                    </td>
     42                                </g:if>
    3043
    3144                                <td width="65%" onclick='window.location = "${request.getContextPath()}/entryDetailed/edit/${entry.id}"'>
  • trunk/grails-app/views/entryDetailed/edit.gsp

    r432 r838  
    3737                                </td>
    3838                            </tr>
     39
     40                            <g:if test="${entryInstance?.entryType?.id == 1}">
     41                                <tr class="prop">
     42                                    <td valign="top" class="name">
     43                                        <label for="productionReference">Production:</label>
     44                                    </td>
     45                                    <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'productionReference','errors')}">
     46                                        <g:select optionKey="id"
     47                                                            from="${ProductionReference.findAllByIsActive(true)}"
     48                                                            name="productionReference.id"
     49                                                            value="${entryInstance.productionReference?.id}"
     50                                                            noSelection="['null':'--None--']">
     51                                        </g:select>
     52                                        <g:helpBalloon code="entry.productionReference.fault" />
     53                                    </td>
     54                                </tr>
     55                            </g:if>
     56
     57                            <g:if test="${entryInstance?.entryType?.id == 6}">
     58                                <tr class="prop">
     59                                    <td valign="top" class="name">
     60                                        <label for="highestSeverity">Condition Severity:</label>
     61                                    </td>
     62                                    <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'highestSeverity','errors')}">
     63                                        <g:select optionKey="id"
     64                                                            from="${ConditionSeverity.findAllByIsActive(true)}"
     65                                                            name="highestSeverity.id"
     66                                                            value="${entryInstance.highestSeverity?.id}"
     67                                                            noSelection="['null':/${g.message(code:'default.please.select.text')}/]" >
     68                                        </g:select>
     69                                        <custom:helpBalloon code="entry.comment.pm.entry" iconSrc="${resource(plugin:'help-balloons', dir:'images', file:'balloon-icon.gif')}" />
     70                                    </td>
     71                                </tr>
     72                            </g:if>
    3973                       
    4074                            <tr class="prop">
     
    5589                                </td>
    5690                            </tr>
    57 
    58                             <g:if test="${entryInstance?.entryType?.id == 1}">
    59                                 <tr class="prop">
    60                                     <td valign="top" class="name">
    61                                         <label for="productionReference">Production:</label>
    62                                     </td>
    63                                     <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'productionReference','errors')}">
    64                                         <g:select optionKey="id"
    65                                                             from="${ProductionReference.findAllByIsActive(true)}"
    66                                                             name="productionReference.id"
    67                                                             value="${entryInstance.productionReference?.id}"
    68                                                             noSelection="['null':'--None--']">
    69                                         </g:select>
    70                                         <g:helpBalloon code="entry.productionReference.fault" />
    71                                     </td>
    72                                 </tr>
    73                             </g:if>
    7491
    7592                            <g:if test="${entryInstance?.entryType?.id != 2}">
  • trunk/grails-app/views/entryDetailed/show.gsp

    r431 r838  
    3333                           
    3434                        </tr>
     35
     36                        <g:if test="${entryInstance.productionReference}">
     37                            <tr class="prop">
     38                                <td valign="top" class="name">Production:</td>
     39
     40                                <td valign="top" class="value">
     41                                    ${fieldValue(bean:entryInstance, field:'productionReference')}
     42                                </td>
     43
     44                            </tr>
     45                        </g:if>
     46
     47                        <g:if test="${entryInstance.highestSeverity}">
     48                            <tr class="prop">
     49                                <td valign="top" class="name">Condition Severity:</td>
     50
     51                                <td valign="top" class="value">
     52                                    ${fieldValue(bean:entryInstance, field:'highestSeverity')}
     53                                </td>
     54
     55                            </tr>
     56                        </g:if>
    3557                   
    3658                        <tr class="prop">
     
    4971                           
    5072                        </tr>
    51 
    52                         <g:if test="${entryInstance.productionReference}">
    53                             <tr class="prop">
    54                                 <td valign="top" class="name">Production:</td>
    55 
    56                                 <td valign="top" class="value">
    57                                     ${fieldValue(bean:entryInstance, field:'productionReference')}
    58                                 </td>
    59 
    60                             </tr>
    61                         </g:if>
    6273                   
    6374                        <tr class="prop">
  • trunk/grails-app/views/taskDetailed/search.gsp

    r836 r838  
    9393                                                                                                params="${filterParams}" />
    9494
     95                                <custom:sortableColumnWithImg property="highestSeverity"
     96                                                                                                imgSrc="${resource(dir:'images/skin',file:'award_star_silver_3.png')}"
     97                                                                                                imgAlt="Severity"
     98                                                                                                imgTitle="Highest Severity"
     99                                                                                                params="${filterParams}" />
     100
    95101                                <g:sortableColumn property="targetStartDate" title="Target Start Date" params="${filterParams}" />
    96102
     
    125131                                    <g:if test="${taskInstance.attentionFlag}">
    126132                                        <img  src="${resource(dir:'images/skin',file:'flag_red.png')}" alt="Flag" title="Attention Flag"/>
     133                                    </g:if>
     134                                </td>
     135
     136                                <td class="idColumn" onclick='window.location = "${request.getContextPath()}/taskDetailed/show/${taskInstance.id}"'>
     137                                    <g:if test="${taskInstance.highestSeverity}">
     138                                        ${taskInstance.highestSeverity.code.encodeAsHTML()}
    127139                                    </g:if>
    128140                                </td>
     
    237249                                                                                leadPerson.firstName,
    238250                                                                                taskGroup.name,
    239                                                                                 associatedAssets.name,
     251                                                                                highestSeverity.code,
    240252                                                                                primaryAsset.name,
    241253                                                                                taskStatus.name,
     
    245257                                                                                'leadPerson.firstName':[values: associatedPropertyValues.firstNameList],
    246258                                                                                'taskGroup.name':[values: associatedPropertyValues.taskGroupList],
    247                                                                                 'associatedAssets.name':[values: associatedPropertyValues.assetList],
     259                                                                                'highestSeverity.code':[values: associatedPropertyValues.highestSeverityList],
    248260                                                                                'primaryAsset.name':[values: associatedPropertyValues.assetList],
    249261                                                                                'taskStatus.name':[values: associatedPropertyValues.taskStatusList],
  • trunk/grails-app/views/taskDetailed/searchCalendar.gsp

    r713 r838  
    122122                                                                                leadPerson.firstName,
    123123                                                                                taskGroup.name,
    124                                                                                 associatedAssets.name,
     124                                                                                highestSeverity.code,
    125125                                                                                primaryAsset.name,
    126126                                                                                taskStatus.name,
     
    130130                                                                                'leadPerson.firstName':[values: associatedPropertyValues.firstNameList],
    131131                                                                                'taskGroup.name':[values: associatedPropertyValues.taskGroupList],
    132                                                                                 'associatedAssets.name':[values: associatedPropertyValues.assetList],
    133132                                                                                'primaryAsset.name':[values: associatedPropertyValues.assetList],
     133                                                                                'highestSeverity.code':[values: associatedPropertyValues.highestSeverityList],
    134134                                                                                'taskStatus.name':[values: associatedPropertyValues.taskStatusList],
    135135                                                                                'taskType.name':[values: associatedPropertyValues.taskTypeList],
Note: See TracChangeset for help on using the changeset viewer.