- Timestamp:
- Jan 21, 2011, 3:19:01 PM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 5 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 -
trunk/grails-app/services/CreateDataService.groovy
r739 r749 816 816 taskTypeInstance = new TaskType(name:"Project") // #5 817 817 saveAndTest(taskTypeInstance) 818 819 taskTypeInstance = new TaskType(name:"Parent PM") // #6 820 saveAndTest(taskTypeInstance) 818 821 } 819 822 -
trunk/grails-app/services/TaskService.groovy
r728 r749 44 44 } 45 45 } 46 } 47 48 /** 49 * Determines and returns a list of parentPM tasks for an asset. 50 * @param asset The asset to get parentPM tasks for. 51 * @returns A list of the possible task types. 52 */ 53 def getParentPMs(asset) { 54 def parentPMs = Task.withCriteria { 55 eq("primaryAsset", asset) 56 taskType { 57 idEq(6L) 58 } 59 maxResults(1000) 60 } 46 61 } 47 62 … … 202 217 p.taskStatus = TaskStatus.get(1) // A new subTask must always be "Not Started". 203 218 p.taskPriority = parentTask.taskPriority 219 204 220 p.taskType = params.taskType ?: parentTask.taskType 221 // Convert "Parent PM" tasks to "Preventative Maintenance" tasks. 222 if(p.taskType.id == 6) 223 p.taskType = TaskType.get(4) 224 205 225 p.leadPerson = params.leadPerson ?: parentTask.leadPerson 206 226 p.primaryAsset = params.primaryAsset ?: parentTask.primaryAsset -
trunk/grails-app/views/assetDetailed/edit.gsp
r704 r749 130 130 </td> 131 131 </tr> 132 133 <tr class="prop"> 134 <td valign="top" class="groupHeader"> 135 <label for="maintenanceActions">Maintenance Actions</label> 136 < /td>137 < td valign="top" class="value">138 </td> 139 </tr> 140 141 <g:each var=" m" in="${assetInstance?.maintenanceActions?}">132 133 <tr class="prop"> 134 <td valign="top" class="groupHeader">Life Plan</td> 135 136 <td valign="top" style="text-align:left;" class="value"> 137 </td> 138 139 </tr> 140 141 <g:each var="t" in="${parentPMs}"> 142 142 <tr class="prop"> 143 <td valign="top" class="name"> 143 <td valign="top" class="name"></td> 144 145 <td valign="top" style="text-align:left;" class="value"> 146 <g:link controller="taskDetailed" action="show" id="${t.id}"> 147 Task #${t.id} 148 </g:link> 149 <g:if test="${t.approved}" > 150 <img src="${resource(dir:'images/skin',file:'cog.png')}" alt="Approved" title="Approved" /> 151 </g:if> 152 <g:if test="${t.taskRecurringSchedule?.enabled}" > 153 <img src="${resource(dir:'images/skin',file:'arrow_refresh.png')}" alt="Recurrence Enabled" title="Recurrence Enabled" /> 154 </g:if> 155 <g:if test="${t.taskStatus.id == 2}" > 156 <img src="${resource(dir:'images/skin',file:'arrow_right.png')}" alt="In Progress" title="In Progress" /> 157 </g:if> 158 <g:if test="${t.attentionFlag}" > 159 <img src="${resource(dir:'images/skin',file:'flag_red.png')}" alt="Attention Flag" title="Attention Flag" /> 160 </g:if> 161 <g:if test="${t.taskStatus.id == 3}" > 162 <img src="${resource(dir:'images/skin',file:'tick.png')}" alt="Complete" title="Complete" /> 163 </g:if> 164 <br /> 165 ${fieldValue(bean:t, field:'description')} 166 <br /> 167 <g:if test="${t.safetyRequirement}" > 168 <img src="${resource(dir:'images/skin',file:'lightning.png')}" alt="Safety Requirement" title="Safety Requirement" /> 169 Safety 170 </g:if> 171 <g:if test="${t.regulatoryRequirement}" > 172 <img src="${resource(dir:'images/skin',file:'script_lightning.png')}" alt="Regulatory Requirement" title="Regulatory Requirement" /> 173 Regulatory 174 </g:if> 175 <g:if test="${t.mandatoryRequirement}" > 176 <img src="${resource(dir:'images/skin',file:'script.png')}" alt="Mandatory Requirement" title="Mandatory Requirement" /> 177 Mandatory 178 </g:if> 144 179 </td> 145 <td valign="top" class="value ${hasErrors(bean:assetInstance,field:'maintenanceActions','errors')}"> 146 <g:link controller="maintenanceActionDetailed" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link> 147 </td> 180 148 181 </tr> 149 182 </g:each> … … 152 185 <td valign="top" class="name"></td> 153 186 <td valign="top" style="text-align:left;" class="value"> 154 <g:link controller=" maintenanceActionDetailed" params="['asset.id':assetInstance?.id]" action="create">+Add Maintenance Action</g:link>187 <g:link controller="taskDetailed" params="['primaryAsset.id':assetInstance?.id, 'taskType.id':6]" action="create">+Add ParentPM</g:link> 155 188 </td> 156 189 </tr> -
trunk/grails-app/views/assetDetailed/show.gsp
r704 r749 110 110 111 111 <tr class="prop"> 112 <td valign="top" class="groupHeader"> Maintenance Actions</td>112 <td valign="top" class="groupHeader">Life Plan</td> 113 113 114 114 <td valign="top" style="text-align:left;" class="value"> … … 117 117 </tr> 118 118 119 120 <g:each var="m" in="${assetInstance.maintenanceActions}"> 119 <g:each var="t" in="${parentPMs}"> 121 120 <tr class="prop"> 122 121 <td valign="top" class="name"></td> 123 122 124 123 <td valign="top" style="text-align:left;" class="value"> 125 <g:link controller=" maintenanceActionDetailed" action="show" id="${m.id}">126 ${m?.encodeAsHTML()}124 <g:link controller="taskDetailed" action="show" id="${t.id}"> 125 Task #${t.id} 127 126 </g:link> 127 <g:if test="${t.approved}" > 128 <img src="${resource(dir:'images/skin',file:'cog.png')}" alt="Approved" title="Approved" /> 129 </g:if> 130 <g:if test="${t.taskRecurringSchedule?.enabled}" > 131 <img src="${resource(dir:'images/skin',file:'arrow_refresh.png')}" alt="Recurrence Enabled" title="Recurrence Enabled" /> 132 </g:if> 133 <g:if test="${t.taskStatus.id == 2}" > 134 <img src="${resource(dir:'images/skin',file:'arrow_right.png')}" alt="In Progress" title="In Progress" /> 135 </g:if> 136 <g:if test="${t.attentionFlag}" > 137 <img src="${resource(dir:'images/skin',file:'flag_red.png')}" alt="Attention Flag" title="Attention Flag" /> 138 </g:if> 139 <g:if test="${t.taskStatus.id == 3}" > 140 <img src="${resource(dir:'images/skin',file:'tick.png')}" alt="Complete" title="Complete" /> 141 </g:if> 142 <br /> 143 ${fieldValue(bean:t, field:'description')} 144 <br /> 145 <g:if test="${t.safetyRequirement}" > 146 <img src="${resource(dir:'images/skin',file:'lightning.png')}" alt="Safety Requirement" title="Safety Requirement" /> 147 Safety 148 </g:if> 149 <g:if test="${t.regulatoryRequirement}" > 150 <img src="${resource(dir:'images/skin',file:'script_lightning.png')}" alt="Regulatory Requirement" title="Regulatory Requirement" /> 151 Regulatory 152 </g:if> 153 <g:if test="${t.mandatoryRequirement}" > 154 <img src="${resource(dir:'images/skin',file:'script.png')}" alt="Mandatory Requirement" title="Mandatory Requirement" /> 155 Mandatory 156 </g:if> 128 157 </td> 129 158
Note: See TracChangeset
for help on using the changeset viewer.