Changeset 633
- Timestamp:
- Jul 19, 2010, 8:47:38 AM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/Config.groovy
r627 r633 401 401 [order:91, controller:'inventoryItemPurchaseDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }] 402 402 ] 403 ], 404 [order:230, controller:'purchasingGroupDetailed', title:'purchasingGroup', action:'list', 405 subItems: [ 406 [order:10, controller:'purchasingGroupDetailed', title:'Purchasing Group List', action:'list', isVisible: { true }], 407 [order:20, controller:'purchasingGroupDetailed', title:'Create', action:'create', isVisible: { true }], 408 [order:90, controller:'purchasingGroupDetailed', title:'Show', action:'show', isVisible: { params.action == 'show' }], 409 [order:91, controller:'purchasingGroupDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }] 410 ] 403 411 ] 404 412 ] -
trunk/grails-app/controllers/CostCodeDetailedController.groovy
r632 r633 78 78 } 79 79 costCodeInstance.properties = params 80 // Trim name to avoid spaces. 81 costCodeInstance.name = costCodeInstance.name.trim() 80 82 if(!costCodeInstance.hasErrors() && costCodeInstance.save(flush: true)) { 81 83 flash.message = "CostCode ${params.id} updated" … … 100 102 def save = { 101 103 def costCodeInstance = new CostCode(params) 104 // Trim name to avoid spaces. 105 costCodeInstance.name = costCodeInstance.name.trim() 102 106 if(!costCodeInstance.hasErrors() && costCodeInstance.save(flush: true)) { 103 107 flash.message = "CostCode ${costCodeInstance.id} created" -
trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
r615 r633 226 226 params.returnTo = params.returnTo ?: 'inventoryItem' 227 227 228 if(!result.error) 229 return [ inventoryItemPurchaseInstance : result.inventoryItemPurchaseInstance ] 228 def costCodes = [] 229 230 if(!result.error) { 231 if(inventoryPurchaseService.isPersonInPurchasingGroup(result.inventoryItemPurchaseInstance.costCode.purchasingGroup)) 232 costCodes = inventoryPurchaseService.getCostCodesByPerson() 233 234 return [ inventoryItemPurchaseInstance : result.inventoryItemPurchaseInstance, 235 'costCodes': costCodes ] 236 } 230 237 231 238 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) … … 248 255 } 249 256 250 render(view:'edit', model:[inventoryItemPurchaseInstance: result.inventoryItemPurchaseInstance.attach()]) 257 result.inventoryItemPurchaseInstance.attach() 258 result.inventoryItemPurchaseInstance.costCode.attach() 259 result.inventoryItemPurchaseInstance.costCode.purchasingGroup.attach() 260 261 def costCodes = [] 262 if(inventoryPurchaseService.isPersonInPurchasingGroup(result.inventoryItemPurchaseInstance.costCode.purchasingGroup)) 263 costCodes = inventoryPurchaseService.getCostCodesByPerson() 264 265 render(view:'edit', model:[inventoryItemPurchaseInstance: result.inventoryItemPurchaseInstance, 266 'costCodes': costCodes]) 251 267 } 252 268 … … 262 278 } 263 279 264 return ['inventoryItemPurchaseInstance':inventoryItemPurchaseInstance] 280 def costCodes = inventoryPurchaseService.getCostCodesByPerson() 281 282 return ['inventoryItemPurchaseInstance': inventoryItemPurchaseInstance, 283 'costCodes': costCodes] 265 284 } 266 285 … … 282 301 } 283 302 303 def costCodes = inventoryPurchaseService.getCostCodesByPerson() 304 284 305 params.errorMessage = g.message(code: result.error.code, args: result.error.args) 285 render(view:'create', model:['inventoryItemPurchaseInstance': result.inventoryItemPurchaseInstance]) 306 render(view:'create', model:['inventoryItemPurchaseInstance': result.inventoryItemPurchaseInstance, 307 'costCodes': costCodes]) 286 308 } 287 309 -
trunk/grails-app/controllers/PersonController.groovy
r628 r633 157 157 person.properties = params 158 158 person.setPersonGroupsFromCheckBoxList(params.personGroups) 159 person.setPurchasingGroupsFromCheckBoxList(params.purchasingGroups) 159 160 160 161 if(params.pass == "") { … … 194 195 person.password = authenticateService.encodePassword(params.pass) 195 196 person.setPersonGroupsFromCheckBoxList(params.personGroups) 197 person.setPurchasingGroupsFromCheckBoxList(params.purchasingGroups) 196 198 if (person.save(flush: true)) { 197 199 addRemoveAuthorities(person) -
trunk/grails-app/domain/CostCode.groovy
r441 r633 1 1 class CostCode { 2 3 PurchasingGroup purchasingGroup 4 2 5 String name 3 6 String description = "" … … 7 10 8 11 static constraints = { 9 name(maxSize:50,unique:true,blank:false) 12 name(blank:false, maxSize:50, validator: {val, obj -> 13 // Name must be unique for a purchasingGroup. 14 def list = CostCode.withCriteria { 15 eq('purchasingGroup', obj.purchasingGroup) 16 eq('name', obj.name) 17 if(obj.id) 18 notEqual('id', obj.id) 19 } 20 if(list.size() > 0) 21 return 'not.unique.for.purchasing.group' 22 // Success. 23 return true 24 }) 10 25 description(maxSize:100) 11 26 } 12 27 13 28 String toString() { 14 "${this.name} "29 "${this.name}.${this.purchasingGroup}" 15 30 } 31 16 32 } -
trunk/grails-app/domain/Person.groovy
r402 r633 7 7 tasks: Task, 8 8 contacts: Contact, 9 addresses: Address] 9 addresses: Address, 10 purchasingGroups: PurchasingGroup] 10 11 11 12 static belongsTo = [Authority] … … 68 69 } 69 70 71 // This additional setter is used to convert the checkBoxList string or string array 72 // of ids selected to the corresponding domain objects. 73 public void setPurchasingGroupsFromCheckBoxList(ids) { 74 def idList = [] 75 if(ids instanceof String) { 76 if(ids.isInteger()) 77 idList << ids.toInteger() 78 } 79 else { 80 ids.each() { 81 if(it.isInteger()) 82 idList << it.toInteger() 83 } 84 } 85 this.purchasingGroups = idList.collect { PurchasingGroup.get( it ) } 86 } 87 70 88 } // end class -
trunk/grails-app/i18n/messages.properties
r631 r633 45 45 person.pass.doesNotMatch=Passwords must match 46 46 47 costCode.name.not.unique.for.purchasing.group=CostCode name must be unique for purchasingGroup. 48 47 49 # 48 50 # Help Balloon and property definitions. … … 61 63 may also provide a record of persons qualified or trained in a specific area. \ 62 64 Groups provide no application authorisations. 65 person.purchasingGroups=Purchasing Groups 66 person.purchasingGroups.help=Purchasing groups determine the available cost codes that a person may purchase against. 63 67 person.loginName=Login Name 64 68 person.loginName.help=This is the id or name that the person will use to login to the application. … … 231 235 inventoryItemPurchase.delete.failure.payment.approved=Could not delete, payment has been approved. 232 236 inventoryItemPurchase.operation.not.permitted.on.inactive.or.obsolete.item=This operation is not permitted on an inactive or obsolete inventory item. 237 inventoryItemPurchase.costCodes.not.found=No cost codes found, a person needs to be assigned to a purchasing group that has cost codes. 233 238 234 239 assignedGroup.task.not.found=Please select a task and then ''Add Assigned Group''. -
trunk/grails-app/services/CreateDataService.groovy
r622 r633 115 115 116 116 // Person and Utils 117 createDemoPersons()118 117 createDemoSites() 119 118 createDemoDepartments() … … 121 120 createDemoManufacturers() 122 121 createDemoProductionReference() 122 createDemoPurchasingGroups() /// @todo: Perhaps a 'createQuickStartData' method? 123 123 createDemoCostCodes() 124 createDemoPersons() 124 125 125 126 // Assets … … 307 308 personInstance.addToAuthorities(Authority.get(2)) // ROLE_Manager. 308 309 personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. 310 personInstance.addToPersonGroups(PersonGroup.get(1)) 311 personInstance.addToPurchasingGroups(PurchasingGroup.get(1)) 312 personInstance.addToPurchasingGroups(PurchasingGroup.get(2)) 309 313 310 314 //Person #4 … … 697 701 } 698 702 703 void createDemoPurchasingGroups() { 704 705 // PurchasingGroup 706 def purchasingGroupInstance 707 708 purchasingGroupInstance = new PurchasingGroup(name:"R&M") 709 saveAndTest(purchasingGroupInstance) 710 711 purchasingGroupInstance = new PurchasingGroup(name:"Raw Materials") 712 saveAndTest(purchasingGroupInstance) 713 714 purchasingGroupInstance = new PurchasingGroup(name:"Safety") 715 saveAndTest(purchasingGroupInstance) 716 } 717 699 718 def createDemoCostCodes() { 700 719 … … 703 722 704 723 // CostCode #1 705 costCodeInstance = new CostCode(name: "RM Reelstand") 724 costCodeInstance = new CostCode(name: "Reelstand.172", 725 purchasingGroup: PurchasingGroup.get(1)) 706 726 saveAndTest(costCodeInstance) 707 727 708 728 // CostCode #2 709 costCodeInstance = new CostCode(name: "CAPEX Reelstand") 729 costCodeInstance = new CostCode(name: "Reelstand.CAPEX", 730 purchasingGroup: PurchasingGroup.get(1)) 731 saveAndTest(costCodeInstance) 732 733 // CostCode #2 734 costCodeInstance = new CostCode(name: "PrintUnit.123", 735 purchasingGroup: PurchasingGroup.get(3)) 710 736 saveAndTest(costCodeInstance) 711 737 } -
trunk/grails-app/services/InventoryPurchaseService.groovy
r610 r633 89 89 } 90 90 91 /** 92 * Get costCodes by person and the purchasingGroups they have been assigned. 93 * @param person A Person, defaults to currentUser. 94 * @returns A list of CostCodes. 95 */ 96 def getCostCodesByPerson(person = authService.currentUser) { 97 if(person.purchasingGroups) { 98 CostCode.withCriteria { 99 eq('isActive', true) 100 or { 101 person.purchasingGroups.each() { purchasingGroup -> 102 eq('purchasingGroup', purchasingGroup) 103 } 104 } 105 }.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } // withCriteria 106 } 107 else 108 [] 109 } // getCostCodesByPerson 110 111 /** 112 * Check if a person is in a purchasing group. 113 * @param person A PurchasingGroup to check for. 114 * @param person A Person, defaults to currentUser. 115 * @returns True if person is in group. 116 */ 117 def isPersonInPurchasingGroup(purchasingGroup, person = authService.currentUser) { 118 for(pg in person.purchasingGroups) { 119 if(pg.id == purchasingGroup.id) 120 return true 121 } 122 } // isPersonInPurchasingGroup 123 91 124 def delete(params) { 92 125 InventoryItemPurchase.withTransaction { status -> -
trunk/grails-app/views/appCore/manager.gsp
r624 r633 27 27 <a href="${createLink(controller:'personGroupDetailed', action:'list')}">Assigned Groups</a> 28 28 <br /> 29 <a href="${createLink(controller:'costCodeDetailed', action:'list')}">Cost Codes</a> 30 <br /> 29 31 <a href="${createLink(controller:'departmentDetailed', action:'list')}">Departments</a> 30 32 <br /> … … 38 40 <br /> 39 41 <a href="${createLink(controller:'manufacturerDetailed', action:'list')}">Manufacturers</a> 42 <br /> 43 <a href="${createLink(controller:'purchasingGroupDetailed', action:'list')}">Purchasing Groups</a> 40 44 <br /> 41 45 <a href="${createLink(controller:'productionReferenceDetailed', action:'list')}">Production Reference</a> -
trunk/grails-app/views/costCodeDetailed/create.gsp
r441 r633 35 35 <tr class="prop"> 36 36 <td valign="top" class="name"> 37 <label for="purchasingGroup">Purchasing Group:</label> 38 </td> 39 <td valign="top" class="value ${hasErrors(bean:costCodeInstance,field:'purchasingGroup','errors')}"> 40 <g:select optionKey="id" 41 from="${PurchasingGroup.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}" 42 name="purchasingGroup.id" 43 value="${costCodeInstance?.purchasingGroup?.id}" > 44 </g:select> 45 <p> 46 <g:link controller="purchasingGroupDetailed" action="create">+Add Group</g:link> 47 </p> 48 </td> 49 </tr> 50 51 <tr class="prop"> 52 <td valign="top" class="name"> 37 53 <label for="description">Description:</label> 38 54 </td> -
trunk/grails-app/views/costCodeDetailed/edit.gsp
r441 r633 37 37 <tr class="prop"> 38 38 <td valign="top" class="name"> 39 <label for="purchasingGroup">Purchasing Group:</label> 40 </td> 41 <td valign="top" class="value ${hasErrors(bean:costCodeInstance,field:'purchasingGroup','errors')}"> 42 <g:select optionKey="id" 43 from="${PurchasingGroup.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}" 44 name="purchasingGroup.id" 45 value="${costCodeInstance?.purchasingGroup?.id}" > 46 </g:select> 47 <p> 48 <g:link controller="purchasingGroupDetailed" action="create">+Add Group</g:link> 49 </p> 50 </td> 51 </tr> 52 53 <tr class="prop"> 54 <td valign="top" class="name"> 39 55 <label for="description">Description:</label> 40 56 </td> -
trunk/grails-app/views/costCodeDetailed/list.gsp
r498 r633 23 23 <g:sortableColumn property="name" title="Name" /> 24 24 25 <g:sortableColumn property="purchasingGroup" title="Group" /> 26 25 27 <g:sortableColumn property="description" title="Description" /> 26 28 … … 41 43 <td onclick='window.location = "${request.getContextPath()}/costCodeDetailed/show/${costCodeInstance.id}"'> 42 44 ${fieldValue(bean:costCodeInstance, field:'name')} 45 </td> 46 47 <td onclick='window.location = "${request.getContextPath()}/costCodeDetailed/show/${costCodeInstance.id}"'> 48 ${fieldValue(bean:costCodeInstance, field:'purchasingGroup')} 43 49 </td> 44 50 -
trunk/grails-app/views/costCodeDetailed/show.gsp
r441 r633 34 34 35 35 <tr class="prop"> 36 <td valign="top" class="name">Purchasing Group:</td> 37 <td valign="top" class="value"> 38 <g:link controller="purchasingGroupDetailed" action="show" id="${costCodeInstance?.purchasingGroup?.id}"> 39 ${costCodeInstance?.purchasingGroup?.encodeAsHTML()} 40 </g:link> 41 </td> 42 </tr> 43 44 <tr class="prop"> 36 45 <td valign="top" class="name">Description:</td> 37 46 … … 44 53 45 54 <td valign="top" class="value">${fieldValue(bean:costCodeInstance, field:'isActive')}</td> 46 47 </tr>48 49 <tr class="prop">50 <td valign="top" class="name">Inventory Item Purchases:</td>51 52 <td valign="top" style="text-align:left;" class="value">53 <ul>54 <g:each var="i" in="${costCodeInstance.inventoryItemPurchases}">55 <li><g:link controller="inventoryItemPurchaseDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>56 </g:each>57 </ul>58 </td>59 55 60 56 </tr> -
trunk/grails-app/views/inventoryItemPurchaseDetailed/create.gsp
r609 r633 15 15 <div class="body"> 16 16 <g:render template="/shared/messages" /> 17 <g:if test="${!costCodes}" > 18 <div class="errors"> 19 <ul> 20 <li><g:message code="inventoryItemPurchase.costCodes.not.found" /><li> 21 </div> 22 </g:if> 17 23 <g:hasErrors bean="${inventoryItemPurchaseInstance}"> 18 24 <div class="errors"> … … 66 72 <td valign="top" class="value ${hasErrors(bean:inventoryItemPurchaseInstance,field:'costCode','errors')}"> 67 73 <g:select optionKey="id" 68 from="${ CostCode.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}"74 from="${ costCodes }" 69 75 name="costCode.id" 70 76 value="${inventoryItemPurchaseInstance?.costCode?.id}" -
trunk/grails-app/views/inventoryItemPurchaseDetailed/edit.gsp
r609 r633 59 59 </td> 60 60 </tr> 61 61 62 62 <tr class="prop"> 63 63 <td valign="top" class="name"> … … 65 65 </td> 66 66 <td valign="top" class="value ${hasErrors(bean:inventoryItemPurchaseInstance,field:'costCode','errors')}"> 67 <g:select optionKey="id" 68 from="${ CostCode.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }" 69 name="costCode.id" 70 value="${inventoryItemPurchaseInstance?.costCode?.id}" > 71 </g:select> 67 <g:if test="${costCodes}"> 68 <g:select optionKey="id" 69 from="${ costCodes }" 70 name="costCode.id" 71 value="${inventoryItemPurchaseInstance.costCode?.id}" > 72 </g:select> 73 </g:if> 74 <g:else> 75 <g:link controller="costCodeDetailed" action="show" id="${inventoryItemPurchaseInstance?.costCode?.id}"> 76 ${inventoryItemPurchaseInstance?.costCode?.encodeAsHTML()} 77 </g:link> 78 </g:else> 72 79 <g:helpBalloon code="inventoryItemPurchase.cost.code" /> 73 80 </td> … … 96 103 from="${ Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }" 97 104 name="supplier.id" 98 value="${inventoryItemPurchaseInstance?.supplier?.id}" 99 noSelection="['null':/${g.message(code:'default.please.select.text')}/]"> 105 value="${inventoryItemPurchaseInstance?.supplier?.id}"> 100 106 </g:select> 101 107 <g:helpBalloon code="inventoryItemPurchase.supplier" /> -
trunk/grails-app/views/person/create.gsp
r506 r633 105 105 106 106 <tr class="prop"> 107 <td valign="top" class="name"> 108 <label for="purchasingGroups">Purchasing Groups:</label> 109 </td> 110 <td valign="top" class="value ${hasErrors(bean:person,field:'purchasingGroups','errors')}"> 111 <g:helpBalloon class="helpballoon" code="person.purchasingGroups" /> 112 <custom:checkBoxList name="purchasingGroups" 113 from="${PurchasingGroup.findAllByIsActive(true)}" 114 value="${person?.purchasingGroups?.collect{it.id}}" 115 optionKey="id" 116 sortBy="name" 117 linkController="purchasingGroupDetailed" 118 linkAction="show"/> 119 <g:link controller="purchasingGroupDetailed" action="create">+Add Group</g:link> 120 </td> 121 </tr> 122 123 <tr class="prop"> 107 124 <td valign="top" class="name" align="left"> 108 125 Authorities: -
trunk/grails-app/views/person/edit.gsp
r506 r633 144 144 145 145 <tr class="prop"> 146 <td valign="top" class="name"> 147 <label for="purchasingGroups">Purchasing Groups:</label> 148 </td> 149 <td valign="top" class="value ${hasErrors(bean:person,field:'purchasingGroups','errors')}"> 150 <g:helpBalloon class="helpballoon" code="person.purchasingGroups" /> 151 <custom:checkBoxList name="purchasingGroups" 152 from="${PurchasingGroup.findAllByIsActive(true)}" 153 value="${person?.purchasingGroups?.collect{it.id}}" 154 optionKey="id" 155 sortBy="name" 156 linkController="purchasingGroupDetailed" 157 linkAction="show"/> 158 <g:link controller="purchasingGroupDetailed" action="create">+Add Group</g:link> 159 </td> 160 </tr> 161 162 <tr class="prop"> 146 163 <td valign="top" class="name" align="left"> 147 164 Authorities: -
trunk/grails-app/views/person/show.gsp
r402 r633 89 89 <td valign="top" class="value"> 90 90 <ul> 91 <g:each in="${person.personGroups}" var='group'> 92 <li>${group}</li> 91 <g:each var='group' in="${ person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }"> 92 <li> 93 <g:link controller="personGroupDetailed" 94 action="show" 95 id="${group.id}"> 96 ${group.encodeAsHTML()} 97 </g:link> 98 </li> 99 </g:each> 100 </ul> 101 </td> 102 </tr> 103 104 <tr class="prop"> 105 <td valign="top" class="name">Purchasing Groups:</td> 106 <td valign="top" class="value"> 107 <ul> 108 <g:each var='a' in="${ person.purchasingGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }"> 109 <li> 110 <g:link controller="purchasingGroupDetailed" 111 action="show" 112 id="${a.id}"> 113 ${a.encodeAsHTML()} 114 </g:link> 115 </li> 93 116 </g:each> 94 117 </ul>
Note: See TracChangeset
for help on using the changeset viewer.