0b1027718f423e6514bb3af42e7b254b01ba04b9
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / webapp / jsp / entitytypes / requirementtypes / requiredcapabilitytype.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  *******************************************************************************/
13 --%>
14
15 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
16 <%@taglib prefix="ct" tagdir="/WEB-INF/tags/common" %>
17
18 <c:choose>
19         <c:when test="${empty it.requirementType.requiredCapabilityType}">
20                 <c:set var="selected" value="(none)" />
21         </c:when>
22         <c:otherwise>
23                 <c:set var="selected" value="${it.requirementType.requiredCapabilityType}" />
24         </c:otherwise>
25 </c:choose>
26
27 <ct:QNameChooser allQNames="${it.allCapabilityTypes}" idOfSelectField="requiredCapabilityType" labelOfSelectField="" includeNONE="true" selected="${selected}"/>
28
29 <script>
30 $("#requiredCapabilityType").on("change", function(e) {
31         var val = $("#requiredCapabilityType").val();
32         if (val == "(none)") {
33                 // remove required capability type assignment
34                 $.ajax({
35                         url: 'requiredcapabilitytype',
36                         type: "DELETE"
37                 }).fail(function(jqXHR, textStatus, errorThrown) {
38                         vShowAJAXError("Could not remove required capability type assignment.", jqXHR, errorThrown);
39                 }).done(function(data, textStatus, jqXHR) {
40                         vShowSuccess("Successfully updated required capability type assignment.");
41                 });
42         } else {
43                 // put new capability type
44                 $.ajax({
45                         url: 'requiredcapabilitytype',
46                         data: val,
47                         contentType: "text/plain",
48                         type: "PUT"
49                 }).fail(function(jqXHR, textStatus, errorThrown) {
50                         vShowAJAXError("Could not update required capability type assignment.", jqXHR, errorThrown);
51                 }).done(function(data, textStatus, jqXHR) {
52                         vShowSuccess("Successfully updated required capability type assignment.");
53                 });
54         }
55 });
56 </script>