Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #27: Adding day balance on when to leave bar after day is done #222

Merged
merged 2 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,7 @@ html[data-theme="dark"] .text-danger {
.waiver-trigger:hover + .day > .waiver-img {
display: block;
}

.hidden {
display: none;
}
25 changes: 24 additions & 1 deletion js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -440,10 +457,16 @@ class Calendar {
static _getSummaryRowCode() {
var leaveByCode = '<input type="text" id="leave-by" size="5" disabled>';
var summaryStr = 'Based on the time you arrived today, you should leave by';
var code = '<tr class="summary">' +
var code = '<tr class="summary" id="summary-unfinished-day">' +
'<td class="leave-by-text" colspan="7">' + summaryStr + '</td>' +
'<td class="leave-by-time">' + leaveByCode + '</td>' +
'</tr>';
var finishedSummaryStr = 'All done for today. The balance for today is:';
var dayBalance = '<input type="text" id="leave-day-balance" size="5" disabled>';
code += '<tr class="summary hidden" id="summary-finished-day">' +
'<td class="leave-by-text" colspan="7">' + finishedSummaryStr + '</td>' +
'<td class="leave-by-time">' + dayBalance + '</td>' +
'</tr>';
return code;
}

Expand Down