numerous improvemts
This commit is contained in:
@@ -321,4 +321,8 @@ table.transposed th.bank-holiday {
|
||||
|
||||
.locum-shift {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.multi-shift {
|
||||
line-height: 1;
|
||||
}
|
||||
+22
-12
@@ -295,7 +295,10 @@ $(".table-div .worker-row .worker").each((n, tr) => {
|
||||
locum_shift_counts = jtr.data("locum-shift-counts")
|
||||
shift_targets = jtr.data("worker-targets")
|
||||
|
||||
console.log(shift_counts, locum_shift_counts, shift_targets)
|
||||
|
||||
oshifts.forEach((s) => {
|
||||
console.log(s, shift_counts, shift_targets, locum_shift_counts)
|
||||
if (s in shift_targets && shift_targets[s] > 0) {
|
||||
if (s in shift_counts) {
|
||||
c = shift_counts[s];
|
||||
@@ -426,6 +429,7 @@ $(".table-div + pre").each((n, pre) => {
|
||||
|
||||
})
|
||||
|
||||
|
||||
$("td").hover((e) => {
|
||||
// start hover
|
||||
worker_td = $(e.target).closest('tr').find('td:first')[0]
|
||||
@@ -436,31 +440,37 @@ $("td").hover((e) => {
|
||||
$($(el).closest('tr').find('td').get(index)).addClass("pair-match")
|
||||
})
|
||||
}
|
||||
if (e.target.dataset.shift != undefined && e.target.dataset.shift.length > 0) {
|
||||
// Highlight all cells containing this shift, even if multiple shifts per day
|
||||
$("td").filter(function() {
|
||||
let shifts = $(this).attr("data-shift");
|
||||
if (!shifts) return false;
|
||||
return shifts.split(",").map(s => s.trim()).includes(e.target.dataset.shift);
|
||||
}).addClass("shift-highlight");
|
||||
|
||||
// For remote site, similar logic if needed
|
||||
// Find the span under the mouse, if any
|
||||
let targetSpan = $(e.target).closest("span.multi-shift-shift").get(0) ||
|
||||
($(e.target).hasClass("multi-shift-shift") ? e.target : null);
|
||||
|
||||
if (targetSpan) {
|
||||
// Only highlight spans with the same text
|
||||
let shiftDisplay = $(targetSpan).text().trim();
|
||||
$("span.multi-shift-shift").filter(function() {
|
||||
return $(this).text().trim() === shiftDisplay;
|
||||
}).addClass("shift-highlight");
|
||||
} else if (e.target.dataset.shift != undefined && e.target.dataset.shift.length > 0) {
|
||||
// Fallback: highlight all cells containing ANY of the hovered shifts (legacy)
|
||||
let hovered_shifts = e.target.dataset.shift.split(",").map(s => s.trim());
|
||||
$("td").filter(function() {
|
||||
let shifts = $(this).attr("data-shift");
|
||||
let remote = $(this).attr("data-remote-site");
|
||||
if (!shifts) return false;
|
||||
return shifts.split(",").map(s => s.trim()).includes(e.target.dataset.shift) &&
|
||||
remote == e.target.dataset.shiftRemoteSite;
|
||||
}).addClass("remote-site-match");
|
||||
let cell_shifts = shifts.split(",").map(s => s.trim());
|
||||
return hovered_shifts.some(s => cell_shifts.includes(s));
|
||||
}).addClass("shift-highlight");
|
||||
}
|
||||
|
||||
}, (e) => {
|
||||
// end hover
|
||||
$("td.pair-match").removeClass("pair-match")
|
||||
$("td.shift-highlight").removeClass("shift-highlight")
|
||||
$("span.shift-highlight").removeClass("shift-highlight")
|
||||
$("td.remote-site-match").removeClass("remote-site-match")
|
||||
});
|
||||
|
||||
|
||||
$("#rota-table tr td:first-child").each((n, td) => {
|
||||
$(td).click(() => {
|
||||
viewWorker(td);
|
||||
|
||||
Reference in New Issue
Block a user