Changeset 352 for trunk/grails-app
- Timestamp:
- Feb 12, 2010, 12:14:23 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetSubItemDetailedController.groovy
r347 r352 116 116 flash.message = "AssetSubItem not found with id ${params.id}" 117 117 redirect(action: "search") 118 } 119 else { 120 return [ assetSubItemInstance : assetSubItemInstance ] 121 } 118 return 119 } 120 121 def possibleParentItems = assetSubItemService.possibleParentItems(assetSubItemInstance) 122 123 return [ assetSubItemInstance : assetSubItemInstance, possibleParentItems: possibleParentItems ] 122 124 } 123 125 … … 137 139 assetSubItemInstance.properties = params 138 140 139 // if(!assetSubItemInstance.asset && !assetSubItemInstance.parentItem) { 140 // flash.message = "Either an asset or parentItem is required." 141 // render(view:'edit',model:[assetSubItemInstance:assetSubItemInstance]) 142 // return 143 // } 144 // 145 // if(assetSubItemInstance.asset && assetSubItemInstance.parentItem) { 146 // flash.message = "Both an asset and parentItem may not be specified at the same time." 147 // render(view:'edit',model:[parentItem:parentItem]) 148 // return 149 // } 141 if(assetSubItemInstance.assets) { 142 assetSubItemInstance.parentItem = null 143 } 150 144 151 145 if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) { -
trunk/grails-app/services/AssetService.groovy
r350 r352 12 12 def criteria = AssetSubItem.createCriteria() 13 13 def possibleAssetSubItems = criteria.list() { 14 isNull("parentItem") 14 and { 15 eq('isActive', true) 16 isNull("parentItem") 17 } 15 18 } 16 19 } -
trunk/grails-app/services/AssetSubItemService.groovy
r350 r352 2 2 3 3 boolean transactional = false 4 5 /** 6 * Determines and returns sorted list of possible parent items. 7 * @param assetSubItemInstance The instance to prepare the list for. 8 * @returns A list of the possible parentItems. 9 */ 10 def possibleParentItems(assetSubItemInstance) { 11 def criteria = AssetSubItem.createCriteria() 12 def possibleParentItems = criteria.list() { 13 and { 14 eq('isActive', true) 15 ne('id', assetSubItemInstance.id) 16 assetSubItemInstance.subItems.each() { notEqual('id', it.id) } 17 } 18 } 19 possibleParentItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } 20 } 4 21 5 22 def delete(params) { -
trunk/grails-app/views/assetSubItemDetailed/edit.gsp
r348 r352 95 95 </td> 96 96 </tr> 97 97 98 98 99 <tr class="prop"> 99 100 <td valign="top" class="name"> … … 101 102 </td> 102 103 <td valign="top" class="value ${hasErrors(bean:assetSubItemInstance,field:'parentItem','errors')}"> 103 <g:select optionKey="id" from="${AssetSubItem.list()}" name="parentItem.id" value="${assetSubItemInstance?.parentItem?.id}" noSelection="['null':'']"></g:select> 104 <g:if test="${assetSubItemInstance.assets}"> 105 Assigned to assets. 106 </g:if> 107 <g:else> 108 <g:select optionKey="id" from="${possibleParentItems}" name="parentItem.id" value="${assetSubItemInstance?.parentItem?.id}" noSelection="['null':'--None--']"></g:select> 109 </g:else> 104 110 </td> 105 </tr> 111 </tr> 106 112 107 113 <tr class="prop">
Note: See TracChangeset
for help on using the changeset viewer.