Merge "Inherit from oparent"
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / webapp / jsp / entitytypes / instancestates.jsp
1 <%--
2 /*******************************************************************************
3  * Copyright (c) 2012-2013 University of Stuttgart.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * and the Apache License 2.0 which both accompany this distribution,
7  * and are available at http://www.eclipse.org/legal/epl-v10.html
8  * and http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Contributors:
11  *    Oliver Kopp - initial API and implementation and/or initial documentation
12  *    Yves Schubert - switch to bootstrap 3
13  *******************************************************************************/
14 --%>
15 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
16
17 <div class="modal fade" id="addStateDiag">
18         <div class="modal-dialog">
19                 <div class="modal-content">
20                         <div class="modal-header">
21                                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
22                                 <h4 class="modal-title">Add State</h4>
23                         </div>
24                         <div class="modal-body">
25                                 <form id="addPropertyForm" enctype="multipart/form-data" method="post">
26                                         <div class="row">
27                                                 <label>
28                                                         State: <input name="state" id="state" type="text" />
29                                                 </label>
30                                         </div>
31                                 </form>
32                         </div>
33                         <div class="modal-footer">
34                                 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
35                                 <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="createState();">Add</button>
36                         </div>
37                 </div>
38         </div>
39 </div>
40
41 <div id="Properties">
42         <button class="rightbutton btn btn-danger btn-xs" type="button" onclick="deleteOnServerAndInTable(propertiesTableInfo, 'InstanceState', 'instancestates/');">Remove</button>
43         <button class="rightbutton btn btn-primary btn-xs" type="button" onclick="$('#addStateDiag').modal('show');">Add</button>
44
45         <table cellpadding="0" cellspacing="0" border="0" class="display" id="propertiesTable">
46                 <thead>
47                         <tr>
48                                 <th>State</th>
49                         </tr>
50                 </thead>
51                 <tbody>
52                         <c:forEach var="t" items="${it.instanceStates}">
53                                 <tr>
54                                         <td>${t}</td>
55                                 </tr>
56                         </c:forEach>
57                 </tbody>
58         </table>
59 </div>
60
61 <script>
62 var propertiesTableInfo = {
63                 id: '#propertiesTable'
64 };
65
66 require(["winery-support"], function(ws) {
67         ws.initTable(propertiesTableInfo);
68 });
69
70 function createState() {
71         $.ajax({
72                 url: "instancestates/",
73                 type: "POST",
74                 async: false,
75                 data: $('#addPropertyForm').serialize(),
76                 error: function(jqXHR, textStatus, errorThrown) {
77                         vShowError("Could not add instancestate: " + errorThrown + "<br/>" + jqXHR.responseText);
78                 },
79                 success: function(data, textStatus, jqXHR) {
80                         var dataToAdd = [$('#state').val()];
81                         propertiesTableInfo.table.fnAddData(dataToAdd);
82                         $('#addStateDiag').modal('hide');
83                 }
84         });
85 }
86 </script>