Changeset 955 for trunk


Ignore:
Timestamp:
Jun 29, 2011, 5:07:36 PM (13 years ago)
Author:
gav
Message:

Add filterpane search to Supplier list view.

Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r913 r955  
    33@Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager'])
    44class SupplierDetailedController extends BaseController {
    5    
     5
     6    def filterService
     7
    68    def index = { redirect(action:list,params:params) }
    79
     
    1113    def list = {
    1214        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    13         [ supplierInstanceList: Supplier.list( params ), supplierInstanceTotal: Supplier.count() ]
     15        def associatedPropertyMax = 1000
     16        def associatedPropertyValues = [:]
     17        def supplierTypeNameQuery = 'select distinct a.name from SupplierType a where a.isActive = ? order by a.name'
     18        associatedPropertyValues.supplierTypeList = SupplierType.executeQuery(supplierTypeNameQuery, [true], [max:associatedPropertyMax])
     19
     20        if(!params.filter) {
     21            return [supplierInstanceList: Supplier.list(params),
     22                    supplierInstanceTotal: Supplier.count(),
     23                    associatedPropertyValues: associatedPropertyValues,
     24                    filterParams: params]
     25        }
     26
     27        // filterPane:
     28        return[ supplierInstanceList: filterService.filter( params, Supplier ),
     29                supplierInstanceTotal: filterService.count( params, Supplier ),
     30                associatedPropertyValues: associatedPropertyValues,
     31                filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),
     32                params:params ]
    1433    }
    1534
     
    7190                def version = params.version.toLong()
    7291                if(supplierInstance.version > version) {
    73                    
     92
    7493                    supplierInstance.errors.rejectValue("version", "default.optimistic.locking.failure")
    7594                    render(view:'edit',model:[supplierInstance:supplierInstance])
  • trunk/grails-app/views/supplierDetailed/list.gsp

    r836 r955  
    1 
    2 
    31<html>
    42    <head>
     
    64        <meta name="layout" content="main" />
    75        <title>Supplier List</title>
     6        <filterpane:includes />
    87        <nav:resources override="true"/>
    98    </head>
     
    1312        </div>
    1413        <div class="body">
    15             <g:if test="${flash.message}">
    16             <div class="message">${flash.message}</div>
    17             </g:if>
    18             <div class="list">
    19                 <table>
    20                     <thead>
     14            <g:render template="/shared/messages" />
     15
     16            <filterpane:currentCriteria domainBean="Supplier"
     17                                        action="list"
     18                                        dateFormat="EEE, dd-MMM-yyyy"
     19                                        removeImgDir="images"
     20                                        removeImgFile="bullet_delete.png"
     21                                        title="Search"/>
     22
     23            <div class="paginateButtons">
     24                Results: ${supplierInstanceList.size()} / ${supplierInstanceTotal}
     25                <span class="searchButtons">
     26                    <filterpane:filterButton text="Search" appliedText="Change Search" />
     27                </span>
     28            </div>
     29
     30            <br />
     31
     32            <g:if test="${supplierInstanceList.size() > 0}">
     33
     34                <div class="list">
     35                    <table>
     36                        <thead>
    2137                        <tr>
    22                        
    23                             <g:sortableColumn property="id" title="Id" />
    2438
    25                             <g:sortableColumn property="name" title="Name" />
     39                            <g:sortableColumn property="id" title="Id" params="${filterParams}" />
    2640
    27                             <g:sortableColumn property="description" title="Description" />
     41                            <g:sortableColumn property="name" title="Name" params="${filterParams}" />
    2842
    29                             <g:sortableColumn property="isActive" title="Is Active" />
     43                            <g:sortableColumn property="description" title="Description" params="${filterParams}" />
     44
     45                            <g:sortableColumn property="isActive" title="Is Active" params="${filterParams}" />
    3046
    3147                            <th>Supplier Type</th>
    32                            
     48
    3349                            <th></th>
    34                            
     50
    3551                        </tr>
    36                     </thead>
    37                     <tbody>
    38                     <g:each in="${supplierInstanceList}" status="i" var="supplierInstance">
    39                         <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}">
    40                        
    41                             <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
    42                                 ${fieldValue(bean:supplierInstance, field:'id')}
    43                             </td>
    44                        
    45                             <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
    46                                 ${fieldValue(bean:supplierInstance, field:'name')}
    47                             </td>
    48                        
    49                             <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
    50                                 ${fieldValue(bean:supplierInstance, field:'description')}
    51                             </td>
    52                        
    53                             <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
    54                                 ${fieldValue(bean:supplierInstance, field:'isActive')}
    55                             </td>
    56                        
    57                             <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
    58                                 ${fieldValue(bean:supplierInstance, field:'supplierType')}
    59                             </td>
     52                        </thead>
     53                        <tbody>
     54                        <g:each in="${supplierInstanceList}" status="i" var="supplierInstance">
     55                            <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}">
    6056
    61                             <td class="notClickable">
    62                                 <g:link action="show" id="${supplierInstance.id}">
    63                                     <img  src="${resource(dir:'images/skin',file:'database_go.png')}" alt="Show" />
    64                                 </g:link>
    65                             </td>
    66                        
    67                         </tr>
    68                     </g:each>
    69                     </tbody>
    70                 </table>
     57                                <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
     58                                    ${fieldValue(bean:supplierInstance, field:'id')}
     59                                </td>
     60
     61                                <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
     62                                    ${fieldValue(bean:supplierInstance, field:'name')}
     63                                </td>
     64
     65                                <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
     66                                    ${fieldValue(bean:supplierInstance, field:'description')}
     67                                </td>
     68
     69                                <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
     70                                    ${fieldValue(bean:supplierInstance, field:'isActive')}
     71                                </td>
     72
     73                                <td onclick='window.location = "${request.getContextPath()}/supplierDetailed/show/${supplierInstance.id}"'>
     74                                    ${fieldValue(bean:supplierInstance, field:'supplierType')}
     75                                </td>
     76
     77                                <td class="notClickable">
     78                                    <g:link action="show" id="${supplierInstance.id}">
     79                                        <img  src="${resource(dir:'images/skin',file:'database_go.png')}" alt="Show" />
     80                                    </g:link>
     81                                </td>
     82
     83                            </tr>
     84                        </g:each>
     85                        </tbody>
     86                    </table>
     87                </div>
     88            </g:if>
     89
     90            <div class="paginateButtons">
     91                <g:paginate total="${supplierInstanceTotal}" params="${filterParams}" />
    7192            </div>
    72             <div class="paginateButtons">
    73                 <g:paginate total="${supplierInstanceTotal}" />
    74             </div>
     93
     94            <filterpane:filterPane domainBean="Supplier"
     95                                   title="Search"
     96                                   action="list"
     97                                   class="overlayPane"
     98                                   associatedProperties="supplierType.name"
     99                                   filterPropertyValues="${['supplierType.name':[values: associatedPropertyValues.supplierTypeList]]}" />
     100
    75101        </div>
    76102    </body>
Note: See TracChangeset for help on using the changeset viewer.