- Timestamp:
- Feb 2, 2011, 8:38:20 PM (14 years ago)
- Location:
- branches/features/taskProcedureRework/grails-app/views/taskProcedureDetailed
- Files:
-
- 2 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/features/taskProcedureRework/grails-app/views/taskProcedureDetailed/_maintenanceActions.gsp
r762 r770 1 1 <script type="text/javascript"> 2 2 var childCount = ${taskProcedureInstance?.maintenanceActions.size()} + 0; 3 var ma_wrapperId = "ma_wrapper"; 4 var ma_cloneId = "maintenanceActionLazyList_clone"; 5 var ma_lazyList = "maintenanceActionLazyList"; 6 var ma_fields = ["toBeDeleted", "isNew", "description", "reasoning", "assetSubItem.id", "procedureStepNumber"]; 7 var ma_focusField = "procedureStepNumber"; 3 8 4 function addChild() { 5 var htmlId = "maintenanceAction" + childCount; 6 var deleteIcon = "${resource(dir:'images/skin', file:'database_delete.png')}"; 7 var templateHtml = "<div id='" + htmlId + "' name='" + htmlId + "'>\n"; 8 templateHtml += "<input type='text' id='maintenanceActionLazyList[" + childCount + "].description' name='maintenanceActionLazyList[" + childCount + "].description' />\n"; 9 templateHtml += "<span onClick='jQuery(\"#" + htmlId + "\").remove();'><img src='" + deleteIcon + "' /></span>\n"; 10 templateHtml += "</div>\n"; 11 jQuery("#childList").append(templateHtml); 9 10 function addChild(wrapperId, cloneId, lazyList, fields, focusField){ 11 12 var clone = jQuery("#"+cloneId).clone(); 13 clone.attr('id', lazyList+childCount); 14 var htmlId = lazyList+'['+childCount+'].'; 15 16 var fieldsMap = {}; 17 jQuery.each(fields, function(index, field) { 18 fieldsMap[field] = clone.find('[id$="'+field+'"]'); 19 fieldsMap[field].attr('id',htmlId + field) 20 .attr('name',htmlId + field); 21 if(field == 'isNew') { 22 fieldsMap[field].attr('value', 'true'); 23 } 24 }); 25 26 jQuery("#"+wrapperId).append(clone); 27 clone.show(); 28 fieldsMap[focusField].focus(); 12 29 childCount++; 13 30 } 31 32 // Click event on add button. 33 jQuery('.add-ma').live('click', function() { 34 addChild(ma_wrapperId, ma_cloneId, ma_lazyList, ma_fields, ma_focusField); 35 }); 36 37 // Click event on delete buttons. 38 jQuery('.del-ma').live('click', function() { 39 //find the parent div 40 var prnt = jQuery(this).parents(".ma-div"); 41 //find the deleted hidden input 42 var delInput = prnt.find("input[id$=toBeDeleted]"); 43 //check if this is still not persisted 44 var newValue = prnt.find("input[id$=isNew]").attr('value'); 45 //if it is new then i can safely remove from dom 46 if(newValue == 'true'){ 47 prnt.remove(); 48 }else{ 49 //set the deletedFlag to true 50 delInput.attr('value','true'); 51 //hide the div 52 prnt.hide(); 53 } 54 }); 55 56 jQuery(window).load(function() { 57 if(childCount == 0) { 58 addChild(ma_wrapperId, ma_cloneId, ma_lazyList, ma_fields, ma_focusField); 59 } 60 }); 61 14 62 </script> 15 63 16 <div id="childList"> 17 <g:each var="ma" in="${taskProcedureInstance.maintenanceActions}" status="i"> 18 <div id="maintenanceAction${i}"> 19 <g:hiddenField name='maintenanceActionLazyList[${i}].id' value='${ma.id}'/> 20 <g:textField name='maintenanceActionLazyList[${i}].description' value='${ma.description}'/> 21 <input type="hidden" name='maintenanceActionLazyList[${i}].deleted' id='maintenanceActionLazyList[${i}].deleted' value='false'/> 22 <span onClick="jQuery('#maintenanceActionLazyList\\[${i}\\]\\.deleted').val('true'); jQuery('#maintenanceAction${i}').hide()"> 23 <img src="${resource(dir:'images/skin', file:'database_delete.png')}" /> 24 </span> 25 </div> 26 </g:each> 27 </div> 28 <input type="button" value="Add MaintenanceAction" onclick="addChild();" /> 64 65 66 <div> 67 <table> 68 <thead> 69 <tr> 70 71 <th>Step</th> 72 <th>Sub Item</th> 73 <th>Description</th> 74 <th>Reasoning</th> 75 <th></th> 76 77 </tr> 78 </thead> 79 <tbody id="ma_wrapper"> 80 <g:each var="ma" in="${taskProcedureInstance.maintenanceActions}" status="i"> 81 <g:render template="maintenanceAction" model="['tp':taskProcedureInstance, 'ma': ma, 'i':i]" /> 82 </g:each> 83 </tr> 84 </tbody> 85 </table> 86 </div> 87 88 <br /> 89 90 <div style="text-align:right;"> 91 <span class="buttons add-ma"> 92 <input type="button" class="add" value="Add MaintenanceAction" /> 93 </span> 94 </div> -
branches/features/taskProcedureRework/grails-app/views/taskProcedureDetailed/create.gsp
r762 r770 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" /> 16 18 17 <g:hasErrors bean="${taskProcedureInstance}"> 19 <div class="errors">20 <g:renderErrors bean="${taskProcedureInstance}" as="list" />21 </div>18 <div class="errors"> 19 <g:renderErrors bean="${taskProcedureInstance}" as="list" /> 20 </div> 22 21 </g:hasErrors> 23 22 24 23 <g:form action="save" method="post" > 25 <input type="hidden" name="linkedTask.id" value="${taskInstance.id}" />24 <input type="hidden" name="linkedTask.id" value="${taskProcedureInstance.linkedTask.id}" /> 26 25 27 <div class="dialog"> 28 <table> 29 <tbody> 26 <g:render template="taskProcedure" model="['taskProcedureInstance': taskProcedureInstance]" /> 30 27 31 <tr class="prop">32 <td valign="top" class="name">33 <label for="taskInstance">Parent Task:</label>34 </td>35 <td valign="top" name="taskInstance" class="value">36 <g:link controller="taskDetailed" action="show" id="${taskInstance.id}">37 ${taskInstance.encodeAsHTML()}38 </g:link>39 </td>40 </tr>41 42 <tr class="prop">43 <td valign="top" class="name">44 <label for="maintenanceActions">Maintenance Actions:</label>45 </td>46 <td valign="top" class="value ${hasErrors(bean:taskProcedureInstance,field:'maintenanceActions','errors')}">47 <g:render template="maintenanceActions" model="['taskProcedureInstance': taskProcedureInstance]" />48 </td>49 </tr>50 51 </tbody>52 </table>53 </div>54 28 <div class="buttons"> 55 29 <span class="button"><input class="save" type="submit" value="Create" /></span> … … 57 31 </g:form> 58 32 </div> 33 <table style="display:none;"> 34 <g:render template="maintenanceAction" model="['tp': null, 'ma': null, 'i': '_clone']" /> 35 </table> 59 36 </body> 60 37 </html> -
branches/features/taskProcedureRework/grails-app/views/taskProcedureDetailed/edit.gsp
r762 r770 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" /> 16 18 17 <g:hasErrors bean="${taskProcedureInstance}"> 19 <div class="errors">20 <g:renderErrors bean="${taskProcedureInstance}" as="list" />21 </div>18 <div class="errors"> 19 <g:renderErrors bean="${taskProcedureInstance}" as="list" /> 20 </div> 22 21 </g:hasErrors> 22 23 23 <g:form method="post" > 24 24 <input type="hidden" name="id" value="${taskProcedureInstance?.id}" /> 25 25 <input type="hidden" name="version" value="${taskProcedureInstance?.version}" /> 26 <div class="dialog">27 <table>28 <tbody>29 26 30 <tr class="prop"> 31 <td valign="top" class="name">Id:</td> 32 <td valign="top" class="value">${fieldValue(bean:taskProcedureInstance, field:'id')}</td> 33 </tr> 27 <g:render template="taskProcedure" model="['taskProcedureInstance': taskProcedureInstance]" /> 34 28 35 <tr class="prop">36 <td valign="top" class="name">37 <label for="taskInstance">Linked Task:</label>38 </td>39 <td valign="top" name="taskInstance" class="value">40 <g:link controller="taskDetailed" action="show" id="${taskProcedureInstance.linkedTask.id}">41 ${taskProcedureInstance.linkedTask.encodeAsHTML()}42 </g:link>43 </td>44 </tr>45 46 <tr class="prop">47 <td valign="top" class="name">48 <label for="maintenanceActions">Maintenance Actions:</label>49 </td>50 51 <td valign="top" class="value ${hasErrors(bean:taskProcedureInstance,field:'maintenanceActions','errors')}">52 <g:render template="maintenanceActions" model="['taskProcedureInstance': taskProcedureInstance]" />53 </td>54 </tr>55 56 </tbody>57 </table>58 </div>59 29 <div class="buttons"> 60 30 <span class="button"><g:actionSubmit class="save" value="Update" /></span> … … 63 33 </g:form> 64 34 </div> 35 <table style="display:none;"> 36 <g:render template="maintenanceAction" model="['tp': null, 'ma': null, 'i': '_clone']" /> 37 </table> 65 38 </body> 66 39 </html>
Note: See TracChangeset
for help on using the changeset viewer.