From 21cace00ad8847d59fc7593430891f07b0a6fc0b Mon Sep 17 00:00:00 2001 From: Emmennater Date: Thu, 16 Nov 2023 12:39:25 -0600 Subject: [PATCH] Fixed Bugs Also changed max pto behavior. --- src/actions.js | 7 +++++++ src/main.js | 20 ++++++++++++-------- style/calandar.css | 8 ++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/actions.js b/src/actions.js index 1e02547..80fe6de 100644 --- a/src/actions.js +++ b/src/actions.js @@ -120,6 +120,13 @@ function updateDayElem(i) { else dayElem.classList.remove("starting-day"); + // Hit max + if (timeOffRatio == 1) { + dayElem.classList.add("hit-max"); + } else { + dayElem.classList.remove("hit-max"); + } + } function updatePTOElems() { diff --git a/src/main.js b/src/main.js index c3012f7..20d74d1 100644 --- a/src/main.js +++ b/src/main.js @@ -116,13 +116,17 @@ class Month { let hitMax = startingPTO >= maxPTO; for (const day of this.days) { cumulativePTO += day.getLocalTimeOff(); - day.setTimeOff(cumulativePTO); - - // Max PTO date - if (!hitMax && cumulativePTO >= maxPTO) { - hitMax = true; - Settings.setMaxDate(day); + + // Max PTO + if (cumulativePTO >= maxPTO) { + cumulativePTO = maxPTO; + if (!hitMax) { + hitMax = true; + Settings.setMaxDate(day); + } } + + day.setTimeOff(cumulativePTO); } } @@ -215,8 +219,8 @@ class Day { } getLocalTimeOff() { - let time = this.isStartingDay() ? Settings.start : 0; - time += this.data.time; + if (this.isStartingDay()) return Settings.start; + let time = this.data.time; if (this.data.add) time += Settings.getSetting("add"); if (this.data.sub) time -= Settings.getSetting("sub"); return time; diff --git a/style/calandar.css b/style/calandar.css index 4572c81..eabb36f 100644 --- a/style/calandar.css +++ b/style/calandar.css @@ -62,6 +62,14 @@ transition: box-shadow 0.1s; } +.day.hit-max { + background: linear-gradient( + to top, + rgba(255, 0, 0, 0.308) calc(var(--pto-ratio) * 100%), + #ffffff12 calc(var(--pto-ratio) * 100%) + ); +} + .day.starting-day { box-shadow: inset 0px 0px 20px #88ffb680; }