Edit case issues fixed - Now add case and edit case are working fine
This commit is contained in:
112
cygnus-onprem-app/build/WebContent/js/edp/punching/edit-cases.js
Normal file
112
cygnus-onprem-app/build/WebContent/js/edp/punching/edit-cases.js
Normal file
@@ -0,0 +1,112 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var currentRow = 0;
|
||||
var lastRow = 0;
|
||||
|
||||
function rows() {
|
||||
return Array.prototype.slice.call(document.querySelectorAll("#casetable tbody tr"));
|
||||
}
|
||||
|
||||
function rowNumber(row) {
|
||||
return Number((row.id || "").replace("row", "")) || 0;
|
||||
}
|
||||
|
||||
function setActiveRow(row) {
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
rows().forEach(function (item) {
|
||||
item.classList.remove("rowhover");
|
||||
});
|
||||
row.classList.add("rowhover");
|
||||
currentRow = rowNumber(row);
|
||||
lastRow = currentRow;
|
||||
row.focus();
|
||||
}
|
||||
|
||||
function hiddenValue(row, suffix) {
|
||||
var input = document.getElementById(row.id + suffix);
|
||||
return input ? input.value : "";
|
||||
}
|
||||
|
||||
function submitForm(action, target, formId) {
|
||||
if (typeof SubmitForm === "function") {
|
||||
SubmitForm(action, target, formId);
|
||||
return;
|
||||
}
|
||||
var form = document.getElementById(formId);
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
form.action = action;
|
||||
form.target = target;
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function openRow(row) {
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
var uuid = hiddenValue(row, "uuid");
|
||||
var portfolioId = hiddenValue(row, "portid");
|
||||
if (!uuid || !portfolioId) {
|
||||
return;
|
||||
}
|
||||
document.getElementById("uuid").value = uuid;
|
||||
document.getElementById("portlist").value = portfolioId;
|
||||
submitForm("caseedit", "_parent", "caseGrid");
|
||||
}
|
||||
|
||||
function moveSelection(direction) {
|
||||
var allRows = rows();
|
||||
if (allRows.length === 0) {
|
||||
return;
|
||||
}
|
||||
var nextIndex = currentRow > 0 ? currentRow - 1 + direction : 0;
|
||||
if (nextIndex < 0) {
|
||||
nextIndex = allRows.length - 1;
|
||||
}
|
||||
if (nextIndex >= allRows.length) {
|
||||
nextIndex = 0;
|
||||
}
|
||||
setActiveRow(allRows[nextIndex]);
|
||||
}
|
||||
|
||||
function handleKeydown(event) {
|
||||
var row = event.target && event.target.closest ? event.target.closest("#casetable tbody tr") : null;
|
||||
if (event.key === "Enter" && row) {
|
||||
event.preventDefault();
|
||||
openRow(row);
|
||||
return;
|
||||
}
|
||||
if (event.key === "ArrowDown") {
|
||||
event.preventDefault();
|
||||
moveSelection(1);
|
||||
return;
|
||||
}
|
||||
if (event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
moveSelection(-1);
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
rows().forEach(function (row) {
|
||||
row.addEventListener("mouseenter", function () {
|
||||
setActiveRow(row);
|
||||
});
|
||||
row.addEventListener("click", function () {
|
||||
openRow(row);
|
||||
});
|
||||
});
|
||||
document.addEventListener("keydown", handleKeydown, false);
|
||||
}
|
||||
|
||||
window.CygnusEditCases = {
|
||||
init: init,
|
||||
openRow: openRow
|
||||
};
|
||||
|
||||
window.InitPage = init;
|
||||
}());
|
||||
Reference in New Issue
Block a user