Add asterisk to conditionally required fields

https://review.openstack.org/#/c/552247/ introduced a way to
add asterisk mark to conditionally required fields.

This commit covers several known forms:
- Create Network / Create Subnet
- Create Port
- Attach Interface to Instance
- Add Security Group Rule

Change-Id: I809c23fd64dc2f379c3fdb585741c6b266ec5b1b
Closes-Bug: #1420370
Closes-Bug: #1292165
Closes-Bug: #1755131
This commit is contained in:
Akihiro Motoki 2018-03-22 08:32:00 +09:00
parent 0399e52e1e
commit f8196331ea
4 changed files with 8 additions and 0 deletions

View File

@ -299,6 +299,7 @@ class AttachInterface(forms.SelfHandlingForm):
required=False,
widget=forms.ThemableSelectWidget(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'specification_method',
'data-specification_method-port': _('Port'),
}))

View File

@ -85,6 +85,7 @@ class CreatePortInfoAction(workflows.Action):
required=False,
widget=forms.ThemableSelectWidget(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'specify_ip',
'data-specify_ip-subnet_id': _('Subnet'),
}))
@ -95,6 +96,7 @@ class CreatePortInfoAction(workflows.Action):
version=forms.IPv4 | forms.IPv6,
widget=forms.TextInput(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'specify_ip',
'data-specify_ip-fixed_ip': _('Fixed IP Address'),
}))

View File

@ -118,6 +118,7 @@ class CreateSubnetInfoAction(workflows.Action):
label=_("Address pool"),
widget=forms.ThemableSelectWidget(attrs={
'class': 'switched switchable',
'data-required-when-shown': 'true',
'data-slug': 'subnetpool',
'data-switch-on': 'source',
'data-source-subnetpool': _('Address pool')},
@ -142,6 +143,7 @@ class CreateSubnetInfoAction(workflows.Action):
initial="",
widget=forms.TextInput(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'source',
'data-source-manual': _("Network Address"),
}),

View File

@ -147,6 +147,7 @@ class AddRule(forms.SelfHandlingForm):
"between 1 and 65535."),
widget=forms.TextInput(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'range',
'data-range-port': _('Port')}),
validators=[
@ -158,6 +159,7 @@ class AddRule(forms.SelfHandlingForm):
"between 1 and 65535."),
widget=forms.TextInput(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'range',
'data-range-range': _('From Port')}),
validators=[
@ -169,6 +171,7 @@ class AddRule(forms.SelfHandlingForm):
"between 1 and 65535."),
widget=forms.TextInput(attrs={
'class': 'switched',
'data-required-when-shown': 'true',
'data-switch-on': 'range',
'data-range-range': _('To Port')}),
validators=[