fix multishifts
This commit is contained in:
+33
-17
@@ -43,7 +43,16 @@ function generateExtra() {
|
||||
shifts = []
|
||||
|
||||
shift_tds.each((n, td) => {
|
||||
shifts.push($(td).attr("data-shift"));
|
||||
let data_shift = $(td).attr("data-shift");
|
||||
if (data_shift && data_shift !== "") {
|
||||
// Split by comma for multiple shifts per day
|
||||
let split_shifts = data_shift.split(",");
|
||||
split_shifts.forEach(s => {
|
||||
if (s && s.trim() !== "") {
|
||||
shifts.push(s.trim());
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
shifts_unique = new Set(shifts);
|
||||
@@ -362,11 +371,12 @@ oshifts.forEach((shift) => {
|
||||
$("table#main-table th.date").each((n, th) => {
|
||||
row = $("<tr>")
|
||||
row.append(`<td>${th.dataset.date}</td>`);
|
||||
$(`table#main-table td[data-date='${th.dataset.date}'][data-shift='${evt.target.dataset.shift}']`).each((n, td) => {
|
||||
|
||||
//row.append(`<td>${}</td>`)
|
||||
row.append($(td).closest("tr").children("td:first").clone())
|
||||
|
||||
$(`table#main-table td[data-date='${th.dataset.date}']`).filter(function() {
|
||||
let shifts = $(this).attr("data-shift");
|
||||
if (!shifts) return false;
|
||||
return shifts.split(",").map(s => s.trim()).includes(evt.target.dataset.shift);
|
||||
}).each((n, td) => {
|
||||
row.append($(td).closest("tr").children("td:first").clone());
|
||||
});
|
||||
|
||||
table.append(row)
|
||||
@@ -417,7 +427,7 @@ $(".table-div + pre").each((n, pre) => {
|
||||
})
|
||||
|
||||
$("td").hover((e) => {
|
||||
//start hover
|
||||
// start hover
|
||||
worker_td = $(e.target).closest('tr').find('td:first')[0]
|
||||
pair = worker_td.dataset.pair;
|
||||
index = $(e.target).index() - 1;
|
||||
@@ -427,23 +437,29 @@ $("td").hover((e) => {
|
||||
})
|
||||
}
|
||||
if (e.target.dataset.shift != undefined && e.target.dataset.shift.length > 0) {
|
||||
$(`td[data-shift=${e.target.dataset.shift}]`).addClass("shift-highlight")
|
||||
// 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");
|
||||
|
||||
|
||||
$(`td[data-remote-site='${e.target.dataset.shiftRemoteSite}']`).closest('tr').find(`td[data-shift=${e.target.dataset.shift}]`).addClass("remote-site-match")
|
||||
// if (e.target.dataset.shiftRemoteSite == worker_td.dataset.remoteSite) {
|
||||
// $(`td[data-shift-remote-site=${e.target.dataset.shiftRemoteSite}]`).addClass("remote-site-match")
|
||||
// }
|
||||
// For remote site, similar logic if needed
|
||||
$("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");
|
||||
}
|
||||
|
||||
}, (e) => {
|
||||
|
||||
//end hover
|
||||
// end hover
|
||||
$("td.pair-match").removeClass("pair-match")
|
||||
$("td.shift-highlight").removeClass("shift-highlight")
|
||||
$("td.remote-site-match").removeClass("remote-site-match")
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
$("#rota-table tr td:first-child").each((n, td) => {
|
||||
$(td).click(() => {
|
||||
|
||||
Reference in New Issue
Block a user