jens-scheffler-bosch commented on code in PR #27063:
URL: https://github.com/apache/airflow/pull/27063#discussion_r1088325402


##########
airflow/www/templates/airflow/trigger.html:
##########
@@ -27,11 +27,93 @@
   <link rel="stylesheet" type="text/css" href="{{ url_for_asset('switch.css') 
}}">
 {% endblock %}
 
+{% macro form_element(form_key, form_details) %}
+<tr>
+  <td class="col-lg-2">
+    <label for="element_{{ form_key }}" control-label="">
+      {%- if "title" in form_details.schema and form_details.schema.title -%}
+        {{ form_details.schema.title }}
+      {%- else -%}
+        {{ form_key }}
+      {%- endif -%}
+      {%- if form_details.schema and form_details.schema.type and not "null" 
in form_details.schema.type and not "boolean" in form_details.schema.type -%}
+        <strong style="color: red"> *</strong>
+      {%- endif -%}
+    : </label>
+  </td>
+  <td>
+    {% if "custom_html_form" in form_details.schema %}
+      {{ form_details.schema.custom_html_form | replace("{name}", "element_" + 
form_key) | replace("{value}", form_details.value) }}
+    {% elif "type" in form_details.schema and form_details.schema.type == 
"boolean" %}
+      <label for="element_{{ form_key }}" control-label="">
+        <input class="switch-input" name="element_{{ form_key }}" 
id="element_{{ form_key }}" type="checkbox"
+          {%- if form_details.value %} checked="checked"{%- endif -%}/>
+        <span class="switch" aria-hidden="true"></span>
+      </label>
+    {% elif "format" in form_details.schema and "date-time" in 
form_details.schema.format %}
+      <div class="input-group datetime datetimepicker">
+        <span class="input-group-addon"><span class="material-icons 
cursor-hand">calendar_today</span></span>
+        <input class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" type="text" valuetype="date"
+          {%- if not "null" in form_details.schema.type %} required=""{%- 
endif %} value="{% if form_details.value %}{{ form_details.value }}{% endif %}" 
/>
+      </div>
+    {% elif "format" in form_details.schema and "date" in 
form_details.schema.format %}
+      <div class="input-group datetime datepicker">
+        <span class="input-group-addon"><span class="material-icons 
cursor-hand">calendar_today</span></span>
+        <input class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" type="text" valuetype="date"
+          {%- if not "null" in form_details.schema.type %} required=""{%- 
endif %} value="{% if form_details.value %}{{ form_details.value }}{% endif %}" 
/>
+      </div>
+    {% elif "format" in form_details.schema and "time" in 
form_details.schema.format %}
+      <div class="input-group datetime timepicker">
+        <span class="input-group-addon"><span class="material-icons 
cursor-hand">calendar_today</span></span>
+        <input class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" type="text" valuetype="date"
+          {%- if not "null" in form_details.schema.type %} required=""{%- 
endif %}
+          value="{% if form_details.value %}{{ form_details.value[0:2] 
}}00-01-01 {{ form_details.value }}{% endif %}" />
+      </div>
+    {% elif "enum" in form_details.schema and form_details.schema.enum %}
+      <select class="my_select2 form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" data-placeholder="Select Value"
+        value="{% if form_details.value %}{{ form_details.value }}{% endif %}" 
onchange="updateJSONconf();"
+        {%- if not "null" in form_details.schema.type %} required=""{% endif 
%}>
+        {% for option in form_details.schema.enum -%}
+        <option>{{ option }}</option>
+        {% endfor -%}
+      </select>
+    {% elif form_details.schema and "array" in form_details.schema.type %}
+      <textarea class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" valuetype="array" rows="6"
+        {%- if not "null" in form_details.schema.type %} required=""{% endif 
-%}>
+        {%- for txt in form_details.value -%}
+          {{ txt }}{{ "\n" }}
+        {%- endfor -%}
+      </textarea>
+    {% elif form_details.schema and "object" in form_details.schema.type %}
+      <textarea class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" valuetype="object" rows="6"
+        {%- if not "null" in form_details.schema.type %} required=""{% endif 
-%}>
+        {{- form_details.value | tojson() -}}
+      </textarea>
+    {% elif form_details.schema and ("integer" in form_details.schema.type or 
"number" in form_details.schema.type) %}
+      <input class="form-control" name="element_{{ form_key }}" id="element_{{ 
form_key }}" placeholder="" valuetype="number" type="number"
+        value="{% if form_details.value %}{{ form_details.value }}{% endif %}"
+        {%- if form_details.schema.minimum %} min="{{ 
form_details.schema.minimum }}"{% endif %}
+        {%- if form_details.schema.maximum %} max="{{ 
form_details.schema.maximum }}"{% endif %}
+        {%- if form_details.schema.type and not "null" in 
form_details.schema.type %} required=""{% endif %} />
+    {% else %}
+      <input class="form-control" name="element_{{ form_key }}" id="element_{{ 
form_key }}" placeholder="" type="text"
+        value="{% if form_details.value %}{{ form_details.value }}{% endif %}"
+        {%- if form_details.schema and form_details.schema.minLength %} 
minlength="{{ form_details.schema.minLength }}"{% endif %}
+        {%- if form_details.schema and form_details.schema.maxLength %} 
maxlength="{{ form_details.schema.maxLength }}"{% endif %}
+        {%- if form_details.schema and form_details.schema.type and not "null" 
in form_details.schema.type %} required=""{% endif %} />
+    {% endif %}
+    {% if form_details.description -%}

Review Comment:
   I'll add some screenshots to the code lines, hope this is not bloating the 
readability. But makes review easier probably. Otherwise spin up the web server 
and call the example_params_ui_tutorial DAG, this contains examples for all 
features.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to