Changeset 885 for branches/features


Ignore:
Timestamp:
Apr 14, 2011, 10:57:50 PM (14 years ago)
Author:
gav
Message:

Refactor assetTreeCompact to use includes and controller action instead of direct render call in gsp.

Location:
branches/features/grailsUpgrade/grails-app
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/features/grailsUpgrade/grails-app/controllers/AssetDetailedController.groovy

    r749 r885  
    4242        def s = assetTreeService.buildAssetTree(params, session)
    4343        render s
     44    }
     45
     46    /**
     47    * Build and return the compact asset tree response.
     48    */
     49    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager', 'ROLE_AssetUser'])
     50    def assetTreeCompact = {
     51        def assetInstance = Asset.read(params.id)
     52        if(!assetInstance) {
     53            render g.message(code: 'default.not.found', args: ['Asset',params.id])
     54            return
     55        }
     56
     57        render(template:"/shared/assetTreeCompact", model:['assetInstance':assetInstance])
    4458    }
    4559
  • branches/features/grailsUpgrade/grails-app/views/shared/_assetTreeCompact.gsp

    r798 r885  
    1 
    2 <%--  Fetch to prevent lazy initialization error.  --%>
    3 <% assetInstance = Asset.read(assetInstance?.id)%>
    4 
    51<div class="static_tree">
    6     ${assetInstance?.encodeAsHTML()}
     2    ${assetInstance.encodeAsHTML()}
    73    <div class="static_tree_compact">
    84        <ul>
    9         <g:each var="assetSubItem1" in="${assetInstance?.assetSubItems?.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }">
     5        <g:each var="assetSubItem1" in="${assetInstance.assetSubItems?.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }">
    106            <li>
    11                 ${assetSubItem1?.encodeAsHTML()}
     7                ${assetSubItem1.encodeAsHTML()}
    128            </li>
    139
     
    1713                <g:each var="assetSubItem2" in="${assetSubItem1.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }">
    1814                    <li>
    19                         ${assetSubItem2?.encodeAsHTML()}
     15                        ${assetSubItem2.encodeAsHTML()}
    2016                    </li>
    2117                </g:each> <!--assetSubItem2-->
  • branches/features/grailsUpgrade/grails-app/views/taskProcedureDetailed/_taskProcedure.gsp

    r809 r885  
    2727                <td valign="top" class="name">Linked Asset:</td>
    2828                <td valign="top" class="value">
    29                     <g:render template="/shared/assetTreeCompact" model="['assetInstance': taskProcedureInstance.linkedTask.primaryAsset]" />
     29                    <g:include controller="assetDetailed" action="assetTreeCompact" id="${taskProcedureInstance.linkedTask.primaryAsset.id}" />
    3030                </td>
    3131            </tr>
  • branches/features/grailsUpgrade/grails-app/views/taskProcedureDetailed/_taskProcedureRevision.gsp

    r854 r885  
    2525                        <td valign="top" class="name">Linked Asset:</td>
    2626                        <td valign="top" class="value">
    27                             <g:render template="/shared/assetTreeCompact" model="['assetInstance': taskProcedureRevision.linkedTask.primaryAsset]" />
     27                            <g:include controller="assetDetailed" action="assetTreeCompact" id="${taskProcedureRevision.linkedTask.primaryAsset.id}" />
     28
    2829                        </td>
    2930                    </tr>
Note: See TracChangeset for help on using the changeset viewer.