feat: pass data_filter/filter_labels to Tabular widget; fix json.loads for data_filter string

This commit is contained in:
yumoqing 2026-05-29 19:44:32 +08:00
parent 41f5b65f1f
commit 057ca605c1

View File

@ -69,6 +69,18 @@ data_browser_tmpl = """
{% if content_view %}
"content_view":{{json.dumps(content_view, indent=4, ensure_ascii=False)}},
{% endif %}
{% if data_filter %}
"data_filter":{{json.dumps(data_filter, indent=4, ensure_ascii=False)}},
{% endif %}
{% if filter_labels %}
"filter_labels":{{json.dumps(filter_labels, indent=4, ensure_ascii=False)}},
{% endif %}
{% if filter_title %}
"filter_title":"{{filter_title}}",
{% endif %}
{% if filter_icon %}
"filter_icon":"{{filter_icon}}",
{% endif %}
{% if subtables_condition %}
{%- raw -%}{% endif %}{%- endraw %}
{% endif %}
@ -133,6 +145,11 @@ ns['sort'] = '{{relation.outter_field}}_text'
sql = '''{{sql}}'''
{% if not relation %}
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
\ttry:
\t\tfilterjson = json.loads(filterjson)
\texcept (json.JSONDecodeError, TypeError):
\t\tfilterjson = None
fields_str=r'''{{json.dumps(fields, indent=4, ensure_ascii=False)}}'''
ori_fields = json.loads(fields_str)
if not filterjson: