From 5c239c221412afeae74808eb7e09178ce7b4077a Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Fri, 8 May 2020 19:51:51 -0300 Subject: [PATCH] Fix #27: Adding day balance on when to leave bar after day is done --- css/styles.css | 4 ++++ js/calendar.js | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/css/styles.css b/css/styles.css index e5ddd6f10..f2c56f043 100644 --- a/css/styles.css +++ b/css/styles.css @@ -232,3 +232,7 @@ html[data-theme="dark"] .text-danger { .waiver-trigger:hover + .day > .waiver-img { display: block; } + +.hidden { + display: none; +} diff --git a/js/calendar.js b/js/calendar.js index 7cf8c67c8..81acc8715 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -397,9 +397,26 @@ class Calendar { //All entries computed document.getElementById('punch-button').disabled = true; ipcRenderer.send('TOGGLE_TRAY_PUNCH_TIME', false); + + var dayTotal = document.getElementById(dayKey + 'day-total').value; + if (dayTotal) { + var dayBalance = subtractTime(getHoursPerDay(), dayTotal); + var leaveDayBalanceElement = document.getElementById('leave-day-balance'); + leaveDayBalanceElement.value = dayBalance; + leaveDayBalanceElement.classList.remove('text-success', 'text-danger'); + leaveDayBalanceElement.classList.add(isNegative(dayBalance) ? 'text-danger' : 'text-success'); + document.getElementById('summary-unfinished-day').classList.add('hidden'); + document.getElementById('summary-finished-day').classList.remove('hidden'); + } else { + document.getElementById('summary-unfinished-day').classList.remove('hidden'); + document.getElementById('summary-finished-day').classList.add('hidden'); + } } else { document.getElementById('punch-button').disabled = false; ipcRenderer.send('TOGGLE_TRAY_PUNCH_TIME', true); + + document.getElementById('summary-unfinished-day').classList.remove('hidden'); + document.getElementById('summary-finished-day').classList.add('hidden'); } } @@ -440,10 +457,16 @@ class Calendar { static _getSummaryRowCode() { var leaveByCode = ''; var summaryStr = 'Based on the time you arrived today, you should leave by'; - var code = '' + + var code = '' + '' + summaryStr + '' + '' + leaveByCode + '' + ''; + var finishedSummaryStr = 'All done for today. Balance of the day:'; + var dayBalance = ''; + code += '' + + '' + finishedSummaryStr + '' + + '' + dayBalance + '' + + ''; return code; }