Skip to content

Commit

Permalink
Add ValueRelation filter expression to field config
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Apr 2, 2024
1 parent be51b99 commit b549ed9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/config_generator/map_viewer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
5 changes: 5 additions & 0 deletions src/config_generator/qgs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b549ed9

Please sign in to comment.