Changeset 387


Ignore:
Timestamp:
Feb 18, 2010, 8:10:41 PM (10 years ago)
Author:
gav
Message:

Capitalise asset and sub items during creation and update.
Small correction to alt menu.

Location:
trunk/grails-app
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/Config.groovy

    r386 r387  
    280280        ]
    281281    ],
    282     [order:140, controller:'extendedAttributeTypeDetailed', title:'extendedAttribute', action:'list',
     282    [order:140, controller:'extendedAttributeTypeDetailed', title:'extendedAttributeType', action:'list',
    283283        subItems: [
    284284            [order:10, controller:'extendedAttributeTypeDetailed', title:'Attribute Type List', action:'list', isVisible: { true }],
  • trunk/grails-app/controllers/AssetDetailedController.groovy

    r375 r387  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22import org.codehaus.groovy.grails.commons.ConfigurationHolder
     3import org.apache.commons.lang.WordUtils
    34
    45@Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager'])
     
    288289            assetInstance.properties = params
    289290
     291            use(WordUtils) {
     292                assetInstance.name = assetInstance.name.capitalize()
     293                assetInstance.description = assetInstance.description.capitalize()
     294            }
     295
    290296            assetInstance.setAssetSubItemsFromCheckBoxList(params.assetSubItems)
    291297
    292298            if(!assetInstance.hasErrors() && assetInstance.save(flush: true)) {
    293                 flash.message = "Asset ${params.id} updated"
     299                flash.message = "Asset '${assetInstance.name}' updated"
    294300                redirect(action:show,id:assetInstance.id)
    295301            }
     
    335341    def save = {
    336342        def result = assetService.save(params)
     343
     344        if(!result.error) {
     345            flash.message = g.message(code: "default.create.success", args: ["Asset",  "'${result.assetInstance.name}'"])
     346            redirect(action:show, id: result.assetInstance.id)
     347            return
     348        }
     349
     350        render(view:'create', model:[assetInstance: result.assetInstance])
     351    }
     352
     353    /**
     354    * Copy save action.
     355    */
     356    def saveCopy = {
     357        def result = assetService.saveCopy(params)
    337358
    338359        if(!result.error) {
     
    342363        }
    343364
    344         render(view:'create', model:[assetInstance: result.assetInstance])
    345     }
    346 
    347     /**
    348     * Copy save action.
    349     */
    350     def saveCopy = {
    351         def result = assetService.saveCopy(params)
    352 
    353         if(!result.error) {
    354             flash.message = g.message(code: "default.create.success", args: ["Asset", result.assetInstance.id])
    355             redirect(action:show, id: result.assetInstance.id)
    356             return
    357         }
    358 
    359365        if(result.error.code == "default.not.found") {
    360366            flash.message = g.message(code: result.error.code, args: ["Asset", params.assetToCopy?.id])
  • trunk/grails-app/controllers/AssetSubItemDetailedController.groovy

    r375 r387  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22import org.codehaus.groovy.grails.commons.ConfigurationHolder
     3import org.apache.commons.lang.WordUtils
    34
    45@Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager'])
     
    165166            assetSubItemInstance.properties = params
    166167
     168            use(WordUtils) {
     169                assetSubItemInstance.name = assetSubItemInstance.name.capitalize()
     170                assetSubItemInstance.description = assetSubItemInstance.description.capitalize()
     171            }
     172
    167173            if(assetSubItemInstance.assets) {
    168174                assetSubItemInstance.parentItem = null
     
    170176
    171177            if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) {
    172                 flash.message = "AssetSubItem ${params.id} updated"
     178                flash.message = "Sub Item '${assetSubItemInstance.name}' updated"
    173179
    174180                if(assetSubItemInstance.assets)
     
    217223        if(!result.error) {
    218224            // Success.
    219             flash.message = g.message(code: "default.create.success", args: ["AssetSubItem", result.assetSubItemInstance.name])
     225            flash.message = g.message(code: "default.create.success", args: ["Sub Item", "'${result.assetSubItemInstance.name}'"])
    220226
    221227            /// @todo: This just grabs the first parent in an unsorted list and needs improving.
  • trunk/grails-app/services/AssetService.groovy

    r360 r387  
     1
     2import org.apache.commons.lang.WordUtils
     3
    14class AssetService {
    25
     
    116119        result.assetInstance = new Asset(params)
    117120
     121        use(WordUtils) {
     122            result.assetInstance.name = result.assetInstance.name.capitalize()
     123            result.assetInstance.description = result.assetInstance.description.capitalize()
     124        }
     125
    118126        if(result.assetInstance.hasErrors() || !result.assetInstance.save(flush: true))
    119127            return fail(code:"default.create.failure")
  • trunk/grails-app/services/AssetSubItemService.groovy

    r360 r387  
     1
     2import org.apache.commons.lang.WordUtils
     3
    14class AssetSubItemService {
    25
     
    9396            result.assetSubItemInstance = new AssetSubItem(params)
    9497
     98            use(WordUtils) {
     99                result.assetSubItemInstance.name = result.assetSubItemInstance.name.capitalize()
     100                result.assetSubItemInstance.description = result.assetSubItemInstance.description.capitalize()
     101            }
     102
    95103            if(params.asset?.id) {
    96104                result.assetInstance = Asset.get(params.asset.id)
Note: See TracChangeset for help on using the changeset viewer.