1 | <script type="text/javascript"> |
---|
2 | var ma_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"; |
---|
8 | |
---|
9 | // Click event on add button. |
---|
10 | jQuery('.add-ma').live('click', function() { |
---|
11 | addChild(ma_wrapperId, ma_cloneId, ma_lazyList, ma_fields, ma_focusField, ma_childCount); |
---|
12 | ma_childCount++; |
---|
13 | }); |
---|
14 | |
---|
15 | // Click event on delete buttons. |
---|
16 | jQuery('.del-ma').live('click', function() { |
---|
17 | //find the parent div |
---|
18 | var prnt = jQuery(this).parents(".ma-div"); |
---|
19 | //find the deleted hidden input |
---|
20 | var delInput = prnt.find("input[id$=toBeDeleted]"); |
---|
21 | //check if this is still not persisted |
---|
22 | var newValue = prnt.find("input[id$=isNew]").attr('value'); |
---|
23 | //if it is new then i can safely remove from dom |
---|
24 | if(newValue == 'true'){ |
---|
25 | prnt.remove(); |
---|
26 | }else{ |
---|
27 | //set the deletedFlag to true |
---|
28 | delInput.attr('value','true'); |
---|
29 | //hide the div |
---|
30 | prnt.hide(); |
---|
31 | } |
---|
32 | }); |
---|
33 | |
---|
34 | jQuery(window).load(function() { |
---|
35 | if(ma_childCount == 0) { |
---|
36 | addChild(ma_wrapperId, ma_cloneId, ma_lazyList, ma_fields, ma_focusField, ma_childCount); |
---|
37 | ma_childCount++; |
---|
38 | } |
---|
39 | }); |
---|
40 | |
---|
41 | </script> |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | <div> |
---|
46 | <table> |
---|
47 | <thead> |
---|
48 | <tr> |
---|
49 | |
---|
50 | <th>Step</th> |
---|
51 | <th>Assembly</th> |
---|
52 | <th>Description</th> |
---|
53 | <th>Reasoning</th> |
---|
54 | <th></th> |
---|
55 | |
---|
56 | </tr> |
---|
57 | </thead> |
---|
58 | <tbody id="ma_wrapper"> |
---|
59 | <g:each var="ma" in="${taskProcedureInstance.maintenanceActions}" status="i"> |
---|
60 | <g:render template="maintenanceAction" model="['tp':taskProcedureInstance, |
---|
61 | 'ma': ma, |
---|
62 | 'i':i, |
---|
63 | 'assemblies': assemblies]" /> |
---|
64 | </g:each> |
---|
65 | </tbody> |
---|
66 | </table> |
---|
67 | </div> |
---|
68 | |
---|
69 | <br /> |
---|
70 | |
---|
71 | <div style="text-align:right;"> |
---|
72 | <span class="buttons add-ma"> |
---|
73 | <input type="button" class="add" value="Add MaintenanceAction" /> |
---|
74 | </span> |
---|
75 | </div> |
---|