Update index.html

Ryan Danenberg committed commitf631e05a34ec43c90b1f760a6540b6c3e35869a3 Browse files
1 file changed+37−11
index.html+37−11View file
@@ -2328,15 +2328,21 @@
recalculateMetrics(assignment);
}
- function toggleWorkedDay(idx, checked) {
- activeEditorDays[idx].worked = checked;
- if (!checked) {
+ function setWorkAmount(idx, amount) {
+ const num = Number(amount);
+ activeEditorDays[idx].workAmount = num;
+ activeEditorDays[idx].worked = num > 0;
+ if (num === 0) {
// clear minutes if not worked
activeEditorDays[idx].meetingDurationMinutes = 0;
}
renderEditorUI(getSelectedAssignment());
}
+ function toggleWorkedDay(idx, checked) {
+ setWorkAmount(idx, checked ? 1.0 : 0);
+ }
+
function updateDayDetails(idx, val) {
activeEditorDays[idx].details = val;
}
@@ -2346,19 +2352,37 @@
recalculateMetrics(getSelectedAssignment());
}
- function quickFillWorkdays() {
+ function quickFillWorkdays(amount = 1.0) {
+ const isHalf = amount === 0.5;
+ const desc = isHalf ? "Half-day development & tasks" : "Full-day development & tasks";
activeEditorDays.forEach(d => {
if (d.inRange && !d.isWeekend) {
+ d.workAmount = amount;
d.worked = true;
- if (!d.details) d.details = "Full-day development & tasks";
+ if (!d.details) d.details = desc;
+ }
+ });
+ renderEditorUI(getSelectedAssignment());
+ const label = isHalf ? 'Half Days (0.5)' : 'Full Days (1.0)';
+ showToast('Quick-fill Applied', `Marked all working weekdays within contract range as ${label}.`, 'info');
+ }
+
+ function clearWeekdays() {
+ activeEditorDays.forEach(d => {
+ if (d.inRange && !d.isWeekend) {
+ d.workAmount = 0;
+ d.worked = false;
+ d.details = '';
+ d.meetingDurationMinutes = 0;
}
});
renderEditorUI(getSelectedAssignment());
- showToast('Quick-fill Applied', 'Marked all working weekdays within contract range.', 'info');
+ showToast('Cleared Weekdays', 'Reset all working weekdays to Off.', 'info');
}
function clearAllDays() {
activeEditorDays.forEach(d => {
+ d.workAmount = 0;
d.worked = false;
d.details = '';
d.meetingDurationMinutes = 0;
@@ -2378,19 +2402,21 @@
let meetingMins = 0;
activeEditorDays.forEach(d => {
- if (d.worked) {
- daysCount++;
+ const amount = d.workAmount !== undefined ? Number(d.workAmount) : (d.worked ? 1.0 : 0);
+ if (amount > 0) {
+ daysCount += amount;
meetingMins += (d.meetingDurationMinutes || 0);
}
});
+ daysCount = Math.round(daysCount * 10) / 10;
const meetingHours = Math.round((meetingMins / 60) * 10) / 10;
const rate = assignment ? (assignment.dailyRate || 0) : 0;
- const estTotal = daysCount * rate;
+ const estTotal = Math.round(daysCount * rate * 100) / 100;
- document.getElementById('stat-days-worked').textContent = `${daysCount} day${daysCount === 1 ? '' : 's'}`;
+ document.getElementById('stat-days-worked').textContent = formatDays(daysCount);
document.getElementById('stat-meeting-hours').textContent = `${meetingHours} hrs (${meetingMins}m)`;
- document.getElementById('stat-estimated-billing').textContent = `€${estTotal.toLocaleString()}`;
+ document.getElementById('stat-estimated-billing').textContent = `€${estTotal.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })}`;
// Update active timesheet totals
activeEditorTimesheet.totalDaysWorked = daysCount;