backoffice: warn about data loss when removing a page fields (#87505)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Frédéric Péters 2024-03-20 21:00:38 +01:00
parent 70b7087ad9
commit 03435d40a6
1 changed files with 14 additions and 1 deletions

View File

@ -196,7 +196,20 @@ class FieldDefPage(Directory):
to_be_deleted.reverse()
# add delete_fields checkbox only if the page has fields
if to_be_deleted:
form.add(CheckboxWidget, 'delete_fields', title=_('Also remove all fields from the page'))
form.add(
CheckboxWidget,
'delete_fields',
title=_('Also remove all fields from the page'),
attrs={'data-dynamic-display-parent': 'true'},
)
form.widgets.append(
HtmlWidget(
'<div class="warningnotice" '
'data-dynamic-display-child-of="delete_fields" '
'data-dynamic-display-checked="true">%s</div>'
% _('Warning: the page fields data will be permanently deleted.')
)
)
form.add_submit('delete', _('Delete'))
form.add_submit('cancel', _('Cancel'))
if form.get_widget('cancel').parse():