misc: add identifier to page field (#41470)

This commit is contained in:
Frédéric Péters 2023-01-21 18:08:20 +01:00 committed by Gitea
parent e63a2d31b8
commit 6523d409bd
2 changed files with 14 additions and 3 deletions

View File

@ -443,8 +443,10 @@ class FieldsDirectory(Directory):
r += htmltext('<span class="optional">%s</span>') % required
if getattr(field, 'condition', None):
r += htmltext(' - <span class="condition">%s</span>') % _('depending on condition')
if getattr(field, 'varname', None) and CompatibilityNamesDict.valid_key_regex.match(
field.varname
if (
field.type != 'page'
and getattr(field, 'varname', None)
and CompatibilityNamesDict.valid_key_regex.match(field.varname)
):
r += htmltext(' - <span class="varname">{{ %s%s }}</span>') % (
self.field_var_prefix,

View File

@ -3031,9 +3031,18 @@ class PageField(Field):
value=self.post_conditions,
advanced=True,
)
form.add(
VarnameWidget,
'varname',
title=_('Identifier'),
value=self.varname,
size=30,
advanced=True,
hint=_('This is used as reference in workflow edition action.'),
)
def get_admin_attributes(self):
return Field.get_admin_attributes(self) + ['post_conditions']
return Field.get_admin_attributes(self) + ['post_conditions', 'varname']
def add_to_view_form(self, *args, **kwargs):
pass