From 057ca605c13a1f82030a2fa83340f43c750063f6 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 29 May 2026 19:44:32 +0800 Subject: [PATCH] feat: pass data_filter/filter_labels to Tabular widget; fix json.loads for data_filter string --- xls2ddl/tmpls.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xls2ddl/tmpls.py b/xls2ddl/tmpls.py index bd359b4..619513d 100644 --- a/xls2ddl/tmpls.py +++ b/xls2ddl/tmpls.py @@ -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: