Skip to content

Commit

Permalink
feat(CreateCRandRequestsPortlet):Added new field Clearing Type for CR…
Browse files Browse the repository at this point in the history
… and Additional columns in Open CR table

Signed-off-by: afsahsyeda <[email protected]>
  • Loading branch information
afsahsyeda committed Oct 13, 2023
1 parent 4666d87 commit edc36b2
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.sw360.datahandler.common.SW360Utils;
import org.eclipse.sw360.datahandler.permissions.PermissionUtils;
import org.eclipse.sw360.datahandler.thrift.ClearingRequestState;
import org.eclipse.sw360.datahandler.thrift.ClearingRequestType;
import org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus;
import org.eclipse.sw360.datahandler.thrift.AddDocumentRequestSummary;
import org.eclipse.sw360.datahandler.thrift.ClearingRequestPriority;
Expand Down Expand Up @@ -131,6 +132,7 @@ public static AddDocumentRequestSummary updateClearingRequest(PortletRequest req
String agreedDate = request.getParameter(ClearingRequest._Fields.AGREED_CLEARING_DATE.toString());
String status = request.getParameter(ClearingRequest._Fields.CLEARING_STATE.toString());
String priority = request.getParameter(ClearingRequest._Fields.PRIORITY.toString());
String clearingType = request.getParameter(ClearingRequest._Fields.CLEARING_TYPE.toString());
if (CommonUtils.isNotNullEmptyOrWhitespace(agreedDate) && !agreedDate.equals(clearingRequest.getAgreedClearingDate())
&& !SW360Utils.isValidDate(agreedDate, DateTimeFormatter.ISO_LOCAL_DATE, null)) {
log.warn("Invalid agreed clearing date: " + agreedDate + " is entered, by user: "+ user.getEmail());
Expand All @@ -139,6 +141,7 @@ public static AddDocumentRequestSummary updateClearingRequest(PortletRequest req
clearingRequest.setAgreedClearingDate(CommonUtils.nullToEmptyString(agreedDate));
clearingRequest.setClearingState(ClearingRequestState.findByValue(parseInt(status)));
clearingRequest.setPriority(ClearingRequestPriority.findByValue(parseInt(priority)));
clearingRequest.setClearingType(ClearingRequestType.findByValue(parseInt(clearingType)));
}
LiferayPortletURL projectUrl = getProjectPortletUrl(request, clearingRequest.getProjectId());
RequestStatus status = client.updateClearingRequest(clearingRequest, user, CommonUtils.nullToEmptyString(projectUrl));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,18 @@
content: attr(data-content);
}

.sw360-tt-ClearingRequestType-HIGH:hover:after {
content: attr(data-content);
}

.sw360-tt-ClearingRequestType-DEEP:hover:after {
content: attr(data-content);
}

.sw360-tt-ClearingRequestType:hover:after {
content: attr(data-content);
}

/** ProjectRelationShip **/
.sw360-tt-ProjectRelationship:hover:after {
content: attr(data-content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<%@page import="org.eclipse.sw360.datahandler.thrift.projects.ClearingRequest"%>
<%@page import="org.eclipse.sw360.datahandler.thrift.ClearingRequestState"%>
<%@page import="org.eclipse.sw360.datahandler.thrift.ClearingRequestPriority"%>
<%@page import="org.eclipse.sw360.datahandler.thrift.ClearingRequestType"%>
<%@page import="org.eclipse.sw360.portal.common.PortalConstants"%>

<portlet:defineObjects/>
Expand Down Expand Up @@ -194,6 +195,26 @@
</core_rt:choose>
</td>
</tr>
<tr>
<td><label class="form-group"><liferay-ui:message key="clearing.type" />:</label></td>
<td>
<core_rt:choose>
<core_rt:when test="${isEditableForClearingTeam}">
<select class="form-control"
name="<portlet:namespace/><%=ClearingRequest._Fields.CLEARING_TYPE%>">
<sw360:DisplayEnumOptions type="<%=ClearingRequestType.class%>" selected="${clearingRequest.clearingType}"/>
</select>
<small class="form-text">
<sw360:DisplayEnumInfo type="<%=ClearingRequestType.class%>"/>
<liferay-ui:message key="learn.more.about.clearing.request.type" />
</small>
</core_rt:when>
<core_rt:otherwise>
<sw360:DisplayEnum value="${clearingRequest.clearingType}"/>
</core_rt:otherwise>
</core_rt:choose>
</td>
</tr>
<tr>
<td><label class="form-group"><liferay-ui:message key="requester.comment" />:</label></td>
<td>
Expand Down Expand Up @@ -418,11 +439,28 @@
<p><liferay-ui:message key="please.enter.preferred.clearing.date.to.reopen.clearing.request" /></p>
<hr/>
<form id="reOpenClearingRequestForm" name="reOpenClearingRequestForm" action="<%=updateClearingRequestURL%>" method="post">
<div class="form-group">
<label for="requestedClearingDate" class="mandatory"><liferay-ui:message key="preferred.clearing.date" />:</label>
<input class="datepicker form-control" id="requestedClearingDate" name="<portlet:namespace/><%=ClearingRequest._Fields.REQUESTED_CLEARING_DATE%>" type="text" pattern="\d{4}-\d{2}-\d{2}" placeholder="<liferay-ui:message key='preferred.clearing.date.yyyy.mm.dd' />" required/>
<div class="invalid-feedback">
<liferay-ui:message key="date.should.be.valid" />!
<div class="row">
<div class="form-group col-md-6">
<label for="clearingType" class="mandatory"><liferay-ui:message
key="clearing.type" />:</label> <select id="clearingType" class="form-control" required
name="<portlet:namespace/><%=ClearingRequest._Fields.CLEARING_TYPE%>">
<sw360:DisplayEnumOptions type="<%=ClearingRequestType.class%>"
selected="${clearingRequest.clearingType}" />
</select> <small class="form-text"> <sw360:DisplayEnumInfo
type="<%=ClearingRequestType.class%>" /> <liferay-ui:message
key="learn.more.about.clearing.request.type" />
</small>
</div>
<div class="form-group col-md-6">
<label for="requestedClearingDate" class="mandatory"><liferay-ui:message
key="preferred.clearing.date" />:</label> <input
class="datepicker form-control" id="requestedClearingDate"
type="text" pattern="\d{4}-\d{2}-\d{2}"
placeholder="<liferay-ui:message key='preferred.clearing.date.yyyy.mm.dd' />"
required />
<div class="invalid-feedback">
<liferay-ui:message key="date.should.be.valid" />
</div>
</div>
</div>
<core_rt:if test="${criticalCount lt 2}">
Expand Down Expand Up @@ -645,8 +683,12 @@ require(['jquery', 'modules/dialog', 'modules/validation', 'modules/button', 'br
if ((isCritical && !validation.isValidDate(selectedDate, 0)) || (!isCritical && !validation.isValidDate(selectedDate, pcdLimit))) {
$("#requestedClearingDate").addClass("is-invalid");
callback();
} else if ($("#clearingType").val() == null){
$("#clearingTypeErrorMsg").addClass("is-invalid");
callback();
} else {
$("#requestedClearingDate").removeClass("is-invalid");
$("#clearingType").removeClass("is-invalid")
$form.addClass('was-validated');
$form.append('<input type="hidden" value="true" name="<portlet:namespace/><%=PortalConstants.RE_OPEN_REQUEST%>"/>');
$form.submit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<%@ page import="org.eclipse.sw360.datahandler.thrift.DateRange" %>
<%@ page import="org.eclipse.sw360.datahandler.thrift.ClearingRequestState"%>
<%@ page import="org.eclipse.sw360.datahandler.thrift.ClearingRequestPriority"%>
<%@ page import="org.eclipse.sw360.datahandler.thrift.ClearingRequestType"%>
<%@ page import="com.liferay.portal.kernel.portlet.PortletURLFactoryUtil" %>
<%@ page import="javax.portlet.PortletRequest" %>
<%@ page import ="java.util.Date" %>
Expand Down Expand Up @@ -216,6 +217,13 @@
<sw360:DisplayEnumOptions type="<%=ClearingRequestState.class%>"/>
</select>
</div>
<div class="form-group" id="cr_type_div">
<label for="date_type"><liferay-ui:message key="clearing.type" />:</label>
<select class="form-control form-control-sm cr_filter" id="cr_type">
<option value="" class="textlabel stackedLabel" ></option>
<sw360:DisplayEnumOptions type="<%=ClearingRequestType.class%>" useStringValues="true"/>
</select>
</div>
</form>
</div>
</div>
Expand Down Expand Up @@ -288,7 +296,7 @@ AUI().use('liferay-portlet-url', function () {
});
// Event listener to the two range filtering inputs to redraw on input
$('#date_type, #date_range, #cr_priority, #ba_bl, #cr_status').on('change', function(e) {
$('#date_type, #date_range, #cr_priority, #ba_bl, #cr_status, #cr_type').on('change', function(e) {
filterChanged();
});
Expand Down Expand Up @@ -332,13 +340,15 @@ AUI().use('liferay-portlet-url', function () {
crPriority = $priority.find(":selected").text(),
babl = $babl.find(":selected").val(),
crStatus = $status.find(":selected").text(),
crType = $('#cr_type').find(":selected").text(),
tab = $('#requestTabs').find('a.active').attr('href');
if (tab === '#tab-OpenCR') {
clearingRequestsDataTable
.column(1).search(babl)
.column(4).search(crStatus)
.column(5).search(crPriority)
.column(14).search(crType)
.draw();
} else if (tab === '#tab-ClosedCR') {
closedClearingRequestsDataTable
Expand Down Expand Up @@ -445,6 +455,7 @@ AUI().use('liferay-portlet-url', function () {
if (tab === '#tab-OpenCR') {
$("#date_type option[value="+"<%=ClearingRequest._Fields.TIMESTAMP_OF_DECISION%>"+"]").hide().attr("disabled", "");
$("#cr_priority_div").show();
$("#cr_type_div").show();
$('#cr_status option').each(function() {
let val = $(this).attr("value");
if (val === "2" || val === "5") {
Expand All @@ -456,6 +467,7 @@ AUI().use('liferay-portlet-url', function () {
} else {
$("#date_type option[value="+"<%=ClearingRequest._Fields.TIMESTAMP_OF_DECISION%>"+"]").show().removeAttr("disabled");
$("#cr_priority_div").hide();
$("#cr_type_div").hide();
$('#cr_status option').each(function() {
let val = $(this).attr("value");
if (val === "" || val === "2" || val === "5") {
Expand Down Expand Up @@ -565,7 +577,8 @@ AUI().use('liferay-portlet-url', function () {
"12": '<fmt:formatDate value="${modifiedOn}" pattern="yyyy-MM-dd"/>',
</core_rt:if>
"13": '',
"14": "${request.projectId}",
"14": "<sw360:DisplayEnum value="${request.clearingType}"/>",
"15": "${request.projectId}",
});
</core_rt:forEach>
return result;
Expand Down Expand Up @@ -598,24 +611,25 @@ AUI().use('liferay-portlet-url', function () {
"12": '<fmt:formatDate value="${modifiedOn}" pattern="yyyy-MM-dd"/>',
</core_rt:if>
"13": '<fmt:formatDate value="${closedOn}" pattern="yyyy-MM-dd"/>',
"14": "${request.projectId}",
"14": '<sw360:out value="${request.clearingType}"/>',
"15": "${request.projectId}",
});
</core_rt:forEach>
return result;
}
function createClearingRequestsTable(tableId, tableData) {
let hiddenCol = (tableId === '#clearingRequestsTable') ? [8, 9, 10, 11, 12, 13] : [3, 5, 7, 12];
let hiddenCol = (tableId === '#clearingRequestsTable') ? [7, 8, 12, 13] : [3, 5, 7, 12, 14];
return datatables.create(tableId, {
searching: true,
deferRender: false, // do not change this value
data: tableData,
columns: [
{title: "<liferay-ui:message key="request.id" />", render: {display: renderClearingRequestUrl}, className: 'text-nowrap', width: "5%" },
{title: "<liferay-ui:message key="ba-bl.slash.group" />", className: 'text-nowrap', width: "10%" },
{title: "<liferay-ui:message key="ba-bl.slash.group" />", className: 'text-nowrap', width: "7%" },
{title: "<liferay-ui:message key="project" />", width: "15%" },
{title: "<liferay-ui:message key="open.components" />", width: "8%" },
{title: "<liferay-ui:message key="status" />", width: "10%" },
{title: "<liferay-ui:message key="status" />", width: "8%" },
{title: "<liferay-ui:message key="priority" />", width: "7%" },
{title: "<liferay-ui:message key="requesting.user" />", className: 'text-nowrap', width: "10%" },
{title: "<liferay-ui:message key="clearing.progress" />", className: 'text-nowrap', width: "30%" },
Expand All @@ -625,6 +639,7 @@ AUI().use('liferay-portlet-url', function () {
{title: "<liferay-ui:message key="agreed.clearing.date" />", width: "7%" },
{title: "<liferay-ui:message key="modified.on" />", width: "7%" },
{title: "<liferay-ui:message key="request.closed.on" />", width: "7%" },
{title: "<liferay-ui:message key="clearing.type" />", width: "15%" },
{title: "<liferay-ui:message key="actions" />", render: {display: renderClearingRequestAction}, className: 'one action', width: "5%" },
],
language: {
Expand Down Expand Up @@ -660,7 +675,7 @@ AUI().use('liferay-portlet-url', function () {
datatables.showPageContainer;
loadProjectDetails(tableId, tableData);
}
}, [0,1,2,3,4,5,6,8,9,10,11,12,13], [7,14]);
}, [0,1,2,3,4,5,6,8,9,10,11,12,13,14], [7,15]);
}
function renderClearingRequestUrl(tableData, type, row) {
Expand All @@ -683,7 +698,7 @@ AUI().use('liferay-portlet-url', function () {
function renderClearingRequestAction(tableData, type, row) {
let clearingTeam = extractEmailFromHTMLElement(row[8]),
requestingUser = extractEmailFromHTMLElement(row[6]);
if (row[14] && (clearingTeam === '${user.emailAddress}' || requestingUser === '${user.emailAddress}' || ${isClearingExpert})) {
if (row[15] && (clearingTeam === '${user.emailAddress}' || requestingUser === '${user.emailAddress}' || ${isClearingExpert})) {
let portletURL = '<%=friendlyClearingURL%>';
return render.linkTo(replaceFriendlyUrlParameter(portletURL.toString(), row.DT_RowId, '<%=PortalConstants.PAGENAME_EDIT_CLEARING_REQUEST%>'),
"",
Expand Down Expand Up @@ -714,15 +729,15 @@ AUI().use('liferay-portlet-url', function () {
$projCell = $(tableId).find('tr#'+value.DT_RowId).find('td:eq('+projectColIndex+')'),
$compCell = $(tableId).find('tr#'+value.DT_RowId).find('td:eq('+componentColIndex+')'),
$progressCell = $(tableId).find('tr#'+value.DT_RowId).find('td:eq('+progressColIndex+')');
if (value[14]) {
projectIds.push(value[14]);
if (value[15]) {
projectIds.push(value[15]);
$buCell.html('<liferay-ui:message key="loading" />');
$projCell.html('<liferay-ui:message key="loading" />');
if (isOpenCrTable) {
$compCell.html('<liferay-ui:message key="loading" />');
$progressCell.html('<liferay-ui:message key="loading" />');
//$progressCell.html('<liferay-ui:message key="loading" />');
}
value[14] = "";
value[15] = "";
} else {
crIds.push(value.DT_RowId);
}
Expand Down Expand Up @@ -804,7 +819,7 @@ AUI().use('liferay-portlet-url', function () {
let clearing = response[i].clearing,
totalCount = (!clearing) ? 0 : d(clearing.newRelease) + d(clearing.underClearing) + d(clearing.sentToClearingTool) + d(clearing.reportAvailable) + d(clearing.approved) + d(clearing.scanAvailable),
approvedCount = (!clearing) ? 0 : d(clearing.reportAvailable) + d(clearing.approved);
compCell.data(totalCount - approvedCount);
compCell.data(approvedCount+"/"+totalCount);
if (!totalCount || $(table.cell('#'+crId, 4).node()).find('span.sw360-tt-ClearingRequestState-NEW').text()) {
progressCell.data('<liferay-ui:message key="not.available" />');
} else {
Expand Down
Loading

0 comments on commit edc36b2

Please sign in to comment.