Salome HOME
Validation of the screens' input fields are implemented.
[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 </script>
46
47 <!-- Import dialog
48      ===========================================================================
49   -->
50 <div id="article-box">
51 <div id="section"><s:text name="title.import" /></div>
52 <div id="article-body" class="text">
53 <table width="100%" cellpadding="0" cellspacing="0" border="0"
54         class="text">
55         <tr height="25" valign="middle">
56                 <td><s:text name="message.upload">
57                         <s:param>
58                                 <s:property value="%{fileName}" />
59                         </s:param>
60                 </s:text></td>
61         </tr>
62         <tr height="1" bgcolor="#AAAAAA">
63                 <td></td>
64         </tr>
65 </table>
66
67 <s:form name="bring" id="bring" action="valid-import" method="post" validate="true" cssClass="text">
68 <s:hidden name="fileName" /> <s:hidden name="reference" /> <s:hidden
69         name="documentTitle" value="%{documentName}" /> <s:hidden
70         name="defaultDocumentType" value="%{documentType}" /> <s:hidden
71         name="defaultDocumentState" value="%{documentState}" /> <s:hidden
72         name="version" /> <s:hidden name="documentDate" />
73         <tr height="15">
74                 <td></td>
75         </tr>
76     <tr id="fieldError"/>
77         <tr>
78                 <td align="right"><s:text name="field.documentype" />&nbsp;&nbsp;</td>
79                 <td align="left">&nbsp;<s:text name="field.documentitle" />&nbsp;<span class="error">*</span></td>
80         </tr>
81         <tr>
82                 <td><s:select theme="simple" name="documentType"
83                         id="documentType" list="documentTypes" listKey="index"
84                         listValue="%{getText('type.document.' + getName())}" /> &nbsp;</td>
85                 <td><s:textfield theme="simple" id="documentName"
86                         name="documentName" disabled="true" /></td>
87         </tr>
88         <s:if test="defaultDocumentUses.size > 0">
89                 <tr>
90                         <td align="right"><s:text name="label.uses" />:</td>
91                 </tr>
92                 <s:iterator value="defaultDocumentUses">
93                         <tr>
94                                 <td align="right"><input type="checkbox" name="uses"
95                                         value="<s:property value="index"/>" checked></td>
96                                 <td><s:property value="title" /></td>
97                         </tr>
98                 </s:iterator>
99         </s:if>
100         <tr height="10">
101                 <td></td>
102         </tr>
103         <tr>
104                 <td align="right"><s:submit theme="simple" name="cancel"
105                         key="button.cancel" />&nbsp;</td>
106                 <td align="left"><s:submit theme="simple" name="save"
107                         key="button.import" /> <s:select theme="simple" id="documentState"
108                         name="documentState" list="documentStates" listKey="value"
109                         listValue="%{getText(key)}" disabled="" /></td>
110         </tr>
111 </s:form>
112 </div>
113 </div>