Skip to content

Commit

Permalink
feat(ProjectObligationsEdit): Save comment and status fields on edit
Browse files Browse the repository at this point in the history
Signed-off-by: afsahsyeda <[email protected]>
  • Loading branch information
afsahsyeda committed Jul 7, 2023
1 parent ec28fa1 commit b95bb4d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ require(['jquery', 'modules/autocomplete', 'modules/dialog', 'modules/listgroup'
</core_rt:if>
$(document).find(".checkStatus select").attr("disabled", false);
$(document).find(".checkedComment input").attr("disabled", false);
localStorage.clear();
$('#projectEditForm').submit();
}
Expand All @@ -331,6 +332,7 @@ require(['jquery', 'modules/autocomplete', 'modules/dialog', 'modules/listgroup'
"<portlet:namespace/><%=PortalConstants.DOCUMENT_ID%>": "${project.id}"
}
}).always(function() {
localStorage.clear();
var baseUrl = '<%= PortletURLFactoryUtil.create(request, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE) %>',
portletURL = Liferay.PortletURL.createURL(baseUrl)
<core_rt:if test="${not addMode}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ require(['jquery', 'bridges/datatables', 'utils/render', 'modules/button', 'modu
actionOptions = {};
var jsonObject = {},
obligationsFromLicenseDatabase = "",
projectId = "<sw360:out value='${projectid}'/>",
licenseTableData=$("#spinnerForLicenseObligation").html().toString();
$("#spinnerForLicenseObligation").remove();
<core_rt:forEach items="${obligationsActionSet}" var="action">
Expand Down Expand Up @@ -327,7 +328,25 @@ require(['jquery', 'bridges/datatables', 'utils/render', 'modules/button', 'modu
"action": updateObligations
}
],
"initComplete": datatables.showPageContainer
"initComplete": datatables.showPageContainer,
"fnDrawCallback": function() {
var table = document.getElementById("editObligationsTable");
for (var i = 1, row; row = table.rows[i]; i++) {
var statusTD = row.cells[4];
var commentTD = row.cells[7];
var oblTD = row.cells[1];
var obl = $(oblTD).find('span').text();

if (localStorage.getItem(obl+"- "+projectId)) {
var json = JSON.parse(localStorage.getItem(obl+"- "+projectId));

dataMap.set(obl, '');

$(statusTD).find('select').val(json['status']);
$(commentTD).find('input').val(json['comment']);
}
}
}
}, undefined, [0, 4, 7]);

function renderStatus(status, type, row) {
Expand Down Expand Up @@ -374,6 +393,7 @@ require(['jquery', 'bridges/datatables', 'utils/render', 'modules/button', 'modu
/* Add event listener for change in any editable fields in table */
$("#editObligationsTable tbody").on("change", 'td select.obl_status', function () {
storeData($(this));
saveStatusAndObl($(this));
});

/* $("#editObligationsTable tbody").on("change", 'td select.obl_action',function () {
Expand All @@ -383,9 +403,20 @@ require(['jquery', 'bridges/datatables', 'utils/render', 'modules/button', 'modu
$("#editObligationsTable tbody").on("change", 'td input.obl_comment', function () {
if ($(this).closest('tr').find("input.obl_comment").val()) {
storeData($(this));
saveStatusAndObl($(this));
}
});

function saveStatusAndObl(thisObj) {
let $tr = thisObj.closest("tr");
let localJsonObject = {};

localJsonObject["comment"] = $tr.find("input.obl_comment").val();
localJsonObject["status"] = $tr.find("select.obl_status").val();

localStorage.setItem($tr.find("span").text()+"- "+projectId, JSON.stringify(localJsonObject));
}

function storeData(thisObj) {
let $tr = thisObj.closest("tr");
if (!$tr.hasClass('orphan')) {
Expand Down

0 comments on commit b95bb4d

Please sign in to comment.