Salome HOME
Fix for mantis #0022093: To exclude the "In-Draft" state from drop-down list during...
[tools/siman.git] / Workspace / Siman / WebContent / study / importDocument.jsp
index 8d8c00bf10cdbde0815e1f909be597eca8ce432b..8c7d22aa4303913358e69961f4d69d9974637653 100644 (file)
@@ -1,19 +1,40 @@
 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
 <%@ taglib prefix="s" uri="/struts-tags"%>
-<script>
+
+<script language="JavaScript">
+// Flags whether a validation cycle of a document type has Review state.
+var hasReview = new Array();
+<s:iterator value="reviewable" status="stat">
+hasReview[<s:property value="#stat.index"/>]=<s:property />;
+</s:iterator>
+
 $(document).ready(function () {
     $("#bring input[name='documentName']").focus();
-    <s:if test="%{reference != null}">
+    <s:if test="%{reference == null}">
         // if versioning then the document name and state can not be modified.
-        $("#bring input[name='documentName']").attr("disabled","disabled");
-        $("#bring input[name='documentState']").attr("disabled","disabled");
+        $("#bring input[name='documentName']").prop("disabled", false);
+        $("#bring input[name='documentState']").prop("disabled", false);
     </s:if>
+    $("#bring #documentType").change(function () {
+        // Hide or show inDraft according to the selected document type
+               if (hasReview[document.bring.documentType.selectedIndex]) {
+                 // Show inDraft
+                 $("#bring #documentState option[value='inDRAFT']").show();
+               } else {
+                 // Deselect inDraft if it is selected
+                 if (document.bring.documentState.value == 'inDRAFT') {
+                     document.bring.documentState.selectedIndex = 0;
+                 }
+                 // Hide inDraft
+                 $("#bring #documentState option[value='inDRAFT']").hide();
+               }
+       }).change();
 });
 </script>
 
 <!-- Import dialog
-     =============================================================================================================================
+     ===========================================================================
   -->
 <div id="article-box">
 <div id="section"><s:text name="title.import" /></div>
@@ -48,14 +69,10 @@ $(document).ready(function () {
        </tr>
        <tr>
                <td><s:select theme="simple" name="documentType"
-                       list="documentTypes" listKey="index"
+                       id="documentType" list="documentTypes" listKey="index"
                        listValue="%{getText('type.document.' + getName())}" /> &nbsp;</td>
-               <td><s:if test="%{reference != null}">
-                       <s:textfield theme="simple" id="documentName" name="documentName"
-                               disabled="" />
-               </s:if> <s:else>
-                       <s:textfield theme="simple" id="documentName" name="documentName" />
-               </s:else></td>
+               <td><s:textfield theme="simple" id="documentName"
+                       name="documentName" disabled="true" /></td>
        </tr>
        <s:if test="defaultDocumentUses.size > 0">
                <tr>
@@ -78,8 +95,7 @@ $(document).ready(function () {
                <td align="left"><s:submit theme="simple" name="save"
                        key="button.import" /> <s:select theme="simple" id="documentState"
                        name="documentState" list="documentStates" listKey="value"
-                       listValue="%{getText(key)}">
-               </s:select></td>
+                       listValue="%{getText(key)}" disabled="" /></td>
        </tr>
 </table>
 </form>