diff --git a/output/timetable.css b/output/timetable.css index 555bece..05676a1 100644 --- a/output/timetable.css +++ b/output/timetable.css @@ -198,10 +198,9 @@ td.worker { } -[data-night-at-derriford="0"] { +/* [data-night-at-derriford="0"] { border: 1px dotted orange; - /* Attribute has this exact value */ -} +} */ th.site-title { transform: unset; @@ -227,7 +226,7 @@ summary h2 { display: inline; } -.derriford-night.shift-highlight { +.remote-site-match.shift-highlight { background-color: yellow; } diff --git a/output/timetable.js b/output/timetable.js index c17a6c0..ec74399 100644 --- a/output/timetable.js +++ b/output/timetable.js @@ -320,7 +320,8 @@ $(".table-div + pre").each((n, pre) => { $("td").hover((e) => { //start hover - pair = $(e.target).closest('tr').find('td:first')[0].dataset.pair; + worker_td = $(e.target).closest('tr').find('td:first')[0] + pair = worker_td.dataset.pair; index = $(e.target).index() - 1; if (pair > 0) { $(`td[data-pair=${pair}]`).each((n, el) => { @@ -330,9 +331,14 @@ $("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") - if (e.target.dataset.shift.includes("night")) { - $(`td[data-night-at-derriford=1]`).siblings().addClass("derriford-night") - } + console.log(`td[data-remote-site='${e.target.dataset.shiftRemoteSite}']`) + console.log($(e.target).closest('tr').find(`td[data-remote-site='${e.target.dataset.shiftRemoteSite}']`)) + + $(`td[data-remote-site='${e.target.dataset.shiftRemoteSite}']`).closest('tr').find(`td[data-shift=${e.target.dataset.shift}]`).addClass("remote-site-match") + // console.log(e.target.dataset.shiftRemoteSite , worker_td.dataset.remoteSite) + // if (e.target.dataset.shiftRemoteSite == worker_td.dataset.remoteSite) { + // $(`td[data-shift-remote-site=${e.target.dataset.shiftRemoteSite}]`).addClass("remote-site-match") + // } } }, (e) => { @@ -340,7 +346,7 @@ $("td").hover((e) => { //end hover $("td.pair-match").removeClass("pair-match") $("td.shift-highlight").removeClass("shift-highlight") - $("td.derriford-night").removeClass("derriford-night") + $("td.remote-site-match").removeClass("remote-site-match") }) diff --git a/rota/shifts.py b/rota/shifts.py index 7108a98..d291115 100644 --- a/rota/shifts.py +++ b/rota/shifts.py @@ -55,6 +55,9 @@ class SingleShift(object): postclear(2) / preclear(2) + require_remote_site_presence: + options: (site, required_number) + night limit_grade_number: @@ -123,7 +126,7 @@ class SingleShift(object): # self.total_shifts = length * len(days) * len(shift_days) def __str__(self): - return f"name: {self.name}, site: {self.site}, length: {self.length}, balance weighting: {self.balance_weighting}, balance offset: {self.balance_offset}, hard_constrain: {self.hard_constrain_shift}, workers required : {self.workers_required}, rota on nwds {self.rota_on_nwds}, assign as block: {self.assign_as_block}, force as block: {self.force_as_block}, constraints: {self.constraints}" # , total shifts: {self.total_shifts}" + return f"name: {self.name}, site: {self.site}, length: {self.length}, balance weighting: {self.balance_weighting}, balance offset: {self.balance_offset}, hard_constrain: {self.hard_constrain_shift}, workers required : {self.workers_required}, rota on nwds {self.rota_on_nwds}, assign as block: {self.assign_as_block}, force as block: {self.force_as_block}, constraints: {self.constraints}, constraint_options: {self.constraint_options}" # , total shifts: {self.total_shifts}" def get_shift_summary(self): """ @@ -181,7 +184,7 @@ class RotaBuilder(object): self.work_requests = set() self.work_requests_map = {} - self.workers = [] + self.workers: list[Worker] = [] self.worker_pairs = [] # self.night_blocks = ["weekday", "weekend", "none"] @@ -197,7 +200,6 @@ class RotaBuilder(object): self.constraint_options = { "ensure_1_st4_plus_on_nights": True, - "ensure_derriford_reg_for_nights": True, "balance_nights": True, "constrain_time_off_after_nights": False, "balance_nights_across_sites": True, @@ -791,25 +793,6 @@ class RotaBuilder(object): ), ) - # def nightShiftDerrifordRule(model, week, shift): - # derriford_workers = [w for w in self.workers if w.night_at_derriford >= 1] - # # if not derriford_workers: - # # return Constraint.Skip - # return ( - # sum( - # model.shift_week_worker_assigned[shift, week, w.id] - # for w in derriford_workers - # ) - # >= 1 - # ) - - # if self.constraint_options["ensure_derriford_reg_for_nights"]: - # self.model.night_shifts_derriford_rule = Constraint( - # [week for week in self.weeks], - # [shift.name for shift in self.get_shifts_with_constraint("night")], - # rule=nightShiftDerrifordRule, - # ) - def presenceAtRemoteSite(model, week, shift, required_site, required_number): required_site_workers = [ w for w in self.workers if required_site == w.remote_site @@ -2465,13 +2448,14 @@ class RotaBuilder(object): a = "-" shift_name = "" + # Loop through all the days possible shifts and see + # if the worker has been assigned for shift in self.get_shift_names_by_week_day(week, day): if model.works[worker.id, week, day, shift].value > 0: shifts.append(shift) a = shift[0] shift_name = shift break - # If we haven't run just add the shift title = f"{shift_name} ({d})" css_class = day unavailable_reason = "" @@ -2503,8 +2487,14 @@ class RotaBuilder(object): title = " ".join((title, "[REQUESTED]")) requests = f" data-shift-request='{self.work_requests_map[worker.id, week, day]}'" + remote_site = "" + if shift_name: + shift = self.get_shift_by_name(shift_name) + if "require_remote_site_presence" in shift.constraints: + remote_site = f" data-shift-remote-site='{shift.constraint_options['require_remote_site_presence'][0]}'" + shift_tds.append( - f"