- Timestamp:
- Jan 20, 2010, 8:34:36 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/Config.groovy
r215 r278 158 158 ] 159 159 ], 160 [order:40, controller:'assetDetailed', title:'assets', action:' search',160 [order:40, controller:'assetDetailed', title:'assets', action:'overview', 161 161 subItems: [ 162 [order:10, controller:'assetDetailed', title:'Search', action:'search', isVisible: { true }], 162 [order:10, controller:'assetDetailed', title:'Overview', action:'overview', isVisible: { true }], 163 [order:11, controller:'assetDetailed', title:'Search', action:'search', isVisible: { true }], 163 164 [order:20, controller:'assetDetailed', title:'Create', action:'create', isVisible: { true }], 164 165 [order:90, controller:'assetDetailed', title:'Show', action:'show', isVisible: { params.action == 'show' }], -
trunk/grails-app/controllers/AssetDetailedController.groovy
r271 r278 7 7 def filterService 8 8 def exportService 9 10 def index = { redirect(action:search,params:params) } 9 def assetService 10 11 def index = { redirect(action:overview,params:params) } 11 12 12 13 // the delete, save and update actions only accept POST requests … … 14 15 15 16 def importAssetTree = { 17 } 18 def overview = { 16 19 } 17 20 … … 245 248 } 246 249 247 def assetInstance = new Asset(name: assetToCopy.name, section: assetToCopy.section) 250 def assetInstance = new Asset(name: assetToCopy.name, 251 description: assetToCopy.description, 252 section: assetToCopy.section) 248 253 assetInstance.properties = params 249 254 return ['assetInstance':assetInstance, assetToCopy: assetToCopy] … … 262 267 263 268 def saveCopy = { 264 def result = saveCopySrvce(params)269 def result = assetService.saveCopy(params) 265 270 266 271 if(!result.error) { … … 276 281 } 277 282 283 if(result.error.code != "default.create.failure") { 284 flash.warning = g.message(code: result.error.code, args: ["Asset"]) 285 } 286 278 287 render(view:'copy', model:[assetInstance: result.assetInstance, assetToCopy: result.assetToCopy]) 279 288 } 280 289 281 def saveCopySrvce(params) {282 Asset.withTransaction { status ->283 def result = [:]284 285 def fail = { Map m ->286 status.setRollbackOnly()287 if(result.assetInstance && m.field)288 result.assetInstance.errors.rejectValue(m.field, m.code)289 result.error = [ code: m.code, args: ["Asset", params.id] ]290 return result291 }292 293 result.assetToCopy = Asset.get(params.assetToCopy?.id)294 if(!result.assetToCopy)295 return fail(code:"default.not.found")296 297 result.assetInstance = new Asset(params)298 299 if(result.assetInstance.hasErrors() || !result.assetInstance.save())300 return fail(code:"default.create.failure")301 302 def assetSubItemInstance1303 304 // Copy subItems from level 2 and bellow.305 def copyAssetSubItem = { assetSubItemToCopy, parentItem ->306 def assetSubItemInstance = new AssetSubItem(name: assetSubItemToCopy.name,307 description: assetSubItemToCopy.description,308 parentItem: parentItem)309 310 if(assetSubItemInstance.hasErrors() || !assetSubItemInstance.save())311 return fail(field:"subItems", code:"default.create.failure")312 313 def i = 0314 for(assetSubItem in assetSubItemToCopy.subItems) {315 call(assetSubItem, assetSubItemInstance)316 // Protect against endless recurrsion.317 i++318 if(i > 100)319 fail(code:"default.create.failure")320 // Stop if an error is flagged.321 if(result.error)322 break323 }324 } //copyAssetSubItem325 326 // Copy the 1st level of subItems.327 def copyAssetSubItem1 = { assetSubItemToCopy ->328 assetSubItemInstance1 = new AssetSubItem(name: assetSubItemToCopy.name,329 description: assetSubItemToCopy.description,330 asset: result.assetInstance)331 332 if(assetSubItemInstance1.hasErrors() || !assetSubItemInstance1.save())333 return fail(field:"assetSubItems", code:"default.create.failure")334 335 def i = 0336 for(assetSubItem in assetSubItemToCopy.subItems) {337 copyAssetSubItem(assetSubItem, assetSubItemInstance1)338 // Protect against endless recurrsion.339 i++340 if(i > 100)341 fail(code:"default.create.failure")342 // Stop if an error is flagged.343 if(result.error)344 break345 }346 } //copyAssetSubItem1347 348 def i = 0349 for(assetSubItem in result.assetToCopy.assetSubItems) {350 copyAssetSubItem1(assetSubItem)351 // Protect against endless recurrsion.352 i++353 if(i > 100)354 fail(code:"default.create.failure")355 // Stop if an error is flagged.356 if(result.error)357 break358 }359 360 // Success or not.361 return result362 363 } //end withTransaction364 } // end saveCopySrvce365 366 290 } // end class -
trunk/grails-app/i18n/messages.properties
r271 r278 4 4 asset.tree.import.file.not.supplied=No file supplied. 5 5 asset.tree.import.no.header=The supplied file does not have the correct headers, please see the template file. 6 7 asset.copy.method.required=Please select a copy method for sub items. 8 asset.copy.method=Copy Method 9 asset.copy.method.help=Link creates a new asset and links it to EXISTING sub items. \ 10 While copy creates a new asset and new sub items. 6 11 7 12 sub.task.create.confirm=Immediately create and save a new sub task? -
trunk/grails-app/views/assetDetailed/copy.gsp
r271 r278 13 13 </div> 14 14 <div class="body"> 15 <g:if test="${flash.message}"> 16 <div class="message">${flash.message}</div> 17 </g:if> 15 <g:render template="/shared/messages" /> 18 16 <g:hasErrors bean="${assetInstance}"> 19 17 <div class="errors"> … … 35 33 </td> 36 34 </tr> 35 36 <tr class="prop"> 37 <td valign="top" class="name"> 38 <label for="copyMethod">Sub Items:</label> 39 </td> 40 <td valign="top" class="value"> 41 <p> 42 <input type="radio" name="copyMethod" value="link" /> 43 Link 44 <g:helpBalloon class="helpballoon" code="asset.copy.method" /> 45 </p> 46 <p> 47 <input type="radio" name="copyMethod" value="copy" /> 48 Copy 49 </p> 50 </td> 51 </tr> 37 52 38 53 <tr class="prop"> -
trunk/grails-app/views/assetDetailed/show.gsp
r271 r278 7 7 <title>Show Asset</title> 8 8 <nav:resources override="true"/> 9 <g:javascript src="overlayPane.js" /> 9 10 </head> 10 11 <body> … … 19 20 <table> 20 21 <tbody> 21 22 22 23 <tr class="prop"> 23 24 <td valign="top" class="name">Id:</td> 24 25 25 26 <td valign="top" class="value">${fieldValue(bean:assetInstance, field:'id')}</td> 26 27 27 28 </tr> 28 29 29 30 <tr class="prop"> 30 31 <td valign="top" class="name">Asset:</td> 31 32 32 33 <td valign="top" style="text-align:left;" class="value"> 33 ${assetInstance.encodeAsHTML()} 34 <g:link controller="assetSubItemDetailed" params="['asset.id':assetInstance?.id]" action="create"> 35 <img src="${resource(dir:'images/skin',file:'database_add.png')}" alt="Add" title="Add Sub Item"/> 36 </g:link> 37 <g:link params="['asset.id':assetInstance?.id]" action="copy"> 38 <img src="${resource(dir:'images/skin',file:'page_copy.png')}" alt="Copy" title="Copy Asset"/> 39 </g:link> 40 <br /> 41 <br /> 42 <ul> 43 <g:each var="assetSubItem1" in="${assetInstance.assetSubItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }"> 44 <li> 45 <g:link controller="assetSubItemDetailed" action="edit" id="${assetSubItem1.id}">${assetSubItem1?.encodeAsHTML()}</g:link> 46 <g:link controller="assetSubItemDetailed" params="['parentItem.id':assetSubItem1?.id]" action="create"> 47 <img src="${resource(dir:'images/skin',file:'database_add.png')}" alt="Add" title="Add Sub Item" /> 48 </g:link> 49 </li> 50 <ul> 51 <g:each var="assetSubItem2" in="${assetSubItem1.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }"> 52 <li> 53 <g:link controller="assetSubItemDetailed" action="edit" id="${assetSubItem2.id}">${assetSubItem2?.encodeAsHTML()}</g:link> 54 <g:link controller="assetSubItemDetailed" params="['parentItem.id':assetSubItem2?.id]" action="create"> 55 <img src="${resource(dir:'images/skin',file:'database_add.png')}" alt="Add" title="Add Sub Item" /> 56 </g:link> 57 </li> 58 <ul> 59 <g:each var="assetSubItem3" in="${assetSubItem2.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }"> 60 <li> 61 <g:link controller="assetSubItemDetailed" action="edit" id="${assetSubItem3.id}">${assetSubItem3?.encodeAsHTML()}</g:link> 62 <g:link controller="assetSubItemDetailed" params="['parentItem.id':assetSubItem3?.id]" action="create"> 63 <img src="${resource(dir:'images/skin',file:'database_add.png')}" alt="Add" title="Add Sub Item" /> 64 </g:link> 65 </li> 66 <ul> 67 <g:each var="assetSubItem4" in="${assetSubItem3.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }"> 68 <li><g:link controller="assetSubItemDetailed" action="edit" id="${assetSubItem4.id}">${assetSubItem4?.encodeAsHTML()}</g:link></li> 69 </g:each> <!--assetSubItem4--> 70 </ul> 71 </g:each> <!--assetSubItem3--> 72 </ul> 73 </g:each> <!--assetSubItem2--> 74 </ul> 75 <br /> 76 <br /> 77 </g:each> <!--assetSubItem1--> 78 </ul> 34 <g:render template="/shared/assetTree" /> 79 35 </td> 80 36 81 37 </tr> 82 83 <tr class="prop">84 <td valign="top" class="name">Description:</td>85 86 <td valign="top" class="value">${fieldValue(bean:assetInstance, field:'description')}</td>87 88 </tr>89 90 <tr class="prop">91 <td valign="top" class="name">Is Active:</td>92 93 <td valign="top" class="value">${fieldValue(bean:assetInstance, field:'isActive')}</td>94 95 </tr>96 97 <tr class="prop">98 <td valign="top" class="name">Section:</td>99 100 <td valign="top" class="value"><g:link controller="sectionDetailed" action="show" id="${assetInstance?.section?.id}">${assetInstance?.section?.encodeAsHTML()}</g:link></td>101 102 </tr>103 104 <tr class="prop">105 <td valign="top" class="name">Asset Extended Attributes:</td>106 107 <td valign="top" style="text-align:left;" class="value">108 <ul>109 <g:each var="a" in="${assetInstance.assetExtendedAttributes}">110 <li><g:link controller="assetExtendedAttributeDetailed" action="edit" id="${a.id}">${a?.encodeAsHTML()}</g:link></li>111 </g:each>112 </ul>113 </td>114 115 </tr>116 117 <tr class="prop">118 <td valign="top" class="name">Maintenance Actions:</td>119 120 <td valign="top" style="text-align:left;" class="value">121 <ul>122 <g:each var="m" in="${assetInstance.maintenanceActions}">123 <li><g:link controller="maintenanceActionDetailed" action="edit" id="${m.id}">${m?.encodeAsHTML()}</g:link></li>124 </g:each>125 </ul>126 </td>127 128 </tr>129 38 39 <tr class="prop"> 40 <td valign="top" class="name">Description:</td> 41 42 <td valign="top" class="value">${fieldValue(bean:assetInstance, field:'description')}</td> 43 44 </tr> 45 46 <tr class="prop"> 47 <td valign="top" class="name">Is Active:</td> 48 49 <td valign="top" class="value">${fieldValue(bean:assetInstance, field:'isActive')}</td> 50 51 </tr> 52 53 <tr class="prop"> 54 <td valign="top" class="name">Section:</td> 55 56 <td valign="top" class="value"><g:link controller="sectionDetailed" action="show" id="${assetInstance?.section?.id}">${assetInstance?.section?.encodeAsHTML()}</g:link></td> 57 58 </tr> 59 60 <tr class="prop"> 61 <td valign="top" class="name">Asset Extended Attributes:</td> 62 63 <td valign="top" style="text-align:left;" class="value"> 64 <ul> 65 <g:each var="a" in="${assetInstance.assetExtendedAttributes}"> 66 <li><g:link controller="assetExtendedAttributeDetailed" action="edit" id="${a.id}">${a?.encodeAsHTML()}</g:link></li> 67 </g:each> 68 </ul> 69 </td> 70 71 </tr> 72 73 <tr class="prop"> 74 <td valign="top" class="name">Maintenance Actions:</td> 75 76 <td valign="top" style="text-align:left;" class="value"> 77 <ul> 78 <g:each var="m" in="${assetInstance.maintenanceActions}"> 79 <li><g:link controller="maintenanceActionDetailed" action="edit" id="${m.id}">${m?.encodeAsHTML()}</g:link></li> 80 </g:each> 81 </ul> 82 </td> 83 84 </tr> 85 130 86 </tbody> 131 87 </table> -
trunk/web-app/css/main.css
r277 r278 566 566 border-width: 1px 0; 567 567 } 568 569 /* Tree */ 570 571 .closednode { 572 /* height: 16px; 573 width: 16px; 574 padding: 0; 575 margin: 0;*/ 576 } 577 578 .emptynode { 579 /* padding: 0; */ 580 /* margin: 0; */ 581 /* height: 16px; */ 582 /* width: 16px; */ 583 /* padding: 0px 12px 5px 8px; */ 584 /* background: url(../images/skin/bullet_toggle_none.png) 0px 3px no-repeat; */ 585 /* border: 1px solid black; */ 586 } 587 588 div.tree { 589 } 590 div.tree li a{ 591 } 592 div.tree ul { 593 list-style-type: none; 594 } 595 div.tree li { 596 background: url(../images/skin/ln.gif) 0px 0px no-repeat; 597 /* line-height: 30px; */ 598 padding-left: 12px; 599 /* border: 1px solid black; */ 600 } -
trunk/web-app/js/overlayPane.js
r155 r278 1 function toggleBranch(divId, imageId) { 2 3 $(divId).toggle(); 4 5 if( $(divId).visible() ) { 6 $(imageId).src= '../images/skin/bullet_tree_minus.png'; 7 } 8 else { 9 $(imageId).src= '../images/skin/bullet_tree_plus.png'; 10 } 11 12 // return false; 13 } 14 1 15 function showElement(id) { 2 16 try {
Note: See TracChangeset
for help on using the changeset viewer.