Changeset 566


Ignore:
Timestamp:
Jun 3, 2010, 4:31:44 AM (14 years ago)
Author:
gav
Message:

Improvements to inventory text search, add inventoryGroup and hide Limit Search unless one of the values is true.

Location:
trunk/grails-app
Files:
5 edited

Legend:

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

    r562 r566  
    148148                params.searchComment = session.inventoryItemSearchComment
    149149                params.searchLocation = session.inventoryItemSearchLocation
     150                params.searchGroup = session.inventoryItemSearchGroup
    150151                params.searchSpareFor = session.inventoryItemSearchSpareFor
    151152            }
     
    186187            session.removeAttribute("inventoryItemSearchComment")
    187188            session.removeAttribute("inventoryItemSearchLocation")
     189            session.removeAttribute("inventoryItemSearchGroup")
    188190            session.removeAttribute("inventoryItemSearchSpareFor")
    189191            session.removeAttribute("inventoryItemQuickSearch")
     
    203205            session.inventoryItemSearchComment = params.searchComment
    204206            session.inventoryItemSearchLocation = params.searchLocation
     207            session.inventoryItemSearchGroup = params.searchGroup
    205208            session.inventoryItemSearchSpareFor = params.searchSpareFor
    206209            // Clear any previous search.
     
    228231            session.removeAttribute("inventoryItemSearchComment")
    229232            session.removeAttribute("inventoryItemSearchLocation")
     233            session.removeAttribute("inventoryItemSearchGroup")
    230234            session.removeAttribute("inventoryItemSearchSpareFor")
    231235            session.removeAttribute("inventoryItemSearchFilterParams")
  • trunk/grails-app/domain/InventoryGroup.groovy

    r116 r566  
    1212
    1313    String toString() {"${this.name}"}
     14
     15    static searchable = {
     16        root false // only index as a component of InventoryItem.
     17        only = ['name']
     18    }
     19
    1420}
  • trunk/grails-app/domain/InventoryItem.groovy

    r562 r566  
    6262
    6363    static searchable = {
    64         only = ['name', 'description', 'comment', 'inventoryLocation', 'spareFor']
     64        only = ['name', 'description', 'comment', 'isActive', 'isObsolete', 'inventoryLocation', 'inventoryGroup', 'spareFor']
    6565        //name boost: 1.5
    6666        inventoryLocation component: true
     67        inventoryGroup component: true
    6768        spareFor component: true
    6869    }
  • trunk/grails-app/services/InventoryItemSearchService.groovy

    r562 r566  
    159159        // Build searchableParams.
    160160        // Do not include params.sort, since not all properites are indexed.
    161         def searchableParams = [max: params.max, offset: params.offset,
    162                                                     reload: true, defaultOperator: 'or']
     161        def searchableParams = [:]
     162        searchableParams.max = params.max
     163        searchableParams.offset = params.offset
     164        searchableParams.reload = true
     165        searchableParams.defaultOperator =  'or'
     166        def properitesList = []
     167        if(params.searchName)
     168            properitesList << '$/InventoryItem/name'
     169        if(params.searchDescription)
     170            properitesList << '$/InventoryItem/description'
     171        if(params.searchComment)
     172            properitesList << '$/InventoryItem/comment'
     173        if(params.searchLocation)
     174            properitesList << '$/InventoryItem/inventoryLocation/name'
     175        if(params.searchGroup)
     176            properitesList << '$/InventoryItem/inventoryGroup/name'
     177        if(params.searchSpareFor) {
     178            properitesList << '$/InventoryItem/spareFor/name'
     179            properitesList << '$/InventoryItem/spareFor/description'
     180            properitesList << '$/InventoryItem/spareFor/comment'
     181        }
     182        if(properitesList)
     183            searchableParams.properties = properitesList
     184
     185        // Require isActive and isObsolete.
     186        def queryString = '( '+result.searchText+' )'+ ' AND isActive:"true" AND isObsolete:"false"'
    163187
    164188        // Perform the searchable query.
    165189        try {
    166             result.inventoryItemList = InventoryItem.search(result.searchText, searchableParams)
     190            result.inventoryItemList = InventoryItem.search(queryString, searchableParams)
     191
     192            // Would be nice if this worked.
     193//             result.inventoryItemList = InventoryItem.search(result.searchText, searchableParams) {
     194//                 must(term("isActive", true))
     195//                 must(term("isObsolete", false))
     196//             }
     197
    167198        } catch (e) {
    168199            log.error e
  • trunk/grails-app/views/inventoryItemDetailed/search.gsp

    r565 r566  
    271271                        <tr class="prop">
    272272                            <td valign="top" class="name">
     273
     274                                <jsUtil:toggleControl toggleId="limitSearch"
     275                                                                        imageId="limitSearchImg"
     276                                                                        closedImgUrl="${resource(dir:'images/skin',file:'bullet_toggle_plus.png')}"
     277                                                                        openImgUrl="${resource(dir:'images/skin',file:'bullet_toggle_minus.png')}"
     278                                                                        effect="fade"
     279                                                                        text="Limit Search"
     280                                                                        />
    273281                            </td>
    274282                            <td valign="top" class="value">
    275 <!--                                 <g:checkBox name="searchName" value="${true}" ></g:checkBox> -->
    276                                 <label for="searchName">Name,</label>
    277 <!--                                 <g:checkBox name="searchDescription" value="${true}" ></g:checkBox> -->
    278                                 <label for="searchDescription">Description,</label>
    279 <!--                                 <g:checkBox name="searchComment" value="${true}" ></g:checkBox> -->
    280                                 <label for="searchComment">Comment,</label>
    281 <!--                                 <g:checkBox name="searchLocation" value="${true}" ></g:checkBox> -->
    282                                 <label for="searchLocation">Location and</label>
    283 <!--                                 <g:checkBox name="searchSpareFor" value="${true}" ></g:checkBox> -->
    284                                 <label for="searchSpareFor">Spare For (Asset: name, description and comment).</label>
     283                                <g:if test="${params.searchName || params.searchDescription || params.searchComment || params.searchLocation || params.searchGroup || params.searchSpareFor}" >
     284                                    <div id="limitSearch">
     285                                </g:if>
     286                                <g:else>
     287                                    <div id="limitSearch" style="display:none;">
     288                                </g:else>
     289                                    <g:checkBox name="searchName" value="${params.searchName}" ></g:checkBox>
     290                                    <label for="searchName">Name</label>
     291                                    <g:checkBox name="searchDescription" value="${params.searchDescription}" ></g:checkBox>
     292                                    <label for="searchDescription">Description</label>
     293                                    <g:checkBox name="searchComment" value="${params.searchComment}" ></g:checkBox>
     294                                    <label for="searchComment">Comment</label>
     295                                    <g:checkBox name="searchLocation" value="${params.searchLocation}" ></g:checkBox>
     296                                    <label for="searchLocation">Location</label>
     297                                    <g:checkBox name="searchGroup" value="${params.searchGroup}" ></g:checkBox>
     298                                    <label for="searchGroup">Group</label>
     299                                    <br />
     300                                    <g:checkBox name="searchSpareFor" value="${params.searchSpareFor}" ></g:checkBox>
     301                                    <label for="searchSpareFor">Spare For (Asset: Name, Description and Comment).</label>
     302                                </div>
    285303                            </td>
    286304                        </tr>
Note: See TracChangeset for help on using the changeset viewer.