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
11 * Oliver Kopp - initial API and implementation and/or initial documentation
12 *******************************************************************************/
14 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
16 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
17 <%@taglib prefix="o" tagdir="/WEB-INF/tags/common/orioneditor"%>
18 <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
19 <%@taglib prefix="w" uri="http://www.eclipse.org/winery/repository/functions"%>
21 <%-- Upload functionality inspired by plans.jsp. That code could be generalized somehow in a .tag file --%>
23 <ul class="nav nav-tabs" id="myTab">
24 <li class="active"><a href="#description">Description</a></li>
25 <li><a href="#images">Images</a></li>
26 <li><a href="#options">Options</a></li>
27 <li><a href="#xml" id="showXMLTab">XML</a></li>
30 <div class="tab-content">
32 <div class="tab-pane active" id="description">
33 <div class="form-group">
34 <label class="label-form">Name</label>
35 <a href="#" class="form-control" data-send="always" id="displayName" data-url="selfserviceportal/displayname" data-tile="Enter Display Name">${it.application.displayName}</a>
38 <div class="form-group">
39 <label class="label-form">Description</label>
40 <div class="form-control" id="applicationDescriptionDiv">${it.application.description}</div>
44 <div class="tab-pane" id="images">
48 URL="selfserviceportal/icon.jpg"
55 URL="selfserviceportal/image.jpg"
62 <div class="tab-pane" id="options">
63 <button class="rightbutton btn btn-xs btn-danger" name="remove" onclick="deleteOnServerAndInTable(optionsTableInfo, 'Option', 'selfserviceportal/options/', 0, 1);">Remove</button>
64 <button class="rightbutton btn btn-xs btn-info" name="add" onclick="$('#addOptionDiag').modal('show');">Add</button>
65 <!-- <button class="rightbutton btn btn-xs btn-default" name="edit" onclick="openOptionEditor();">Edit</button> -->
67 <table id="optionsTable">
73 <th>Plan Service Name</th>
77 <c:if test="${not empty it.application}">
78 <c:forEach var="option" items="${it.application.options.option}">
81 <td>${option.name}</td>
82 <td><img src="selfserviceportal/options/${w:URLencode(option.id)}/icon.jpg" style="width:50px;"></td>
83 <td>${option.planServiceName}</td>
91 <div class="tab-pane" id="xml">
92 <o:orioneditorarea areaid="XML" url="selfserviceportal/" reloadAfterSuccess="true">${it.applicationAsXMLStringEncoded}</o:orioneditorarea>
98 function letUserChooseAFile() {
99 $('#fileInput').trigger('click');
100 $('#chooseBtn').focus();
103 $('#showXMLTab').on('shown.bs.tab', function (e) {
104 window.winery.orionareas['XML'].fixEditorHeight();
108 <div class="modal fade" id="addOptionDiag">
109 <div class="modal-dialog">
110 <div class="modal-content">
111 <div class="modal-header">
112 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
113 <h4 class="modal-title">Add Option</h4>
115 <div class="modal-body">
116 <form id="addOptionForm" enctype="multipart/form-data" action="selfserviceportal/options/" method="post">
117 <div class="form-group">
118 <label class="control-label">Name</label>
119 <input name="name" type="text" class="form-control" required="required">
122 <div class="form-group">
123 <label class="control-label">Description</label>
124 <textarea id="optionDescription" name="description" class="form-control" required="required"></textarea>
127 <div class="form-group">
128 <label class="control-label" for="fileDiv">Icon</label>
129 <div style="display: block; width: 100%" id="iconDiv">
130 <input id="fileInput" name="file" type="file" style="display:none" accept="image/*">
131 <input name="fileText" id="fileText" type="text" class="form-control" style="width:300px; display:inline;" onclick="letUserChooseAFile();" required="required">
132 <button type="button" id="chooseBtn" class="btn btn-default btn-xs" onclick="letUserChooseAFile();">Choose</button>
136 <div class="form-group">
137 <label class="control-label">Plan Service Name</label>
138 <input name="planServiceName" type="text" class="form-control" required="required">
141 <div class="form-group">
142 <label class="control-label">Plan Input Message</label>
143 <textarea name="planInputMessage" class="form-control" required="required" rows="20"><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
144 <soapenv:Header/>
146 </soapenv:Body>
147 </soapenv:Envelope></textarea>
152 <div class="modal-footer">
153 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
154 <button type="button" class="btn btn-primary" data-loading-text="Uploading..." id="addOptionBtn">Add</button>
162 $("#displayName").editable({
163 ajaxOptions: {type: "PUT"},
164 success: function() {
165 vShowSuccess("Successfully updated display name");
167 error: function(response) {
168 vShowError("Could not update display name: " + response.status + " " + response.responseText);
172 $("#applicationDescriptionDiv").editable({
175 url: "selfserviceportal/description",
176 ajaxOptions: {type: "PUT"},
177 success: function() {
178 vShowSuccess("Successfully updated description");
180 error: function(response) {
181 vShowError("Could not update description: " + response.status + " " + response.responseText);
185 $("#optionDescription").wysihtml5();
187 var optionsTableInfo = {
191 $('#myTab a').click(function (e) {
197 // initialize table and hide first column
198 require(["winery-support"], function(ws) {
199 ws.initTable(optionsTableInfo, {
201 { "bSearchable": false, "bVisible": false, "aTargets": [ 0 ] }
206 $("#addOptionDiag").on("hidden.bs.modal", function() {
207 // we currently do not send data back from the server
208 // we emulate the AJAX refresh by a reaload
209 doTheTabSelection(function() {
210 $('#myTab a[href="#options"]').tab('show');
215 function createOption(data) {
216 if (highlightRequiredFields()) {
217 vShowError("Please fill out all required fields");
223 requirejs(["jquery.fileupload"], function(){
224 $('#addOptionForm').fileupload({
225 // dropping should only be available in the addOptionDialog. This, however, does not work correctly
226 dropZone: $("#addOptionDiag")
227 }).bind("fileuploadadd", function(e, data) {
228 $.each(data.files, function (index, file) {
229 $("#fileText").val(file.name);
231 $("#addOptionBtn").off("click");
232 $("#addOptionBtn").on("click", function() {
235 }).bind("fileuploadstart", function(e) {
236 $("#addOptionBtn").button("loading");
237 }).bind('fileuploadfail', function(e, data) {
238 vShowAJAXError("Could not add option", data.jqXHR, data.errorThrown);
239 $("#addOptionBtn").button("reset");
240 }).bind('fileuploaddone', function(e, data) {
241 vShowSuccess("Option created successfully.");
243 // reset the add button
244 $("#addOptionBtn").button("reset");
245 // do not allow submission of the old files on a click if the dialog is opened another time
246 $("#addOptionBtn").off("click");
249 //embeddedPlansTableInfo.table.fnAddData(data.result.tableData);
250 // current workaround: event on hidden.bs.modal
252 $('#addOptionDiag').modal('hide');