Changeset 749 for trunk/grails-app/controllers
- Timestamp:
- Jan 21, 2011, 3:19:01 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetDetailedController.groovy
r615 r749 11 11 def assetService 12 12 def assetTreeService 13 def taskService 13 14 14 15 // the delete, save and update actions only accept POST requests … … 235 236 flash.message = "Asset not found with id ${params.id}" 236 237 redirect(action:search) 237 } 238 else { return [ assetInstance : assetInstance ] } 238 return 239 } 240 241 return [ assetInstance : assetInstance, 242 parentPMs: taskService.getParentPMs(assetInstance)] 239 243 } 240 244 … … 275 279 flash.message = "Asset not found with id ${params.id}" 276 280 redirect(action:search) 277 } 278 else { 279 return [ assetInstance : assetInstance, possibleAssetSubItems: assetService.possibleAssetSubItems() ] 280 } 281 return 282 } 283 284 return [ assetInstance : assetInstance, 285 possibleAssetSubItems: assetService.possibleAssetSubItems(), 286 parentPMs: taskService.getParentPMs(assetInstance) ] 287 281 288 } 282 289 … … 286 293 def update = { 287 294 def assetInstance = Asset.get( params.id ) 288 if(assetInstance) { 289 if(params.version) { 290 def version = params.version.toLong() 291 if(assetInstance.version > version) { 292 293 assetInstance.errors.rejectValue("version", "default.optimistic.locking.failure") 294 render(view:'edit',model:[assetInstance:assetInstance, possibleAssetSubItems: assetService.possibleAssetSubItems()]) 295 return 296 } 295 296 if(!assetInstance) { 297 flash.message = "Asset not found with id ${params.id}" 298 redirect(action:search) 299 return 300 } 301 302 if(params.version) { 303 def version = params.version.toLong() 304 if(assetInstance.version > version) { 305 306 assetInstance.errors.rejectValue("version", "default.optimistic.locking.failure") 307 render(view:'edit',model:[assetInstance:assetInstance, 308 possibleAssetSubItems: assetService.possibleAssetSubItems(), 309 parentPMs: taskService.getParentPMs(assetInstance)] ) 310 return 297 311 } 298 299 assetInstance.properties = params 300 301 use(WordUtils) { 302 assetInstance.name = assetInstance.name.capitalize() 303 assetInstance.description = assetInstance.description.capitalize() 304 } 305 306 assetInstance.setAssetSubItemsFromCheckBoxList(params.assetSubItems) 307 308 if(!assetInstance.hasErrors() && assetInstance.save(flush: true)) { 309 flash.message = "Asset '${assetInstance.name}' updated" 310 redirect(action:show,id:assetInstance.id) 311 } 312 else { 313 render(view:'edit',model:[assetInstance:assetInstance, possibleAssetSubItems: assetService.possibleAssetSubItems()]) 314 } 312 } 313 314 assetInstance.properties = params 315 316 use(WordUtils) { 317 assetInstance.name = assetInstance.name.capitalize() 318 assetInstance.description = assetInstance.description.capitalize() 319 } 320 321 assetInstance.setAssetSubItemsFromCheckBoxList(params.assetSubItems) 322 323 if(!assetInstance.hasErrors() && assetInstance.save(flush: true)) { 324 flash.message = "Asset '${assetInstance.name}' updated" 325 redirect(action:show,id:assetInstance.id) 315 326 } 316 327 else { 317 flash.message = "Asset not found with id ${params.id}" 318 redirect(action:search) 319 } 328 render(view:'edit',model:[assetInstance:assetInstance, 329 possibleAssetSubItems: assetService.possibleAssetSubItems(), 330 parentPMs: taskService.getParentPMs(assetInstance)] ) 331 } 332 320 333 } 321 334
Note: See TracChangeset
for help on using the changeset viewer.