Changeset 285 for trunk/grails-app
- Timestamp:
- Jan 21, 2010, 1:38:57 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetSubItemDetailedController.groovy
r276 r285 2 2 3 3 class AssetSubItemDetailedController extends BaseController { 4 4 5 def assetSubItemService 6 5 7 def index = { redirect(controller: "assetDetailed", params:params) } 6 8 … … 27 29 } 28 30 catch(org.springframework.dao.DataIntegrityViolationException e) { 29 flash. message = "AssetSubItem ${params.id} could not be deleted"31 flash.errorMessage = "AssetSubItem ${params.id} could not be deleted" 30 32 redirect(action:show,id:params.id) 31 33 } … … 110 112 111 113 def create = { 112 def assetSubItemInstance = new AssetSubItem() 113 assetSubItemInstance.properties = params 114 return ['assetSubItemInstance':assetSubItemInstance] 114 def result = assetSubItemService.create(params) 115 116 if(!result.error) 117 return [assetSubItemInstance: result.assetSubItemInstance, assetInstance: result.assetInstance] 118 119 flash.message = g.message(code: result.error.code, args: result.error.args) 120 redirect(controller: 'assetDetailed', action: 'search') 115 121 } 116 122 117 123 def save = { 118 def assetSubItemInstance = new AssetSubItem(params)124 def result = assetSubItemService.save(params) 119 125 120 // if(!assetSubItemInstance.asset && !assetSubItemInstance.parentItem) { 121 // flash.message = "Either an asset or parentItem is required." 122 // render(view:'create',model:[assetSubItemInstance:assetSubItemInstance]) 123 // return 124 // } 125 // 126 // if(assetSubItemInstance.asset && assetSubItemInstance.parentItem) { 127 // flash.message = "Both an asset and parentItem may not be specified at the same time." 128 // render(view:'create',model:[assetSubItemInstance:assetSubItemInstance]) 129 // return 130 // } 126 if(!result.error) { 127 // Success. 128 flash.message = g.message(code: "default.create.success", args: ["AssetSubItem", result.assetSubItemInstance.name]) 131 129 132 if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) { 133 flash.message = "AssetSubItem ${assetSubItemInstance.id} created" 134 135 if(assetSubItemInstance.assets) 136 redirect(controller: "assetDetailed", action:"show", id: assetSubItemInstance.assets.toArray()[0].id) 130 /// @todo: This just grabs the first parent in an unsorted list and needs improving. 131 if(result.assetSubItemInstance.assets) 132 redirect(controller: "assetDetailed", action:"show", id: result.assetSubItemInstance.assets.toArray()[0].id) 137 133 else { 138 134 //Get the top parentItem. 139 def parentItem = assetSubItemInstance.parentItem135 def parentItem = result.assetSubItemInstance.parentItem 140 136 def i = 0 141 137 while(parentItem?.parentItem) { … … 150 146 redirect(controller: "assetDetailed", action:"show", id: parentItem.assets.toArray()[0].id) 151 147 else 152 redirect(action:"show", id: assetSubItemInstance.id) // End stop if all else fails.148 redirect(action:"show", id: result.assetSubItemInstance.id) // End stop if all else fails. 153 149 } 150 return 151 } 154 152 155 }156 else {157 render(view:'create',model:[assetSubItemInstance:assetSubItemInstance]) 158 }159 } // end save()153 if(result.error.code == "assetSubItem.asset.not.found") 154 flash.errorMessage = g.message(code: "default.create.success") 155 156 render(view:'create', model:[assetSubItemInstance: result.assetSubItemInstance, assetInstance: result.assetInstance]) 157 } 160 158 161 159 } // end class -
trunk/grails-app/i18n/messages.properties
r284 r285 10 10 While copy creates a new asset and new sub items. 11 11 asset.copy.asset.required=Please select an asset to copy. 12 13 assetSubItem.asset.not.found=Could not complete operation as an asset was supplied but not found. 12 14 13 15 sub.task.create.confirm=Immediately create and save a new sub task? -
trunk/grails-app/taglib/AssetTreeTagLib.groovy
r284 r285 271 271 } 272 272 273 def assetSubItemCreateLink( id) {274 createLink(controller: 'assetSubItemDetailed', action: 'create', params: [' id': id] ).toString()273 def assetSubItemCreateLink(assetId) { 274 createLink(controller: 'assetSubItemDetailed', action: 'create', params: ['asset.id': assetId] ).toString() 275 275 } 276 276 -
trunk/grails-app/views/assetSubItemDetailed/create.gsp
r276 r285 12 12 </div> 13 13 <div class="body"> 14 <g:if test="${flash.message}"> 15 <div class="message">${flash.message}</div> 16 </g:if> 14 <g:render template="/shared/messages" /> 17 15 <g:hasErrors bean="${assetSubItemInstance}"> 18 16 <div class="errors"> … … 29 27 <tr class="prop"> 30 28 <td valign="top" class="name"> 31 <label for=" asset">Parent Item:</label>29 <label for="parentItem">Parent Item:</label> 32 30 </td> 33 31 <td valign="top" class="value"> 34 32 ${assetSubItemInstance.parentItem.encodeAsHTML()} 33 </td> 34 </tr> 35 </g:if> 36 37 <g:if test="${assetInstance}" > 38 <g:hiddenField name="asset.id" value="${assetInstance.id}" /> 39 <tr class="prop"> 40 <td valign="top" class="name"> 41 <label for="asset">Link with Asset:</label> 42 </td> 43 <td valign="top" class="value"> 44 ${assetInstance.encodeAsHTML()} 35 45 </td> 36 46 </tr> -
trunk/grails-app/views/assetSubItemDetailed/edit.gsp
r276 r285 12 12 </div> 13 13 <div class="body"> 14 <g:if test="${flash.message}"> 15 <div class="message">${flash.message}</div> 16 </g:if> 14 <g:render template="/shared/messages" /> 17 15 <g:hasErrors bean="${assetSubItemInstance}"> 18 16 <div class="errors"> … … 56 54 <tr class="prop"> 57 55 <td valign="top" class="name"> 58 <label for="parentItem">Parent Item:</label>59 </td>60 <td valign="top" class="value ${hasErrors(bean:assetSubItemInstance,field:'parentItem','errors')}">61 <g:select optionKey="id" from="${AssetSubItem.list()}" name="parentItem.id" value="${assetSubItemInstance?.parentItem?.id}" noSelection="['null':'']"></g:select>62 </td>63 </tr>64 65 <tr class="prop">66 <td valign="top" class="name">67 56 <label for="assetSubItemExtendedAttributes">Asset Sub Item Extended Attributes:</label> 68 57 </td> … … 76 65 <g:link controller="assetSubItemExtendedAttributeDetailed" params="['assetSubItem.id':assetSubItemInstance?.id]" action="create">Add AssetSubItemExtendedAttribute</g:link> 77 66 78 </td>79 </tr>80 81 <tr class="prop">82 <td valign="top" class="name">83 <label for="assets">Assets:</label>84 </td>85 <td valign="top" class="value ${hasErrors(bean:assetSubItemInstance,field:'assets','errors')}">86 87 67 </td> 88 68 </tr> … … 104 84 105 85 </td> 86 </tr> 87 88 <tr class="prop"> 89 <td valign="top" class="name"> 90 <label for="parentItem">Parent Item:</label> 91 </td> 92 <td valign="top" class="value ${hasErrors(bean:assetSubItemInstance,field:'parentItem','errors')}"> 93 <g:select optionKey="id" from="${AssetSubItem.list()}" name="parentItem.id" value="${assetSubItemInstance?.parentItem?.id}" noSelection="['null':'']"></g:select> 94 </td> 106 95 </tr> 107 96 97 <tr class="prop"> 98 <td valign="top" class="name">Assets:</td> 99 100 <td valign="top" style="text-align:left;" class="value"> 101 <ul> 102 <g:each var="a" in="${assetSubItemInstance.assets}"> 103 <li><g:link controller="assetDetailed" action="show" id="${a.id}">${a?.encodeAsHTML()}</g:link></li> 104 </g:each> 105 </ul> 106 </td> 107 108 </tr> 109 108 110 <tr class="prop"> 109 111 <td valign="top" class="name"> … … 117 119 </g:each> 118 120 </ul> 119 <g:link controller="assetSubItemDetailed" params="[' assetSubItem.id':assetSubItemInstance?.id]" action="create">Add AssetSubItem</g:link>121 <g:link controller="assetSubItemDetailed" params="['parentItem.id':assetSubItemInstance?.id]" action="create">Add AssetSubItem</g:link> 120 122 121 123 </td> -
trunk/grails-app/views/assetSubItemDetailed/show.gsp
r276 r285 12 12 </div> 13 13 <div class="body"> 14 <g:if test="${flash.message}"> 15 <div class="message">${flash.message}</div> 16 </g:if> 14 <g:render template="/shared/messages" /> 17 15 <div class="dialog"> 18 16 <table> … … 49 47 50 48 <tr class="prop"> 51 <td valign="top" class="name">Parent Item:</td>52 53 <td valign="top" class="value"><g:link controller="assetSubItemDetailed" action="show" id="${assetSubItemInstance?.parentItem?.id}">${assetSubItemInstance?.parentItem?.encodeAsHTML()}</g:link></td>54 55 </tr>56 57 <tr class="prop">58 49 <td valign="top" class="name">Asset Sub Item Extended Attributes:</td> 59 50 … … 65 56 </ul> 66 57 </td> 58 59 </tr> 60 61 <tr class="prop"> 62 <td valign="top" class="name">Maintenance Actions:</td> 63 64 <td valign="top" style="text-align:left;" class="value"> 65 <ul> 66 <g:each var="m" in="${assetSubItemInstance.maintenanceActions}"> 67 <li><g:link controller="maintenanceActionDetailed" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link></li> 68 </g:each> 69 </ul> 70 </td> 71 72 </tr> 73 74 <tr class="prop"> 75 <td valign="top" class="name">Parent Item:</td> 76 77 <td valign="top" class="value"><g:link controller="assetSubItemDetailed" action="show" id="${assetSubItemInstance?.parentItem?.id}">${assetSubItemInstance?.parentItem?.encodeAsHTML()}</g:link></td> 67 78 68 79 </tr> … … 79 90 </td> 80 91 81 </tr>82 83 <tr class="prop">84 <td valign="top" class="name">Maintenance Actions:</td>85 86 <td valign="top" style="text-align:left;" class="value">87 <ul>88 <g:each var="m" in="${assetSubItemInstance.maintenanceActions}">89 <li><g:link controller="maintenanceActionDetailed" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link></li>90 </g:each>91 </ul>92 </td>93 94 92 </tr> 95 93
Note: See TracChangeset
for help on using the changeset viewer.