Ignore:
Timestamp:
Jul 19, 2010, 8:47:38 AM (14 years ago)
Author:
gav
Message:

Domain change: Add PurchasingGroup?.
Logic and views to suite.

Location:
trunk/grails-app/controllers
Files:
1 added
3 edited

Legend:

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

    r632 r633  
    7878            }
    7979            costCodeInstance.properties = params
     80            // Trim name to avoid spaces.
     81            costCodeInstance.name = costCodeInstance.name.trim()
    8082            if(!costCodeInstance.hasErrors() && costCodeInstance.save(flush: true)) {
    8183                flash.message = "CostCode ${params.id} updated"
     
    100102    def save = {
    101103        def costCodeInstance = new CostCode(params)
     104        // Trim name to avoid spaces.
     105        costCodeInstance.name = costCodeInstance.name.trim()
    102106        if(!costCodeInstance.hasErrors() && costCodeInstance.save(flush: true)) {
    103107            flash.message = "CostCode ${costCodeInstance.id} created"
  • trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy

    r615 r633  
    226226        params.returnTo = params.returnTo ?: 'inventoryItem'
    227227
    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        }
    230237
    231238        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     
    248255        }
    249256
    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])
    251267    }
    252268
     
    262278        }
    263279
    264         return ['inventoryItemPurchaseInstance':inventoryItemPurchaseInstance]
     280        def costCodes = inventoryPurchaseService.getCostCodesByPerson()
     281
     282        return ['inventoryItemPurchaseInstance': inventoryItemPurchaseInstance,
     283                        'costCodes': costCodes]
    265284    }
    266285
     
    282301        }
    283302
     303        def costCodes = inventoryPurchaseService.getCostCodesByPerson()
     304
    284305        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])
    286308    }
    287309
  • trunk/grails-app/controllers/PersonController.groovy

    r628 r633  
    157157            person.properties = params
    158158            person.setPersonGroupsFromCheckBoxList(params.personGroups)
     159            person.setPurchasingGroupsFromCheckBoxList(params.purchasingGroups)
    159160
    160161            if(params.pass == "") {
     
    194195            person.password = authenticateService.encodePassword(params.pass)
    195196            person.setPersonGroupsFromCheckBoxList(params.personGroups)
     197            person.setPurchasingGroupsFromCheckBoxList(params.purchasingGroups)
    196198            if (person.save(flush: true)) {
    197199                addRemoveAuthorities(person)
Note: See TracChangeset for help on using the changeset viewer.