Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script> $(document).ready(function () { // Add custom class to the Due Date column $("table tbody tr").each(function () { // Find the right column: adjust the index (e.g., td:eq(1)) to match Due Date column const td = $(this).find("td:eq(1)"); // Change index as needed const text = td.text().trim(); if (text.match(/^\d{4}-\d{2}-\d{2}/)) { td.addClass("due-date-column"); td.attr("data-due-date", text); } }); // Function to calculate the difference between current date and target date function getDateDifference(targetDateString) { const parts = targetDateString.split(/[- :]/); const targetDate = new Date(parts[0], parts[1] - 1, parts[2], parts[3] || 0, parts[4] || 0, 0); const currentDate = new Date(); let differenceMs = targetDate - currentDate; let isPast = false; if (differenceMs < 0) { differenceMs = Math.abs(differenceMs); isPast = true; } let differenceSeconds = Math.floor(differenceMs / 1000); let differenceMinutes = Math.floor(differenceSeconds / 60); let differenceHours = Math.floor(differenceMinutes / 60); const differenceDays = Math.floor(differenceHours / 24); differenceHours %= 24; differenceMinutes %= 60; differenceSeconds %= 60; return { days: differenceDays, hours: differenceHours, minutes: differenceMinutes, seconds: differenceSeconds, isPast: isPast }; } function getBackgroundColor(difference) { if (difference.isPast) { return 'red'; } else if (difference.days > 1 || (difference.days === 1 && (difference.hours > 0 || difference.minutes > 0))) { return 'green'; } else if (difference.hours >= 12) { return 'orange'; } else { return 'red'; } } // For each row with a due date, calculate and show "Due In" $('.due-date-column').each(function () { const span = $(this); const dueDateValue = span.text().trim(); if (dueDateValue) { const difference = getDateDifference(dueDateValue); const trElement = span.closest('tr')[0]; if (trElement) { const divElement = document.createElement('div'); divElement.textContent = `${difference.days} days, ${difference.hours} hours, ${difference.minutes} minutes, ${difference.seconds} seconds`; divElement.style.backgroundColor = getBackgroundColor(difference); divElement.style.padding = '5px'; divElement.style.borderRadius = '5px'; divElement.style.color = 'white'; divElement.style.display = 'inline-block'; // Insert into a specific column, adjust selector as needed const targetTd = trElement.querySelector('.column_body.column_name.body_column_2'); if (targetTd) { targetTd.innerHTML = ''; // Clear existing targetTd.appendChild(divElement); } } } }); }); </script> |
Figure 22: Configure the List View Custom Header
...