Skip to content

Commit

Permalink
fix(projectportlet): fix issue sw360#417
Browse files Browse the repository at this point in the history
closes sw360#417

Signed-off-by: Maximilian Huber <[email protected]>
  • Loading branch information
maxhbr committed May 26, 2017
1 parent c38e31d commit 74a2754
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ public class PortalConstants {
public static final String UPDATE_VULNERABILITIES__UPDATED_IDS = "updateVulnerabilities_updatedIds";

//custom map keywords
public static final String CUSTOM_MAP = "customMap";
public static final String CUSTOM_MAP_KEY = "customMapKey";
public static final String CUSTOM_MAP_VALUE = "customMapValue";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ private void prepareComponentEdit(RenderRequest request) {
addEditDocumentMessage(request, permissions, documentState);
Set<String> releaseIds = SW360Utils.getReleaseIds(component.getReleases());
setUsingDocs(request, user, client, releaseIds);
request.setAttribute(CUSTOM_MAP, component.isSetRoles() ? component.roles : Collections.emptyMap());
} catch (TException e) {
log.error("Error fetching component from backend!", e);
setSW360SessionError(request, ErrorMessages.ERROR_GETTING_COMPONENT);
Expand All @@ -395,7 +394,6 @@ private void prepareComponentEdit(RenderRequest request) {
setUsingDocs(request, user, null, component.getReleaseIds());
setAttachmentsInRequest(request, component.getAttachments());
SessionMessages.add(request, "request_processed", "New Component");
request.setAttribute(CUSTOM_MAP, Collections.emptyMap());
}
}
}
Expand Down Expand Up @@ -425,7 +423,6 @@ private void prepareReleaseEdit(RenderRequest request, RenderResponse response)
Map<RequestedAction, Boolean> permissions = release.getPermissions();
DocumentState documentState = release.getDocumentState();
setUsingDocs(request, releaseId, user, client);
request.setAttribute(CUSTOM_MAP, release.isSetRoles() ? release.roles : Collections.emptyMap());
addEditDocumentMessage(request, permissions, documentState);

if (isNullOrEmpty(id)) {
Expand All @@ -442,7 +439,6 @@ private void prepareReleaseEdit(RenderRequest request, RenderResponse response)
putDirectlyLinkedReleaseRelationsInRequest(request, release.getReleaseIdToRelationship());
setAttachmentsInRequest(request, release.getAttachments());
setUsingDocs(request, null, user, client);
request.setAttribute(CUSTOM_MAP, Collections.emptyMap());
SessionMessages.add(request, "request_processed", "New Release");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,6 @@ private void prepareProjectEdit(RenderRequest request) {
return;
}

request.setAttribute(CUSTOM_MAP, project.isSetRoles() ? project.roles : Collections.emptyMap());
request.setAttribute(USING_PROJECTS, usingProjects);
Map<RequestedAction, Boolean> permissions = project.getPermissions();
DocumentState documentState = project.getDocumentState();
Expand All @@ -829,7 +828,6 @@ private void prepareProjectEdit(RenderRequest request) {
log.error("Could not put empty linked projects or linked releases in projects view.", e);
}
request.setAttribute(USING_PROJECTS, Collections.emptySet());
request.setAttribute(CUSTOM_MAP, Collections.emptyMap());

SessionMessages.add(request, "request_processed", "New Project");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
<core_rt:set var="mapTitle" value="Additional Roles"/>
<core_rt:set var="inputType" value="email"/>
<core_rt:set var="inputSubtitle" value="Enter mail address"/>

<core_rt:set var="customMap" value="${release.roles}"/>
<%@include file="/html/utils/includes/mapEdit.jspf" %>
<%@include file="/html/components/includes/releases/editReleaseRepository.jspf" %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@
<core_rt:set var="mapTitle" value="Additional Roles"/>
<core_rt:set var="inputType" value="email"/>
<core_rt:set var="inputSubtitle" value="Enter mail address"/>

<core_rt:set var="customMap" value="${component.roles}"/>
<%@include file="/html/utils/includes/mapEdit.jspf" %>
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
<core_rt:set var="mapTitle" value="Additional Roles"/>
<core_rt:set var="inputType" value="email"/>
<core_rt:set var="inputSubtitle" value="Enter mail address"/>

<core_rt:set var="customMap" value="${project.roles}"/>
<%@include file="/html/utils/includes/mapEdit.jspf" %>


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,85 @@
<%--
~ Copyright (c) Bosch Software Innovations GmbH 2016.
~ Copyright (c) Bosch Software Innovations GmbH 2016-2017.
~
~ All rights reserved. This program and the accompanying materials
~ are made available under the terms of the Eclipse Public License v1.0
~ which accompanies this distribution, and is available at
~ http://www.eclipse.org/legal/epl-v10.html
--%>

<script src="<%=request.getContextPath()%>/js/external/jquery.validate.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/external/additional-methods.min.js" type="text/javascript"></script>

<table class="table info_table" id="mapEditTable">
<thead>
<tr>
<th colspan="3" class="headlabel">${mapTitle}</th>
</tr>
</thead>
<tbody>
<%@include file="/html/utils/ajax/mapEditBody.jsp" %>
<core_rt:if test="${customMap != null}">
<core_rt:forEach items="${customMap.entrySet()}" var="mapEntry" varStatus="loop1">
<core_rt:forEach items="${mapEntry.value}" var="setItem" varStatus="loop2">
<tr id="mapEditTableRow${loop1.count}_${loop2.count}" >
<td width="46%">
<select class="toplabelledInput" id="<%=PortalConstants.CUSTOM_MAP_KEY%>${loop1.count}_${loop2.count}"
name="<portlet:namespace/><%=PortalConstants.CUSTOM_MAP_KEY%>${loop1.count}_${loop2.count}"
style="min-width: 162px; min-height: 28px;">

<core_rt:forEach items="${keys}" var="key">
<option value="${key}" class="textlabel stackedLabel" <core_rt:if
test='${mapEntry.key == key}'>selected="selected"</core_rt:if>> ${key} </option>
</core_rt:forEach>
</select>
</td>
<td width="46%">
<input id="<%=PortalConstants.CUSTOM_MAP_VALUE%>${loop1.count}_${loop2.count}" name="<portlet:namespace/><%=PortalConstants.CUSTOM_MAP_VALUE%>${loop1.count}_${loop2.count}" type="email" class="toplabelledInput" placeholder="${inputSubtitle}" title="${inputSubtitle}"
value="<sw360:out value='${setItem}'/>"/>
</td>

<td class="deletor">
<img src="<%=request.getContextPath()%>/images/Trash.png"
onclick="deleteMapItem('mapEditTableRow${loop1.count}_${loop2.count}')"
alt="Delete">
</td>
</tr>
</core_rt:forEach>
</core_rt:forEach>
</core_rt:if>
</tbody>
</table>

<input type="button" class="addButton" onclick="addRowToMapEditTable();" value="Click to add row to ${mapTitle} "/>
<br/>
<br/>

<script>
function deleteMapItem(rowId) {
function deleteMapItemInternal() {
$('#' + rowId).remove();
};

deleteConfirmed("Do you really want to remove this item?", deleteMapItemInternal);
}

function addRowToMapEditTable() {
var randomRowId = "mapItemRow" + Date.now();
var newRowAsString =
'<tr id="' + randomRowId + '" >'+
'<td width="46%">'+
'<select class="toplabelledInput" id="<%=PortalConstants.CUSTOM_MAP_KEY%>'+randomRowId+'" name="<portlet:namespace/><%=PortalConstants.CUSTOM_MAP_KEY%>'+randomRowId+'" style="min-width: 162px; min-height: 28px;">' +
<core_rt:forEach items="${keys}" var="key">
'<option value="${key}" class="textlabel stackedLabel"> ${key} </option>'+
</core_rt:forEach>
'</select>'+
'</td>'+
'<td width="46%">'+
'<input id="<%=PortalConstants.CUSTOM_MAP_VALUE%>'+randomRowId+'" name="<portlet:namespace/><%=PortalConstants.CUSTOM_MAP_VALUE%>'+randomRowId+'" type="email" class="toplabelledInput" placeholder="${inputSubtitle}" title="${inputSubtitle}" />'+
'</td>'+
'<td class="deletor">'+
'<img src="<%=request.getContextPath()%>/images/Trash.png" onclick="deleteMapItem(\''+ randomRowId +'\')" alt="Delete">' +
'</td>'+
'</tr>';
$('#mapEditTable tr:last').after(newRowAsString);
}
</script>

0 comments on commit 74a2754

Please sign in to comment.