Make default option be selected option in edit

This commit is contained in:
Andrew 2022-09-16 13:15:07 -04:00
parent 1b2fef06fb
commit 9ecf912a98
2 changed files with 33 additions and 10 deletions

View File

@ -1009,6 +1009,7 @@ class PanelHandler(BaseHandler):
# We'll just default to basic for new schedules
page_data["schedule"]["difficulty"] = "basic"
page_data["schedule"]["interval_type"] = "days"
page_data["parent"] = None
if not EnumPermissionsServer.SCHEDULE in page_data["user_permissions"]:
if not superuser:
@ -1091,8 +1092,12 @@ class PanelHandler(BaseHandler):
page_data["schedule"]["interval_type"] = schedule.interval_type
if schedule.interval_type == "reaction":
difficulty = "reaction"
page_data["parent"] = self.controller.management.get_scheduled_task(
schedule.parent
)
elif schedule.cron_string == "":
difficulty = "basic"
page_data["parent"] = None
else:
difficulty = "advanced"
page_data["schedule"]["difficulty"] = difficulty

View File

@ -145,17 +145,35 @@
data['lang']) }}</small> </label>
<select id="parent" name="parent" class="form-control form-control-lg select-css"
value="{{ data['schedule']['action'] }}">
{% for schedule in data['schedules'] %}
{% if schedule.schedule_id != data['schedule']['schedule_id'] %}
{% if schedule.interval != '' %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.interval}} {{
schedule.interval_type}}</option>
{% if data['parent'] %}
<option id="{{data['parent']['schedule_id']}}" value="{{data['parent']['schedule_id']}}">
{{data['parent']['name']}} | {{data['parent']['command']}} | {{data['parent']['interval']}}
</option>
{% for schedule in data['schedules'] %}
{% if schedule.schedule_id != data['schedule']['schedule_id'] and schedule.schedule_id != data['parent']['schedule_id'] %}
{% if schedule.interval != '' %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.interval}} {{
schedule.interval_type}}</option>
{% else %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
{% end %}
{% end %}
{% end %}
{% else %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
{% end %}
{% end %}
{% for schedule in data['schedules'] %}
{% if schedule.schedule_id != data['schedule']['schedule_id'] and schedule.schedule_id %}
{% if schedule.interval != '' %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.interval}} {{
schedule.interval_type}}</option>
{% else %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
{% end %}
{% end %}
{% end %}
{% end %}
</select>
</div>