diff --git a/src/config_generator/map_viewer_config.py b/src/config_generator/map_viewer_config.py index fc3dba7..1e88ea1 100644 --- a/src/config_generator/map_viewer_config.py +++ b/src/config_generator/map_viewer_config.py @@ -893,6 +893,9 @@ def edit_config(self, map_name, cfg_item, assets_dir): if 'defaultValue' in field: edit_field['defaultValue'] = field['defaultValue'] + if 'filterExpression' in field: + edit_field['filterExpression'] = field['filterExpression'] + if 'constraints' in field: # add any constraints edit_field['constraints'] = field['constraints'] diff --git a/src/config_generator/qgs_reader.py b/src/config_generator/qgs_reader.py index 4409f41..ff715ab 100644 --- a/src/config_generator/qgs_reader.py +++ b/src/config_generator/qgs_reader.py @@ -345,6 +345,11 @@ def __attributes_metadata(self, maplayer): else: fields[field]['defaultValue'] = "expr:%s" % default.get('expression').strip() + # any any filter expression + filterExpression = maplayer.find("fieldConfiguration/field[@name='%s']/editWidget[@type='ValueRelation']/config/Option/Option[@name='FilterExpression']" % field) + if filterExpression is not None and filterExpression.get('value'): + fields[field]['filterExpression'] = filterExpression.get('value') + # get any constraints from edit widgets constraints = self.__edit_widget_constraints(maplayer, field, keyvaltables) if constraints: