diff --git a/owrx/form/input/device.py b/owrx/form/input/device.py index 358886f..9e1415e 100644 --- a/owrx/form/input/device.py +++ b/owrx/form/input/device.py @@ -42,9 +42,7 @@ class GainInput(Input): {errors} """.format( - id=self.id, - input=self.render_input(value, errors), - errors=self.render_errors(errors) + id=self.id, input=self.render_input(value, errors), errors=self.render_errors(errors) ) def render_options(self, value): @@ -187,11 +185,28 @@ class SchedulerInput(Input): self.profiles = config["profiles"] return super().render(config, errors) - def render_profiles_select(self, value, errors, config_key, stage, extra_classes=""): + def render_profiles_select(self, value, errors, config_key, stage, extra_classes="", allow_empty=False): stage_value = "" if value and "schedule" in value and config_key in value["schedule"]: stage_value = value["schedule"][config_key] + options = "".join( + """ + + """.format( + id=p_id, + name=p["name"], + selected="selected" if stage_value == p_id else "", + ) + for p_id, p in self.profiles.items() + ) + + if allow_empty: + # prepend a special "off" option to allow a schedule slot to go unused (daylight scheduler) + options = """""".format( + selected="selected" if value is None else "" + ) + options + return """