Skip to content

Commit

Permalink
ToDo: consider after-work hours in timer
Browse files Browse the repository at this point in the history
  • Loading branch information
GaturaN committed Nov 14, 2024
1 parent f7bed4c commit 2603578
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Account for after-work hours on Countdown.
### Account for after-work hours on Countdown.
~~# Let the assignee only be able to complete, but the assginer closed. ~~
~~# Once assignee closes, the assigner should get notified. ~~
51 changes: 50 additions & 1 deletion assist/assist/doctype/assist/assist.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function startCountdown(frm) {
function resumeCountdown(frm) {
if (frm.doc.progress_status === "Closed") {
displayElapsedTime(frm);
return; // Exit without starting a countdown interval
return;
}

let countDownDate = frm.doc.countdown_end_time;
Expand Down Expand Up @@ -353,3 +353,52 @@ function displayElapsedTime(frm) {
frm.fields_dict["close_in"].$wrapper.html(timeDisplay);
}
}

// function resumeCountdown(frm) {
// if (frm.doc.progress_status === "Closed") {
// displayElapsedTime(frm);
// return; // Exit without starting a countdown interval
// }

// let countDownDate = new Date(frm.doc.countdown_end_time).getTime();
// let interval = setInterval(function () {
// let now = new Date();
// let nowTimestamp = now.getTime();
// let distance = countDownDate - nowTimestamp;

// if (isNaN(distance) || typeof distance === "undefined") {
// clearInterval(interval);
// return;
// }

// // pause on weekends (Saturday and Sunday)
// if (now.getDay() === 6 || now.getDay() === 0) {
// return;
// }

// // pause outside working hours
// if (now.getHours() < 8 || now.getHours() > 17) {
// return;
// }

// // calculate the remaining time
// let isNegative = distance < 0;
// distance = Math.abs(distance);

// let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
// let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
// let seconds = Math.floor((distance % (1000 * 60)) / 1000);

// let timeDisplay = isNegative ? `Overdue by: ${hours}h ${minutes}m ${seconds}s` : `Close In: ${hours}h ${minutes}m ${seconds}s`;

// if (frm.fields_dict["close_in"]) {
// frm.fields_dict["close_in"].$wrapper.html(timeDisplay);
// }

// // stop countdown if the document is closed
// if (frm.doc.progress_status === "Closed") {
// clearInterval(interval);
// displayElapsedTime(frm);
// }
// }, 1000);
// }

0 comments on commit 2603578

Please sign in to comment.