Ignore:
Timestamp:
Mar 8, 2010, 10:58:13 AM (15 years ago)
Author:
gav
Message:

Change InventoryItem to have a preferred and many alternate suppliers and manufacturers.
Controllers and views updated.

File:
1 edited

Legend:

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

    r425 r435  
    240240        if(!result.error) {
    241241            def possibleAlternateItems = inventoryItemService.getPossibleAlternateItems(result.inventoryItemInstance)
    242             return [ inventoryItemInstance : result.inventoryItemInstance, possibleAlternateItems: possibleAlternateItems]
     242            def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     243            def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     244
     245            return [ inventoryItemInstance : result.inventoryItemInstance,
     246                            possibleAlternateItems: possibleAlternateItems,
     247                            suppliers: suppliers,
     248                            manufacturers: manufacturers]
    243249        }
    244250
     
    263269
    264270        def possibleAlternateItems = inventoryItemService.getPossibleAlternateItems(result.inventoryItemInstance)
    265         render(view:'edit', model:[inventoryItemInstance: result.inventoryItemInstance.attach(), possibleAlternateItems: possibleAlternateItems])
     271        def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     272        def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     273        render(view:'edit', model:[inventoryItemInstance: result.inventoryItemInstance.attach(),
     274                                                possibleAlternateItems: possibleAlternateItems,
     275                                                suppliers: suppliers,
     276                                                manufacturers: manufacturers])
    266277    }
    267278
    268279    def create = {
    269280        def result = inventoryItemService.create(params)
     281        def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     282        def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
    270283
    271284        if(!result.error)
    272             return [inventoryItemInstance: result.inventoryItemInstance]
     285            return [inventoryItemInstance: result.inventoryItemInstance,
     286                            suppliers: suppliers,
     287                            manufacturers: manufacturers]
    273288
    274289        //flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     
    285300        }
    286301
     302        def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     303        def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     304
    287305        //flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
    288         render(view:'create', model:[inventoryItemInstance: result.inventoryItemInstance])
     306        render(view:'create', model:[inventoryItemInstance: result.inventoryItemInstance,
     307                                                    suppliers: suppliers,
     308                                                    manufacturers: manufacturers])
    289309    }
    290310
Note: See TracChangeset for help on using the changeset viewer.