Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / wizard_javascript.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal SDK
4   ================================================================================
5   Copyright (C) 2017 AT&T Intellectual Property
6   ================================================================================
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18   ================================================================================
19   --%>
20 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportDefinition" %>
21 <%@ page import="org.openecomp.portalsdk.analytics.util.AppConstants"%>
22 <%@ page import="org.openecomp.portalsdk.analytics.controller.WizardSequence"%>
23 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.FormFieldType"%>
24 <%@ page import="java.util.Iterator"%>
25 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.JavascriptItemType"%>
26 <%@ page import="org.openecomp.portalsdk.analytics.system.AppUtils"%>
27
28 <% 
29    ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
30    WizardSequence ws = rdef.getWizardSequence();
31    FormFieldType fft = null;
32    boolean isFormfieldPresent = (rdef.getFormFieldList()!=null && rdef.getFormFieldList().getFormField().size()<=0);
33 %>
34
35 <table width="100%" class="tableBorder" border="0" cellspacing="1" cellpadding="3" align=center>
36         <tr>
37                 <td class=rbg1 valign="top"><b class=rtableheader>Step <%= ws.getCurrentStepIndex() %> of <%= ws.getStepCount() %> - <%= ws.getCurrentStep() %> Wizard <%= isFormfieldPresent?" <a href=\"javascript:uitmpl_qh('javascript_text'); if(typeof window.parent.resizeWindow == 'function') window.parent.resizeWindow();\" class=\"qh-link\" style=\"position:fixed;\"></a>":""%></b></td>
38         </tr>
39       <% if(isFormfieldPresent) { %>      
40            <tr>
41                 <td class="nopad"><!-- quick help text -->
42                 <div id="javascript_text" class="mQH">
43                         <p><span class="label">Form Field Information:<BR></span>
44                            <table>
45                          <%
46                             
47                         for(Iterator iter1=rdef.getFormFieldList().getFormField().iterator(); iter1.hasNext();) { 
48                                 fft = (FormFieldType) iter1.next(); 
49                          %>
50                                 
51                                 <%= "<TR><TD align=\"right\">" +  fft.getFieldName() +":</TD><TD>&nbsp;</TD><TD>document.formd." + fft.getFieldId()+"</TD></TR>" %> 
52                          <% } 
53                          %> 
54                           </table>  
55                         </p>
56                 </div>
57                 <!-- /quick help text --></td>          
58         </tr>
59            <% } %>
60         <tr>
61                 <td  width="65%" class=rbg3 align="center">
62                         <textarea name="<%= AppConstants.RI_JAVASCRIPT%>" cols="100" rows="30"><%= (rdef.getJavascriptElement()!=null)?rdef.getJavascriptElement():"" %></textarea> 
63                 </td>
64         </tr> 
65     <tr>
66                 <table class=mTAB width="100%" class="tableBorder" border="3" cellspacing="1" cellpadding="3" align=center>
67                         <tr class=rbg1>
68                                 <td align="center" valign="Middle" width="7%" height="30"><b class=rtableheader>&nbsp;&nbsp;No&nbsp;&nbsp;</b></td>
69                                 <td align="center" valign="Middle" width="7%"><b class=rtableheader>Form Field</b></td>
70                                 <td align="center" valign="Middle" width="72%"><b class=rtableheader>Calling Javascript</b></td>
71                                 <td align="center" valign="Middle" width="14%">
72                                    &nbsp;
73                  </td>
74                         </tr>
75             <%
76             int iCount = 0;
77             String javascriptFieldId = "";
78             String id = "";
79             String callText = "";
80             
81             int count = 0;
82             if(rdef.getJavascriptList()!=null )  {
83                 for(Iterator iter=rdef.getJavascriptList().getJavascriptItem().iterator(); iter.hasNext(); ) { 
84                         count++;
85                         JavascriptItemType javascriptItem = (JavascriptItemType) iter.next();
86                         id = javascriptItem.getId();
87                         javascriptFieldId = javascriptItem.getFieldId();
88                         callText = javascriptItem.getCallText();
89                 %> 
90                         <tr class=<%=(count%2==0)?"rowalt2":"rowalt1"%>> 
91                                 <td align="center" height="30"><font class=rtabletext><%= ++iCount %></font></td>
92                                 <td align="center" >
93                  <select name="javascriptFormField-<%=id %>" style="width: 100px">
94                                 <option value="-1"> <-- SELECT --> </option>
95                                         <option value="ol1" <%= ("ol1".equals(javascriptFieldId))?" selected":""%>>OnLoad</option>
96                         <option value="os1" <%= ("os1".equals(javascriptFieldId))?" selected":""%>>OnSubmit</option>
97
98
99                       <%
100                       if(rdef.getFormFieldList()!=null){
101                         for(Iterator iter1=rdef.getFormFieldList().getFormField().iterator(); iter1.hasNext();) { 
102                                 fft = (FormFieldType) iter1.next(); 
103                                 %>
104                                         <option value="<%=fft.getFieldId() %>" <%= (fft.getFieldId().equals(javascriptFieldId))?" selected":""%>><%=fft.getFieldName() %></option>
105                                 <%                                      
106                       }
107                       }
108                      %> 
109                       
110                                 </select>
111                                 </td>
112                                 <td align="center">
113                                         <textarea name="callText-<%=id %>" rows="3" cols="100"><%=callText %></textarea>        
114                                 </td>
115                 <td width="30%"> 
116                   <button type="submit" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_SAVE %>'; document.forma.<%=AppConstants.RI_JAVASCRIPT_ITEM_ID %>.value='<%= id %>'; document.forma.submit();" width="12" height="12"   att-button btn-type="primary" size="small" title='Save'>Save</button>
117                   <button type="submit" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE %>'; document.forma.<%=AppConstants.RI_JAVASCRIPT_ITEM_ID %>.value='<%= id %>'; document.forma.submit();" width="12" height="12"   att-button btn-type="primary" size="small" title='Delete'>Delete</button>
118                 </td>
119                         </tr>
120                         <% } %>
121                         <% } 
122              
123              id = "-1";
124              %>
125                         <tr class=rowalt1>
126                                 <td align="center" height="30"><font class=rtabletext><%= ++iCount %></font></td>
127                                 <td align="center">
128                  <select name="javascriptFormField-<%=id %>" style="width: 100px">
129                                 <option value="-1"> <-- SELECT --> </option>
130                                         <option value="ol1">OnLoad</option>
131                                         <option value="os1">OnSubmit</option>
132                                         
133                       <%
134                       if(rdef.getFormFieldList()!=null){
135                         for(Iterator iter1=rdef.getFormFieldList().getFormField().iterator(); iter1.hasNext();) { 
136                                 fft = (FormFieldType) iter1.next(); 
137                                 %>
138                                         <option value="<%=fft.getFieldId() %>"><%=fft.getFieldName() %></option>
139                                 <%                                      
140                       }
141                       }
142                       %>
143                                 </select>
144                                 </td>
145                                 <td align="center">
146                                         <textarea name="callText-<%=id %>" rows="3" cols="100"></textarea>              
147                                 </td>
148                 <td width="40%"> 
149                   <button type="submit" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_SAVE %>'; document.forma.<%=AppConstants.RI_JAVASCRIPT_ITEM_ID %>.value='<%= id %>'; document.forma.submit();" width="12" height="12"   att-button btn-type="primary" size="small" title='Save'>Save</button>
150                   <button type="submit" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE %>'; document.forma.<%=AppConstants.RI_JAVASCRIPT_ITEM_ID %>.value='<%= id %>'; document.forma.submit();" width="12" height="12"   att-button btn-type="primary" size="small" title='Delete'>Delete</button>
151                 </td>
152                         </tr>
153                 </table>        
154         </tr>  
155         
156 <%!
157         private String nvl(String s)                  { return (s==null)?"":s; }
158         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } 
159 %>
160
161 <script language="JavaScript">
162 <!--
163 function dataValidate() {
164  return true;
165 }   // dataValidate
166 //-->
167 </script>