{% extends frame.html %}

{% block body %}
<div class="w3-container w3-blue" style="margin-top: 32px;">
  <h3>{% if hydra_type %}Edit{% else %}New{% end %} Work Type</h3>
</div>

<form id="hydra_add" class="w3-card w3-padding" action="{{request.path}}" method="POST">
  {% raw xsrf_form_html() %}
  {% if hydra_type and hydra_type.get('hydra_type_id') %}
  <input type="hidden" name="hydra_type_id" value="{{hydra_type['hydra_type_id']}}"/>
  {% end %}

  <p>
    <label><b>Work Type Name</b> {% if errors.get('hydra_type_name') %}<span class="w3-text-red">{{errors['hydra_type_name']}}</span>{% end %}</label>
    <input class="w3-input {% if errors.get('hydra_type_name') %}w3-border w3-border-red{% end %}" type="text" name="hydra_type_name" value="{{hydra_type.get('hydra_type_name') or ''}}" placeholder="ie 'housekeeping' [required]" />
  </p>

  <p>
    <label><b>Work Description</b> {% if errors.get('hydra_type_desc') %}<span class="w3-text-red">{{errors['hydra_type_desc']}}</span>{% end %}</label>
    <input class="w3-input {% if errors.get('hydra_type_desc') %}w3-border w3-border-red{% end %}" type="text" name="hydra_type_desc" value="{{hydra_type.get('hydra_type_desc') or ''}}" placeholder="ie 'tidying and rotating data'" />
  </p>

  <p>
    <label><b>Priority</b> {% if errors.get('priority_ndx') %}<span class="w3-text-red">{{errors['priority_ndx']}}</span>{% end %}</label>
    <input class="w3-input {% if errors.get('priority_ndx') %}w3-border w3-border-red{% end %}" type="text" name="priority_ndx" value="{{hydra_type.get('priority_ndx') or ''}}" placeholder="Lower number is higher priority [required] " />
  </p>

  <p>
      <label><b>Next Run SQL</b></label>
      <input class="w3-input" type="text" name="next_run_sql" value="{{hydra_type.get('next_run_sql', '')}}" placeholder="SQL to set next_run_dttm, ie DATE(DATE_ADD(next_run_dttm, INTERVAL 1 DAY)) for tomorrow start of day" />
  </p>

  <p>
      <label><b>Run Host</b></label>
      <input class="w3-input" type="text" name="run_host" value="{{hydra_type.get('run_host', '')}}" placeholder="Specify a single host that should always run this Hydra Type. Not required." />
  </p>

  <p>
      <label><b>Run Env</b></label>
      <input class="w3-input" type="text" name="run_env" value="{{hydra_type.get('run_env', '')}}" placeholder="Specify a single environment that should only run this Hydra Type. Not required." />
  </p>

  <div class="w3-center w3-padding">
    <a class="w3-left w3-text-blue" href="/admin/hydra">Cancel</a>
    <input type="submit" class="w3-button w3-blue w3-center" value="{% if hydra_type %}Update{% else %}Add{% end %} Work Type"/>
  </div>
</form>

{% end %}
