This is an automated email from the ASF dual-hosted git repository.

jscheffl pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new 200bd6297c6 [v2-10-test] Fix update issues for object and 
advanced-arrays fields when empty default (#45313) (#45315)
200bd6297c6 is described below

commit 200bd6297c6f5775860d9585e265116f45a42d96
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Dec 31 21:13:53 2024 +0100

    [v2-10-test] Fix update issues for object and advanced-arrays fields when 
empty default (#45313) (#45315)
    
    (cherry picked from commit 6eab1f24c2fe070b6d68a1435eadaccd807ed1c0)
    
    Co-authored-by: Jens Scheffler <[email protected]>
---
 airflow/www/static/js/trigger.js           | 4 ++--
 airflow/www/templates/airflow/trigger.html | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/airflow/www/static/js/trigger.js b/airflow/www/static/js/trigger.js
index 7a3444f460f..9242984e75b 100644
--- a/airflow/www/static/js/trigger.js
+++ b/airflow/www/static/js/trigger.js
@@ -59,8 +59,6 @@ function updateJSONconf() {
           }
         }
         params[keyName] = values.length === 0 ? null : values;
-      } else if (elements[i].value.length === 0) {
-        params[keyName] = null;
       } else if (
         elements[i].attributes.valuetype &&
         (elements[i].attributes.valuetype.value === "object" ||
@@ -81,6 +79,8 @@ function updateJSONconf() {
           // ignore JSON parsing errors
           // we don't want to bother users during entry, error will be 
displayed before submit
         }
+      } else if (elements[i].value.length === 0) {
+        params[keyName] = null;
       } else if (Number.isNaN(elements[i].value)) {
         params[keyName] = elements[i].value;
       } else if (
diff --git a/airflow/www/templates/airflow/trigger.html 
b/airflow/www/templates/airflow/trigger.html
index 158b54cabaf..20019db6903 100644
--- a/airflow/www/templates/airflow/trigger.html
+++ b/airflow/www/templates/airflow/trigger.html
@@ -120,7 +120,9 @@
     {% 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() -}}
+        {%- if form_details.value %}
+          {{- form_details.value | tojson() -}}
+        {% endif -%}
       </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 }}"

Reply via email to