- Timestamp:
- Jan 20, 2010, 8:12:16 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetSubItemDetailedController.groovy
r274 r276 64 64 assetSubItemInstance.properties = params 65 65 66 if(!assetSubItemInstance.asset && !assetSubItemInstance.parentItem) {67 flash.message = "Either an asset or parentItem is required."68 render(view:'edit',model:[assetSubItemInstance:assetSubItemInstance])69 return70 }71 72 if(assetSubItemInstance.asset && assetSubItemInstance.parentItem) {73 flash.message = "Both an asset and parentItem may not be specified at the same time."74 render(view:'edit',model:[parentItem:parentItem])75 return76 }66 // if(!assetSubItemInstance.asset && !assetSubItemInstance.parentItem) { 67 // flash.message = "Either an asset or parentItem is required." 68 // render(view:'edit',model:[assetSubItemInstance:assetSubItemInstance]) 69 // return 70 // } 71 // 72 // if(assetSubItemInstance.asset && assetSubItemInstance.parentItem) { 73 // flash.message = "Both an asset and parentItem may not be specified at the same time." 74 // render(view:'edit',model:[parentItem:parentItem]) 75 // return 76 // } 77 77 78 78 if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) { 79 79 flash.message = "AssetSubItem ${params.id} updated" 80 80 81 if(assetSubItemInstance.asset )82 redirect(controller: "assetDetailed", action:"show", id: assetSubItemInstance.asset .id)81 if(assetSubItemInstance.assets) 82 redirect(controller: "assetDetailed", action:"show", id: assetSubItemInstance.assets.toArray()[0].id) 83 83 else { 84 84 //Get the top parentItem. … … 93 93 } 94 94 95 if(parentItem .asset)96 redirect(controller: "assetDetailed", action:"show", id: parentItem.asset .id)95 if(parentItem?.assets) 96 redirect(controller: "assetDetailed", action:"show", id: parentItem.assets.toArray()[0].id) 97 97 else 98 98 redirect(action:"show", id: assetSubItemInstance.id) // End stop if all else fails. … … 118 118 def assetSubItemInstance = new AssetSubItem(params) 119 119 120 if(!assetSubItemInstance.asset && !assetSubItemInstance.parentItem) {121 flash.message = "Either an asset or parentItem is required."122 render(view:'create',model:[assetSubItemInstance:assetSubItemInstance])123 return124 }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 return130 }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 // } 131 131 132 132 if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) { 133 133 flash.message = "AssetSubItem ${assetSubItemInstance.id} created" 134 134 135 if(assetSubItemInstance.asset )136 redirect(controller: "assetDetailed", action:"show", id: assetSubItemInstance.asset .id)135 if(assetSubItemInstance.assets) 136 redirect(controller: "assetDetailed", action:"show", id: assetSubItemInstance.assets.toArray()[0].id) 137 137 else { 138 138 //Get the top parentItem. … … 147 147 } 148 148 149 if(parentItem .asset)150 redirect(controller: "assetDetailed", action:"show", id: parentItem.asset .id)149 if(parentItem?.assets) 150 redirect(controller: "assetDetailed", action:"show", id: parentItem.assets.toArray()[0].id) 151 151 else 152 152 redirect(action:"show", id: assetSubItemInstance.id) // End stop if all else fails. -
trunk/grails-app/domain/AssetSubItem.groovy
r268 r276 1 1 class AssetSubItem { 2 2 3 Asset asset4 3 AssetSubItem parentItem 5 4 … … 8 7 boolean isActive = true 9 8 10 static hasMany = [subItems: AssetSubItem, 9 static hasMany = [assets: Asset, 10 subItems: AssetSubItem, 11 11 maintenanceActions: MaintenanceAction, 12 12 assetSubItemExtendedAttributes: AssetSubItemExtendedAttribute] … … 18 18 description(maxSize:100) 19 19 isActive() 20 asset(nullable:true)21 20 parentItem(nullable:true) 22 21 } -
trunk/grails-app/services/CreateDataService.groovy
r275 r276 129 129 createDemoMaintenanceActions() 130 130 createDemoSections() 131 createDemoAsset s()131 createDemoAssetTree() 132 132 createDemoAssetExtenedAttributes() 133 createDemoAssetSubItems()134 133 135 134 // Record that data has been created. … … 1047 1046 //Section #1 1048 1047 sectionInstance = new Section(name: "Press Section", 1048 site: Site.get(3), 1049 department: Department.get(1)) 1050 saveAndTest(sectionInstance) 1051 1052 //Section #2 1053 sectionInstance = new Section(name: "RO System", 1054 site: Site.get(1), 1055 department: Department.get(2)) 1056 saveAndTest(sectionInstance) 1057 1058 //Section #3 1059 sectionInstance = new Section(name: "Auxiliary Section", 1049 1060 site: Site.get(1), 1050 1061 department: Department.get(1)) 1051 1062 saveAndTest(sectionInstance) 1052 1053 //Section #2 1054 sectionInstance = new Section(name: "RO System", 1055 site: Site.get(2), 1056 department: Department.get(2)) 1057 saveAndTest(sectionInstance) 1058 1059 //Section #3 1060 sectionInstance = new Section(name: "Auxilliray Section", 1061 site: Site.get(1), 1062 department: Department.get(1)) 1063 saveAndTest(sectionInstance) 1064 } 1065 1066 def createDemoAssets() { 1063 } 1064 1065 def createDemoAssetTree() { 1067 1066 1068 1067 //Asset … … 1070 1069 1071 1070 //Asset #1 1072 assetInstance= new Asset(name: "Print Tower 22",1073 section: Section.get(1))1074 saveAndTest(assetInstance )1071 def assetInstance1 = new Asset(name: "Print Tower 22", 1072 section: Section.get(1)) 1073 saveAndTest(assetInstance1) 1075 1074 // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) 1076 1075 1077 1076 //Asset #2 1078 assetInstance= new Asset(name: "Print Tower 21",1079 section: Section.get(1))1080 saveAndTest(assetInstance )1077 def assetInstance2 = new Asset(name: "Print Tower 21", 1078 section: Section.get(1)) 1079 saveAndTest(assetInstance2) 1081 1080 1082 1081 //Asset #3 1083 assetInstance= new Asset(name: "Print Tower 23",1084 section: Section.get(1))1085 saveAndTest(assetInstance )1082 def assetInstance3 = new Asset(name: "Print Tower 23", 1083 section: Section.get(1)) 1084 saveAndTest(assetInstance3) 1086 1085 1087 1086 //Asset #4 1088 assetInstance = new Asset(name: "RO 1", 1089 section: Section.get(2)) 1090 saveAndTest(assetInstance) 1091 } 1092 1093 def createDemoAssetSubItems() { 1087 def assetInstance4 = new Asset(name: "RO 1", 1088 section: Section.get(2)) 1089 saveAndTest(assetInstance4) 1094 1090 1095 1091 //AssetSubItem 1096 1092 def assetSubItemInstance 1097 1093 1098 //AssetSubItem #1 1099 assetSubItemInstance = new AssetSubItem(name: "Print Unit Lower", 1100 asset: Asset.get(2)) 1094 //AssetSubItem #1 Level1 1095 def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower") 1096 saveAndTest(assetSubItemInstance1) 1097 1098 // Add assetSubItemInstance1 to some assets. 1099 assetInstance1.addToAssetSubItems(assetSubItemInstance1) 1100 assetInstance2.addToAssetSubItems(assetSubItemInstance1) 1101 assetInstance3.addToAssetSubItems(assetSubItemInstance1) 1102 1103 //AssetSubItem #2 Level1 1104 def assetSubItemInstance2 = new AssetSubItem(name: "Reactor Tower") 1105 saveAndTest(assetSubItemInstance2) 1106 1107 // Add assetSubItemInstance2 to some assets. 1108 assetInstance4.addToAssetSubItems(assetSubItemInstance2) 1109 1110 //AssetSubItem #3 Level1 1111 def assetSubItemInstance3 = new AssetSubItem(name: "Blower Tower") 1112 saveAndTest(assetSubItemInstance3) 1113 1114 // Add assetSubItemInstance3 to some assets. 1115 assetInstance4.addToAssetSubItems(assetSubItemInstance3) 1116 1117 //AssetSubItem #4 Level2 1118 assetSubItemInstance = new AssetSubItem(name: "Print Unit Upper", 1119 parentItem: AssetSubItem.get(1)) 1101 1120 saveAndTest(assetSubItemInstance) 1102 1121 1103 //AssetSubItem # 21104 assetSubItemInstance = new AssetSubItem(name: " Print Unit Upper",1105 asset: Asset.get(2))1122 //AssetSubItem #5 Level3 1123 assetSubItemInstance = new AssetSubItem(name: "Agitator", 1124 parentItem: AssetSubItem.get(2)) 1106 1125 saveAndTest(assetSubItemInstance) 1107 1126 1108 //AssetSubItem # 31109 assetSubItemInstance = new AssetSubItem(name: " Reactor Tower",1110 asset: Asset.get(1))1127 //AssetSubItem #6 Level2 1128 assetSubItemInstance = new AssetSubItem(name: "Scraper", 1129 parentItem: AssetSubItem.get(3)) 1111 1130 saveAndTest(assetSubItemInstance) 1112 } 1131 1132 //AssetSubItem #7 Level3 1133 assetSubItemInstance = new AssetSubItem(name: "Motor", 1134 parentItem: AssetSubItem.get(5)) 1135 saveAndTest(assetSubItemInstance) 1136 1137 //AssetSubItem #8 Level3 1138 assetSubItemInstance = new AssetSubItem(name: "Gearbox", 1139 parentItem: AssetSubItem.get(5)) 1140 saveAndTest(assetSubItemInstance) 1141 1142 //AssetSubItem #9 Level4 1143 assetSubItemInstance = new AssetSubItem(name: "DS Bearing", 1144 parentItem: AssetSubItem.get(7)) 1145 saveAndTest(assetSubItemInstance) 1146 1147 //AssetSubItem #10 Level4 1148 assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", 1149 parentItem: AssetSubItem.get(7)) 1150 saveAndTest(assetSubItemInstance) 1151 } // createDemoAssetTree() 1113 1152 1114 1153 def createDemoAssetExtenedAttributes() { -
trunk/grails-app/views/assetDetailed/edit.gsp
r271 r276 86 86 <td valign="top" class="value ${hasErrors(bean:assetInstance,field:'assetSubItems','errors')}"> 87 87 88 <ul> 89 <g:each var="a" in="${assetInstance?.assetSubItems?}"> 90 <li><g:link controller="assetSubItemDetailed" action="show" id="${a.id}">${a?.encodeAsHTML()}</g:link></li> 91 </g:each> 92 </ul> 93 <g:link controller="assetSubItemDetailed" params="['asset.id':assetInstance?.id]" action="create">Add AssetSubItem</g:link> 88 <g:select name="assetSubItems" 89 from="${AssetSubItem.list()}" 90 size="5" multiple="yes" optionKey="id" 91 value="${assetInstance?.assetSubItems}" /> 94 92 95 93 </td> -
trunk/grails-app/views/assetSubItemDetailed/create.gsp
r274 r276 24 24 <table> 25 25 <tbody> 26 27 <g:if test="${assetSubItemInstance?.asset}" >28 <g:hiddenField name="asset.id" value="${assetSubItemInstance.asset.id}" />29 <tr class="prop">30 <td valign="top" class="name">31 <label for="asset">Asset:</label>32 </td>33 <td valign="top" class="value">34 ${assetSubItemInstance.asset.encodeAsHTML()}35 </td>36 </tr>37 </g:if>38 26 39 27 <g:if test="${assetSubItemInstance?.parentItem}" > -
trunk/grails-app/views/assetSubItemDetailed/edit.gsp
r274 r276 56 56 <tr class="prop"> 57 57 <td valign="top" class="name"> 58 <label for="asset">Asset:</label>59 </td>60 <td valign="top" class="value ${hasErrors(bean:assetSubItemInstance,field:'asset','errors')}">61 <g:select optionKey="id" from="${Asset.list()}" name="asset.id" value="${assetSubItemInstance?.asset?.id}" noSelection="['null':'']"></g:select>62 </td>63 </tr>64 65 <tr class="prop">66 <td valign="top" class="name">67 58 <label for="parentItem">Parent Item:</label> 68 59 </td> … … 86 77 87 78 </td> 88 </tr> 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 </td> 88 </tr> 89 90 <tr class="prop"> 89 91 90 92 <tr class="prop"> -
trunk/grails-app/views/assetSubItemDetailed/show.gsp
r274 r276 49 49 50 50 <tr class="prop"> 51 <td valign="top" class="name">Asset:</td>52 53 <td valign="top" class="value"><g:link controller="assetDetailed" action="show" id="${assetSubItemInstance?.asset?.id}">${assetSubItemInstance?.asset?.encodeAsHTML()}</g:link></td>54 55 </tr>56 57 <tr class="prop">58 51 <td valign="top" class="name">Parent Item:</td> 59 52 … … 73 66 </td> 74 67 68 </tr> 69 70 <tr class="prop"> 71 <td valign="top" class="name">Assets:</td> 72 73 <td valign="top" style="text-align:left;" class="value"> 74 <ul> 75 <g:each var="a" in="${assetSubItemInstance.assets}"> 76 <li><g:link controller="assetDetailed" action="show" id="${a.id}">${a?.encodeAsHTML()}</g:link></li> 77 </g:each> 78 </ul> 79 </td> 80 75 81 </tr> 76 82
Note: See TracChangeset
for help on using the changeset viewer.