Changeset 485 for trunk/grails-app
- Timestamp:
- Apr 13, 2010, 12:37:51 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/InventoryItemDetailedController.groovy
r453 r485 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 import org.codehaus.groovy.grails.commons.ConfigurationHolder 3 import com.zeddware.grails.plugins.filterpane.FilterUtils 4 import org.springframework.web.servlet.support.RequestContextUtils as RCU 3 5 4 6 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager']) … … 9 11 def inventoryCsvService 10 12 def inventoryItemService 13 def inventoryItemSearchService 11 14 def inventoryMovementService 12 15 … … 114 117 } 115 118 119 /** 120 * Search for Inventory items. 121 */ 116 122 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) 117 123 def search = { … … 120 126 params.max = session.inventoryItemSearchParamsMax 121 127 122 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 128 // Protect filterPane. 129 params.max = Math.min( params.max ? params.max.toInteger() : 10, 1000) 123 130 124 131 def inventoryItemInstanceList = [] 125 132 def inventoryItemInstanceTotal 126 def filterParams = [:] 127 128 // Quick Search: 129 if(!params.filter) { 130 inventoryItemInstanceList = InventoryItem.list( params ) 131 inventoryItemInstanceTotal = InventoryItem.count() 132 filterParams = params 133 } 134 else { 135 // filterPane: 133 def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 134 def isFilterApplied = FilterUtils.isFilterApplied(params) 135 136 // Restore search unless a new search is being requested. 137 if(!params.quickSearch && !filterParams) { 138 if(session.inventoryItemQuickSearch) 139 params.quickSearch = session.inventoryItemQuickSearch 140 else if(session.inventoryItemSearchFilterParams) { 141 session.inventoryItemSearchFilterParams.each() { params[it.key] = it.value } 142 params.filter = session.inventoryItemSearchFilter 143 isFilterApplied = FilterUtils.isFilterApplied(params) 144 } 145 } 146 147 // Remember sort if supplied, otherwise try to restore. 148 if(params.sort && params.order) { 149 session.inventoryItemSearchSort = params.sort 150 session.inventoryItemSearchOrder = params.order 151 } 152 else if(session.inventoryItemSearchSort && session.inventoryItemSearchOrder) { 153 params.sort = session.inventoryItemSearchSort 154 params.order = session.inventoryItemSearchOrder 155 } 156 157 if(isFilterApplied) { 158 // filterPane: 136 159 inventoryItemInstanceList = filterService.filter( params, InventoryItem ) 137 160 inventoryItemInstanceTotal = filterService.count( params, InventoryItem ) 138 161 filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 162 // Remember search. 163 session.inventoryItemSearchFilterParams = new LinkedHashMap(filterParams) 164 session.inventoryItemSearchFilter = new LinkedHashMap(params.filter) 165 session.inventoryItemQuickSearch = null 166 } 167 else { 168 // Quick Search: 169 if(!params.quickSearch) params.quickSearch = "all" 170 def result = inventoryItemSearchService.getQuickSearch(params, RCU.getLocale(request)) 171 inventoryItemInstanceList = result.inventoryItemList 172 inventoryItemInstanceTotal = result.inventoryItemList.totalCount 173 params.message = result.message 174 filterParams.quickSearch = result.quickSearch 175 // Remember search. 176 session.inventoryItemSearchFilterParams = null 177 session.inventoryItemSearchFilter = null 178 session.inventoryItemQuickSearch = result.quickSearch 139 179 } 140 180 … … 145 185 formatDate(format: "EEE, dd-MMM-yyyy", date: date) 146 186 } 147 String title = "Inventory List." 187 188 String title 189 if(params.quickSearch) 190 title = params.message 191 else 192 title = "Filtered Inventory List." 148 193 149 194 response.contentType = ConfigurationHolder.config.grails.mime.types[params.format] … … 152 197 "description", 153 198 "unitsInStock", 199 "reorderPoint", 154 200 "unitOfMeasure", 155 201 "inventoryLocation", … … 158 204 "description": "Description", 159 205 "unitsInStock":"In Stock", 206 "reorderPoint":"Reorder Point", 160 207 "unitOfMeasure": "UOM", 161 208 "inventoryLocation": "Location", … … 177 224 filterParams.max = params.max 178 225 filterParams.offset = params.offset?.toInteger() ?: 0 179 filterParams.sort = params.sort ?: " id"180 filterParams.order = params.order ?: " desc"226 filterParams.sort = params.sort ?: "name" 227 filterParams.order = params.order ?: "asc" 181 228 182 229 return[ inventoryItemInstanceList: inventoryItemInstanceList, 183 230 inventoryItemInstanceTotal: inventoryItemInstanceTotal, 184 filterParams: filterParams ] 231 filterParams: filterParams, 232 params: params ] 185 233 } // end search() 186 234 -
trunk/grails-app/i18n/messages.properties
r482 r485 200 200 default.options.text=Options 201 201 default.none.text=None 202 default.all.text=All 202 203 203 204 # Rich UI plugin - Calendar … … 287 288 task.search.text.planners.range.none.found=No tasks found in the past week or two weeks ahead. 288 289 task.search.calendar.text.too.many.results=Too many results, only {0} are shown. 290 291 # InventoryItemSearch 292 inventoryItem.search.text.below.reorder=Bellow Reorder 293 inventoryItem.search.text.below.reorder.description=Inventory items at or below reorder point, with reorder enabled. 294 inventoryItem.search.text.below.reorder.all=Below Reorder (all) 295 inventoryItem.search.text.below.reorder.all.description=Inventory items at or below reorder point, including reorder disabled. 296 inventoryItem.search.text.below.reorder.none.found=No inventory items found at or below reorder point. 297 inventoryItem.search.text.all.description=All inventory items. 298 inventoryItem.search.text.all.none.found=No inventory items found. -
trunk/grails-app/views/inventoryItemDetailed/search.gsp
r468 r485 197 197 <tr class="prop"> 198 198 <td valign="top" class="name"> 199 <label>Inventory:</label> 200 </td> 201 <td valign="top" class="value"> 202 <g:link controller="inventoryItemDetailed" 203 action="search" 204 params="[quickSearch: 'all']"> 205 <g:message code="default.all.text" /> 206 </g:link> 207 <br /> 208 <g:link controller="inventoryItemDetailed" 209 action="search" 210 params="[quickSearch: 'inventoryBelowReorder']"> 211 <g:message code="inventoryItem.search.text.below.reorder" /> 212 </g:link> - <g:message code="inventoryItem.search.text.below.reorder.description" /> 213 <br /> 214 <g:link controller="inventoryItemDetailed" 215 action="search" 216 params="[quickSearch: 'inventoryBelowReorderAll']"> 217 <g:message code="inventoryItem.search.text.below.reorder.all" /> 218 </g:link> - <g:message code="inventoryItem.search.text.below.reorder.all.description" /> 219 </td> 220 </tr> 221 222 <tr class="prop"> 223 <td valign="top" class="name"> 199 224 <label>Links:</label> 200 225 </td> … … 204 229 Purchases 205 230 </g:link> 206 <br />207 231 </td> 208 232 </tr>
Note: See TracChangeset
for help on using the changeset viewer.