Salome HOME
- Back-arrow is added when the user selects the new product on the new study screen
[tools/siman.git] / Workspace / Siman / WebContent / study / newStudy.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 <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
5 <tiles:importAttribute name="valid_action" scope="request" />
6
7 <script language="JavaScript">
8         function initialize() {
9                 create.elements[0].focus();
10         }
11
12         function setValue() {
13                 var select = create.projectContextId.value; // contextValue select input
14                 if (select == "0") { // Creation of a new context type
15                         tds = document.getElementById("select");
16                         tde = document.getElementById("enter");
17                         tds.style.display = "none"; // Hides the select input
18                         tde.style.display = "block"; // Displays the text input
19                 }
20                 create.projectContext.focus();
21         }
22         
23     function setDefaultSelection() {
24         tds = document.getElementById("select");
25         tde = document.getElementById("enter");
26         tds.style.display = "block"; // Hides the select input
27         tde.style.display = "none"; // Displays the text input
28         
29         create.projectContextId.value = -1;
30         create.projectContextId.focus();
31     }
32
33         $(document).ready(function() {
34         <s:if test="projectContextValues.size > 0">
35                 create.projectContextId.value = <s:property value="projectContextId"/>;
36         </s:if>
37                 setValue();
38                 
39                 //Studied product validation (based on struts-generated validation)
40             //relies on javascript included by 'validate="true"' for displaying error messages
41             document.getElementById("create").addEventListener('submit', function(event) {   //cross-browser solution
42                 form = document.getElementById("create");
43         
44                 var errors = false;
45                 var continueValidation = true;
46                         
47                 // field name: product
48                 // custom validation function
49                 if (form.elements['projectContext'] && form.elements['projectContextId']) {
50                     field = form.elements['projectContext'];
51                     id = form.elements['projectContextId'];
52                     var error = "The field \'Studied product\' must be filled";
53                     if (continueValidation
54                             && id.value != null && (
55                                 (id.value == 0
56                                    && field.value != null 
57                                    && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)
58                                 )
59                                 || id.value == -1
60                             )
61                         ) {
62                         addError(field, error);
63                         errors = true;
64                     }
65                 }
66                 if(errors) {
67                     event.preventDefault();    //cross-browser solution
68                 }
69             });
70         });
71 </script>
72
73 <!-- New study dialog
74      ===========================================================================
75   -->
76 <div id="article-box">
77         <div id="section">
78                 <s:text name="title.newstudy" />
79         </div>
80         <div id="top-spacer"></div>
81         <s:form id="create" name="create"
82                 action="%{#request.valid_action}" method="post" validate="true" cssClass="text">
83
84                         <tr class="error">
85                                 <td colspan="3"><s:text name="%{error}" /></td>
86                         </tr>
87
88                         <tr>
89                                 <td>&nbsp;<s:text name="field.studytitle" />:&nbsp;<span class="error">*</span>
90                                 </td>
91                                 <td><s:textfield theme="simple" size="60" name="title" /></td>
92                         </tr>
93
94                         <tr>
95                                 <td>&nbsp;<s:text name="field.product" />:&nbsp;<span class="error">*</span>
96                                 </td>
97                                 <s:if test="projectContextValues.size > 0">
98                                         <td id="select"><select name="projectContextId"
99                                                 style="width: 214px" onChange="setValue()">
100                                                         <option value="-1">
101                                                                 <s:text name="menu.select" />
102                                                         </option>
103                                                         <option value="0">
104                                                                 &nbsp;
105                                                                 <s:text name="menu.newproduct" />
106                                                         </option>
107                                                         <optgroup label="&nbsp;<s:text name="label.products"/>">
108                                                                 <s:iterator value="projectContextValues">
109                                                                         <option value="<s:property value="index"/>">
110                                                                                 &nbsp;
111                                                                                 <s:property value="value" />
112                                                                         </option>
113                                                                 </s:iterator>
114                                                         </optgroup>
115                                         </select></td>
116                                         <td id="enter" style="display: none">
117                                            <s:textfield theme="simple" size="30" name="projectContext" />
118                                <img src="<s:url value="/skin/icon.undo.png"/>" border="none" 
119                                        title="<s:text name="tooltip.cancel"/>"
120                                        onclick="setDefaultSelection()"/>
121                             </td>
122                                 </s:if>
123                                 <s:else>
124                                         <td><s:hidden name="projectContextId" value="0" /> <s:textfield
125                                                         theme="simple" size="30" name="projectContext" /></td>
126                                 </s:else>
127                         </tr>
128                         <tiles:insertAttribute name="source_study" ignore="true" />
129
130                         <tr>
131                                 <td align="right" colspan="2"><s:submit
132                                                 theme="simple" type="button"
133                                                 key="button.newstudy" /></td>
134                         </tr>
135
136         </s:form>
137         <div id="top-spacer"></div>
138 </div>
139
140 <!-- Reserved
141   -->
142 <div id="right-pane"></div>
143 <div id="bottom-spacer"></div>