Changeset 336


Ignore:
Timestamp:
Feb 9, 2010, 2:54:30 AM (15 years ago)
Author:
gav
Message:

Add search view and detailing to AssetSubItem.

Location:
trunk/grails-app
Files:
1 added
4 edited

Legend:

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

    r298 r336  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2import org.codehaus.groovy.grails.commons.ConfigurationHolder
    23
    34@Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager'])
    45class AssetSubItemDetailedController extends BaseController {
    56
     7    def filterService
     8    def exportService
    69    def assetSubItemService
    710
     
    1114    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager', 'ROLE_AssetUser'])
    1215    def index = { redirect(controller: "assetDetailed", params:params) }
     16
     17    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager', 'ROLE_AssetUser'])
     18    def search = {
     19
     20        if(session.assetSearchParamsMax)
     21            params.max = session.assetSearchParamsMax
     22
     23        params.max = Math.min( params.max ? params.max.toInteger() : 10,  1000)
     24
     25        def assetSubItemInstanceList = []
     26        def assetSubItemInstanceTotal
     27        def filterParams = [:]
     28
     29        // Quick Search:
     30        if(!params.filter) {
     31            assetSubItemInstanceList = AssetSubItem.list( params )
     32            assetSubItemInstanceTotal = AssetSubItem.count()
     33            filterParams.quickSearch = params.quickSearch
     34        }
     35        else {
     36        // filterPane:
     37            assetSubItemInstanceList = filterService.filter( params, AssetSubItem )
     38            assetSubItemInstanceTotal = filterService.count( params, AssetSubItem )
     39            filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params)
     40        }
     41
     42        // export plugin:
     43        if(params?.format && params.format != "html") {
     44
     45            def dateFmt = { date ->
     46                formatDate(format: "EEE, dd-MMM-yyyy", date: date)
     47            }
     48
     49            String title = "AssetSubItem List."
     50
     51            response.contentType = ConfigurationHolder.config.grails.mime.types[params.format]
     52            response.setHeader("Content-disposition", "attachment; filename=assets.${params.extension}")
     53            List fields = ["name",
     54                                "description"]
     55            Map labels = ["name": "AssetSubItem",
     56                                "description": "Description"]
     57
     58            Map formatters = [:]
     59            Map parameters = [title: title, separator: ","]
     60
     61            exportService.export(params.format,
     62                                                response.outputStream,
     63                                                assetSubItemInstanceList.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) },
     64                                                fields,
     65                                                labels,
     66                                                formatters,
     67                                                parameters)
     68        }
     69
     70        // Add some basic params to filterParams.
     71        filterParams.max = params.max
     72        filterParams.offset = params.offset?.toInteger() ?: 0
     73        filterParams.sort = params.sort ?: "id"
     74        filterParams.order = params.order ?: "desc"
     75
     76        return[ assetSubItemInstanceList: assetSubItemInstanceList,
     77                assetSubItemInstanceTotal: assetSubItemInstanceTotal,
     78                filterParams: filterParams ]
     79
     80    } // end search()
    1381
    1482    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager', 'ROLE_AssetUser'])
  • trunk/grails-app/views/assetSubItemDetailed/create.gsp

    r330 r336  
    99    <body>
    1010        <div class="nav">
    11             <h1>Create Sub Item</h1>
     11            <span class="menuButton"><g:link class="list" action="search">Sub Item Search</g:link></span>
    1212        </div>
    1313        <div class="body">
     14            <h1>Create Sub Item</h1>
    1415            <g:render template="/shared/messages" />
    1516            <g:hasErrors bean="${assetSubItemInstance}">
  • trunk/grails-app/views/assetSubItemDetailed/edit.gsp

    r330 r336  
    99    <body>
    1010        <div class="nav">
    11             <h1>Edit Sub Item</h1>
     11            <span class="menuButton"><g:link class="list" action="search">Sub Item Search</g:link></span>
    1212        </div>
    1313        <div class="body">
     14            <h1>Edit Sub Item</h1>
    1415            <g:render template="/shared/messages" />
    1516            <g:hasErrors bean="${assetSubItemInstance}">
  • trunk/grails-app/views/assetSubItemDetailed/show.gsp

    r330 r336  
    99    <body>
    1010        <div class="nav">
    11             <h1>Show Sub Item</h1>
     11            <span class="menuButton"><g:link class="list" action="search">Sub Item Search</g:link></span>
     12            <span class="menuButton"><g:link class="create" action="create">New Sub Item</g:link></span>
    1213        </div>
    1314        <div class="body">
     15            <h1>Show Sub Item</h1>
    1416            <g:render template="/shared/messages" />
    1517            <div class="dialog">
Note: See TracChangeset for help on using the changeset viewer.