diff --git a/htdocs/css/admin.css b/htdocs/css/admin.css index cab552f..8b4780a 100644 --- a/htdocs/css/admin.css +++ b/htdocs/css/admin.css @@ -98,6 +98,7 @@ table.bookmarks .frequency { .removable-group.removable .removable-item { flex: 1 0 auto; + margin-right: .25rem; } .removable-group.removable .option-remove-button { diff --git a/htdocs/lib/settings/SchedulerInput.js b/htdocs/lib/settings/SchedulerInput.js index 86870e3..1dd8156 100644 --- a/htdocs/lib/settings/SchedulerInput.js +++ b/htdocs/lib/settings/SchedulerInput.js @@ -1,6 +1,8 @@ $.fn.schedulerInput = function() { this.each(function() { var $container = $(this); + var $template = $container.find('.template'); + $template.find('input, select').prop('disabled', true); var update = function(value){ $container.find('.option').hide(); @@ -13,5 +15,19 @@ $.fn.schedulerInput = function() { update(value); }); update($select.val()); + + $container.find('.add-button').on('click', function() { + var row = $template.clone(); + row.removeClass('template').show(); + row.find('input, select').prop('disabled', false); + $template.before(row); + + return false; + }); + + $container.on('click', '.remove-button', function(e) { + var row = $(e.target).parents('.scheduler-static-time-inputs'); + row.remove(); + }); }); } \ No newline at end of file diff --git a/owrx/form/device.py b/owrx/form/device.py index 2fcdb93..5375cb5 100644 --- a/owrx/form/device.py +++ b/owrx/form/device.py @@ -177,33 +177,33 @@ class SchedulerInput(Input): self.profiles = config["profiles"] return super().render(config) - def render_input(self, value): - def render_profiles_select(config_key, stage, extra_classes=""): - stage_value = "" - if value and "schedule" in value and config_key in value["schedule"]: - stage_value = value["schedule"][config_key] + def render_profiles_select(self, value, config_key, stage, extra_classes=""): + stage_value = "" + if value and "schedule" in value and config_key in value["schedule"]: + stage_value = value["schedule"][config_key] - return """ - - """.format( - id="{}-{}".format(self.id, stage), - classes=self.input_classes(), - extra_classes=extra_classes, - disabled="disabled" if self.disabled else "", - 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() - ), - ) + return """ + + """.format( + id="{}-{}".format(self.id, stage), + classes=self.input_classes(), + extra_classes=extra_classes, + disabled="disabled" if self.disabled else "", + 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() + ), + ) + def render_static_entires(self, value): def render_time_inputs(v): values = ["{}:{}".format(x[0:2], x[2:4]) for x in [v[0:4], v[5:9]]] return '