Salome HOME
Update uses list functionality
[tools/siman.git] / Workspace / Siman / WebContent / study / importDocument.jsp
1 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2         pageEncoding="ISO-8859-1"%>
3 <%@ taglib prefix="s" uri="/struts-tags"%>
4
5 <script language="JavaScript">
6 // Flags whether a validation cycle of a document type has Review state.
7 var hasReview = new Array();
8 <s:iterator value="reviewable" status="stat">
9 hasReview[<s:property value="#stat.index"/>]=<s:property />;
10 </s:iterator>
11
12 $(document).ready(function () {
13     $("#bring input[name='documentName']").focus();
14     <s:if test="%{reference == null}">
15         // if versioning then the document name and state can not be modified.
16         $("#bring input[name='documentName']").prop("disabled", false);
17         $("#bring input[name='documentState']").prop("disabled", false);
18     </s:if>
19     $("#bring #documentType").change(function () {
20         // Hide or show inDraft according to the selected document type
21                 if (hasReview[document.bring.documentType.selectedIndex]) {
22                   // Show inDraft
23                   $("#bring #documentState option[value='inDRAFT']").show();
24                 } else {
25                   // Deselect inDraft if it is selected
26                   if (document.bring.documentState.value == 'inDRAFT') {
27                       document.bring.documentState.selectedIndex = 0;
28                   }
29                   // Hide inDraft
30                   $("#bring #documentState option[value='inDRAFT']").hide();
31                 }
32         }).change();
33         
34     //hack for displaying document title error message above field labels
35         var done=false;
36         bring.addEventListener("DOMNodeInserted", function(e) {
37            if(done) {
38            done = false;
39            } else {
40            done = true;
41                $('[errorfor="documentName"]').insertAfter($('#fieldError'));
42            }
43         });
44 });
45
46 $(document).ready(function () {
47         $("#bring #documentType").change(function () {          
48                  $.ajax({
49                          type: 'POST',
50                          url:'update-uses.action?documentType=' + $('#documentType').val(),
51                          success: function(data){                
52                                 $("#bring .dynamic").remove();
53                                 $(data).insertBefore("#bring .inner");                          
54                          }                       
55                  });             
56         }
57 )}).change();
58 </script>
59
60 <!-- Import dialog
61      ===========================================================================
62   -->
63 <div id="article-box">
64 <div id="section"><s:text name="title.import" /></div>
65 <div id="article-body" class="text">
66 <table width="100%" cellpadding="0" cellspacing="0" border="0"
67         class="text">
68         <tr height="25" valign="middle">
69                 <td><s:text name="message.upload">
70                         <s:param>
71                                 <s:property value="%{fileName}" />
72                         </s:param>
73                 </s:text></td>
74         </tr>
75         <tr height="1" bgcolor="#AAAAAA">
76                 <td></td>
77         </tr>
78 </table>
79
80 <s:form name="bring" id="bring" action="valid-import" method="post" validate="true" cssClass="text">
81 <s:hidden name="fileName" /> <s:hidden name="reference" /> <s:hidden
82         name="documentTitle" value="%{documentName}" /> <s:hidden
83         name="defaultDocumentType" value="%{documentType}" /> <s:hidden
84         name="defaultDocumentState" value="%{documentState}" /> <s:hidden
85         name="version" /> <s:hidden name="documentDate" />
86         <tr height="15">
87                 <td></td>
88         </tr>
89     <tr id="fieldError"/>
90         <tr>
91                 <td align="right"><s:text name="field.documentype" />&nbsp;&nbsp;</td>
92                 <td align="left">&nbsp;<s:text name="field.documentitle" />&nbsp;<span class="error">*</span></td>
93         </tr>
94         <tr>
95                 <td><s:select theme="simple" name="documentType"
96                         id="documentType" list="documentTypes" listKey="index"
97                         listValue="%{getText('type.document.' + getName())}" /> &nbsp;</td>
98                 <td><s:textfield theme="simple" id="documentName"
99                         name="documentName" disabled="true" /></td>
100         </tr>
101                                 <s:if test="defaultDocumentUses.size > 0">
102                                 <tr class="dynamic">
103                                         <td align="right"><s:text name="label.uses" />:</td>
104                                 </tr>
105                                 <s:iterator value="defaultDocumentUses">
106                                         <tr class=dynamic>
107                                                 <td align="right"><input type="checkbox" name="uses"
108                                                         value="<s:property value="index"/>" checked></td>
109                                                 <td><s:property value="title" /></td>
110                                         </tr>
111                                 </s:iterator>
112                         </s:if>
113
114                         <tr height="10" class ="inner">
115                 <td></td>
116         </tr>
117         <tr>
118                 <td align="right">
119                         <s:a action="step-study">
120                 <button type='button'><s:text name="button.cancel"/></button>
121             </s:a>&nbsp;
122                 </td>
123                 <td align="left"><s:submit theme="simple" name="save"
124                         key="button.import" /> <s:select theme="simple" id="documentState"
125                         name="documentState" list="documentStates" listKey="value"
126                         listValue="%{getText(key)}" disabled="" /></td>
127         </tr>
128 </s:form>
129 </div>
130 </div>