Skip to content

Commit

Permalink
Merge pull request #1505 from toshiba/releases/feature-improve_additi…
Browse files Browse the repository at this point in the history
…onal_data_for_component_and_release

fix(ui): Display url, email, text  of Additional Data for Component/Release

reviewed-by: abdul.kapti@siemens-healthineers.com
tested-by: abdul.kapti@siemens-healthineers.com
  • Loading branch information
Abdul Kapti authored May 25, 2022
2 parents 2a1f3c9 + 8ead75c commit 011762a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<script>
document.title = $("<span></span>").html("<sw360:out value='${component.name}'/> - " + document.title).text();

require(['jquery', 'modules/button', 'modules/listgroup', 'utils/link', 'utils/includes/clipboard'], function($, button, listgroup, linkutil, clipboard) {
require(['jquery', 'components/includes/releases/regexjs','modules/button', 'modules/listgroup', 'utils/link', 'utils/includes/clipboard'], function($,regexjs, button, listgroup, linkutil, clipboard) {
listgroup.initialize('detailTab', $('#detailTab').data('initial-tab') || 'tab-Summary');

$('#mergeButton').on('click', function(event) {
Expand Down Expand Up @@ -213,5 +213,18 @@
textToCopy = $(textSelector).clone().children().remove().end().text().trim();
clipboard.copyToClipboard(textToCopy, textSelector);
});

let keyComponent, valueComponent;
renderDataComponent();
function renderDataComponent() {
let content = '';
<core_rt:forEach items="${component.additionalData}" var="additional">
keyComponent = '<sw360:out value='${additional.key}'/>';
valueComponent = '<sw360:out value='${additional.value}'/>';
content+=regexjs.regex(keyComponent,valueComponent);
</core_rt:forEach>
$('#list-data-additional-contentComponent').append(content);
}
});

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</tr>
<tr>
<td><liferay-ui:message key="additional.data" />:</td>
<td><sw360:DisplayMap value="${component.additionalData}"/></td>
<td><ul id="list-data-additional-contentComponent" class="mapDisplayRootItem"></ul> </td>
</tr>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<script>
document.title = $("<span></span>").html("<sw360:out value='${component.name}'/> - " + document.title).text();

require(['jquery', 'components/includes/releases/linkProject', 'modules/button', 'modules/listgroup', 'utils/includes/clipboard'], function($, linkProject, button, listgroup, clipboard) {
require(['jquery','components/includes/releases/regexjs','components/includes/releases/linkProject', 'modules/button', 'modules/listgroup', 'utils/includes/clipboard'], function($,regexjs,linkProject, button, listgroup, clipboard) {
linkProject.initialize();
listgroup.initialize('detailTab', $('#detailTab').data('initial-tab') || 'tab-Summary');

Expand Down Expand Up @@ -258,5 +258,17 @@
}
});
}

let keyReleases, valueReleases;
renderDataReleases();
function renderDataReleases() {
let content ='';
<core_rt:forEach items="${release.additionalData}" var="additional">
keyReleases = '<sw360:out value='${additional.key}'/>';
valueReleases = '<sw360:out value='${additional.value}'/>';
content+=regexjs.regex(keyReleases,valueReleases);
</core_rt:forEach>
$('#list-data-additional-release').append(content);
}
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</tr>
<tr>
<td><liferay-ui:message key="additional.data" />:</td>
<td><sw360:DisplayMap value="${release.additionalData}"/></td>
<td><ul id="list-data-additional-release" class="mapDisplayRootItem"></ul> </td>
</tr>
</table>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright TOSHIBA CORPORATION, 2022. Part of the SW360 Portal Project.
* Copyright Toshiba Software Development (Vietnam) Co., Ltd., 2022. Part of the SW360 Portal Project.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/

define('components/includes/releases/regexjs', ['jquery'] , function($) {
function regex(key,value) {
let regexEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
let regexUrl = /^(https?|chrome):\/\/[^\s$.?#].[^\s]*$/g;
let content = '';
if (value.match(regexEmail)) {
content +=
'<li>' +
'<span class="mapDisplayChildItemLeft">'+ key +': </span>'+
'<span class="mapDisplayChildItemRight"><a href="mailto:'+ value +'"> '+ value +'</a></span>'+
'</li>'
} else if (value.match(regexUrl)) {
content +=
'<li>' +
'<span class="mapDisplayChildItemLeft">'+ key +': </span>'+
'<span class="mapDisplayChildItemRight"><a href="'+ value +'"> '+ value +'</a></span>'+
'</li>'
} else {
content +=
'<li>' +
'<span class="mapDisplayChildItemLeft">' + key + ': </span>' +
'<span class="mapDisplayChildItemRight"> ' + value + '</span>' +
'</li>'
}
return content;
}
return {
regex: regex,
};
});

0 comments on commit 011762a

Please sign in to comment.