Skip to content

Commit 02ac05d

Browse files
Merge pull request #125 from niteeshkanna-sh/claude/stoic-rubin-fnglq7
The booking calendar lets you back-date a week
2 parents 8537d00 + 3653b43 commit 02ac05d

3 files changed

Lines changed: 54 additions & 9 deletions

File tree

‎admin/admin.css‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,14 +919,27 @@ label.finance-toggle {
919919
text-decoration: line-through; cursor: not-allowed;
920920
}
921921
.cal-day:disabled:not(.is-busy) { color: var(--ink-faint); opacity: 0.45; cursor: not-allowed; }
922+
923+
/* A day that has been and gone but can still be chosen, for writing down a
924+
hire after it happened. Ringed rather than filled: it is selectable, so it
925+
must not read as taken, and it is behind us, so it must not read as an
926+
ordinary open day either. */
927+
.cal-day.is-back:not(.is-on) {
928+
color: var(--ink-dim);
929+
box-shadow: inset 0 0 0 1px var(--border);
930+
}
931+
.cal-day.is-back:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
922932
.cal-key {
923-
display: flex; align-items: center; gap: 6px;
933+
display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
924934
margin-top: 8px; font-size: 0.7rem; color: var(--ink-faint);
925935
}
936+
/* The second swatch needs air before it, or the two keys run together. */
937+
.cal-key .cal-swatch-back { margin-left: 6px; }
926938
.cal-swatch {
927939
display: inline-block; width: 12px; height: 12px; border-radius: 3px;
928940
background: var(--accent);
929941
}
942+
.cal-swatch-back { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
930943
.cal-warn { margin-top: 6px; font-size: 0.8rem; font-weight: 600; color: var(--danger); }
931944

932945
/* ---------- Bookings ---------- */

‎admin/booking-dates.js‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,33 @@
1717
'use strict';
1818

1919
var DAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
20+
21+
/**
22+
* How far back a day can still be chosen.
23+
*
24+
* The grid used to stop at today, which is right for a booking being taken
25+
* over the phone and wrong for the other half of what this form does:
26+
* writing down a hire that already happened. A car goes out, comes back, and
27+
* the paperwork is caught up at the end of the week -- and the days that
28+
* hire actually ran were greyed out.
29+
*
30+
* Nothing else was stopping it. The date boxes carry no min and the server
31+
* has no rule about it, so a past date typed by hand always saved. This only
32+
* ever blocked the clicking.
33+
*
34+
* A week rather than forever: far enough to catch up the week's paperwork,
35+
* near enough that a mistyped year does not quietly land a booking in 2019.
36+
* Days before it stay disabled, and the month arrows still page back as far
37+
* as anyone wants to look.
38+
*/
39+
var BACKDATE_DAYS = 7;
40+
41+
/** The earliest day the grid will let anyone click. */
42+
function earliestSelectable() {
43+
var d = new Date();
44+
d.setDate(d.getDate() - BACKDATE_DAYS);
45+
return iso(d);
46+
}
2047
var ranges = {}; // vehicle id -> [[from, to], ...]
2148
var loaded = false;
2249

@@ -72,6 +99,7 @@
7299
/** Draws one month into `host`, for `input`. */
73100
function draw(host, input, busy, month) {
74101
var today = iso(new Date());
102+
var earliest = earliestSelectable();
75103
var first = new Date(month.getFullYear(), month.getMonth(), 1);
76104
var count = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();
77105
var lead = (first.getDay() + 6) % 7;
@@ -91,18 +119,22 @@
91119
var date = new Date(month.getFullYear(), month.getMonth(), d);
92120
var key = iso(date);
93121
var out = busy.has(key);
94-
var past = key < today;
122+
var past = key < earliest;
123+
// Backdated but still selectable: shown for what it is, so nobody
124+
// records last Tuesday's hire thinking they booked next Tuesday's.
125+
var back = !past && key < today;
95126
var on = key === input.value;
96127
cells += '<button type="button" class="cal-day' +
97-
(on ? ' is-on' : '') + (out ? ' is-busy' : '') + '"' +
128+
(on ? ' is-on' : '') + (out ? ' is-busy' : '') + (back ? ' is-back' : '') + '"' +
98129
(out || past ? ' disabled' : '') +
99130
' data-date="' + key + '"' +
100131
' aria-label="' + date.toLocaleDateString('en-IN', { day: 'numeric', month: 'long' }) +
101-
(out ? ' — already booked' : '') + '">' + d + '</button>';
132+
(out ? ' — already booked' : '') + (back ? ' — a past date' : '') + '">' + d + '</button>';
102133
}
103134

104135
host.innerHTML = head + names + '<div class="cal-grid">' + cells + '</div>' +
105-
'<p class="cal-key"><span class="cal-swatch" aria-hidden="true"></span>Already booked</p>';
136+
'<p class="cal-key"><span class="cal-swatch" aria-hidden="true"></span>Already booked' +
137+
'<span class="cal-swatch cal-swatch-back" aria-hidden="true"></span>Past date</p>';
106138

107139
host.querySelectorAll('.cal-nav').forEach(function (b) {
108140
b.addEventListener('click', function () {

‎build.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"publishedAt": "2026-10-05T05:50:14.118Z",
3-
"commit": "cb7b9955",
4-
"commitAt": "2026-10-05T05:47:50+00:00",
5-
"sourceHash": "70ac601b75f862af",
2+
"publishedAt": "2026-10-05T05:59:57.760Z",
3+
"commit": "8537d009",
4+
"commitAt": "2026-10-05T11:21:47+05:30",
5+
"sourceHash": "c203a960f2aeb37d",
66
"assets": [
77
"About-BiQBytBo.js",
88
"Bikes-BmUE2d0I.js",

0 commit comments

Comments
 (0)